diff --git a/webrtc/modules/audio_coding/neteq/neteq_error_codes.h b/webrtc/modules/audio_coding/neteq/neteq_error_codes.h index 1ce468096..ab639d9c3 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_error_codes.h +++ b/webrtc/modules/audio_coding/neteq/neteq_error_codes.h @@ -40,6 +40,8 @@ #define RECIN_CNG_ERROR -3001 #define RECIN_UNKNOWNPAYLOAD -3002 #define RECIN_BUFFERINSERT_ERROR -3003 +#define RECIN_SYNC_RTP_CHANGED_CODEC -3004 +#define RECIN_SYNC_RTP_NOT_ACCEPTABLE -3005 /* PBUFFER/BUFSTAT ERRORS */ #define PBUFFER_INIT_ERROR -4001 diff --git a/webrtc/modules/audio_coding/neteq/recin.c b/webrtc/modules/audio_coding/neteq/recin.c index 15d618e76..17bea5f5b 100644 --- a/webrtc/modules/audio_coding/neteq/recin.c +++ b/webrtc/modules/audio_coding/neteq/recin.c @@ -17,13 +17,12 @@ #include -#include "signal_processing_library.h" - #include "automode.h" #include "dtmf_buffer.h" +#include "mcu_dsp_common.h" #include "neteq_defines.h" #include "neteq_error_codes.h" - +#include "signal_processing_library.h" int WebRtcNetEQ_RecInInternal(MCUInst_t *MCU_inst, RTPPacket_t *RTPpacketInput, uint32_t uw32_timeRec) @@ -36,6 +35,8 @@ int WebRtcNetEQ_RecInInternal(MCUInst_t *MCU_inst, RTPPacket_t *RTPpacketInput, int curr_Codec; int16_t isREDPayload = 0; int32_t temp_bufsize; + int is_sync_rtp = MCU_inst->av_sync && WebRtcNetEQ_IsSyncPayload( + RTPpacketInput->payload, RTPpacketInput->payloadLen); #ifdef NETEQ_RED_CODEC RTPPacket_t* RTPpacketPtr[2]; /* Support for redundancy up to 2 payloads */ RTPpacketPtr[0] = &RTPpacket[0]; @@ -77,15 +78,23 @@ int WebRtcNetEQ_RecInInternal(MCUInst_t *MCU_inst, RTPPacket_t *RTPpacketInput, } - /* Call RTCP statistics */ - i_ok |= WebRtcNetEQ_RTCPUpdate(&(MCU_inst->RTCP_inst), RTPpacket[0].seqNumber, - RTPpacket[0].timeStamp, uw32_timeRec); + if (!is_sync_rtp) { /* Update only if it not sync packet. */ + /* Call RTCP statistics if it is not sync packet. */ + i_ok |= WebRtcNetEQ_RTCPUpdate(&(MCU_inst->RTCP_inst), + RTPpacket[0].seqNumber, + RTPpacket[0].timeStamp, uw32_timeRec); + } /* If Redundancy is supported and this is the redundancy payload, separate the payloads */ #ifdef NETEQ_RED_CODEC if (RTPpacket[0].payloadType == WebRtcNetEQ_DbGetPayload(&MCU_inst->codec_DB_inst, kDecoderRED)) { + if (is_sync_rtp) + { + /* Sync packet should not have RED payload type. */ + return RECIN_SYNC_RTP_NOT_ACCEPTABLE; + } /* Split the payload into a main and a redundancy payloads */ i_ok = WebRtcNetEQ_RedundancySplit(RTPpacketPtr, 2, &i_No_Of_Payloads); @@ -127,7 +136,7 @@ int WebRtcNetEQ_RecInInternal(MCUInst_t *MCU_inst, RTPPacket_t *RTPpacketInput, /* Force update of SplitInfo if it's iLBC because of potential change between 20/30ms */ if (RTPpacket[i_k].payloadType == WebRtcNetEQ_DbGetPayload(&MCU_inst->codec_DB_inst, - kDecoderILBC)) + kDecoderILBC) && !is_sync_rtp) /* Don't update if sync RTP. */ { i_ok = WebRtcNetEQ_DbGetSplitInfo( &MCU_inst->PayloadSplit_inst, @@ -175,6 +184,12 @@ int WebRtcNetEQ_RecInInternal(MCUInst_t *MCU_inst, RTPPacket_t *RTPpacketInput, if (RTPpacket[i_k].payloadType == WebRtcNetEQ_DbGetPayload(&MCU_inst->codec_DB_inst, kDecoderAVT)) { + if (is_sync_rtp) + { + /* Sync RTP should not have AVT payload type. */ + return RECIN_SYNC_RTP_NOT_ACCEPTABLE; + } + #ifdef NETEQ_ATEVENT_DECODE if (MCU_inst->AVT_PlayoutOn) { @@ -205,6 +220,11 @@ int WebRtcNetEQ_RecInInternal(MCUInst_t *MCU_inst, RTPPacket_t *RTPpacketInput, /* Get CNG sample rate */ uint16_t fsCng = WebRtcNetEQ_DbGetSampleRate(&MCU_inst->codec_DB_inst, RTPpacket[i_k].payloadType); + if (is_sync_rtp) + { + /* Sync RTP should not have CNG payload type. */ + return RECIN_SYNC_RTP_NOT_ACCEPTABLE; + } /* Force sampling frequency to 32000 Hz CNG 48000 Hz. */ /* TODO(tlegrand): remove limitation once ACM has full 48 kHz @@ -245,6 +265,11 @@ int WebRtcNetEQ_RecInInternal(MCUInst_t *MCU_inst, RTPPacket_t *RTPpacketInput, { return RECIN_UNKNOWNPAYLOAD; } + if (is_sync_rtp) + { + /* Sync RTP should not cause codec change. */ + return RECIN_SYNC_RTP_CHANGED_CODEC; + } MCU_inst->current_Codec = curr_Codec; MCU_inst->current_Payload = RTPpacket[i_k].payloadType; i_ok = WebRtcNetEQ_DbGetSplitInfo(&MCU_inst->PayloadSplit_inst, @@ -280,10 +305,11 @@ int WebRtcNetEQ_RecInInternal(MCUInst_t *MCU_inst, RTPPacket_t *RTPpacketInput, } /* - * Update Bandwidth Estimate - * Only send the main payload to BWE + * If not sync RTP, update Bandwidth Estimate. + * Only send the main payload to BWE. */ - if ((curr_Codec = WebRtcNetEQ_DbGetCodec(&MCU_inst->codec_DB_inst, + if (!is_sync_rtp && + (curr_Codec = WebRtcNetEQ_DbGetCodec(&MCU_inst->codec_DB_inst, RTPpacket[0].payloadType)) >= 0) { codecPos = MCU_inst->codec_DB_inst.position[curr_Codec]; diff --git a/webrtc/modules/audio_coding/neteq/split_and_insert.c b/webrtc/modules/audio_coding/neteq/split_and_insert.c index 252d7139e..d7f17fdc8 100644 --- a/webrtc/modules/audio_coding/neteq/split_and_insert.c +++ b/webrtc/modules/audio_coding/neteq/split_and_insert.c @@ -16,9 +16,9 @@ #include -#include "signal_processing_library.h" - +#include "mcu_dsp_common.h" #include "neteq_error_codes.h" +#include "signal_processing_library.h" int WebRtcNetEQ_SplitAndInsertPayload(RTPPacket_t* packet, PacketBuf_t* Buffer_inst, @@ -33,6 +33,8 @@ int WebRtcNetEQ_SplitAndInsertPayload(RTPPacket_t* packet, RTPPacket_t temp_packet; int16_t localFlushed = 0; const int16_t *pw16_startPayload; + const int is_sync_rtp = av_sync && + WebRtcNetEQ_IsSyncPayload(packet->payload, packet->payloadLen); *flushed = 0; len = packet->payloadLen; @@ -41,7 +43,8 @@ int WebRtcNetEQ_SplitAndInsertPayload(RTPPacket_t* packet, WEBRTC_SPL_MEMCPY_W8(&temp_packet,packet,sizeof(RTPPacket_t)); - if (split_inst->deltaBytes == NO_SPLIT) + if (split_inst->deltaBytes == NO_SPLIT || + is_sync_rtp) /* Don't split sync RTPs just insert. */ { /* Not splittable codec */ i_ok = WebRtcNetEQ_PacketBufferInsert(Buffer_inst, packet,