niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
mflodman@webrtc.org | 9a065d1 | 2012-03-07 08:12:21 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
turaj@webrtc.org | b7edd06 | 2013-03-12 22:27:27 +0000 | [diff] [blame] | 11 | #include "webrtc/voice_engine/voe_dtmf_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
turaj@webrtc.org | b7edd06 | 2013-03-12 22:27:27 +0000 | [diff] [blame] | 13 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 14 | #include "webrtc/system_wrappers/interface/trace.h" |
| 15 | #include "webrtc/voice_engine/channel.h" |
| 16 | #include "webrtc/voice_engine/include/voe_errors.h" |
| 17 | #include "webrtc/voice_engine/output_mixer.h" |
| 18 | #include "webrtc/voice_engine/transmit_mixer.h" |
| 19 | #include "webrtc/voice_engine/voice_engine_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | VoEDtmf* VoEDtmf::GetInterface(VoiceEngine* voiceEngine) |
| 24 | { |
| 25 | #ifndef WEBRTC_VOICE_ENGINE_DTMF_API |
| 26 | return NULL; |
| 27 | #else |
| 28 | if (NULL == voiceEngine) |
| 29 | { |
| 30 | return NULL; |
| 31 | } |
tommi@webrtc.org | 0989fb7 | 2013-02-15 15:07:32 +0000 | [diff] [blame] | 32 | VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
tommi@webrtc.org | a990e12 | 2012-04-26 15:28:22 +0000 | [diff] [blame] | 33 | s->AddRef(); |
| 34 | return s; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | #endif |
| 36 | } |
| 37 | |
| 38 | #ifdef WEBRTC_VOICE_ENGINE_DTMF_API |
| 39 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 40 | VoEDtmfImpl::VoEDtmfImpl(voe::SharedData* shared) : |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | _dtmfFeedback(true), |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 42 | _dtmfDirectFeedback(false), |
| 43 | _shared(shared) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 45 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | "VoEDtmfImpl::VoEDtmfImpl() - ctor"); |
| 47 | } |
| 48 | |
| 49 | VoEDtmfImpl::~VoEDtmfImpl() |
| 50 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 51 | WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | "VoEDtmfImpl::~VoEDtmfImpl() - dtor"); |
| 53 | } |
| 54 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | int VoEDtmfImpl::SendTelephoneEvent(int channel, |
andrew@webrtc.org | f81f9f8 | 2011-08-19 22:56:22 +0000 | [diff] [blame] | 56 | int eventCode, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | bool outOfBand, |
| 58 | int lengthMs, |
| 59 | int attenuationDb) |
| 60 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 61 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | "SendTelephoneEvent(channel=%d, eventCode=%d, outOfBand=%d," |
| 63 | "length=%d, attenuationDb=%d)", |
| 64 | channel, eventCode, (int)outOfBand, lengthMs, attenuationDb); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 65 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 67 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | return -1; |
| 69 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 70 | voe::ScopedChannel sc(_shared->channel_manager(), channel); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | voe::Channel* channelPtr = sc.ChannelPtr(); |
| 72 | if (channelPtr == NULL) |
| 73 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 74 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 75 | "SendTelephoneEvent() failed to locate channel"); |
| 76 | return -1; |
| 77 | } |
| 78 | if (!channelPtr->Sending()) |
| 79 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 80 | _shared->SetLastError(VE_NOT_SENDING, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | "SendTelephoneEvent() sending is not active"); |
| 82 | return -1; |
| 83 | } |
| 84 | |
| 85 | // Sanity check |
| 86 | const int maxEventCode = outOfBand ? |
| 87 | static_cast<int>(kMaxTelephoneEventCode) : |
| 88 | static_cast<int>(kMaxDtmfEventCode); |
| 89 | const bool testFailed = ((eventCode < 0) || |
| 90 | (eventCode > maxEventCode) || |
| 91 | (lengthMs < kMinTelephoneEventDuration) || |
| 92 | (lengthMs > kMaxTelephoneEventDuration) || |
| 93 | (attenuationDb < kMinTelephoneEventAttenuation) || |
| 94 | (attenuationDb > kMaxTelephoneEventAttenuation)); |
| 95 | if (testFailed) |
| 96 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 97 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 98 | "SendTelephoneEvent() invalid parameter(s)"); |
| 99 | return -1; |
| 100 | } |
| 101 | |
| 102 | const bool isDtmf = |
| 103 | (eventCode >= 0) && (eventCode <= kMaxDtmfEventCode); |
| 104 | const bool playDtmfToneDirect = |
| 105 | isDtmf && (_dtmfFeedback && _dtmfDirectFeedback); |
| 106 | |
| 107 | if (playDtmfToneDirect) |
| 108 | { |
| 109 | // Mute the microphone signal while playing back the tone directly. |
| 110 | // This is to reduce the risk of introducing echo from the added output. |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 111 | _shared->transmit_mixer()->UpdateMuteMicrophoneTime(lengthMs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | |
| 113 | // Play out local feedback tone directly (same approach for both inband |
| 114 | // and outband). |
| 115 | // Reduce the length of the the tone with 80ms to reduce risk of echo. |
| 116 | // For non-direct feedback, outband and inband cases are handled |
| 117 | // differently. |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 118 | _shared->output_mixer()->PlayDtmfTone(eventCode, lengthMs - 80, |
| 119 | attenuationDb); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | if (outOfBand) |
| 123 | { |
| 124 | // The RTP/RTCP module will always deliver OnPlayTelephoneEvent when |
| 125 | // an event is transmitted. It is up to the VoE to utilize it or not. |
| 126 | // This flag ensures that feedback/playout is enabled; however, the |
| 127 | // channel object must still parse out the Dtmf events (0-15) from |
| 128 | // all possible events (0-255). |
| 129 | const bool playDTFMEvent = (_dtmfFeedback && !_dtmfDirectFeedback); |
| 130 | |
| 131 | return channelPtr->SendTelephoneEventOutband(eventCode, |
| 132 | lengthMs, |
| 133 | attenuationDb, |
| 134 | playDTFMEvent); |
| 135 | } |
| 136 | else |
| 137 | { |
| 138 | // For Dtmf tones, we want to ensure that inband tones are played out |
| 139 | // in sync with the transmitted audio. This flag is utilized by the |
| 140 | // channel object to determine if the queued Dtmf e vent shall also |
| 141 | // be fed to the output mixer in the same step as input audio is |
| 142 | // replaced by inband Dtmf tones. |
| 143 | const bool playDTFMEvent = |
| 144 | (isDtmf && _dtmfFeedback && !_dtmfDirectFeedback); |
| 145 | |
| 146 | return channelPtr->SendTelephoneEventInband(eventCode, |
| 147 | lengthMs, |
| 148 | attenuationDb, |
| 149 | playDTFMEvent); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | int VoEDtmfImpl::SetSendTelephoneEventPayloadType(int channel, |
| 154 | unsigned char type) |
| 155 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 156 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 157 | "SetSendTelephoneEventPayloadType(channel=%d, type=%u)", |
| 158 | channel, type); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 159 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 160 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 161 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 162 | return -1; |
| 163 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 164 | voe::ScopedChannel sc(_shared->channel_manager(), channel); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 165 | voe::Channel* channelPtr = sc.ChannelPtr(); |
| 166 | if (channelPtr == NULL) |
| 167 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 168 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 169 | "SetSendTelephoneEventPayloadType() failed to locate channel"); |
| 170 | return -1; |
| 171 | } |
| 172 | return channelPtr->SetSendTelephoneEventPayloadType(type); |
| 173 | } |
| 174 | |
| 175 | int VoEDtmfImpl::GetSendTelephoneEventPayloadType(int channel, |
| 176 | unsigned char& type) |
| 177 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 178 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 179 | "GetSendTelephoneEventPayloadType(channel=%d)", channel); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 180 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 181 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 182 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 183 | return -1; |
| 184 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 185 | voe::ScopedChannel sc(_shared->channel_manager(), channel); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 186 | voe::Channel* channelPtr = sc.ChannelPtr(); |
| 187 | if (channelPtr == NULL) |
| 188 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 189 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 190 | "GetSendTelephoneEventPayloadType() failed to locate channel"); |
| 191 | return -1; |
| 192 | } |
| 193 | return channelPtr->GetSendTelephoneEventPayloadType(type); |
| 194 | } |
| 195 | |
andrew@webrtc.org | f81f9f8 | 2011-08-19 22:56:22 +0000 | [diff] [blame] | 196 | int VoEDtmfImpl::PlayDtmfTone(int eventCode, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 197 | int lengthMs, |
| 198 | int attenuationDb) |
| 199 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 200 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 201 | "PlayDtmfTone(eventCode=%d, lengthMs=%d, attenuationDb=%d)", |
| 202 | eventCode, lengthMs, attenuationDb); |
| 203 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 204 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 205 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 206 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 207 | return -1; |
| 208 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 209 | if (!_shared->audio_device()->Playing()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 210 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 211 | _shared->SetLastError(VE_NOT_PLAYING, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 212 | "PlayDtmfTone() no channel is playing out"); |
| 213 | return -1; |
| 214 | } |
| 215 | if ((eventCode < kMinDtmfEventCode) || |
| 216 | (eventCode > kMaxDtmfEventCode) || |
| 217 | (lengthMs < kMinTelephoneEventDuration) || |
| 218 | (lengthMs > kMaxTelephoneEventDuration) || |
| 219 | (attenuationDb <kMinTelephoneEventAttenuation) || |
| 220 | (attenuationDb > kMaxTelephoneEventAttenuation)) |
| 221 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 222 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 223 | "PlayDtmfTone() invalid tone parameter(s)"); |
| 224 | return -1; |
| 225 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 226 | return _shared->output_mixer()->PlayDtmfTone(eventCode, lengthMs, |
| 227 | attenuationDb); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 228 | } |
| 229 | |
andrew@webrtc.org | f81f9f8 | 2011-08-19 22:56:22 +0000 | [diff] [blame] | 230 | int VoEDtmfImpl::StartPlayingDtmfTone(int eventCode, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 231 | int attenuationDb) |
| 232 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 233 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 234 | "StartPlayingDtmfTone(eventCode=%d, attenuationDb=%d)", |
| 235 | eventCode, attenuationDb); |
| 236 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 237 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 238 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 239 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 240 | return -1; |
| 241 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 242 | if (!_shared->audio_device()->Playing()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 243 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 244 | _shared->SetLastError(VE_NOT_PLAYING, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 245 | "StartPlayingDtmfTone() no channel is playing out"); |
| 246 | return -1; |
| 247 | } |
| 248 | if ((eventCode < kMinDtmfEventCode) || |
| 249 | (eventCode > kMaxDtmfEventCode) || |
| 250 | (attenuationDb < kMinTelephoneEventAttenuation) || |
| 251 | (attenuationDb > kMaxTelephoneEventAttenuation)) |
| 252 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 253 | _shared->SetLastError(VE_INVALID_ARGUMENT, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 254 | "StartPlayingDtmfTone() invalid tone parameter(s)"); |
| 255 | return -1; |
| 256 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 257 | return _shared->output_mixer()->StartPlayingDtmfTone(eventCode, |
| 258 | attenuationDb); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | int VoEDtmfImpl::StopPlayingDtmfTone() |
| 262 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 263 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 264 | "StopPlayingDtmfTone()"); |
| 265 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 266 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 267 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 268 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 269 | return -1; |
| 270 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 271 | return _shared->output_mixer()->StopPlayingDtmfTone(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 272 | } |
| 273 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 274 | int VoEDtmfImpl::SetDtmfFeedbackStatus(bool enable, bool directFeedback) |
| 275 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 276 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 277 | "SetDtmfFeedbackStatus(enable=%d, directFeeback=%d)", |
| 278 | (int)enable, (int)directFeedback); |
| 279 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 280 | CriticalSectionScoped sc(_shared->crit_sec()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 281 | |
| 282 | _dtmfFeedback = enable; |
| 283 | _dtmfDirectFeedback = directFeedback; |
| 284 | |
| 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | int VoEDtmfImpl::GetDtmfFeedbackStatus(bool& enabled, bool& directFeedback) |
| 289 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 290 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 291 | "GetDtmfFeedbackStatus()"); |
| 292 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 293 | CriticalSectionScoped sc(_shared->crit_sec()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 294 | |
| 295 | enabled = _dtmfFeedback; |
| 296 | directFeedback = _dtmfDirectFeedback; |
| 297 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 298 | WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, |
| 299 | VoEId(_shared->instance_id(), -1), |
| 300 | "GetDtmfFeedbackStatus() => enabled=%d, directFeedback=%d", |
| 301 | enabled, directFeedback); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 302 | return 0; |
| 303 | } |
| 304 | |
| 305 | int VoEDtmfImpl::SetDtmfPlayoutStatus(int channel, bool enable) |
| 306 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 307 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 308 | "SetDtmfPlayoutStatus(channel=%d, enable=%d)", |
| 309 | channel, enable); |
sjlee@webrtc.org | 4b42508 | 2012-09-10 17:58:21 +0000 | [diff] [blame] | 310 | IPHONE_NOT_SUPPORTED(_shared->statistics()); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 311 | |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 312 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 313 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 314 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 315 | return -1; |
| 316 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 317 | voe::ScopedChannel sc(_shared->channel_manager(), channel); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 318 | voe::Channel* channelPtr = sc.ChannelPtr(); |
| 319 | if (channelPtr == NULL) |
| 320 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 321 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 322 | "SetDtmfPlayoutStatus() failed to locate channel"); |
| 323 | return -1; |
| 324 | } |
| 325 | return channelPtr->SetDtmfPlayoutStatus(enable); |
| 326 | } |
| 327 | |
| 328 | int VoEDtmfImpl::GetDtmfPlayoutStatus(int channel, bool& enabled) |
| 329 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 330 | WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 331 | "GetDtmfPlayoutStatus(channel=%d, enabled=?)", channel); |
sjlee@webrtc.org | 4b42508 | 2012-09-10 17:58:21 +0000 | [diff] [blame] | 332 | IPHONE_NOT_SUPPORTED(_shared->statistics()); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 333 | if (!_shared->statistics().Initialized()) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 334 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 335 | _shared->SetLastError(VE_NOT_INITED, kTraceError); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 336 | return -1; |
| 337 | } |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 338 | voe::ScopedChannel sc(_shared->channel_manager(), channel); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 339 | voe::Channel* channelPtr = sc.ChannelPtr(); |
| 340 | if (channelPtr == NULL) |
| 341 | { |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 342 | _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 343 | "GetDtmfPlayoutStatus() failed to locate channel"); |
| 344 | return -1; |
| 345 | } |
| 346 | enabled = channelPtr->DtmfPlayoutStatus(); |
tommi@webrtc.org | 851becd | 2012-04-04 14:57:19 +0000 | [diff] [blame] | 347 | WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, |
| 348 | VoEId(_shared->instance_id(), -1), |
| 349 | "GetDtmfPlayoutStatus() => enabled=%d", enabled); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | #endif // #ifdef WEBRTC_VOICE_ENGINE_DTMF_API |
| 354 | |
| 355 | } // namespace webrtc |