From 80c3a98209f8743b71c203b1d92c7a0469180f20 Mon Sep 17 00:00:00 2001 From: Ripinder Singh Date: Thu, 12 Mar 2026 09:20:00 +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 e36297286..b47443ccc 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1957,6 +1957,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 ) { @@ -1993,7 +1996,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 ebb81866e..7b5780f33 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -230,6 +230,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 @@ -623,7 +626,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 69a6a1d30..9fc919c96 100644 --- a/apps/encoder_fmtsw.c +++ b/apps/encoder_fmtsw.c @@ -340,6 +340,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 @@ -731,7 +734,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 b4b6579f2..4e1d09560 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -66,6 +66,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 bbea3aa15..2a5ebed82 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,6 +169,7 @@ /* any switch which is non-be wrt. TS 26.258 V3.0 */ #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_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 6b23bd04e..574dae12e 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 35733681c..3f39806a6 100644 --- a/lib_util/ivas_rtp_file.c +++ b/lib_util/ivas_rtp_file.c @@ -816,13 +816,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; @@ -842,7 +853,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 71b70fcc2..8db6ddb0c 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -174,8 +174,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 */ @@ -184,6 +186,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; @@ -192,6 +206,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