From 332274dfefdf1f7a106c9f035f83eb8b001b2e44 Mon Sep 17 00:00:00 2001 From: Minyue Li Date: Wed, 13 Nov 2019 16:05:46 +0100 Subject: [PATCH] Adding GetInDtx to WebRTC Opus Interface. Bug: webrtc:11085 Change-Id: Ie9152cbe3f3c70f6febafb877852d68a831bcae9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159708 Commit-Queue: Minyue Li Reviewed-by: Henrik Lundin Cr-Commit-Position: refs/heads/master@{#29834} --- modules/audio_coding/codecs/opus/opus_interface.cc | 12 ++++++++++++ modules/audio_coding/codecs/opus/opus_interface.h | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/modules/audio_coding/codecs/opus/opus_interface.cc b/modules/audio_coding/codecs/opus/opus_interface.cc index 2f475cbed1..f98afd792f 100644 --- a/modules/audio_coding/codecs/opus/opus_interface.cc +++ b/modules/audio_coding/codecs/opus/opus_interface.cc @@ -370,6 +370,18 @@ int16_t WebRtcOpus_SetForceChannels(OpusEncInst* inst, size_t num_channels) { } } +int32_t WebRtcOpus_GetInDtx(OpusEncInst* inst) { + if (!inst) { + return -1; + } + int32_t in_dtx; + if (ENCODER_CTL(inst, OPUS_GET_IN_DTX(&in_dtx)) == 0) { + return in_dtx; + } else { + return -1; + } +} + int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, size_t channels, int sample_rate_hz) { diff --git a/modules/audio_coding/codecs/opus/opus_interface.h b/modules/audio_coding/codecs/opus/opus_interface.h index ef62e0d04d..e8de973010 100644 --- a/modules/audio_coding/codecs/opus/opus_interface.h +++ b/modules/audio_coding/codecs/opus/opus_interface.h @@ -306,6 +306,20 @@ int32_t WebRtcOpus_GetBandwidth(OpusEncInst* inst); */ int16_t WebRtcOpus_SetBandwidth(OpusEncInst* inst, int32_t bandwidth); +/* + * WebRtcOpus_GetInDtx(...) + * + * Gets the DTX state of the encoder. + * + * Input: + * - inst : Encoder context + * + * Return value : -1 - Error. + * 1 - Last encoded frame was comfort noise update during DTX. + * 0 - Last encoded frame was encoded with encoder not in DTX. + */ +int32_t WebRtcOpus_GetInDtx(OpusEncInst* inst); + /* * WebRtcOpus_SetForceChannels(...) *