| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "webrtc/modules/utility/include/process_thread.h" | 33 #include "webrtc/modules/utility/include/process_thread.h" |
| 34 #include "webrtc/system_wrappers/include/trace.h" | 34 #include "webrtc/system_wrappers/include/trace.h" |
| 35 #include "webrtc/voice_engine/include/voe_base.h" | 35 #include "webrtc/voice_engine/include/voe_base.h" |
| 36 #include "webrtc/voice_engine/include/voe_external_media.h" | 36 #include "webrtc/voice_engine/include/voe_external_media.h" |
| 37 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 37 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
| 38 #include "webrtc/voice_engine/output_mixer.h" | 38 #include "webrtc/voice_engine/output_mixer.h" |
| 39 #include "webrtc/voice_engine/statistics.h" | 39 #include "webrtc/voice_engine/statistics.h" |
| 40 #include "webrtc/voice_engine/transmit_mixer.h" | 40 #include "webrtc/voice_engine/transmit_mixer.h" |
| 41 #include "webrtc/voice_engine/utility.h" | 41 #include "webrtc/voice_engine/utility.h" |
| 42 | 42 |
| 43 #if defined(_WIN32) | |
| 44 #include <Qos.h> | |
| 45 #endif | |
| 46 | |
| 47 namespace webrtc { | 43 namespace webrtc { |
| 48 namespace voe { | 44 namespace voe { |
| 49 | 45 |
| 46 const int kTelephoneEventAttenuationdB = 10; |
| 47 |
| 50 class TransportFeedbackProxy : public TransportFeedbackObserver { | 48 class TransportFeedbackProxy : public TransportFeedbackObserver { |
| 51 public: | 49 public: |
| 52 TransportFeedbackProxy() : feedback_observer_(nullptr) { | 50 TransportFeedbackProxy() : feedback_observer_(nullptr) { |
| 53 pacer_thread_.DetachFromThread(); | 51 pacer_thread_.DetachFromThread(); |
| 54 network_thread_.DetachFromThread(); | 52 network_thread_.DetachFromThread(); |
| 55 } | 53 } |
| 56 | 54 |
| 57 void SetTransportFeedbackObserver( | 55 void SetTransportFeedbackObserver( |
| 58 TransportFeedbackObserver* feedback_observer) { | 56 TransportFeedbackObserver* feedback_observer) { |
| 59 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 57 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 } | 354 } |
| 357 | 355 |
| 358 void Channel::OnPlayTelephoneEvent(uint8_t event, | 356 void Channel::OnPlayTelephoneEvent(uint8_t event, |
| 359 uint16_t lengthMs, | 357 uint16_t lengthMs, |
| 360 uint8_t volume) { | 358 uint8_t volume) { |
| 361 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 359 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 362 "Channel::OnPlayTelephoneEvent(event=%u, lengthMs=%u," | 360 "Channel::OnPlayTelephoneEvent(event=%u, lengthMs=%u," |
| 363 " volume=%u)", | 361 " volume=%u)", |
| 364 event, lengthMs, volume); | 362 event, lengthMs, volume); |
| 365 | 363 |
| 366 if (!_playOutbandDtmfEvent || (event > 15)) { | 364 if (event > 15) { |
| 367 // Ignore callback since feedback is disabled or event is not a | 365 // Ignore callback since feedback is disabled or event is not a |
| 368 // Dtmf tone event. | 366 // Dtmf tone event. |
| 369 return; | 367 return; |
| 370 } | 368 } |
| 371 | 369 |
| 372 assert(_outputMixerPtr != NULL); | 370 assert(_outputMixerPtr != NULL); |
| 373 | 371 |
| 374 // Start playing out the Dtmf tone (if playout is enabled). | 372 // Start playing out the Dtmf tone (if playout is enabled). |
| 375 // Reduce length of tone with 80ms to the reduce risk of echo. | 373 // Reduce length of tone with 80ms to the reduce risk of echo. |
| 376 _outputMixerPtr->PlayDtmfTone(event, lengthMs - 80, volume); | 374 _outputMixerPtr->PlayDtmfTone(event, lengthMs - 80, volume); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 _externalTransport(false), | 752 _externalTransport(false), |
| 755 _inputFilePlayerPtr(NULL), | 753 _inputFilePlayerPtr(NULL), |
| 756 _outputFilePlayerPtr(NULL), | 754 _outputFilePlayerPtr(NULL), |
| 757 _outputFileRecorderPtr(NULL), | 755 _outputFileRecorderPtr(NULL), |
| 758 // Avoid conflict with other channels by adding 1024 - 1026, | 756 // Avoid conflict with other channels by adding 1024 - 1026, |
| 759 // won't use as much as 1024 channels. | 757 // won't use as much as 1024 channels. |
| 760 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024), | 758 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024), |
| 761 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025), | 759 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025), |
| 762 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026), | 760 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026), |
| 763 _outputFileRecording(false), | 761 _outputFileRecording(false), |
| 764 _inbandDtmfQueue(VoEModuleId(instanceId, channelId)), | |
| 765 _inbandDtmfGenerator(VoEModuleId(instanceId, channelId)), | |
| 766 _outputExternalMedia(false), | 762 _outputExternalMedia(false), |
| 767 _inputExternalMediaCallbackPtr(NULL), | 763 _inputExternalMediaCallbackPtr(NULL), |
| 768 _outputExternalMediaCallbackPtr(NULL), | 764 _outputExternalMediaCallbackPtr(NULL), |
| 769 _timeStamp(0), // This is just an offset, RTP module will add it's own | 765 _timeStamp(0), // This is just an offset, RTP module will add it's own |
| 770 // random offset | 766 // random offset |
| 771 _sendTelephoneEventPayloadType(106), | |
| 772 ntp_estimator_(Clock::GetRealTimeClock()), | 767 ntp_estimator_(Clock::GetRealTimeClock()), |
| 773 jitter_buffer_playout_timestamp_(0), | 768 jitter_buffer_playout_timestamp_(0), |
| 774 playout_timestamp_rtp_(0), | 769 playout_timestamp_rtp_(0), |
| 775 playout_timestamp_rtcp_(0), | 770 playout_timestamp_rtcp_(0), |
| 776 playout_delay_ms_(0), | 771 playout_delay_ms_(0), |
| 777 _numberOfDiscardedPackets(0), | 772 _numberOfDiscardedPackets(0), |
| 778 send_sequence_number_(0), | 773 send_sequence_number_(0), |
| 779 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), | 774 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), |
| 780 capture_start_rtp_time_stamp_(-1), | 775 capture_start_rtp_time_stamp_(-1), |
| 781 capture_start_ntp_time_ms_(-1), | 776 capture_start_ntp_time_ms_(-1), |
| 782 _engineStatisticsPtr(NULL), | 777 _engineStatisticsPtr(NULL), |
| 783 _outputMixerPtr(NULL), | 778 _outputMixerPtr(NULL), |
| 784 _transmitMixerPtr(NULL), | 779 _transmitMixerPtr(NULL), |
| 785 _moduleProcessThreadPtr(NULL), | 780 _moduleProcessThreadPtr(NULL), |
| 786 _audioDeviceModulePtr(NULL), | 781 _audioDeviceModulePtr(NULL), |
| 787 _voiceEngineObserverPtr(NULL), | 782 _voiceEngineObserverPtr(NULL), |
| 788 _callbackCritSectPtr(NULL), | 783 _callbackCritSectPtr(NULL), |
| 789 _transportPtr(NULL), | 784 _transportPtr(NULL), |
| 790 _rxVadObserverPtr(NULL), | 785 _rxVadObserverPtr(NULL), |
| 791 _oldVadDecision(-1), | 786 _oldVadDecision(-1), |
| 792 _sendFrameType(0), | 787 _sendFrameType(0), |
| 793 _externalMixing(false), | 788 _externalMixing(false), |
| 794 _mixFileWithMicrophone(false), | 789 _mixFileWithMicrophone(false), |
| 795 _mute(false), | 790 _mute(false), |
| 796 _panLeft(1.0f), | 791 _panLeft(1.0f), |
| 797 _panRight(1.0f), | 792 _panRight(1.0f), |
| 798 _outputGain(1.0f), | 793 _outputGain(1.0f), |
| 799 _playOutbandDtmfEvent(false), | |
| 800 _playInbandDtmfEvent(false), | |
| 801 _lastLocalTimeStamp(0), | 794 _lastLocalTimeStamp(0), |
| 802 _lastPayloadType(0), | 795 _lastPayloadType(0), |
| 803 _includeAudioLevelIndication(false), | 796 _includeAudioLevelIndication(false), |
| 804 _outputSpeechType(AudioFrame::kNormalSpeech), | 797 _outputSpeechType(AudioFrame::kNormalSpeech), |
| 805 _average_jitter_buffer_delay_us(0), | 798 _average_jitter_buffer_delay_us(0), |
| 806 _previousTimestamp(0), | 799 _previousTimestamp(0), |
| 807 _recPacketDelayMs(20), | 800 _recPacketDelayMs(20), |
| 808 _RxVadDetection(false), | 801 _RxVadDetection(false), |
| 809 _rxAgcIsEnabled(false), | 802 _rxAgcIsEnabled(false), |
| 810 _rxNsIsEnabled(false), | 803 _rxNsIsEnabled(false), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 823 if (config.Get<NetEqCapacityConfig>().enabled) { | 816 if (config.Get<NetEqCapacityConfig>().enabled) { |
| 824 // Clamping the buffer capacity at 20 packets. While going lower will | 817 // Clamping the buffer capacity at 20 packets. While going lower will |
| 825 // probably work, it makes little sense. | 818 // probably work, it makes little sense. |
| 826 acm_config.neteq_config.max_packets_in_buffer = | 819 acm_config.neteq_config.max_packets_in_buffer = |
| 827 std::max(20, config.Get<NetEqCapacityConfig>().capacity); | 820 std::max(20, config.Get<NetEqCapacityConfig>().capacity); |
| 828 } | 821 } |
| 829 acm_config.neteq_config.enable_fast_accelerate = | 822 acm_config.neteq_config.enable_fast_accelerate = |
| 830 config.Get<NetEqFastAccelerate>().enabled; | 823 config.Get<NetEqFastAccelerate>().enabled; |
| 831 audio_coding_.reset(AudioCodingModule::Create(acm_config)); | 824 audio_coding_.reset(AudioCodingModule::Create(acm_config)); |
| 832 | 825 |
| 833 _inbandDtmfQueue.ResetDtmf(); | |
| 834 _inbandDtmfGenerator.Init(); | |
| 835 _outputAudioLevel.Clear(); | 826 _outputAudioLevel.Clear(); |
| 836 | 827 |
| 837 RtpRtcp::Configuration configuration; | 828 RtpRtcp::Configuration configuration; |
| 838 configuration.audio = true; | 829 configuration.audio = true; |
| 839 configuration.outgoing_transport = this; | 830 configuration.outgoing_transport = this; |
| 840 configuration.audio_messages = this; | 831 configuration.audio_messages = this; |
| 841 configuration.receive_statistics = rtp_receive_statistics_.get(); | 832 configuration.receive_statistics = rtp_receive_statistics_.get(); |
| 842 configuration.bandwidth_callback = rtcp_observer_.get(); | 833 configuration.bandwidth_callback = rtcp_observer_.get(); |
| 843 if (pacing_enabled_) { | 834 if (pacing_enabled_) { |
| 844 configuration.paced_sender = rtp_packet_sender_proxy_.get(); | 835 configuration.paced_sender = rtp_packet_sender_proxy_.get(); |
| (...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 _outputGain = scaling; | 2196 _outputGain = scaling; |
| 2206 return 0; | 2197 return 0; |
| 2207 } | 2198 } |
| 2208 | 2199 |
| 2209 int Channel::GetChannelOutputVolumeScaling(float& scaling) const { | 2200 int Channel::GetChannelOutputVolumeScaling(float& scaling) const { |
| 2210 rtc::CritScope cs(&volume_settings_critsect_); | 2201 rtc::CritScope cs(&volume_settings_critsect_); |
| 2211 scaling = _outputGain; | 2202 scaling = _outputGain; |
| 2212 return 0; | 2203 return 0; |
| 2213 } | 2204 } |
| 2214 | 2205 |
| 2215 int Channel::SendTelephoneEventOutband(unsigned char eventCode, | 2206 int Channel::SendTelephoneEventOutband(int event, int duration_ms) { |
| 2216 int lengthMs, | |
| 2217 int attenuationDb, | |
| 2218 bool playDtmfEvent) { | |
| 2219 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2207 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 2220 "Channel::SendTelephoneEventOutband(..., playDtmfEvent=%d)", | 2208 "Channel::SendTelephoneEventOutband(...)"); |
| 2221 playDtmfEvent); | 2209 RTC_DCHECK_LE(0, event); |
| 2210 RTC_DCHECK_GE(255, event); |
| 2211 RTC_DCHECK_LE(0, duration_ms); |
| 2212 RTC_DCHECK_GE(65535, duration_ms); |
| 2222 if (!Sending()) { | 2213 if (!Sending()) { |
| 2223 return -1; | 2214 return -1; |
| 2224 } | 2215 } |
| 2225 | 2216 if (_rtpRtcpModule->SendTelephoneEventOutband( |
| 2226 _playOutbandDtmfEvent = playDtmfEvent; | 2217 event, duration_ms, kTelephoneEventAttenuationdB) != 0) { |
| 2227 | |
| 2228 if (_rtpRtcpModule->SendTelephoneEventOutband(eventCode, lengthMs, | |
| 2229 attenuationDb) != 0) { | |
| 2230 _engineStatisticsPtr->SetLastError( | 2218 _engineStatisticsPtr->SetLastError( |
| 2231 VE_SEND_DTMF_FAILED, kTraceWarning, | 2219 VE_SEND_DTMF_FAILED, kTraceWarning, |
| 2232 "SendTelephoneEventOutband() failed to send event"); | 2220 "SendTelephoneEventOutband() failed to send event"); |
| 2233 return -1; | 2221 return -1; |
| 2234 } | 2222 } |
| 2235 return 0; | 2223 return 0; |
| 2236 } | 2224 } |
| 2237 | 2225 |
| 2238 int Channel::SendTelephoneEventInband(unsigned char eventCode, | 2226 int Channel::SetSendTelephoneEventPayloadType(int payload_type) { |
| 2239 int lengthMs, | |
| 2240 int attenuationDb, | |
| 2241 bool playDtmfEvent) { | |
| 2242 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 2243 "Channel::SendTelephoneEventInband(..., playDtmfEvent=%d)", | |
| 2244 playDtmfEvent); | |
| 2245 | |
| 2246 _playInbandDtmfEvent = playDtmfEvent; | |
| 2247 _inbandDtmfQueue.AddDtmf(eventCode, lengthMs, attenuationDb); | |
| 2248 | |
| 2249 return 0; | |
| 2250 } | |
| 2251 | |
| 2252 int Channel::SetSendTelephoneEventPayloadType(unsigned char type) { | |
| 2253 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2227 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 2254 "Channel::SetSendTelephoneEventPayloadType()"); | 2228 "Channel::SetSendTelephoneEventPayloadType()"); |
| 2255 if (type > 127) { | 2229 RTC_DCHECK_LE(0, payload_type); |
| 2256 _engineStatisticsPtr->SetLastError( | 2230 RTC_DCHECK_GE(127, payload_type); |
| 2257 VE_INVALID_ARGUMENT, kTraceError, | 2231 CodecInst codec = {0}; |
| 2258 "SetSendTelephoneEventPayloadType() invalid type"); | |
| 2259 return -1; | |
| 2260 } | |
| 2261 CodecInst codec = {}; | |
| 2262 codec.plfreq = 8000; | 2232 codec.plfreq = 8000; |
| 2263 codec.pltype = type; | 2233 codec.pltype = payload_type; |
| 2264 memcpy(codec.plname, "telephone-event", 16); | 2234 memcpy(codec.plname, "telephone-event", 16); |
| 2265 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { | 2235 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { |
| 2266 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); | 2236 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); |
| 2267 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { | 2237 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { |
| 2268 _engineStatisticsPtr->SetLastError( | 2238 _engineStatisticsPtr->SetLastError( |
| 2269 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | 2239 VE_RTP_RTCP_MODULE_ERROR, kTraceError, |
| 2270 "SetSendTelephoneEventPayloadType() failed to register send" | 2240 "SetSendTelephoneEventPayloadType() failed to register send" |
| 2271 "payload type"); | 2241 "payload type"); |
| 2272 return -1; | 2242 return -1; |
| 2273 } | 2243 } |
| 2274 } | 2244 } |
| 2275 _sendTelephoneEventPayloadType = type; | |
| 2276 return 0; | 2245 return 0; |
| 2277 } | 2246 } |
| 2278 | 2247 |
| 2279 int Channel::GetSendTelephoneEventPayloadType(unsigned char& type) { | |
| 2280 type = _sendTelephoneEventPayloadType; | |
| 2281 return 0; | |
| 2282 } | |
| 2283 | |
| 2284 int Channel::UpdateRxVadDetection(AudioFrame& audioFrame) { | 2248 int Channel::UpdateRxVadDetection(AudioFrame& audioFrame) { |
| 2285 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 2249 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 2286 "Channel::UpdateRxVadDetection()"); | 2250 "Channel::UpdateRxVadDetection()"); |
| 2287 | 2251 |
| 2288 int vadDecision = 1; | 2252 int vadDecision = 1; |
| 2289 | 2253 |
| 2290 vadDecision = (audioFrame.vad_activity_ == AudioFrame::kVadActive) ? 1 : 0; | 2254 vadDecision = (audioFrame.vad_activity_ == AudioFrame::kVadActive) ? 1 : 0; |
| 2291 | 2255 |
| 2292 if ((vadDecision != _oldVadDecision) && _rxVadObserverPtr) { | 2256 if ((vadDecision != _oldVadDecision) && _rxVadObserverPtr) { |
| 2293 OnRxVadDetected(vadDecision); | 2257 OnRxVadDetected(vadDecision); |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3020 rtc::CritScope cs(&_callbackCritSect); | 2984 rtc::CritScope cs(&_callbackCritSect); |
| 3021 const bool isStereo = (_audioFrame.num_channels_ == 2); | 2985 const bool isStereo = (_audioFrame.num_channels_ == 2); |
| 3022 if (_inputExternalMediaCallbackPtr) { | 2986 if (_inputExternalMediaCallbackPtr) { |
| 3023 _inputExternalMediaCallbackPtr->Process( | 2987 _inputExternalMediaCallbackPtr->Process( |
| 3024 _channelId, kRecordingPerChannel, (int16_t*)_audioFrame.data_, | 2988 _channelId, kRecordingPerChannel, (int16_t*)_audioFrame.data_, |
| 3025 _audioFrame.samples_per_channel_, _audioFrame.sample_rate_hz_, | 2989 _audioFrame.samples_per_channel_, _audioFrame.sample_rate_hz_, |
| 3026 isStereo); | 2990 isStereo); |
| 3027 } | 2991 } |
| 3028 } | 2992 } |
| 3029 | 2993 |
| 3030 InsertInbandDtmfTone(); | |
| 3031 | |
| 3032 if (_includeAudioLevelIndication) { | 2994 if (_includeAudioLevelIndication) { |
| 3033 size_t length = | 2995 size_t length = |
| 3034 _audioFrame.samples_per_channel_ * _audioFrame.num_channels_; | 2996 _audioFrame.samples_per_channel_ * _audioFrame.num_channels_; |
| 3035 if (is_muted) { | 2997 if (is_muted) { |
| 3036 rms_level_.ProcessMuted(length); | 2998 rms_level_.ProcessMuted(length); |
| 3037 } else { | 2999 } else { |
| 3038 rms_level_.Process(_audioFrame.data_, length); | 3000 rms_level_.Process(_audioFrame.data_, length); |
| 3039 } | 3001 } |
| 3040 } | 3002 } |
| 3041 | 3003 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3341 "Channel::MixAudioWithFile() samples_per_channel_(%" PRIuS | 3303 "Channel::MixAudioWithFile() samples_per_channel_(%" PRIuS |
| 3342 ") != " | 3304 ") != " |
| 3343 "fileSamples(%" PRIuS ")", | 3305 "fileSamples(%" PRIuS ")", |
| 3344 audioFrame.samples_per_channel_, fileSamples); | 3306 audioFrame.samples_per_channel_, fileSamples); |
| 3345 return -1; | 3307 return -1; |
| 3346 } | 3308 } |
| 3347 | 3309 |
| 3348 return 0; | 3310 return 0; |
| 3349 } | 3311 } |
| 3350 | 3312 |
| 3351 int Channel::InsertInbandDtmfTone() { | |
| 3352 // Check if we should start a new tone. | |
| 3353 if (_inbandDtmfQueue.PendingDtmf() && !_inbandDtmfGenerator.IsAddingTone() && | |
| 3354 _inbandDtmfGenerator.DelaySinceLastTone() > | |
| 3355 kMinTelephoneEventSeparationMs) { | |
| 3356 int8_t eventCode(0); | |
| 3357 uint16_t lengthMs(0); | |
| 3358 uint8_t attenuationDb(0); | |
| 3359 | |
| 3360 eventCode = _inbandDtmfQueue.NextDtmf(&lengthMs, &attenuationDb); | |
| 3361 _inbandDtmfGenerator.AddTone(eventCode, lengthMs, attenuationDb); | |
| 3362 if (_playInbandDtmfEvent) { | |
| 3363 // Add tone to output mixer using a reduced length to minimize | |
| 3364 // risk of echo. | |
| 3365 _outputMixerPtr->PlayDtmfTone(eventCode, lengthMs - 80, attenuationDb); | |
| 3366 } | |
| 3367 } | |
| 3368 | |
| 3369 if (_inbandDtmfGenerator.IsAddingTone()) { | |
| 3370 uint16_t frequency(0); | |
| 3371 _inbandDtmfGenerator.GetSampleRate(frequency); | |
| 3372 | |
| 3373 if (frequency != _audioFrame.sample_rate_hz_) { | |
| 3374 // Update sample rate of Dtmf tone since the mixing frequency | |
| 3375 // has changed. | |
| 3376 _inbandDtmfGenerator.SetSampleRate( | |
| 3377 (uint16_t)(_audioFrame.sample_rate_hz_)); | |
| 3378 // Reset the tone to be added taking the new sample rate into | |
| 3379 // account. | |
| 3380 _inbandDtmfGenerator.ResetTone(); | |
| 3381 } | |
| 3382 | |
| 3383 int16_t toneBuffer[320]; | |
| 3384 uint16_t toneSamples(0); | |
| 3385 // Get 10ms tone segment and set time since last tone to zero | |
| 3386 if (_inbandDtmfGenerator.Get10msTone(toneBuffer, toneSamples) == -1) { | |
| 3387 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 3388 "Channel::EncodeAndSend() inserting Dtmf failed"); | |
| 3389 return -1; | |
| 3390 } | |
| 3391 | |
| 3392 // Replace mixed audio with DTMF tone. | |
| 3393 for (size_t sample = 0; sample < _audioFrame.samples_per_channel_; | |
| 3394 sample++) { | |
| 3395 for (size_t channel = 0; channel < _audioFrame.num_channels_; channel++) { | |
| 3396 const size_t index = sample * _audioFrame.num_channels_ + channel; | |
| 3397 _audioFrame.data_[index] = toneBuffer[sample]; | |
| 3398 } | |
| 3399 } | |
| 3400 | |
| 3401 assert(_audioFrame.samples_per_channel_ == toneSamples); | |
| 3402 } else { | |
| 3403 // Add 10ms to "delay-since-last-tone" counter | |
| 3404 _inbandDtmfGenerator.UpdateDelaySinceLastTone(); | |
| 3405 } | |
| 3406 return 0; | |
| 3407 } | |
| 3408 | |
| 3409 void Channel::UpdatePlayoutTimestamp(bool rtcp) { | 3313 void Channel::UpdatePlayoutTimestamp(bool rtcp) { |
| 3410 uint32_t playout_timestamp = 0; | 3314 uint32_t playout_timestamp = 0; |
| 3411 | 3315 |
| 3412 if (audio_coding_->PlayoutTimestamp(&playout_timestamp) == -1) { | 3316 if (audio_coding_->PlayoutTimestamp(&playout_timestamp) == -1) { |
| 3413 // This can happen if this channel has not been received any RTP packet. In | 3317 // This can happen if this channel has not been received any RTP packet. In |
| 3414 // this case, NetEq is not capable of computing playout timestamp. | 3318 // this case, NetEq is not capable of computing playout timestamp. |
| 3415 return; | 3319 return; |
| 3416 } | 3320 } |
| 3417 | 3321 |
| 3418 uint16_t delay_ms = 0; | 3322 uint16_t delay_ms = 0; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3647 int64_t min_rtt = 0; | 3551 int64_t min_rtt = 0; |
| 3648 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3552 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 3649 0) { | 3553 0) { |
| 3650 return 0; | 3554 return 0; |
| 3651 } | 3555 } |
| 3652 return rtt; | 3556 return rtt; |
| 3653 } | 3557 } |
| 3654 | 3558 |
| 3655 } // namespace voe | 3559 } // namespace voe |
| 3656 } // namespace webrtc | 3560 } // namespace webrtc |
| OLD | NEW |