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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 if (audio_sink_) { | 660 if (audio_sink_) { |
661 AudioSinkInterface::Data data( | 661 AudioSinkInterface::Data data( |
662 &audioFrame->data_[0], audioFrame->samples_per_channel_, | 662 &audioFrame->data_[0], audioFrame->samples_per_channel_, |
663 audioFrame->sample_rate_hz_, audioFrame->num_channels_, | 663 audioFrame->sample_rate_hz_, audioFrame->num_channels_, |
664 audioFrame->timestamp_); | 664 audioFrame->timestamp_); |
665 audio_sink_->OnData(data); | 665 audio_sink_->OnData(data); |
666 } | 666 } |
667 } | 667 } |
668 | 668 |
669 float output_gain = 1.0f; | 669 float output_gain = 1.0f; |
670 float left_pan = 1.0f; | |
671 float right_pan = 1.0f; | |
672 { | 670 { |
673 rtc::CritScope cs(&volume_settings_critsect_); | 671 rtc::CritScope cs(&volume_settings_critsect_); |
674 output_gain = _outputGain; | 672 output_gain = _outputGain; |
675 left_pan = _panLeft; | |
676 right_pan = _panRight; | |
677 } | 673 } |
678 | 674 |
679 // Output volume scaling | 675 // Output volume scaling |
680 if (output_gain < 0.99f || output_gain > 1.01f) { | 676 if (output_gain < 0.99f || output_gain > 1.01f) { |
| 677 // TODO(solenberg): Combine with mute state - this can cause clicks! |
681 AudioFrameOperations::ScaleWithSat(output_gain, *audioFrame); | 678 AudioFrameOperations::ScaleWithSat(output_gain, *audioFrame); |
682 } | 679 } |
683 | 680 |
684 // Scale left and/or right channel(s) if stereo and master balance is | |
685 // active | |
686 | |
687 if (left_pan != 1.0f || right_pan != 1.0f) { | |
688 if (audioFrame->num_channels_ == 1) { | |
689 // Emulate stereo mode since panning is active. | |
690 // The mono signal is copied to both left and right channels here. | |
691 AudioFrameOperations::MonoToStereo(audioFrame); | |
692 } | |
693 // For true stereo mode (when we are receiving a stereo signal), no | |
694 // action is needed. | |
695 | |
696 // Do the panning operation (the audio frame contains stereo at this | |
697 // stage) | |
698 AudioFrameOperations::Scale(left_pan, right_pan, *audioFrame); | |
699 } | |
700 | |
701 // Mix decoded PCM output with file if file mixing is enabled | 681 // Mix decoded PCM output with file if file mixing is enabled |
702 if (state.output_file_playing) { | 682 if (state.output_file_playing) { |
703 MixAudioWithFile(*audioFrame, audioFrame->sample_rate_hz_); | 683 MixAudioWithFile(*audioFrame, audioFrame->sample_rate_hz_); |
704 muted = false; // We may have added non-zero samples. | 684 muted = false; // We may have added non-zero samples. |
705 } | 685 } |
706 | 686 |
707 // Record playout if enabled | 687 // Record playout if enabled |
708 { | 688 { |
709 rtc::CritScope cs(&_fileCritSect); | 689 rtc::CritScope cs(&_fileCritSect); |
710 | 690 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 capture_start_rtp_time_stamp_(-1), | 887 capture_start_rtp_time_stamp_(-1), |
908 capture_start_ntp_time_ms_(-1), | 888 capture_start_ntp_time_ms_(-1), |
909 _engineStatisticsPtr(NULL), | 889 _engineStatisticsPtr(NULL), |
910 _outputMixerPtr(NULL), | 890 _outputMixerPtr(NULL), |
911 _moduleProcessThreadPtr(NULL), | 891 _moduleProcessThreadPtr(NULL), |
912 _audioDeviceModulePtr(NULL), | 892 _audioDeviceModulePtr(NULL), |
913 _voiceEngineObserverPtr(NULL), | 893 _voiceEngineObserverPtr(NULL), |
914 _callbackCritSectPtr(NULL), | 894 _callbackCritSectPtr(NULL), |
915 _transportPtr(NULL), | 895 _transportPtr(NULL), |
916 _sendFrameType(0), | 896 _sendFrameType(0), |
917 _mixFileWithMicrophone(false), | |
918 input_mute_(false), | 897 input_mute_(false), |
919 previous_frame_muted_(false), | 898 previous_frame_muted_(false), |
920 _panLeft(1.0f), | |
921 _panRight(1.0f), | |
922 _outputGain(1.0f), | 899 _outputGain(1.0f), |
| 900 _mixFileWithMicrophone(false), |
923 _lastLocalTimeStamp(0), | 901 _lastLocalTimeStamp(0), |
924 _lastPayloadType(0), | 902 _lastPayloadType(0), |
925 _includeAudioLevelIndication(false), | 903 _includeAudioLevelIndication(false), |
926 transport_overhead_per_packet_(0), | 904 transport_overhead_per_packet_(0), |
927 rtp_overhead_per_packet_(0), | 905 rtp_overhead_per_packet_(0), |
928 _outputSpeechType(AudioFrame::kNormalSpeech), | 906 _outputSpeechType(AudioFrame::kNormalSpeech), |
929 restored_packet_in_use_(false), | 907 restored_packet_in_use_(false), |
930 rtcp_observer_(new VoERtcpObserver(this)), | 908 rtcp_observer_(new VoERtcpObserver(this)), |
931 associate_send_channel_(ChannelOwner(nullptr)), | 909 associate_send_channel_(ChannelOwner(nullptr)), |
932 pacing_enabled_(config.enable_voice_pacing), | 910 pacing_enabled_(config.enable_voice_pacing), |
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 _outputFileRecording = false; | 2221 _outputFileRecording = false; |
2244 | 2222 |
2245 return 0; | 2223 return 0; |
2246 } | 2224 } |
2247 | 2225 |
2248 void Channel::SetMixWithMicStatus(bool mix) { | 2226 void Channel::SetMixWithMicStatus(bool mix) { |
2249 rtc::CritScope cs(&_fileCritSect); | 2227 rtc::CritScope cs(&_fileCritSect); |
2250 _mixFileWithMicrophone = mix; | 2228 _mixFileWithMicrophone = mix; |
2251 } | 2229 } |
2252 | 2230 |
2253 int Channel::GetSpeechOutputLevel(uint32_t& level) const { | 2231 int Channel::GetSpeechOutputLevel() const { |
2254 int8_t currentLevel = _outputAudioLevel.Level(); | 2232 return _outputAudioLevel.Level(); |
2255 level = static_cast<int32_t>(currentLevel); | |
2256 return 0; | |
2257 } | 2233 } |
2258 | 2234 |
2259 int Channel::GetSpeechOutputLevelFullRange(uint32_t& level) const { | 2235 int Channel::GetSpeechOutputLevelFullRange() const { |
2260 int16_t currentLevel = _outputAudioLevel.LevelFullRange(); | 2236 return _outputAudioLevel.LevelFullRange(); |
2261 level = static_cast<int32_t>(currentLevel); | |
2262 return 0; | |
2263 } | 2237 } |
2264 | 2238 |
2265 int Channel::SetInputMute(bool enable) { | 2239 void Channel::SetInputMute(bool enable) { |
2266 rtc::CritScope cs(&volume_settings_critsect_); | 2240 rtc::CritScope cs(&volume_settings_critsect_); |
2267 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
2268 "Channel::SetMute(enable=%d)", enable); | |
2269 input_mute_ = enable; | 2241 input_mute_ = enable; |
2270 return 0; | |
2271 } | 2242 } |
2272 | 2243 |
2273 bool Channel::InputMute() const { | 2244 bool Channel::InputMute() const { |
2274 rtc::CritScope cs(&volume_settings_critsect_); | 2245 rtc::CritScope cs(&volume_settings_critsect_); |
2275 return input_mute_; | 2246 return input_mute_; |
2276 } | 2247 } |
2277 | 2248 |
2278 int Channel::SetOutputVolumePan(float left, float right) { | 2249 void Channel::SetChannelOutputVolumeScaling(float scaling) { |
2279 rtc::CritScope cs(&volume_settings_critsect_); | 2250 rtc::CritScope cs(&volume_settings_critsect_); |
2280 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
2281 "Channel::SetOutputVolumePan()"); | |
2282 _panLeft = left; | |
2283 _panRight = right; | |
2284 return 0; | |
2285 } | |
2286 | |
2287 int Channel::GetOutputVolumePan(float& left, float& right) const { | |
2288 rtc::CritScope cs(&volume_settings_critsect_); | |
2289 left = _panLeft; | |
2290 right = _panRight; | |
2291 return 0; | |
2292 } | |
2293 | |
2294 int Channel::SetChannelOutputVolumeScaling(float scaling) { | |
2295 rtc::CritScope cs(&volume_settings_critsect_); | |
2296 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
2297 "Channel::SetChannelOutputVolumeScaling()"); | |
2298 _outputGain = scaling; | 2251 _outputGain = scaling; |
2299 return 0; | |
2300 } | |
2301 | |
2302 int Channel::GetChannelOutputVolumeScaling(float& scaling) const { | |
2303 rtc::CritScope cs(&volume_settings_critsect_); | |
2304 scaling = _outputGain; | |
2305 return 0; | |
2306 } | 2252 } |
2307 | 2253 |
2308 int Channel::SendTelephoneEventOutband(int event, int duration_ms) { | 2254 int Channel::SendTelephoneEventOutband(int event, int duration_ms) { |
2309 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2255 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
2310 "Channel::SendTelephoneEventOutband(...)"); | 2256 "Channel::SendTelephoneEventOutband(...)"); |
2311 RTC_DCHECK_LE(0, event); | 2257 RTC_DCHECK_LE(0, event); |
2312 RTC_DCHECK_GE(255, event); | 2258 RTC_DCHECK_GE(255, event); |
2313 RTC_DCHECK_LE(0, duration_ms); | 2259 RTC_DCHECK_LE(0, duration_ms); |
2314 RTC_DCHECK_GE(65535, duration_ms); | 2260 RTC_DCHECK_GE(65535, duration_ms); |
2315 if (!Sending()) { | 2261 if (!Sending()) { |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3064 int64_t min_rtt = 0; | 3010 int64_t min_rtt = 0; |
3065 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3011 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3066 0) { | 3012 0) { |
3067 return 0; | 3013 return 0; |
3068 } | 3014 } |
3069 return rtt; | 3015 return rtt; |
3070 } | 3016 } |
3071 | 3017 |
3072 } // namespace voe | 3018 } // namespace voe |
3073 } // namespace webrtc | 3019 } // namespace webrtc |
OLD | NEW |