| 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 3318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3329 { | 3329 { |
| 3330 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), | 3330 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), |
| 3331 "Channel::Demultiplex()"); | 3331 "Channel::Demultiplex()"); |
| 3332 _audioFrame.CopyFrom(audioFrame); | 3332 _audioFrame.CopyFrom(audioFrame); |
| 3333 _audioFrame.id_ = _channelId; | 3333 _audioFrame.id_ = _channelId; |
| 3334 return 0; | 3334 return 0; |
| 3335 } | 3335 } |
| 3336 | 3336 |
| 3337 void Channel::Demultiplex(const int16_t* audio_data, | 3337 void Channel::Demultiplex(const int16_t* audio_data, |
| 3338 int sample_rate, | 3338 int sample_rate, |
| 3339 int number_of_frames, | 3339 size_t number_of_frames, |
| 3340 int number_of_channels) { | 3340 int number_of_channels) { |
| 3341 CodecInst codec; | 3341 CodecInst codec; |
| 3342 GetSendCodec(codec); | 3342 GetSendCodec(codec); |
| 3343 | 3343 |
| 3344 if (!mono_recording_audio_.get()) { | 3344 if (!mono_recording_audio_.get()) { |
| 3345 // Temporary space for DownConvertToCodecFormat. | 3345 // Temporary space for DownConvertToCodecFormat. |
| 3346 mono_recording_audio_.reset(new int16_t[kMaxMonoDataSizeSamples]); | 3346 mono_recording_audio_.reset(new int16_t[kMaxMonoDataSizeSamples]); |
| 3347 } | 3347 } |
| 3348 DownConvertToCodecFormat(audio_data, | 3348 DownConvertToCodecFormat(audio_data, |
| 3349 number_of_frames, | 3349 number_of_frames, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3391 (int16_t*)_audioFrame.data_, | 3391 (int16_t*)_audioFrame.data_, |
| 3392 _audioFrame.samples_per_channel_, | 3392 _audioFrame.samples_per_channel_, |
| 3393 _audioFrame.sample_rate_hz_, | 3393 _audioFrame.sample_rate_hz_, |
| 3394 isStereo); | 3394 isStereo); |
| 3395 } | 3395 } |
| 3396 } | 3396 } |
| 3397 | 3397 |
| 3398 InsertInbandDtmfTone(); | 3398 InsertInbandDtmfTone(); |
| 3399 | 3399 |
| 3400 if (_includeAudioLevelIndication) { | 3400 if (_includeAudioLevelIndication) { |
| 3401 int length = _audioFrame.samples_per_channel_ * _audioFrame.num_channels_; | 3401 size_t length = |
| 3402 _audioFrame.samples_per_channel_ * _audioFrame.num_channels_; |
| 3402 if (is_muted) { | 3403 if (is_muted) { |
| 3403 rms_level_.ProcessMuted(length); | 3404 rms_level_.ProcessMuted(length); |
| 3404 } else { | 3405 } else { |
| 3405 rms_level_.Process(_audioFrame.data_, length); | 3406 rms_level_.Process(_audioFrame.data_, length); |
| 3406 } | 3407 } |
| 3407 } | 3408 } |
| 3408 | 3409 |
| 3409 return 0; | 3410 return 0; |
| 3410 } | 3411 } |
| 3411 | 3412 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3679 *rtp_receiver = rtp_receiver_.get(); | 3680 *rtp_receiver = rtp_receiver_.get(); |
| 3680 return 0; | 3681 return 0; |
| 3681 } | 3682 } |
| 3682 | 3683 |
| 3683 // TODO(andrew): refactor Mix functions here and in transmit_mixer.cc to use | 3684 // TODO(andrew): refactor Mix functions here and in transmit_mixer.cc to use |
| 3684 // a shared helper. | 3685 // a shared helper. |
| 3685 int32_t | 3686 int32_t |
| 3686 Channel::MixOrReplaceAudioWithFile(int mixingFrequency) | 3687 Channel::MixOrReplaceAudioWithFile(int mixingFrequency) |
| 3687 { | 3688 { |
| 3688 rtc::scoped_ptr<int16_t[]> fileBuffer(new int16_t[640]); | 3689 rtc::scoped_ptr<int16_t[]> fileBuffer(new int16_t[640]); |
| 3689 int fileSamples(0); | 3690 size_t fileSamples(0); |
| 3690 | 3691 |
| 3691 { | 3692 { |
| 3692 CriticalSectionScoped cs(&_fileCritSect); | 3693 CriticalSectionScoped cs(&_fileCritSect); |
| 3693 | 3694 |
| 3694 if (_inputFilePlayerPtr == NULL) | 3695 if (_inputFilePlayerPtr == NULL) |
| 3695 { | 3696 { |
| 3696 WEBRTC_TRACE(kTraceWarning, kTraceVoice, | 3697 WEBRTC_TRACE(kTraceWarning, kTraceVoice, |
| 3697 VoEId(_instanceId, _channelId), | 3698 VoEId(_instanceId, _channelId), |
| 3698 "Channel::MixOrReplaceAudioWithFile() fileplayer" | 3699 "Channel::MixOrReplaceAudioWithFile() fileplayer" |
| 3699 " doesnt exist"); | 3700 " doesnt exist"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3749 return 0; | 3750 return 0; |
| 3750 } | 3751 } |
| 3751 | 3752 |
| 3752 int32_t | 3753 int32_t |
| 3753 Channel::MixAudioWithFile(AudioFrame& audioFrame, | 3754 Channel::MixAudioWithFile(AudioFrame& audioFrame, |
| 3754 int mixingFrequency) | 3755 int mixingFrequency) |
| 3755 { | 3756 { |
| 3756 assert(mixingFrequency <= 48000); | 3757 assert(mixingFrequency <= 48000); |
| 3757 | 3758 |
| 3758 rtc::scoped_ptr<int16_t[]> fileBuffer(new int16_t[960]); | 3759 rtc::scoped_ptr<int16_t[]> fileBuffer(new int16_t[960]); |
| 3759 int fileSamples(0); | 3760 size_t fileSamples(0); |
| 3760 | 3761 |
| 3761 { | 3762 { |
| 3762 CriticalSectionScoped cs(&_fileCritSect); | 3763 CriticalSectionScoped cs(&_fileCritSect); |
| 3763 | 3764 |
| 3764 if (_outputFilePlayerPtr == NULL) | 3765 if (_outputFilePlayerPtr == NULL) |
| 3765 { | 3766 { |
| 3766 WEBRTC_TRACE(kTraceWarning, kTraceVoice, | 3767 WEBRTC_TRACE(kTraceWarning, kTraceVoice, |
| 3767 VoEId(_instanceId, _channelId), | 3768 VoEId(_instanceId, _channelId), |
| 3768 "Channel::MixAudioWithFile() file mixing failed"); | 3769 "Channel::MixAudioWithFile() file mixing failed"); |
| 3769 return -1; | 3770 return -1; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3787 // TODO(xians): Change the code when FilePlayer supports real stereo. | 3788 // TODO(xians): Change the code when FilePlayer supports real stereo. |
| 3788 MixWithSat(audioFrame.data_, | 3789 MixWithSat(audioFrame.data_, |
| 3789 audioFrame.num_channels_, | 3790 audioFrame.num_channels_, |
| 3790 fileBuffer.get(), | 3791 fileBuffer.get(), |
| 3791 1, | 3792 1, |
| 3792 fileSamples); | 3793 fileSamples); |
| 3793 } | 3794 } |
| 3794 else | 3795 else |
| 3795 { | 3796 { |
| 3796 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), | 3797 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), |
| 3797 "Channel::MixAudioWithFile() samples_per_channel_(%d) != " | 3798 "Channel::MixAudioWithFile() samples_per_channel_(%" PRIuS ") != " |
| 3798 "fileSamples(%d)", | 3799 "fileSamples(%" PRIuS ")", |
| 3799 audioFrame.samples_per_channel_, fileSamples); | 3800 audioFrame.samples_per_channel_, fileSamples); |
| 3800 return -1; | 3801 return -1; |
| 3801 } | 3802 } |
| 3802 | 3803 |
| 3803 return 0; | 3804 return 0; |
| 3804 } | 3805 } |
| 3805 | 3806 |
| 3806 int | 3807 int |
| 3807 Channel::InsertInbandDtmfTone() | 3808 Channel::InsertInbandDtmfTone() |
| 3808 { | 3809 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3848 // Get 10ms tone segment and set time since last tone to zero | 3849 // Get 10ms tone segment and set time since last tone to zero |
| 3849 if (_inbandDtmfGenerator.Get10msTone(toneBuffer, toneSamples) == -1) | 3850 if (_inbandDtmfGenerator.Get10msTone(toneBuffer, toneSamples) == -1) |
| 3850 { | 3851 { |
| 3851 WEBRTC_TRACE(kTraceWarning, kTraceVoice, | 3852 WEBRTC_TRACE(kTraceWarning, kTraceVoice, |
| 3852 VoEId(_instanceId, _channelId), | 3853 VoEId(_instanceId, _channelId), |
| 3853 "Channel::EncodeAndSend() inserting Dtmf failed"); | 3854 "Channel::EncodeAndSend() inserting Dtmf failed"); |
| 3854 return -1; | 3855 return -1; |
| 3855 } | 3856 } |
| 3856 | 3857 |
| 3857 // Replace mixed audio with DTMF tone. | 3858 // Replace mixed audio with DTMF tone. |
| 3858 for (int sample = 0; | 3859 for (size_t sample = 0; |
| 3859 sample < _audioFrame.samples_per_channel_; | 3860 sample < _audioFrame.samples_per_channel_; |
| 3860 sample++) | 3861 sample++) |
| 3861 { | 3862 { |
| 3862 for (int channel = 0; | 3863 for (int channel = 0; |
| 3863 channel < _audioFrame.num_channels_; | 3864 channel < _audioFrame.num_channels_; |
| 3864 channel++) | 3865 channel++) |
| 3865 { | 3866 { |
| 3866 const int index = sample * _audioFrame.num_channels_ + channel; | 3867 const size_t index = |
| 3868 sample * _audioFrame.num_channels_ + channel; |
| 3867 _audioFrame.data_[index] = toneBuffer[sample]; | 3869 _audioFrame.data_[index] = toneBuffer[sample]; |
| 3868 } | 3870 } |
| 3869 } | 3871 } |
| 3870 | 3872 |
| 3871 assert(_audioFrame.samples_per_channel_ == toneSamples); | 3873 assert(_audioFrame.samples_per_channel_ == toneSamples); |
| 3872 } else | 3874 } else |
| 3873 { | 3875 { |
| 3874 // Add 10ms to "delay-since-last-tone" counter | 3876 // Add 10ms to "delay-since-last-tone" counter |
| 3875 _inbandDtmfGenerator.UpdateDelaySinceLastTone(); | 3877 _inbandDtmfGenerator.UpdateDelaySinceLastTone(); |
| 3876 } | 3878 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4145 int64_t min_rtt = 0; | 4147 int64_t min_rtt = 0; |
| 4146 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) | 4148 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) |
| 4147 != 0) { | 4149 != 0) { |
| 4148 return 0; | 4150 return 0; |
| 4149 } | 4151 } |
| 4150 return rtt; | 4152 return rtt; |
| 4151 } | 4153 } |
| 4152 | 4154 |
| 4153 } // namespace voe | 4155 } // namespace voe |
| 4154 } // namespace webrtc | 4156 } // namespace webrtc |
| OLD | NEW |