Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 options.audio_network_adaptor_config) { | 156 options.audio_network_adaptor_config) { |
| 157 // Turn on audio network adaptor only when |options_.audio_network_adaptor| | 157 // Turn on audio network adaptor only when |options_.audio_network_adaptor| |
| 158 // equals true and |options_.audio_network_adaptor_config| has a value. | 158 // equals true and |options_.audio_network_adaptor_config| has a value. |
| 159 return options.audio_network_adaptor_config; | 159 return options.audio_network_adaptor_config; |
| 160 } | 160 } |
| 161 return rtc::Optional<std::string>(); | 161 return rtc::Optional<std::string>(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 webrtc::AudioState::Config MakeAudioStateConfig( | 164 webrtc::AudioState::Config MakeAudioStateConfig( |
| 165 VoEWrapper* voe_wrapper, | 165 VoEWrapper* voe_wrapper, |
| 166 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer) { | 166 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, |
| 167 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing) { | |
| 167 webrtc::AudioState::Config config; | 168 webrtc::AudioState::Config config; |
| 168 config.voice_engine = voe_wrapper->engine(); | 169 config.voice_engine = voe_wrapper->engine(); |
| 169 if (audio_mixer) { | 170 if (audio_mixer) { |
| 170 config.audio_mixer = audio_mixer; | 171 config.audio_mixer = audio_mixer; |
| 171 } else { | 172 } else { |
| 172 config.audio_mixer = webrtc::AudioMixerImpl::Create(); | 173 config.audio_mixer = webrtc::AudioMixerImpl::Create(); |
| 173 } | 174 } |
| 175 config.audio_processing = audio_processing; | |
| 174 return config; | 176 return config; |
| 175 } | 177 } |
| 176 | 178 |
| 177 // |max_send_bitrate_bps| is the bitrate from "b=" in SDP. | 179 // |max_send_bitrate_bps| is the bitrate from "b=" in SDP. |
| 178 // |rtp_max_bitrate_bps| is the bitrate from RtpSender::SetParameters. | 180 // |rtp_max_bitrate_bps| is the bitrate from RtpSender::SetParameters. |
| 179 rtc::Optional<int> ComputeSendBitrate(int max_send_bitrate_bps, | 181 rtc::Optional<int> ComputeSendBitrate(int max_send_bitrate_bps, |
| 180 rtc::Optional<int> rtp_max_bitrate_bps, | 182 rtc::Optional<int> rtp_max_bitrate_bps, |
| 181 const webrtc::AudioCodecSpec& spec) { | 183 const webrtc::AudioCodecSpec& spec) { |
| 182 // If application-configured bitrate is set, take minimum of that and SDP | 184 // If application-configured bitrate is set, take minimum of that and SDP |
| 183 // bitrate. | 185 // bitrate. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 207 return rtc::Optional<int>(std::min(bps, spec.info.max_bitrate_bps)); | 209 return rtc::Optional<int>(std::min(bps, spec.info.max_bitrate_bps)); |
| 208 } | 210 } |
| 209 } | 211 } |
| 210 | 212 |
| 211 } // namespace | 213 } // namespace |
| 212 | 214 |
| 213 WebRtcVoiceEngine::WebRtcVoiceEngine( | 215 WebRtcVoiceEngine::WebRtcVoiceEngine( |
| 214 webrtc::AudioDeviceModule* adm, | 216 webrtc::AudioDeviceModule* adm, |
| 215 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory, | 217 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory, |
| 216 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, | 218 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, |
| 217 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer) | 219 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, |
| 220 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing) | |
| 218 : WebRtcVoiceEngine(adm, | 221 : WebRtcVoiceEngine(adm, |
| 219 encoder_factory, | 222 encoder_factory, |
| 220 decoder_factory, | 223 decoder_factory, |
| 221 audio_mixer, | 224 audio_mixer, |
| 225 audio_processing, | |
| 222 nullptr) {} | 226 nullptr) {} |
| 223 | 227 |
| 224 WebRtcVoiceEngine::WebRtcVoiceEngine( | 228 WebRtcVoiceEngine::WebRtcVoiceEngine( |
| 225 webrtc::AudioDeviceModule* adm, | 229 webrtc::AudioDeviceModule* adm, |
| 226 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory, | 230 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory, |
| 227 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, | 231 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory, |
| 228 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, | 232 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, |
| 233 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing, | |
| 229 VoEWrapper* voe_wrapper) | 234 VoEWrapper* voe_wrapper) |
| 230 : adm_(adm), | 235 : adm_(adm), |
| 231 encoder_factory_(encoder_factory), | 236 encoder_factory_(encoder_factory), |
| 232 decoder_factory_(decoder_factory), | 237 decoder_factory_(decoder_factory), |
| 233 audio_mixer_(audio_mixer), | 238 audio_mixer_(audio_mixer), |
| 239 apm_(audio_processing), | |
| 234 voe_wrapper_(voe_wrapper) { | 240 voe_wrapper_(voe_wrapper) { |
| 235 // This may be called from any thread, so detach thread checkers. | 241 // This may be called from any thread, so detach thread checkers. |
| 236 worker_thread_checker_.DetachFromThread(); | 242 worker_thread_checker_.DetachFromThread(); |
| 237 signal_thread_checker_.DetachFromThread(); | 243 signal_thread_checker_.DetachFromThread(); |
| 238 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; | 244 LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; |
| 239 RTC_DCHECK(decoder_factory); | 245 RTC_DCHECK(decoder_factory); |
| 240 RTC_DCHECK(encoder_factory); | 246 RTC_DCHECK(encoder_factory); |
| 247 RTC_DCHECK(audio_processing); | |
| 241 // The rest of our initialization will happen in Init. | 248 // The rest of our initialization will happen in Init. |
| 242 } | 249 } |
| 243 | 250 |
| 244 WebRtcVoiceEngine::~WebRtcVoiceEngine() { | 251 WebRtcVoiceEngine::~WebRtcVoiceEngine() { |
| 245 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 252 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 246 LOG(LS_INFO) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; | 253 LOG(LS_INFO) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; |
| 247 if (initialized_) { | 254 if (initialized_) { |
| 248 StopAecDump(); | 255 StopAecDump(); |
| 249 voe_wrapper_->base()->Terminate(); | 256 voe_wrapper_->base()->Terminate(); |
| 250 webrtc::Trace::SetTraceCallback(nullptr); | 257 webrtc::Trace::SetTraceCallback(nullptr); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 277 for (const AudioCodec& codec : recv_codecs_) { | 284 for (const AudioCodec& codec : recv_codecs_) { |
| 278 LOG(LS_INFO) << ToString(codec); | 285 LOG(LS_INFO) << ToString(codec); |
| 279 } | 286 } |
| 280 | 287 |
| 281 channel_config_.enable_voice_pacing = true; | 288 channel_config_.enable_voice_pacing = true; |
| 282 | 289 |
| 283 // Temporarily turn logging level up for the Init() call. | 290 // Temporarily turn logging level up for the Init() call. |
| 284 webrtc::Trace::SetTraceCallback(this); | 291 webrtc::Trace::SetTraceCallback(this); |
| 285 webrtc::Trace::set_level_filter(kElevatedTraceFilter); | 292 webrtc::Trace::set_level_filter(kElevatedTraceFilter); |
| 286 LOG(LS_INFO) << webrtc::VoiceEngine::GetVersionString(); | 293 LOG(LS_INFO) << webrtc::VoiceEngine::GetVersionString(); |
| 287 RTC_CHECK_EQ(0, voe_wrapper_->base()->Init(adm_.get(), nullptr, | 294 RTC_CHECK_EQ(0, |
| 288 decoder_factory_)); | 295 voe_wrapper_->base()->Init(adm_.get(), apm(), decoder_factory_)); |
| 289 webrtc::Trace::set_level_filter(kDefaultTraceFilter); | 296 webrtc::Trace::set_level_filter(kDefaultTraceFilter); |
| 290 | 297 |
| 291 // No ADM supplied? Get the default one from VoE. | 298 // No ADM supplied? Get the default one from VoE. |
| 292 if (!adm_) { | 299 if (!adm_) { |
| 293 adm_ = voe_wrapper_->base()->audio_device_module(); | 300 adm_ = voe_wrapper_->base()->audio_device_module(); |
| 294 } | 301 } |
| 295 RTC_DCHECK(adm_); | 302 RTC_DCHECK(adm_); |
| 296 | 303 |
| 297 apm_ = voe_wrapper_->base()->audio_processing(); | |
| 298 RTC_DCHECK(apm_); | |
| 299 | |
| 300 transmit_mixer_ = voe_wrapper_->base()->transmit_mixer(); | 304 transmit_mixer_ = voe_wrapper_->base()->transmit_mixer(); |
| 301 RTC_DCHECK(transmit_mixer_); | 305 RTC_DCHECK(transmit_mixer_); |
| 302 | 306 |
| 303 // Save the default AGC configuration settings. This must happen before | 307 // Save the default AGC configuration settings. This must happen before |
| 304 // calling ApplyOptions or the default will be overwritten. | 308 // calling ApplyOptions or the default will be overwritten. |
| 305 default_agc_config_ = webrtc::apm_helpers::GetAgcConfig(apm_); | 309 default_agc_config_ = webrtc::apm_helpers::GetAgcConfig(apm()); |
| 306 | 310 |
| 307 // Set default engine options. | 311 // Set default engine options. |
| 308 { | 312 { |
| 309 AudioOptions options; | 313 AudioOptions options; |
| 310 options.echo_cancellation = rtc::Optional<bool>(true); | 314 options.echo_cancellation = rtc::Optional<bool>(true); |
| 311 options.auto_gain_control = rtc::Optional<bool>(true); | 315 options.auto_gain_control = rtc::Optional<bool>(true); |
| 312 options.noise_suppression = rtc::Optional<bool>(true); | 316 options.noise_suppression = rtc::Optional<bool>(true); |
| 313 options.highpass_filter = rtc::Optional<bool>(true); | 317 options.highpass_filter = rtc::Optional<bool>(true); |
| 314 options.stereo_swapping = rtc::Optional<bool>(false); | 318 options.stereo_swapping = rtc::Optional<bool>(false); |
| 315 options.audio_jitter_buffer_max_packets = rtc::Optional<int>(50); | 319 options.audio_jitter_buffer_max_packets = rtc::Optional<int>(50); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 329 | 333 |
| 330 // Set default audio devices. | 334 // Set default audio devices. |
| 331 #if !defined(WEBRTC_IOS) | 335 #if !defined(WEBRTC_IOS) |
| 332 webrtc::adm_helpers::SetRecordingDevice(adm_); | 336 webrtc::adm_helpers::SetRecordingDevice(adm_); |
| 333 apm()->Initialize(); | 337 apm()->Initialize(); |
| 334 webrtc::adm_helpers::SetPlayoutDevice(adm_); | 338 webrtc::adm_helpers::SetPlayoutDevice(adm_); |
| 335 #endif // !WEBRTC_IOS | 339 #endif // !WEBRTC_IOS |
| 336 | 340 |
| 337 // May be null for VoE injected for testing. | 341 // May be null for VoE injected for testing. |
| 338 if (voe()->engine()) { | 342 if (voe()->engine()) { |
| 339 audio_state_ = | 343 audio_state_ = webrtc::AudioState::Create( |
| 340 webrtc::AudioState::Create(MakeAudioStateConfig(voe(), audio_mixer_)); | 344 MakeAudioStateConfig(voe(), audio_mixer_, apm_)); |
|
Taylor Brandstetter
2017/06/25 19:13:12
nit: Should use either "apm_" or "apm()" consisten
peah-webrtc
2017/06/27 14:57:40
That does not work here, as apm() returns a AudioP
| |
| 341 } | 345 } |
| 342 | 346 |
| 343 initialized_ = true; | 347 initialized_ = true; |
| 344 } | 348 } |
| 345 | 349 |
| 346 rtc::scoped_refptr<webrtc::AudioState> | 350 rtc::scoped_refptr<webrtc::AudioState> |
| 347 WebRtcVoiceEngine::GetAudioState() const { | 351 WebRtcVoiceEngine::GetAudioState() const { |
| 348 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 352 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 349 return audio_state_; | 353 return audio_state_; |
| 350 } | 354 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 default_agc_config_.limiterEnable = | 504 default_agc_config_.limiterEnable = |
| 501 options.tx_agc_limiter.value_or(default_agc_config_.limiterEnable); | 505 options.tx_agc_limiter.value_or(default_agc_config_.limiterEnable); |
| 502 | 506 |
| 503 webrtc::AgcConfig config = default_agc_config_; | 507 webrtc::AgcConfig config = default_agc_config_; |
| 504 if (options.adjust_agc_delta) { | 508 if (options.adjust_agc_delta) { |
| 505 config.targetLeveldBOv -= *options.adjust_agc_delta; | 509 config.targetLeveldBOv -= *options.adjust_agc_delta; |
| 506 LOG(LS_INFO) << "Adjusting AGC level from default -" | 510 LOG(LS_INFO) << "Adjusting AGC level from default -" |
| 507 << default_agc_config_.targetLeveldBOv << "dB to -" | 511 << default_agc_config_.targetLeveldBOv << "dB to -" |
| 508 << config.targetLeveldBOv << "dB"; | 512 << config.targetLeveldBOv << "dB"; |
| 509 } | 513 } |
| 510 webrtc::apm_helpers::SetAgcConfig(apm_, config); | 514 webrtc::apm_helpers::SetAgcConfig(apm(), config); |
| 511 } | 515 } |
| 512 | 516 |
| 513 if (options.intelligibility_enhancer) { | 517 if (options.intelligibility_enhancer) { |
| 514 intelligibility_enhancer_ = options.intelligibility_enhancer; | 518 intelligibility_enhancer_ = options.intelligibility_enhancer; |
| 515 } | 519 } |
| 516 if (intelligibility_enhancer_ && *intelligibility_enhancer_) { | 520 if (intelligibility_enhancer_ && *intelligibility_enhancer_) { |
| 517 LOG(LS_INFO) << "Enabling NS when Intelligibility Enhancer is active."; | 521 LOG(LS_INFO) << "Enabling NS when Intelligibility Enhancer is active."; |
| 518 options.noise_suppression = intelligibility_enhancer_; | 522 options.noise_suppression = intelligibility_enhancer_; |
| 519 } | 523 } |
| 520 | 524 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 } | 747 } |
| 744 | 748 |
| 745 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() { | 749 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() { |
| 746 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 750 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 747 RTC_DCHECK(adm_); | 751 RTC_DCHECK(adm_); |
| 748 return adm_; | 752 return adm_; |
| 749 } | 753 } |
| 750 | 754 |
| 751 webrtc::AudioProcessing* WebRtcVoiceEngine::apm() { | 755 webrtc::AudioProcessing* WebRtcVoiceEngine::apm() { |
| 752 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 756 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 753 RTC_DCHECK(apm_); | 757 return apm_.get(); |
| 754 return apm_; | |
| 755 } | 758 } |
| 756 | 759 |
| 757 webrtc::voe::TransmitMixer* WebRtcVoiceEngine::transmit_mixer() { | 760 webrtc::voe::TransmitMixer* WebRtcVoiceEngine::transmit_mixer() { |
| 758 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 761 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 759 RTC_DCHECK(transmit_mixer_); | 762 RTC_DCHECK(transmit_mixer_); |
| 760 return transmit_mixer_; | 763 return transmit_mixer_; |
| 761 } | 764 } |
| 762 | 765 |
| 763 AudioCodecs WebRtcVoiceEngine::CollectCodecs( | 766 AudioCodecs WebRtcVoiceEngine::CollectCodecs( |
| 764 const std::vector<webrtc::AudioCodecSpec>& specs) const { | 767 const std::vector<webrtc::AudioCodecSpec>& specs) const { |
| (...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2365 ssrc); | 2368 ssrc); |
| 2366 if (it != unsignaled_recv_ssrcs_.end()) { | 2369 if (it != unsignaled_recv_ssrcs_.end()) { |
| 2367 unsignaled_recv_ssrcs_.erase(it); | 2370 unsignaled_recv_ssrcs_.erase(it); |
| 2368 return true; | 2371 return true; |
| 2369 } | 2372 } |
| 2370 return false; | 2373 return false; |
| 2371 } | 2374 } |
| 2372 } // namespace cricket | 2375 } // namespace cricket |
| 2373 | 2376 |
| 2374 #endif // HAVE_WEBRTC_VOICE | 2377 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |