From b718619f0ab1ad984e334dd90f67e08bb6d80af3 Mon Sep 17 00:00:00 2001 From: "roosa@google.com" Date: Wed, 12 Dec 2012 21:59:14 +0000 Subject: [PATCH] Expose NetEq playout mode off through VoiceEngine. BUG= Review URL: https://webrtc-codereview.appspot.com/971016 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3272 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/common_types.h | 3 ++ .../interface/audio_coding_module_typedefs.h | 5 ++- .../audio_coding/main/source/acm_neteq.cc | 6 +++ .../main/source/audio_coding_module_impl.cc | 3 +- webrtc/voice_engine/channel.cc | 5 +++ .../test/auto_test/standard/neteq_test.cc | 37 +++++++++++++++---- 6 files changed, 49 insertions(+), 10 deletions(-) diff --git a/webrtc/common_types.h b/webrtc/common_types.h index 52cc075ffb..b21fc1b089 100644 --- a/webrtc/common_types.h +++ b/webrtc/common_types.h @@ -430,6 +430,9 @@ enum NetEqModes // NetEQ playout configurations // Optimzed for decodability of fax signals rather than for perceived audio // quality. kNetEqFax = 2, + // Minimal buffer management. Inserts zeros for lost packets and during + // buffer increases. + kNetEqOff = 3, }; enum NetEqBgnModes // NetEQ Background Noise (BGN) configurations diff --git a/webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h b/webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h index c0e06efcd5..1cb28f6f68 100644 --- a/webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h +++ b/webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h @@ -34,11 +34,14 @@ namespace webrtc { // conference participant, a webinar, or a streaming application, // this mode can be used to improve the jitter robustness at // the cost of increased delay. +// -off : Turns off most of NetEQ's features. Stuffs zeros for lost +// packets and during buffer increases. // enum AudioPlayoutMode { voice = 0, fax = 1, - streaming = 2 + streaming = 2, + off = 3, }; /////////////////////////////////////////////////////////////////////////// diff --git a/webrtc/modules/audio_coding/main/source/acm_neteq.cc b/webrtc/modules/audio_coding/main/source/acm_neteq.cc index 24ecba1a13..671a5e33df 100644 --- a/webrtc/modules/audio_coding/main/source/acm_neteq.cc +++ b/webrtc/modules/audio_coding/main/source/acm_neteq.cc @@ -324,6 +324,9 @@ WebRtc_Word32 ACMNetEQ::SetPlayoutMode(const AudioPlayoutMode mode) { case streaming: playoutMode = kPlayoutStreaming; break; + case off: + playoutMode = kPlayoutOff; + break; } if (WebRtcNetEQ_SetPlayoutMode(_inst[idx], playoutMode) < 0) { LogError("SetPlayoutMode", idx); @@ -984,6 +987,9 @@ WebRtc_Word16 ACMNetEQ::AddSlave(const WebRtcNetEQDecoder* usedCodecs, case streaming: playoutMode = kPlayoutStreaming; break; + case off: + playoutMode = kPlayoutOff; + break; } if (WebRtcNetEQ_SetPlayoutMode(_inst[slaveIdx], playoutMode) < 0) { LogError("SetPlayoutMode", 1); diff --git a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc index c659c664f1..7b47b122b7 100644 --- a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc +++ b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc @@ -2226,7 +2226,8 @@ WebRtc_Word32 AudioCodingModuleImpl::DecoderEstimatedBandwidth() const { // Set playout mode for: voice, fax, or streaming. WebRtc_Word32 AudioCodingModuleImpl::SetPlayoutMode( const AudioPlayoutMode mode) { - if ((mode != voice) && (mode != fax) && (mode != streaming)) { + if ((mode != voice) && (mode != fax) && (mode != streaming) && + (mode != off)) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, "Invalid playout mode."); return -1; diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index 4027315d99..ff4a5cedd7 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -2096,6 +2096,9 @@ Channel::SetNetEQPlayoutMode(NetEqModes mode) case kNetEqFax: playoutMode = fax; break; + case kNetEqOff: + playoutMode = off; + break; } if (_audioCodingModule.SetPlayoutMode(playoutMode) != 0) { @@ -2122,6 +2125,8 @@ Channel::GetNetEQPlayoutMode(NetEqModes& mode) case fax: mode = kNetEqFax; break; + case off: + mode = kNetEqOff; } WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,_channelId), diff --git a/webrtc/voice_engine/test/auto_test/standard/neteq_test.cc b/webrtc/voice_engine/test/auto_test/standard/neteq_test.cc index 8184535d67..b54c7778e3 100644 --- a/webrtc/voice_engine/test/auto_test/standard/neteq_test.cc +++ b/webrtc/voice_engine/test/auto_test/standard/neteq_test.cc @@ -13,14 +13,16 @@ class NetEQTest : public AfterStreamingFixture { protected: void SetUp() { - additional_channel_ = voe_base_->CreateChannel(); + additional_channel_[0] = voe_base_->CreateChannel(); + additional_channel_[1] = voe_base_->CreateChannel(); } void TearDown() { - voe_base_->DeleteChannel(additional_channel_); + voe_base_->DeleteChannel(additional_channel_[0]); + voe_base_->DeleteChannel(additional_channel_[1]); } - int additional_channel_; + int additional_channel_[2]; }; TEST_F(NetEQTest, GetNetEQPlayoutModeReturnsDefaultModeByDefault) { @@ -31,22 +33,37 @@ TEST_F(NetEQTest, GetNetEQPlayoutModeReturnsDefaultModeByDefault) { TEST_F(NetEQTest, SetNetEQPlayoutModeActuallySetsTheModeForTheChannel) { webrtc::NetEqModes mode; - // Set for the first channel but leave the second. + // Set for the first channel but leave the others. EXPECT_EQ(0, voe_base_->SetNetEQPlayoutMode(channel_, webrtc::kNetEqFax)); EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(channel_, mode)); EXPECT_EQ(webrtc::kNetEqFax, mode); - EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(additional_channel_, mode)); + EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(additional_channel_[0], mode)); + EXPECT_EQ(webrtc::kNetEqDefault, mode); + EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(additional_channel_[1], mode)); EXPECT_EQ(webrtc::kNetEqDefault, mode); - // Set the second channel, leave the first. + // Set the second channel, leave the others. EXPECT_EQ(0, voe_base_->SetNetEQPlayoutMode( - additional_channel_, webrtc::kNetEqStreaming)); - EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(additional_channel_, mode)); + additional_channel_[0], webrtc::kNetEqStreaming)); + EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(additional_channel_[0], mode)); EXPECT_EQ(webrtc::kNetEqStreaming, mode); EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(channel_, mode)); EXPECT_EQ(webrtc::kNetEqFax, mode); + EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(additional_channel_[1], mode)); + EXPECT_EQ(webrtc::kNetEqDefault, mode); + + // Set the third channel, leave the others. + EXPECT_EQ(0, voe_base_->SetNetEQPlayoutMode( + additional_channel_[1], webrtc::kNetEqOff)); + EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(additional_channel_[1], mode)); + EXPECT_EQ(webrtc::kNetEqOff, mode); + + EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(channel_, mode)); + EXPECT_EQ(webrtc::kNetEqFax, mode); + EXPECT_EQ(0, voe_base_->GetNetEQPlayoutMode(additional_channel_[0], mode)); + EXPECT_EQ(webrtc::kNetEqStreaming, mode); } TEST_F(NetEQTest, GetNetEQBgnModeReturnsBgnOnByDefault) { @@ -79,4 +96,8 @@ TEST_F(NetEQTest, ManualSetEQPlayoutModeStillProducesOkAudio) { EXPECT_EQ(0, voe_base_->SetNetEQPlayoutMode(channel_, webrtc::kNetEqFax)); TEST_LOG("NetEQ fax playout mode enabled => should hear OK audio.\n"); Sleep(2000); + + EXPECT_EQ(0, voe_base_->SetNetEQPlayoutMode(channel_, webrtc::kNetEqOff)); + TEST_LOG("NetEQ off playout mode enabled => should hear OK audio.\n"); + Sleep(2000); }