Commit 1d0f51e9 authored by Ripinder Singh's avatar Ripinder Singh
Browse files

Code review comments #1

parent e568f54d
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@
/* ################## Start DEVELOPMENT switches ######################### */


//#define RTP_S4_251135_CR26253_0016_REV1                /* RTP Pack/Unpack API corresponding to CR 26253 */
#define IVAS_RTPDUMP                                   /* RTPDUMP writing and reading for IVAS payloads */

/* ################### Start BE switches ################################# */
+50 −54
Original line number Diff line number Diff line
@@ -34,8 +34,10 @@
#define IVAS_RTP_API_H

#pragma once
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include "options.h"
#include "ivas_error.h"

#ifdef __cplusplus
@@ -80,7 +82,7 @@ extern "C"
    {
        IVAS_RTP_EVS, /* EVS  */
        IVAS_RTP_IVAS /* IVAS */
    } IVAS_RTP_CODECS;
    } IVAS_RTP_CODEC;

    /* IVAS Bandwidth Requests */
    typedef enum
@@ -119,6 +121,7 @@ extern "C"
        IVAS_FMT_NO_REQ, /* No preference */
    } IVAS_RTP_FORMAT;

#ifdef RTP_S4_251135_CR26253_0016_REV1
    /* Coded Subformat Requests */
    typedef enum
    {
@@ -197,36 +200,41 @@ extern "C"
        uint32_t roll: 1;      /* transmission metadata for correction around roll axis  */
        uint32_t reserved: 28; /* reserved */
    } IVAS_RTP_SPLITRENDER;
#endif /* RTP_S4_251135_CR26253_0016_REV1 */

    /* Remote Requests Types (Keys) */
    typedef enum
    {
        IVAS_REQUEST_CODEC,      /* Request codec type, value of type IVAS_RTP_CODECS          */
        IVAS_REQUEST_CODEC,      /* Request codec type, value of type IVAS_RTP_CODEC           */
        IVAS_REQUEST_BITRATE,    /* Request bitrate, value of type uint32_t in kbps            */
        IVAS_REQUEST_BANDWIDTH,  /* Request bandwidth, value of type IVAS_RTP_BANDWIDTH        */
        IVAS_REQUEST_FORMAT,     /* Request format, value of type IVAS_RTP_FORMAT              */
        IVAS_REQUEST_SUBFORMAT,  /* Request subFormat, value of type IVAS_RTP_SUBFORMAT        */
        IVAS_REQUEST_CA_MODE,    /* Request channel awareness, value of type IVAS_RTP_CA_MODE  */
#ifdef RTP_S4_251135_CR26253_0016_REV1
        IVAS_REQUEST_SUBFORMAT,  /* Request subFormat, value of type IVAS_RTP_SUBFORMAT        */
        IVAS_REQUEST_SR_CONFIG,  /* Request spit rendering, value of type IVAS_RTP_SPLITRENDER */
#endif /* RTP_S4_251135_CR26253_0016_REV1 */
        IVAS_REQUEST_MAX         /* Max number of requests */
    } IVAS_RTP_REQUEST_TYPE;

    /* Remote Request Values */
    typedef union {
        uint32_t bitrate;                 /* bitrate in kbps when request type is IVAS_REQUEST_BITRATE          */
        IVAS_RTP_CODECS codec;            /* codec id when request type is IVAS_REQUEST_CODEC                   */
        IVAS_RTP_CODEC codec;             /* codec id when request type is IVAS_REQUEST_CODEC                   */
        IVAS_RTP_BANDWIDTH bandwidth;     /* badwidth when request type is IVAS_REQUEST_BANDWIDTH               */
        IVAS_RTP_FORMAT formatType;       /* format type when request type is IVAS_REQUEST_FORMAT               */
        IVAS_RTP_SUBFORMAT subFormatType; /* sub-format type when request type is IVAS_REQUEST_SUBFORMAT        */
        IVAS_RTP_CA_MODE caMode;          /* channel aware mode when request type is IVAS_REQUEST_CA_MODE       */
#ifdef RTP_S4_251135_CR26253_0016_REV1
        IVAS_RTP_SUBFORMAT subFormatType; /* sub-format type when request type is IVAS_REQUEST_SUBFORMAT        */
        IVAS_RTP_SPLITRENDER srConfig;    /* split rendering config when request type is IVAS_REQUEST_SR_CONFIG */
#endif /* RTP_S4_251135_CR26253_0016_REV1 */
    } IVAS_RTP_REQUEST_VALUE;

    /* Template for pi data types, all defined pi data follow this template
     * for example scene orientation pi data can be represented as :-
     *
     *     typedef struct {
     *         uint32_t size;       // sizeof(IVAS_PIDATA_SCENE_ORIENTATION)
     *         size_t size;         // sizeof(IVAS_PIDATA_SCENE_ORIENTATION)
     *         uint32_t piDataType; // IVAS_PI_SCENE_ORIENTATION
     *         float w, x, y, z;    // pi data of scene orientation in quaternions
     *     } IVAS_PIDATA_SCENE_ORIENTATION;
@@ -234,20 +242,20 @@ extern "C"
     */
    typedef struct
    {
        uint32_t size;       /* size of this structure */
        size_t size;         /* size of this structure */
        uint32_t piDataType; /* IVAS PI data type      */
        uint8_t data[1];     /* Variable length array (length calculated as size - 2*sizeof(uint32_t))*/
        uint8_t data[1];     /* Variable length array */
    } IVAS_PIDATA_GENERIC;

    /* Generic data buffer for sending/receiving coded frames / rtp packets
    /* Generic data buffer for sending/receiving coded frames / rtp payloads
     * data buffer is owned and initialized by caller, rtp api will ensure
     * buffer write does not exceed allocSize.
     * buffer write does not exceed capacity.
     */
    typedef struct
    {
        uint32_t allocSize; /* allocated size of the data buffer            */
        uint32_t length;    /* length of the initialized data in the buffer */
        uint8_t *buffer;    /* pointer to the packet buffer                 */
        size_t capacity; /* allocated size of the data buffer            */
        size_t length;   /* length of the initialized data in the buffer */
        uint8_t *buffer; /* pointer to the payload buffer                */
    } IVAS_DATA_BUFFER;

    /**********************************************/
@@ -260,14 +268,10 @@ extern "C"
    /* Initial configuration for rtp packer
     *  - maxFramesPerPacket is used to define if more than one frame should be packed
     *    in the same rtp packet.
     *
     * - piDataRepeatIntervalMs is used to define pi data repetition interval
     *
     */
    typedef struct
    {
        uint32_t maxFramesPerPacket;     /* maximum no of frame per packet desired during the session */
        uint32_t piDataRepeatIntervalMs; /* period for pi data repeat 0 = each frame, UINT_MAX=never  */
    } IVAS_RTP_PACK_CONFIG;

    /* Open an instance of the RTP packer and return a handle to rtp packer on success
@@ -290,7 +294,7 @@ extern "C"
     * in this API. E.g. Codec ID and supported bitrates/bandwidths
     * will not be performed at this level.
     */
    ivas_error IVAS_RTP_PACK_RemoteRequest(
    ivas_error IVAS_RTP_PACK_PushRemoteRequest(
        IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o : IVAS rtp packer handle      */
        IVAS_RTP_REQUEST_TYPE reqType,  /* i   : remote request type         */
        IVAS_RTP_REQUEST_VALUE reqValue /* i   : value of the requested type */
@@ -299,23 +303,23 @@ extern "C"
    /* Push a single IVAS/EVS frame to rtp packer
     *
     * If multiple frames per RTP packet are desired, multiple frames must be explicitly
     * pushed before a call to IVAS_RTP_PACK_GetPacket to generate a rtp packet.
     * pushed before a call to IVAS_RTP_PACK_GetPayload to generate a rtp payload.
     *
     * It is possible to have variable frames per packet until maxFramesPerPacket frames
     * if IVAS_RTP_PACK_GetPacket is invoked asyncronously w.r.t this api.
     * if IVAS_RTP_PACK_GetPayload is invoked asyncronously w.r.t this api.
     *
     */
    ivas_error IVAS_RTP_PACK_PushFrame(
        IVAS_RTP_PACK_HANDLE hIvasPack,     /* i/o : IVAS rtp packer handle              */
        IVAS_RTP_CODECS codecId,            /* i   : Codec type (IVAS/EVS)               */
        IVAS_RTP_CODEC codecId,             /* i   : Codec type (IVAS/EVS)               */
        const IVAS_DATA_BUFFER *frameBuffer /* i   : packed frame bitstream for IVAS/EVS */
    );

    /* Push single PI data to rtp packer
     *
     * Provide PI data for a current RTP packet. All PI data is locally cached in the packer
     * and set to the rtp packet with policy defined in initial configuration during call to
     * IVAS_RTP_PACK_GetPacket.
     * and set to the rtp payload with policy defined in initial configuration during call to
     * IVAS_RTP_PACK_GetPayload.
     *
     */
    ivas_error IVAS_RTP_PACK_PushPiData(
@@ -323,15 +327,15 @@ extern "C"
        const IVAS_PIDATA_GENERIC *data /* i   : pointer to the PIData stucture */
    );

    /* Generate a rtp packet using available pushed frames
    /* Generate a rtp payload using available pushed frames
     *
     * Available remote requests, pi data and frames will be packed into a rtp packet. If no
     * Available remote requests, pi data and frames will be packed into a rtp payload. If no
     * frame is pushed before call to this api, NO_DATA_FRAME will be generated
     *
     */
    ivas_error IVAS_RTP_PACK_GetPacket(
    ivas_error IVAS_RTP_PACK_GetPayload(
        IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o : IVAS rtp packer handle  */
        IVAS_DATA_BUFFER *packet        /* o   : encapsulated rtp packet */
        IVAS_DATA_BUFFER *payload       /* o   : encapsulated rtp payload */
    );


@@ -345,7 +349,7 @@ extern "C"
    /* Initial configuration for rtp unpacker */
    typedef struct
    {
        uint32_t maxNumberOfPacketInFifo; /* input packet fifo 's max length */
        uint32_t maxNumberOfPayloadsInFifo; /* input payload fifo 's max length */
    } IVAS_RTP_UNPACK_CONFIG;

    /* Open an instance of the RTP unpacker and return a handle to rtp unpacker on success
@@ -362,16 +366,20 @@ extern "C"
    );

    /* Push a received rtp Ivas Payload to unpacker to extract number of frames, pi data and
     * any remote request present in the packet. Caller must extract RTP header and header
     * any remote request present in the payload. Caller must extract RTP header and header
     * extension and feed Ivas Payload alongwith RTP Timestamp and sequence number.
     *
     * In case of DTX transmission modes, the number of frames in packet will be reduced by
     * the number of NO_DATA frame received. All PullFrame calls for non NO_DATA frames shall
     * be reported with timestamp jump indicating missing/NO_DATA IVAS frames.
     *
     * Example usage : -
     * ==================
     * err = IVAS_RTP_UNPACK_PushPacket(hIvasUnpack, payload, rtpTs, seqNum,
     * err = IVAS_RTP_UNPACK_PushPayload(hIvasUnpack, payload, rtpTs, seqNum,
     *                                   &nFrames, &nPiData, &reqBitmap);
     * if (err != IVAS_ERR_OK) { return err; }
     *
     * // Read the frames in packet and feed to decoder
     * // Read the frames in payload and feed to decoder
     * while (nFrames-- > 0) {
     *     err = IVAS_RTP_UNPACK_PullFrame(hIvasUnpack, &recCodecId, &frame, &frameTs, &seqNum);
     *     if (err != IVAS_ERR_OK) { return err; }
@@ -381,7 +389,7 @@ extern "C"
     *
     * // Read PI Data
     * while (nPiData-- > 0) {
     *     err = IVAS_RTP_UNPACK_GetNextPiData(hIvasUnpack, &piData, &piTs);
     *     err = IVAS_RTP_UNPACK_PullNextPiData(hIvasUnpack, &piData, &piTs);
     *     if (err != IVAS_ERR_OK) { return err; }
     *     // handle pi data based on fwd/rev pi data types
     *     handlePIData(&piData, piTs)
@@ -405,31 +413,20 @@ extern "C"
     * }
     *
     */
    ivas_error IVAS_RTP_UNPACK_PushPacket(
    ivas_error IVAS_RTP_UNPACK_PushPayload(
        IVAS_RTP_UNPACK_HANDLE hIvasUnpack, /* i/o : IVAS rtp unpacker handle                        */
        const IVAS_DATA_BUFFER *packet,     /* i   : received rtp packet                             */
        const IVAS_DATA_BUFFER *payload,    /* i   : received rtp payload                           */
        uint32_t  timestamp,                /* i   : timestamp in RTP Clock @ 16KHz  from rtp header */
        uint16_t  sequenceNumbers,          /* i   : sequence number from rtp header                 */
        uint16_t  sequenceNumber,           /* i   : sequence number from rtp header                 */
        uint32_t *numFramesInPacket,        /* o   : number of IVAS/EVS frames in rtp packet         */
        uint32_t *numPiDataInPacket,        /* o   : number of PI data received in rtp packet        */
        uint32_t *remoteRequestBitmap       /* o   : bitmap of available request in this packet      */
    );

    /* Push a received rtp extension header to unpacker to extract pi data
     * Caller must feed rtp extension header alongwith RTP Timestamp and sequence number.
     */
    ivas_error IVAS_RTP_UNPACK_HeaderExtension (
        IVAS_RTP_UNPACK_HANDLE hIvasUnpack,    /* i/o : IVAS rtp unpacker handle                        */
        const IVAS_DATA_BUFFER *hdrExtnBuffer, /* i   : received rtp header extension buffer            */
        uint32_t  timestamp,                   /* i   : timestamp in RTP Clock @ 16KHz  from rtp header */
        uint16_t  sequenceNumbers,             /* i   : sequence number from rtp header                 */
        uint32_t *numPiDataInPacket            /* o   : number of PI data received in rtp packet        */
    );

    /* Fetch requests from sender using a key value pair api
     * each key must be provided with a corresponding value storage type
     *
     * On call to IVAS_RTP_UNPACK_PushPacket(), remoteRequestBitmap can be used
     * On call to IVAS_RTP_UNPACK_PushPayload(), remoteRequestBitmap can be used
     * an indicator of new request available this frame
     *
     */
@@ -439,25 +436,24 @@ extern "C"
        IVAS_RTP_REQUEST_VALUE *value       /* o   : pointer of the requested type */
    );

    /* Extract a single IVAS/EVS frame from provided rtp packet alongwith rtp timestamp
    /* Extract a single IVAS/EVS frame from provided rtp payload alongwith rtp timestamp
     * and sequence number
     *
     * If multiple frames per RTP packet are available, multiple calls to IVAS_RTP_UNPACK_PullFrame
     * are needed. A frameBuffer.length == 0 indicates NO_DATA_FRAME
     *
     * are needed.
     */
    ivas_error IVAS_RTP_UNPACK_PullFrame(
        IVAS_RTP_UNPACK_HANDLE hIvasUnpack, /* i/o : IVAS rtp unpacker handle            */
        IVAS_RTP_CODECS *receivedCodecId,   /* i   : Codec type (IVAS/EVS)               */
        IVAS_RTP_CODEC *receivedCodecId,    /* i   : Codec type (IVAS/EVS)               */
        IVAS_DATA_BUFFER *frameBuffer,      /* o   : packed frame bitstream for IVAS/EVS */
        uint32_t *timestamp,                /* o   : timestamp in RTP Clock @ 16KHz      */
        uint16_t *sequenceNumbers           /* o   : sequence number from rtp header     */
        uint16_t *sequenceNumber            /* o   : sequence number from rtp header     */
    );

    /* Pull a single PI data from rtp unpacker instance for current packet
     * Each Pi data is accompanied with a corresponding timestamp
     */
    ivas_error IVAS_RTP_UNPACK_GetNextPiData(
    ivas_error IVAS_RTP_UNPACK_PullNextPiData(
        IVAS_RTP_UNPACK_HANDLE hIvasUnpack, /* i/o : IVAS rtp unpacker handle           */
        IVAS_PIDATA_GENERIC *data,          /* o   : output data buffer for the Pi data */
        uint32_t *timestamp                 /* o   : timestamp in RTP Clock @ 16KHz     */