From 260d6f824ba83dbf6eb31106926a9f3acd692a46 Mon Sep 17 00:00:00 2001 From: Ripinder Singh Date: Fri, 27 Mar 2026 11:30:01 +1100 Subject: [PATCH] Issue 1540: Expose payload type in IVAS_RTP_PACK_UpdateHeader API Signed-off-by: Ripinder Singh --- apps/decoder.c | 7 +++++++ apps/encoder.c | 7 +++++++ apps/encoder_fmtsw.c | 7 +++++++ lib_com/common_api_types.h | 4 ++++ lib_com/options.h | 1 + lib_util/ivas_rtp_api.h | 14 ++++++++++++++ lib_util/ivas_rtp_file.c | 15 +++++++++++++++ lib_util/ivas_rtp_file.h | 4 ++++ lib_util/ivas_rtp_payload.c | 17 +++++++++++++++++ 9 files changed, 76 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index f37b0acec..fca2d9e6e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1728,6 +1728,9 @@ static ivas_error initOnFirstGoodFrame( uint16_t rtpDecSeed = RANDOM_INITSEED_DEC; uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpDecSeed ) << 16 ); uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpDecSeed ); +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API + uint8_t payloadType = DEFAULT_IVAS_PAYLOAD_TYPE; /* Dynamic PT are in range [96, 127] */ +#endif if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) { @@ -1764,7 +1767,11 @@ static ivas_error initOnFirstGoodFrame( /* Split Rendering RTPDump Output file */ +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API + if ( ( error = IVAS_RTP_WRITER_Init( srRtp, arg.outputWavFilename, 1000 / ( IVAS_NUM_FRAMES_PER_SEC * splitRendCodecFrameSizeMs ), payloadType, ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_RTP_WRITER_Init( srRtp, arg.outputWavFilename, 1000 / ( IVAS_NUM_FRAMES_PER_SEC * splitRendCodecFrameSizeMs ), ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError: Can't open SR output bitstream file for RTP output %s \n\n", arg.outputWavFilename ); return error; diff --git a/apps/encoder.c b/apps/encoder.c index 31d9b448c..e157cc8c6 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -227,6 +227,9 @@ int main( uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16 ); uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpEncSeed ); +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API + uint8_t payloadType = DEFAULT_IVAS_PAYLOAD_TYPE; /* Dynamic PT are in range [96, 127] */ +#endif /*------------------------------------------------------------------------------------------* * Parse command-line arguments @@ -618,7 +621,11 @@ int main( if ( arg.rtpdumpOutput ) { +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API + if ( ( error = IVAS_RTP_WRITER_Init( &ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket, payloadType, ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_RTP_WRITER_Init( &ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket, ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError: Can't open output bitstream file for RTP output %s \n\n", arg.outputBitstreamFilename ); goto cleanup; diff --git a/apps/encoder_fmtsw.c b/apps/encoder_fmtsw.c index 036144175..0222bef66 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -338,6 +338,9 @@ int encoder_main( uint16_t rtpEncSeed = RANDOM_INITSEED_ENC; uint32_t ssrc = ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) & 0x0000FFFF ) | ( (uint32_t) IVAS_RTP_OwnRandom( &rtpEncSeed ) << 16 ); uint16_t seqNumInitVal = IVAS_RTP_OwnRandom( &rtpEncSeed ); +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API + uint8_t payloadType = DEFAULT_IVAS_PAYLOAD_TYPE; /* Dynamic PT are in range [96, 127] */ +#endif /*------------------------------------------------------------------------------------------* * Parse command-line arguments @@ -727,7 +730,11 @@ int encoder_main( if ( arg.rtpdumpOutput && init_RtpWriter ) { +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API + if ( ( error = IVAS_RTP_WRITER_Init( ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket, payloadType, ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_RTP_WRITER_Init( ivasRtp, arg.outputBitstreamFilename, arg.numFramesPerPacket, ssrc, seqNumInitVal ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError: Can't open output bitstream file for RTP output %s \n\n", arg.outputBitstreamFilename ); goto cleanup; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index aac5939fc..5b158d957 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -68,6 +68,10 @@ #define IVAS_TIME_SCALE_MIN 50 /* min. time-scaling [%] */ #define IVAS_TIME_SCALE_MAX 150 /* max. time-scaling [%] */ +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API +/* RTP constants */ +#define DEFAULT_IVAS_PAYLOAD_TYPE ( 96 ) +#endif /*----------------------------------------------------------------------------------* * Common API enum for output audio configurations diff --git a/lib_com/options.h b/lib_com/options.h index 374e387de..07ebed8ce 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -99,6 +99,7 @@ #define FIX_1543_MID_LSF_BITS /* VA: float issue 1543: Resolve "MSAN: use-of-uninitialized-value in lib_enc/lsf_enc.c:262:5 for EVS encoder" */ #define FIX_2488_PREVENT_NEG_PITCH /* VA: Fix for 2488, use saturation to prevent possible wrap-around, thus negative pitch values */ #define FIX_1547_ISMDTX_HANDLE /* VA: float issue 1547: fix use of 'hISMDTX' handle */ +#define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_util/ivas_rtp_api.h b/lib_util/ivas_rtp_api.h index f196539fb..db889f562 100644 --- a/lib_util/ivas_rtp_api.h +++ b/lib_util/ivas_rtp_api.h @@ -303,8 +303,10 @@ void IVAS_RTP_PACK_Close( ); /* Update the RTP Header structure */ +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API ivas_error IVAS_RTP_PACK_UpdateHeader( IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + uint8_t payloadType, /* i : 7-bit payload type indication, negotiated via sdp */ uint16_t seqNumInitVal, /* i : Initial sequence number to be used for 1st packet */ uint32_t ssrc, /* i : Unique 32-bit Source ID as negotiated during SDP */ uint8_t numCC, /* i : numCC indicates no. of contributing sources */ @@ -313,6 +315,18 @@ ivas_error IVAS_RTP_PACK_UpdateHeader( uint16_t numExtensionBytes, /* i : length of the extension data */ uint8_t *extData /* i : extension data pointer */ ); +#else +ivas_error IVAS_RTP_PACK_UpdateHeader( + IVAS_RTP_PACK_HANDLE hIvasPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + uint16_t seqNumInitVal, /* i : Initial sequence number to be used for 1st packet */ + uint32_t ssrc, /* i : Unique 32-bit Source ID as negotiated during SDP */ + uint8_t numCC, /* i : numCC indicates no. of contributing sources */ + uint32_t *csrc, /* i : SSRCs of contributing Sources for a mixed stream */ + uint16_t extHeaderId, /* i : extension header ID */ + uint16_t numExtensionBytes, /* i : length of the extension data */ + uint8_t *extData /* i : extension data pointer */ +); +#endif /* Add requests for remote sender using a key value pair api * each key must be provided with a corresponding value type diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c index 37d03a385..3a6ccaddc 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -864,13 +864,24 @@ void IVAS_RTP_Term( } } +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, /* i/o : IVAS RTP File writer handle */ const char *outputBitstreamFilename, /* i : RTP Dump filename */ uint32_t numFramesPerPacket, /* i : No. of frames per packet desired */ + uint8_t payloadType, /* i : Payload Type negotiated via sdp */ uint32_t SSRC, /* i : SSRC for RTP Header */ uint16_t seqNumInitVal /* i : Initial seq number in rtp header */ ) +#else +ivas_error IVAS_RTP_WRITER_Init( + IVAS_RTP *rtp, /* i/o : IVAS RTP File writer handle */ + const char *outputBitstreamFilename, /* i : RTP Dump filename */ + uint32_t numFramesPerPacket, /* i : No. of frames per packet desired */ + uint32_t SSRC, /* i : SSRC for RTP Header */ + uint16_t seqNumInitVal /* i : Initial seq number in rtp header */ +) +#endif { ivas_error error = IVAS_ERR_OK; @@ -891,7 +902,11 @@ ivas_error IVAS_RTP_WRITER_Init( return error; } +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API + error = IVAS_RTP_PACK_UpdateHeader( rtp->hPack, payloadType, seqNumInitVal, SSRC, 0, NULL, 0, 0, NULL ); +#else error = IVAS_RTP_PACK_UpdateHeader( rtp->hPack, seqNumInitVal, SSRC, 0, NULL, 0, 0, NULL ); +#endif if ( error != IVAS_ERR_OK ) { fprintf( stderr, "error in IVAS_RTP_PACK_UpdateHeader(): %d\n", error ); diff --git a/lib_util/ivas_rtp_file.h b/lib_util/ivas_rtp_file.h index a3742c6c8..4483dea95 100644 --- a/lib_util/ivas_rtp_file.h +++ b/lib_util/ivas_rtp_file.h @@ -68,7 +68,11 @@ typedef struct IVAS_RTP_SR_INFO srInfo; } IVAS_RTP; +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API +ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, const char *outputBitstreamFilename, uint32_t numFramesPerPacket, uint8_t payloadType, uint32_t SSRC, uint16_t seqNumInitVal ); +#else ivas_error IVAS_RTP_WRITER_Init( IVAS_RTP *rtp, const char *outputBitstreamFilename, uint32_t numFramesPerPacket, uint32_t SSRC, uint16_t seqNumInitVal ); +#endif ivas_error IVAS_RTP_READER_Init( IVAS_RTP *rtp, const char *inputBitstreamFilename, const char *piOutputFilename, bool isExtOutput, const char *outputWavFilename ); void IVAS_RTP_Term( IVAS_RTP *rtp ); ivas_error IVAS_RTP_WriteNextFrame( IVAS_RTP *rtp, uint8_t *au, const IVAS_RTP_SR_INFO *srInfo, int16_t auSizeBits, bool isMono, bool forcePacket ); diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 137c44119..77b1c641a 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -173,8 +173,10 @@ static const uint32_t amrWBIOFrameSizeInBits[] = { /* Update the RTP Header structure */ +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API ivas_error IVAS_RTP_PACK_UpdateHeader( IVAS_RTP_PACK_HANDLE hPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + uint8_t payloadType, /* i : 7-bit payload type indication, negotiated via sdp */ uint16_t seqNumInitVal, /* i : Initial sequence number to be used for 1st packet */ uint32_t ssrc, /* i : Unique 32-bit Source ID as negotiated during SDP */ uint8_t numCC, /* i : numCC indicates no. of contributing sources */ @@ -183,6 +185,18 @@ ivas_error IVAS_RTP_PACK_UpdateHeader( uint16_t numExtensionBytes, /* i : length of the extension data */ uint8_t *extData /* i : extension data pointer */ ) +#else +ivas_error IVAS_RTP_PACK_UpdateHeader( + IVAS_RTP_PACK_HANDLE hPack, /* i/o: pointer to an IVAS rtp packer handle to be opened */ + uint16_t seqNumInitVal, /* i : Initial sequence number to be used for 1st packet */ + uint32_t ssrc, /* i : Unique 32-bit Source ID as negotiated during SDP */ + uint8_t numCC, /* i : numCC indicates no. of contributing sources */ + uint32_t *csrc, /* i : SSRCs of contributing Sources for a mixed stream */ + uint16_t extHeaderId, /* i : extension header ID */ + uint16_t numExtensionBytes, /* i : length of the extension data */ + uint8_t *extData /* i : extension data pointer */ +) +#endif { RTP_HEADER *header = &hPack->header; @@ -191,6 +205,9 @@ ivas_error IVAS_RTP_PACK_UpdateHeader( return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "CC must be less than 16" ); } +#ifdef FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API + header->payloadType = payloadType; +#endif header->seqNumber = seqNumInitVal; header->ssrc = ssrc; header->CC = numCC; -- GitLab