From 3987f10c1142ffa07d749ce7b055b8a68892c19d Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Tue, 23 Sep 2014 13:15:14 +0000 Subject: [PATCH] Revert "Remove DTMF status methods from Voice Engine" r7276 This change caused some trouble. TBR=henrika@webrtc.org,pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/29569004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7277 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/media/webrtc/fakewebrtcvoiceengine.h | 2 + webrtc/voice_engine/channel.cc | 21 +++++++++ webrtc/voice_engine/channel.h | 2 + webrtc/voice_engine/include/voe_dtmf.h | 7 +++ .../test/auto_test/standard/dtmf_test.cc | 12 +++++ webrtc/voice_engine/voe_dtmf_impl.cc | 47 +++++++++++++++++++ webrtc/voice_engine/voe_dtmf_impl.h | 4 ++ 7 files changed, 95 insertions(+) diff --git a/talk/media/webrtc/fakewebrtcvoiceengine.h b/talk/media/webrtc/fakewebrtcvoiceengine.h index 1a1abb8991..52a50ff284 100644 --- a/talk/media/webrtc/fakewebrtcvoiceengine.h +++ b/talk/media/webrtc/fakewebrtcvoiceengine.h @@ -690,6 +690,8 @@ class FakeWebRtcVoiceEngine WEBRTC_STUB(SetDtmfFeedbackStatus, (bool enable, bool directFeedback)); WEBRTC_STUB(GetDtmfFeedbackStatus, (bool& enabled, bool& directFeedback)); + WEBRTC_STUB(SetDtmfPlayoutStatus, (int channel, bool enable)); + WEBRTC_STUB(GetDtmfPlayoutStatus, (int channel, bool& enabled)); WEBRTC_FUNC(PlayDtmfTone, (int event_code, int length_ms = 200, int attenuation_db = 10)) { diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index 1d23afd4b9..93a241be34 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -2626,6 +2626,27 @@ int Channel::SendTelephoneEventInband(unsigned char eventCode, return 0; } +int +Channel::SetDtmfPlayoutStatus(bool enable) +{ + WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), + "Channel::SetDtmfPlayoutStatus()"); + if (audio_coding_->SetDtmfPlayoutStatus(enable) != 0) + { + _engineStatisticsPtr->SetLastError( + VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning, + "SetDtmfPlayoutStatus() failed to set Dtmf playout"); + return -1; + } + return 0; +} + +bool +Channel::DtmfPlayoutStatus() const +{ + return audio_coding_->DtmfPlayoutStatus(); +} + int Channel::SetSendTelephoneEventPayloadType(unsigned char type) { diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index bbc286ba38..535922fae8 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/voice_engine/channel.h @@ -294,6 +294,8 @@ public: int attenuationDb, bool playDtmfEvent); int SendTelephoneEventInband(unsigned char eventCode, int lengthMs, int attenuationDb, bool playDtmfEvent); + int SetDtmfPlayoutStatus(bool enable); + bool DtmfPlayoutStatus() const; int SetSendTelephoneEventPayloadType(unsigned char type); int GetSendTelephoneEventPayloadType(unsigned char& type); diff --git a/webrtc/voice_engine/include/voe_dtmf.h b/webrtc/voice_engine/include/voe_dtmf.h index 4fd44961c4..4db8cbc596 100644 --- a/webrtc/voice_engine/include/voe_dtmf.h +++ b/webrtc/voice_engine/include/voe_dtmf.h @@ -71,6 +71,13 @@ public: virtual int GetSendTelephoneEventPayloadType(int channel, unsigned char& type) = 0; + // Enables or disables local tone playout for received DTMF events + // out-of-band. + virtual int SetDtmfPlayoutStatus(int channel, bool enable) = 0; + + // Gets the DTMF playout status. + virtual int GetDtmfPlayoutStatus(int channel, bool& enabled) = 0; + // Toogles DTMF feedback state: when a DTMF tone is sent, the same tone // is played out on the speaker. virtual int SetDtmfFeedbackStatus(bool enable, diff --git a/webrtc/voice_engine/test/auto_test/standard/dtmf_test.cc b/webrtc/voice_engine/test/auto_test/standard/dtmf_test.cc index 18faa971c5..a4feb2eb65 100644 --- a/webrtc/voice_engine/test/auto_test/standard/dtmf_test.cc +++ b/webrtc/voice_engine/test/auto_test/standard/dtmf_test.cc @@ -52,6 +52,18 @@ TEST_F(DtmfTest, TestTwoNonDtmfEvents) { EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 110, true)); } +TEST_F(DtmfTest, ManualCanDisableDtmfPlayoutExceptOnIphone) { + TEST_LOG("Disabling DTMF playout (no tone should be heard) \n"); + EXPECT_EQ(0, voe_dtmf_->SetDtmfPlayoutStatus(channel_, false)); + EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 0, true)); + Sleep(500); + + TEST_LOG("Enabling DTMF playout (tone should be heard) \n"); + EXPECT_EQ(0, voe_dtmf_->SetDtmfPlayoutStatus(channel_, true)); + EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 0, true)); + Sleep(500); +} + // This test modifies the DTMF payload type from the default 106 to 88 // and then runs through 16 DTMF out.of-band events. TEST_F(DtmfTest, ManualCanChangeDtmfPayloadType) { diff --git a/webrtc/voice_engine/voe_dtmf_impl.cc b/webrtc/voice_engine/voe_dtmf_impl.cc index 2d775e34ca..70872c694c 100644 --- a/webrtc/voice_engine/voe_dtmf_impl.cc +++ b/webrtc/voice_engine/voe_dtmf_impl.cc @@ -257,6 +257,53 @@ int VoEDtmfImpl::GetDtmfFeedbackStatus(bool& enabled, bool& directFeedback) enabled, directFeedback); return 0; } + +int VoEDtmfImpl::SetDtmfPlayoutStatus(int channel, bool enable) +{ + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), + "SetDtmfPlayoutStatus(channel=%d, enable=%d)", + channel, enable); + + if (!_shared->statistics().Initialized()) + { + _shared->SetLastError(VE_NOT_INITED, kTraceError); + return -1; + } + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); + if (channelPtr == NULL) + { + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "SetDtmfPlayoutStatus() failed to locate channel"); + return -1; + } + return channelPtr->SetDtmfPlayoutStatus(enable); +} + +int VoEDtmfImpl::GetDtmfPlayoutStatus(int channel, bool& enabled) +{ + WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), + "GetDtmfPlayoutStatus(channel=%d, enabled=?)", channel); + if (!_shared->statistics().Initialized()) + { + _shared->SetLastError(VE_NOT_INITED, kTraceError); + return -1; + } + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); + if (channelPtr == NULL) + { + _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, + "GetDtmfPlayoutStatus() failed to locate channel"); + return -1; + } + enabled = channelPtr->DtmfPlayoutStatus(); + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "GetDtmfPlayoutStatus() => enabled=%d", enabled); + return 0; +} + #endif // #ifdef WEBRTC_VOICE_ENGINE_DTMF_API } // namespace webrtc diff --git a/webrtc/voice_engine/voe_dtmf_impl.h b/webrtc/voice_engine/voe_dtmf_impl.h index 81a95c0b19..921623845f 100644 --- a/webrtc/voice_engine/voe_dtmf_impl.h +++ b/webrtc/voice_engine/voe_dtmf_impl.h @@ -42,6 +42,10 @@ public: int lengthMs = 200, int attenuationDb = 10); + virtual int SetDtmfPlayoutStatus(int channel, bool enable); + + virtual int GetDtmfPlayoutStatus(int channel, bool& enabled); + protected: VoEDtmfImpl(voe::SharedData* shared); virtual ~VoEDtmfImpl();