From deaf6fb071e68a242db342d61a11220edd2bb546 Mon Sep 17 00:00:00 2001 From: "henrik.lundin" Date: Wed, 1 Mar 2017 00:49:18 -0800 Subject: [PATCH] Opus: Let the decoder interpret 2-byte payloads as DTX/CNG packets This CL matches the work done in https://codereview.webrtc.org/2693453003. BUG=webrtc:7272 TBR=minyue@webrtc.org Review-Url: https://codereview.webrtc.org/2723893004 Cr-Commit-Position: refs/heads/master@{#16930} --- webrtc/modules/audio_coding/codecs/opus/opus_interface.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c index 41e17ae510..5bb3472b5a 100644 --- a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c +++ b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c @@ -283,7 +283,11 @@ static int16_t DetermineAudioType(OpusDecInst* inst, size_t encoded_bytes) { // to be so if the following |encoded_byte| are 0 or 1. if (encoded_bytes == 0 && inst->in_dtx_mode) { return 2; // Comfort noise. - } else if (encoded_bytes == 1) { + } else if (encoded_bytes == 1 || encoded_bytes == 2) { + // TODO(henrik.lundin): There is a slight risk that a 2-byte payload is in + // fact a 1-byte TOC with a 1-byte payload. That will be erroneously + // interpreted as comfort noise output, but such a payload is probably + // faulty anyway. inst->in_dtx_mode = 1; return 2; // Comfort noise. } else {