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}
diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c
index 41e17ae..5bb3472 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 @@
// 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 {