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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 } | 360 } |
363 | 361 |
364 void Channel::OnPlayTelephoneEvent(uint8_t event, | 362 void Channel::OnPlayTelephoneEvent(uint8_t event, |
365 uint16_t lengthMs, | 363 uint16_t lengthMs, |
366 uint8_t volume) { | 364 uint8_t volume) { |
367 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 365 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
368 "Channel::OnPlayTelephoneEvent(event=%u, lengthMs=%u," | 366 "Channel::OnPlayTelephoneEvent(event=%u, lengthMs=%u," |
369 " volume=%u)", | 367 " volume=%u)", |
370 event, lengthMs, volume); | 368 event, lengthMs, volume); |
371 | 369 |
372 if (!_playOutbandDtmfEvent || (event > 15)) { | 370 if (event > 15) { |
373 // Ignore callback since feedback is disabled or event is not a | 371 // Ignore callback since feedback is disabled or event is not a |
374 // Dtmf tone event. | 372 // Dtmf tone event. |
375 return; | 373 return; |
376 } | 374 } |
377 | 375 |
378 assert(_outputMixerPtr != NULL); | 376 assert(_outputMixerPtr != NULL); |
379 | 377 |
380 // Start playing out the Dtmf tone (if playout is enabled). | 378 // Start playing out the Dtmf tone (if playout is enabled). |
381 // Reduce length of tone with 80ms to the reduce risk of echo. | 379 // Reduce length of tone with 80ms to the reduce risk of echo. |
382 _outputMixerPtr->PlayDtmfTone(event, lengthMs - 80, volume); | 380 _outputMixerPtr->PlayDtmfTone(event, lengthMs - 80, volume); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
760 _externalTransport(false), | 758 _externalTransport(false), |
761 _inputFilePlayerPtr(NULL), | 759 _inputFilePlayerPtr(NULL), |
762 _outputFilePlayerPtr(NULL), | 760 _outputFilePlayerPtr(NULL), |
763 _outputFileRecorderPtr(NULL), | 761 _outputFileRecorderPtr(NULL), |
764 // Avoid conflict with other channels by adding 1024 - 1026, | 762 // Avoid conflict with other channels by adding 1024 - 1026, |
765 // won't use as much as 1024 channels. | 763 // won't use as much as 1024 channels. |
766 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024), | 764 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024), |
767 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025), | 765 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025), |
768 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026), | 766 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026), |
769 _outputFileRecording(false), | 767 _outputFileRecording(false), |
770 _inbandDtmfQueue(VoEModuleId(instanceId, channelId)), | |
771 _inbandDtmfGenerator(VoEModuleId(instanceId, channelId)), | |
772 _outputExternalMedia(false), | 768 _outputExternalMedia(false), |
773 _inputExternalMediaCallbackPtr(NULL), | 769 _inputExternalMediaCallbackPtr(NULL), |
774 _outputExternalMediaCallbackPtr(NULL), | 770 _outputExternalMediaCallbackPtr(NULL), |
775 _timeStamp(0), // This is just an offset, RTP module will add it's own | 771 _timeStamp(0), // This is just an offset, RTP module will add it's own |
776 // random offset | 772 // random offset |
777 _sendTelephoneEventPayloadType(106), | |
778 ntp_estimator_(Clock::GetRealTimeClock()), | 773 ntp_estimator_(Clock::GetRealTimeClock()), |
779 jitter_buffer_playout_timestamp_(0), | 774 jitter_buffer_playout_timestamp_(0), |
780 playout_timestamp_rtp_(0), | 775 playout_timestamp_rtp_(0), |
781 playout_timestamp_rtcp_(0), | 776 playout_timestamp_rtcp_(0), |
782 playout_delay_ms_(0), | 777 playout_delay_ms_(0), |
783 _numberOfDiscardedPackets(0), | 778 _numberOfDiscardedPackets(0), |
784 send_sequence_number_(0), | 779 send_sequence_number_(0), |
785 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), | 780 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), |
786 capture_start_rtp_time_stamp_(-1), | 781 capture_start_rtp_time_stamp_(-1), |
787 capture_start_ntp_time_ms_(-1), | 782 capture_start_ntp_time_ms_(-1), |
788 _engineStatisticsPtr(NULL), | 783 _engineStatisticsPtr(NULL), |
789 _outputMixerPtr(NULL), | 784 _outputMixerPtr(NULL), |
790 _transmitMixerPtr(NULL), | 785 _transmitMixerPtr(NULL), |
791 _moduleProcessThreadPtr(NULL), | 786 _moduleProcessThreadPtr(NULL), |
792 _audioDeviceModulePtr(NULL), | 787 _audioDeviceModulePtr(NULL), |
793 _voiceEngineObserverPtr(NULL), | 788 _voiceEngineObserverPtr(NULL), |
794 _callbackCritSectPtr(NULL), | 789 _callbackCritSectPtr(NULL), |
795 _transportPtr(NULL), | 790 _transportPtr(NULL), |
796 _rxVadObserverPtr(NULL), | 791 _rxVadObserverPtr(NULL), |
797 _oldVadDecision(-1), | 792 _oldVadDecision(-1), |
798 _sendFrameType(0), | 793 _sendFrameType(0), |
799 _externalMixing(false), | 794 _externalMixing(false), |
800 _mixFileWithMicrophone(false), | 795 _mixFileWithMicrophone(false), |
801 _mute(false), | 796 _mute(false), |
802 _panLeft(1.0f), | 797 _panLeft(1.0f), |
803 _panRight(1.0f), | 798 _panRight(1.0f), |
804 _outputGain(1.0f), | 799 _outputGain(1.0f), |
805 _playOutbandDtmfEvent(false), | |
806 _playInbandDtmfEvent(false), | |
807 _lastLocalTimeStamp(0), | 800 _lastLocalTimeStamp(0), |
808 _lastPayloadType(0), | 801 _lastPayloadType(0), |
809 _includeAudioLevelIndication(false), | 802 _includeAudioLevelIndication(false), |
810 _outputSpeechType(AudioFrame::kNormalSpeech), | 803 _outputSpeechType(AudioFrame::kNormalSpeech), |
811 _average_jitter_buffer_delay_us(0), | 804 _average_jitter_buffer_delay_us(0), |
812 _previousTimestamp(0), | 805 _previousTimestamp(0), |
813 _recPacketDelayMs(20), | 806 _recPacketDelayMs(20), |
814 _RxVadDetection(false), | 807 _RxVadDetection(false), |
815 _rxAgcIsEnabled(false), | 808 _rxAgcIsEnabled(false), |
816 _rxNsIsEnabled(false), | 809 _rxNsIsEnabled(false), |
(...skipping 12 matching lines...) Expand all Loading... | |
829 if (config.Get<NetEqCapacityConfig>().enabled) { | 822 if (config.Get<NetEqCapacityConfig>().enabled) { |
830 // Clamping the buffer capacity at 20 packets. While going lower will | 823 // Clamping the buffer capacity at 20 packets. While going lower will |
831 // probably work, it makes little sense. | 824 // probably work, it makes little sense. |
832 acm_config.neteq_config.max_packets_in_buffer = | 825 acm_config.neteq_config.max_packets_in_buffer = |
833 std::max(20, config.Get<NetEqCapacityConfig>().capacity); | 826 std::max(20, config.Get<NetEqCapacityConfig>().capacity); |
834 } | 827 } |
835 acm_config.neteq_config.enable_fast_accelerate = | 828 acm_config.neteq_config.enable_fast_accelerate = |
836 config.Get<NetEqFastAccelerate>().enabled; | 829 config.Get<NetEqFastAccelerate>().enabled; |
837 audio_coding_.reset(AudioCodingModule::Create(acm_config)); | 830 audio_coding_.reset(AudioCodingModule::Create(acm_config)); |
838 | 831 |
839 _inbandDtmfQueue.ResetDtmf(); | |
840 _inbandDtmfGenerator.Init(); | |
841 _outputAudioLevel.Clear(); | 832 _outputAudioLevel.Clear(); |
842 | 833 |
843 RtpRtcp::Configuration configuration; | 834 RtpRtcp::Configuration configuration; |
844 configuration.audio = true; | 835 configuration.audio = true; |
845 configuration.outgoing_transport = this; | 836 configuration.outgoing_transport = this; |
846 configuration.audio_messages = this; | 837 configuration.audio_messages = this; |
847 configuration.receive_statistics = rtp_receive_statistics_.get(); | 838 configuration.receive_statistics = rtp_receive_statistics_.get(); |
848 configuration.bandwidth_callback = rtcp_observer_.get(); | 839 configuration.bandwidth_callback = rtcp_observer_.get(); |
849 if (pacing_enabled_) { | 840 if (pacing_enabled_) { |
850 configuration.paced_sender = rtp_packet_sender_proxy_.get(); | 841 configuration.paced_sender = rtp_packet_sender_proxy_.get(); |
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2207 _outputGain = scaling; | 2198 _outputGain = scaling; |
2208 return 0; | 2199 return 0; |
2209 } | 2200 } |
2210 | 2201 |
2211 int Channel::GetChannelOutputVolumeScaling(float& scaling) const { | 2202 int Channel::GetChannelOutputVolumeScaling(float& scaling) const { |
2212 rtc::CritScope cs(&volume_settings_critsect_); | 2203 rtc::CritScope cs(&volume_settings_critsect_); |
2213 scaling = _outputGain; | 2204 scaling = _outputGain; |
2214 return 0; | 2205 return 0; |
2215 } | 2206 } |
2216 | 2207 |
2217 int Channel::SendTelephoneEventOutband(unsigned char eventCode, | 2208 int Channel::SendTelephoneEventOutband(uint8_t eventCode, uint16_t lengthMs) { |
hlundin-webrtc
2016/02/24 10:33:20
Update variable name formatting while you are at i
the sun
2016/03/08 15:20:48
Done.
| |
2218 int lengthMs, | |
2219 int attenuationDb, | |
2220 bool playDtmfEvent) { | |
2221 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2209 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
2222 "Channel::SendTelephoneEventOutband(..., playDtmfEvent=%d)", | 2210 "Channel::SendTelephoneEventOutband(...)"); |
2223 playDtmfEvent); | |
2224 if (!Sending()) { | 2211 if (!Sending()) { |
2225 return -1; | 2212 return -1; |
2226 } | 2213 } |
2227 | 2214 |
2228 _playOutbandDtmfEvent = playDtmfEvent; | 2215 if (_rtpRtcpModule->SendTelephoneEventOutband( |
2229 | 2216 eventCode, lengthMs, kTelephoneEventAttenuationdB) != 0) { |
2230 if (_rtpRtcpModule->SendTelephoneEventOutband(eventCode, lengthMs, | |
2231 attenuationDb) != 0) { | |
2232 _engineStatisticsPtr->SetLastError( | 2217 _engineStatisticsPtr->SetLastError( |
2233 VE_SEND_DTMF_FAILED, kTraceWarning, | 2218 VE_SEND_DTMF_FAILED, kTraceWarning, |
2234 "SendTelephoneEventOutband() failed to send event"); | 2219 "SendTelephoneEventOutband() failed to send event"); |
2235 return -1; | 2220 return -1; |
2236 } | 2221 } |
2237 return 0; | 2222 return 0; |
2238 } | 2223 } |
2239 | 2224 |
2240 int Channel::SendTelephoneEventInband(unsigned char eventCode, | 2225 int Channel::SetSendTelephoneEventPayloadType(uint8_t type) { |
2241 int lengthMs, | |
2242 int attenuationDb, | |
2243 bool playDtmfEvent) { | |
2244 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
2245 "Channel::SendTelephoneEventInband(..., playDtmfEvent=%d)", | |
2246 playDtmfEvent); | |
2247 | |
2248 _playInbandDtmfEvent = playDtmfEvent; | |
2249 _inbandDtmfQueue.AddDtmf(eventCode, lengthMs, attenuationDb); | |
2250 | |
2251 return 0; | |
2252 } | |
2253 | |
2254 int Channel::SetSendTelephoneEventPayloadType(unsigned char type) { | |
2255 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2226 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
2256 "Channel::SetSendTelephoneEventPayloadType()"); | 2227 "Channel::SetSendTelephoneEventPayloadType()"); |
2257 if (type > 127) { | 2228 if (type > 127) { |
2258 _engineStatisticsPtr->SetLastError( | 2229 _engineStatisticsPtr->SetLastError( |
2259 VE_INVALID_ARGUMENT, kTraceError, | 2230 VE_INVALID_ARGUMENT, kTraceError, |
2260 "SetSendTelephoneEventPayloadType() invalid type"); | 2231 "SetSendTelephoneEventPayloadType() invalid type"); |
2261 return -1; | 2232 return -1; |
2262 } | 2233 } |
2263 CodecInst codec = {}; | 2234 CodecInst codec = {}; |
2264 codec.plfreq = 8000; | 2235 codec.plfreq = 8000; |
2265 codec.pltype = type; | 2236 codec.pltype = type; |
2266 memcpy(codec.plname, "telephone-event", 16); | 2237 memcpy(codec.plname, "telephone-event", 16); |
2267 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { | 2238 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { |
2268 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); | 2239 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); |
2269 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { | 2240 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { |
2270 _engineStatisticsPtr->SetLastError( | 2241 _engineStatisticsPtr->SetLastError( |
2271 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | 2242 VE_RTP_RTCP_MODULE_ERROR, kTraceError, |
2272 "SetSendTelephoneEventPayloadType() failed to register send" | 2243 "SetSendTelephoneEventPayloadType() failed to register send" |
2273 "payload type"); | 2244 "payload type"); |
2274 return -1; | 2245 return -1; |
2275 } | 2246 } |
2276 } | 2247 } |
2277 _sendTelephoneEventPayloadType = type; | |
2278 return 0; | 2248 return 0; |
2279 } | 2249 } |
2280 | 2250 |
2281 int Channel::GetSendTelephoneEventPayloadType(unsigned char& type) { | |
2282 type = _sendTelephoneEventPayloadType; | |
2283 return 0; | |
2284 } | |
2285 | |
2286 int Channel::UpdateRxVadDetection(AudioFrame& audioFrame) { | 2251 int Channel::UpdateRxVadDetection(AudioFrame& audioFrame) { |
2287 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 2252 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
2288 "Channel::UpdateRxVadDetection()"); | 2253 "Channel::UpdateRxVadDetection()"); |
2289 | 2254 |
2290 int vadDecision = 1; | 2255 int vadDecision = 1; |
2291 | 2256 |
2292 vadDecision = (audioFrame.vad_activity_ == AudioFrame::kVadActive) ? 1 : 0; | 2257 vadDecision = (audioFrame.vad_activity_ == AudioFrame::kVadActive) ? 1 : 0; |
2293 | 2258 |
2294 if ((vadDecision != _oldVadDecision) && _rxVadObserverPtr) { | 2259 if ((vadDecision != _oldVadDecision) && _rxVadObserverPtr) { |
2295 OnRxVadDetected(vadDecision); | 2260 OnRxVadDetected(vadDecision); |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3023 rtc::CritScope cs(&_callbackCritSect); | 2988 rtc::CritScope cs(&_callbackCritSect); |
3024 const bool isStereo = (_audioFrame.num_channels_ == 2); | 2989 const bool isStereo = (_audioFrame.num_channels_ == 2); |
3025 if (_inputExternalMediaCallbackPtr) { | 2990 if (_inputExternalMediaCallbackPtr) { |
3026 _inputExternalMediaCallbackPtr->Process( | 2991 _inputExternalMediaCallbackPtr->Process( |
3027 _channelId, kRecordingPerChannel, (int16_t*)_audioFrame.data_, | 2992 _channelId, kRecordingPerChannel, (int16_t*)_audioFrame.data_, |
3028 _audioFrame.samples_per_channel_, _audioFrame.sample_rate_hz_, | 2993 _audioFrame.samples_per_channel_, _audioFrame.sample_rate_hz_, |
3029 isStereo); | 2994 isStereo); |
3030 } | 2995 } |
3031 } | 2996 } |
3032 | 2997 |
3033 InsertInbandDtmfTone(); | |
3034 | |
3035 if (_includeAudioLevelIndication) { | 2998 if (_includeAudioLevelIndication) { |
3036 size_t length = | 2999 size_t length = |
3037 _audioFrame.samples_per_channel_ * _audioFrame.num_channels_; | 3000 _audioFrame.samples_per_channel_ * _audioFrame.num_channels_; |
3038 if (is_muted) { | 3001 if (is_muted) { |
3039 rms_level_.ProcessMuted(length); | 3002 rms_level_.ProcessMuted(length); |
3040 } else { | 3003 } else { |
3041 rms_level_.Process(_audioFrame.data_, length); | 3004 rms_level_.Process(_audioFrame.data_, length); |
3042 } | 3005 } |
3043 } | 3006 } |
3044 | 3007 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3344 "Channel::MixAudioWithFile() samples_per_channel_(%" PRIuS | 3307 "Channel::MixAudioWithFile() samples_per_channel_(%" PRIuS |
3345 ") != " | 3308 ") != " |
3346 "fileSamples(%" PRIuS ")", | 3309 "fileSamples(%" PRIuS ")", |
3347 audioFrame.samples_per_channel_, fileSamples); | 3310 audioFrame.samples_per_channel_, fileSamples); |
3348 return -1; | 3311 return -1; |
3349 } | 3312 } |
3350 | 3313 |
3351 return 0; | 3314 return 0; |
3352 } | 3315 } |
3353 | 3316 |
3354 int Channel::InsertInbandDtmfTone() { | |
3355 // Check if we should start a new tone. | |
3356 if (_inbandDtmfQueue.PendingDtmf() && !_inbandDtmfGenerator.IsAddingTone() && | |
3357 _inbandDtmfGenerator.DelaySinceLastTone() > | |
3358 kMinTelephoneEventSeparationMs) { | |
3359 int8_t eventCode(0); | |
3360 uint16_t lengthMs(0); | |
3361 uint8_t attenuationDb(0); | |
3362 | |
3363 eventCode = _inbandDtmfQueue.NextDtmf(&lengthMs, &attenuationDb); | |
3364 _inbandDtmfGenerator.AddTone(eventCode, lengthMs, attenuationDb); | |
3365 if (_playInbandDtmfEvent) { | |
3366 // Add tone to output mixer using a reduced length to minimize | |
3367 // risk of echo. | |
3368 _outputMixerPtr->PlayDtmfTone(eventCode, lengthMs - 80, attenuationDb); | |
3369 } | |
3370 } | |
3371 | |
3372 if (_inbandDtmfGenerator.IsAddingTone()) { | |
3373 uint16_t frequency(0); | |
3374 _inbandDtmfGenerator.GetSampleRate(frequency); | |
3375 | |
3376 if (frequency != _audioFrame.sample_rate_hz_) { | |
3377 // Update sample rate of Dtmf tone since the mixing frequency | |
3378 // has changed. | |
3379 _inbandDtmfGenerator.SetSampleRate( | |
3380 (uint16_t)(_audioFrame.sample_rate_hz_)); | |
3381 // Reset the tone to be added taking the new sample rate into | |
3382 // account. | |
3383 _inbandDtmfGenerator.ResetTone(); | |
3384 } | |
3385 | |
3386 int16_t toneBuffer[320]; | |
3387 uint16_t toneSamples(0); | |
3388 // Get 10ms tone segment and set time since last tone to zero | |
3389 if (_inbandDtmfGenerator.Get10msTone(toneBuffer, toneSamples) == -1) { | |
3390 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | |
3391 "Channel::EncodeAndSend() inserting Dtmf failed"); | |
3392 return -1; | |
3393 } | |
3394 | |
3395 // Replace mixed audio with DTMF tone. | |
3396 for (size_t sample = 0; sample < _audioFrame.samples_per_channel_; | |
3397 sample++) { | |
3398 for (size_t channel = 0; channel < _audioFrame.num_channels_; channel++) { | |
3399 const size_t index = sample * _audioFrame.num_channels_ + channel; | |
3400 _audioFrame.data_[index] = toneBuffer[sample]; | |
3401 } | |
3402 } | |
3403 | |
3404 assert(_audioFrame.samples_per_channel_ == toneSamples); | |
3405 } else { | |
3406 // Add 10ms to "delay-since-last-tone" counter | |
3407 _inbandDtmfGenerator.UpdateDelaySinceLastTone(); | |
3408 } | |
3409 return 0; | |
3410 } | |
3411 | |
3412 void Channel::UpdatePlayoutTimestamp(bool rtcp) { | 3317 void Channel::UpdatePlayoutTimestamp(bool rtcp) { |
3413 uint32_t playout_timestamp = 0; | 3318 uint32_t playout_timestamp = 0; |
3414 | 3319 |
3415 if (audio_coding_->PlayoutTimestamp(&playout_timestamp) == -1) { | 3320 if (audio_coding_->PlayoutTimestamp(&playout_timestamp) == -1) { |
3416 // This can happen if this channel has not been received any RTP packet. In | 3321 // This can happen if this channel has not been received any RTP packet. In |
3417 // this case, NetEq is not capable of computing playout timestamp. | 3322 // this case, NetEq is not capable of computing playout timestamp. |
3418 return; | 3323 return; |
3419 } | 3324 } |
3420 | 3325 |
3421 uint16_t delay_ms = 0; | 3326 uint16_t delay_ms = 0; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3650 int64_t min_rtt = 0; | 3555 int64_t min_rtt = 0; |
3651 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3556 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3652 0) { | 3557 0) { |
3653 return 0; | 3558 return 0; |
3654 } | 3559 } |
3655 return rtt; | 3560 return rtt; |
3656 } | 3561 } |
3657 | 3562 |
3658 } // namespace voe | 3563 } // namespace voe |
3659 } // namespace webrtc | 3564 } // namespace webrtc |
OLD | NEW |