Chromium Code Reviews| 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 |
| 11 #include "webrtc/voice_engine/voe_base_impl.h" | 11 #include "webrtc/voice_engine/voe_base_impl.h" |
| 12 | 12 |
| 13 #include "webrtc/base/format_macros.h" | 13 #include "webrtc/base/format_macros.h" |
| 14 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/common.h" | 15 #include "webrtc/common.h" |
| 16 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" | 16 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" |
| 17 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" | |
| 17 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" | 18 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
| 18 #include "webrtc/modules/audio_device/audio_device_impl.h" | 19 #include "webrtc/modules/audio_device/audio_device_impl.h" |
| 19 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 20 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 20 #include "webrtc/system_wrappers/include/file_wrapper.h" | 21 #include "webrtc/system_wrappers/include/file_wrapper.h" |
| 21 #include "webrtc/voice_engine/channel.h" | 22 #include "webrtc/voice_engine/channel.h" |
| 22 #include "webrtc/voice_engine/include/voe_errors.h" | 23 #include "webrtc/voice_engine/include/voe_errors.h" |
| 23 #include "webrtc/voice_engine/output_mixer.h" | 24 #include "webrtc/voice_engine/output_mixer.h" |
| 24 #include "webrtc/voice_engine/transmit_mixer.h" | 25 #include "webrtc/voice_engine/transmit_mixer.h" |
| 25 #include "webrtc/voice_engine/utility.h" | 26 #include "webrtc/voice_engine/utility.h" |
| 26 #include "webrtc/voice_engine/voice_engine_impl.h" | 27 #include "webrtc/voice_engine/voice_engine_impl.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 | 205 |
| 205 // Deregister the observer in all active channels | 206 // Deregister the observer in all active channels |
| 206 for (voe::ChannelManager::Iterator it(&shared_->channel_manager()); | 207 for (voe::ChannelManager::Iterator it(&shared_->channel_manager()); |
| 207 it.IsValid(); it.Increment()) { | 208 it.IsValid(); it.Increment()) { |
| 208 it.GetChannel()->DeRegisterVoiceEngineObserver(); | 209 it.GetChannel()->DeRegisterVoiceEngineObserver(); |
| 209 } | 210 } |
| 210 | 211 |
| 211 return 0; | 212 return 0; |
| 212 } | 213 } |
| 213 | 214 |
| 214 int VoEBaseImpl::Init(AudioDeviceModule* external_adm, | 215 int VoEBaseImpl::Init( |
| 215 AudioProcessing* audioproc) { | 216 AudioDeviceModule* external_adm, |
| 217 AudioProcessing* audioproc, | |
| 218 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) { | |
| 216 rtc::CritScope cs(shared_->crit_sec()); | 219 rtc::CritScope cs(shared_->crit_sec()); |
| 217 WebRtcSpl_Init(); | 220 WebRtcSpl_Init(); |
| 218 if (shared_->statistics().Initialized()) { | 221 if (shared_->statistics().Initialized()) { |
| 219 return 0; | 222 return 0; |
| 220 } | 223 } |
| 221 if (shared_->process_thread()) { | 224 if (shared_->process_thread()) { |
| 222 shared_->process_thread()->Start(); | 225 shared_->process_thread()->Start(); |
| 223 } | 226 } |
| 224 | 227 |
| 225 // Create an internal ADM if the user has not added an external | 228 // Create an internal ADM if the user has not added an external |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 bool agc_enabled = | 371 bool agc_enabled = |
| 369 agc->mode() == GainControl::kAdaptiveAnalog && agc->is_enabled(); | 372 agc->mode() == GainControl::kAdaptiveAnalog && agc->is_enabled(); |
| 370 if (shared_->audio_device()->SetAGC(agc_enabled) != 0) { | 373 if (shared_->audio_device()->SetAGC(agc_enabled) != 0) { |
| 371 LOG_F(LS_ERROR) << "Failed to set agc to enabled: " << agc_enabled; | 374 LOG_F(LS_ERROR) << "Failed to set agc to enabled: " << agc_enabled; |
| 372 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR); | 375 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR); |
| 373 // TODO(ajm): No error return here due to | 376 // TODO(ajm): No error return here due to |
| 374 // https://code.google.com/p/webrtc/issues/detail?id=1464 | 377 // https://code.google.com/p/webrtc/issues/detail?id=1464 |
| 375 } | 378 } |
| 376 #endif | 379 #endif |
| 377 | 380 |
| 381 if (decoder_factory) | |
| 382 decoder_factory_ = decoder_factory; | |
| 383 else | |
| 384 decoder_factory_ = CreateBuiltinAudioDecoderFactory(); | |
|
the sun
2016/05/30 18:46:48
I think since the VoEBase::Init() interface has be
ossu
2016/05/31 08:54:18
Now, the last time we spoke about this you wanted
| |
| 385 | |
| 378 return shared_->statistics().SetInitialized(); | 386 return shared_->statistics().SetInitialized(); |
| 379 } | 387 } |
| 380 | 388 |
| 381 int VoEBaseImpl::Terminate() { | 389 int VoEBaseImpl::Terminate() { |
| 382 rtc::CritScope cs(shared_->crit_sec()); | 390 rtc::CritScope cs(shared_->crit_sec()); |
| 383 return TerminateInternal(); | 391 return TerminateInternal(); |
| 384 } | 392 } |
| 385 | 393 |
| 386 int VoEBaseImpl::CreateChannel() { | 394 int VoEBaseImpl::CreateChannel() { |
| 387 rtc::CritScope cs(shared_->crit_sec()); | 395 rtc::CritScope cs(shared_->crit_sec()); |
| 388 if (!shared_->statistics().Initialized()) { | 396 if (!shared_->statistics().Initialized()) { |
| 389 shared_->SetLastError(VE_NOT_INITED, kTraceError); | 397 shared_->SetLastError(VE_NOT_INITED, kTraceError); |
| 390 return -1; | 398 return -1; |
| 391 } | 399 } |
| 392 | 400 |
| 393 voe::ChannelOwner channel_owner = shared_->channel_manager().CreateChannel(); | 401 voe::ChannelOwner channel_owner = |
| 402 shared_->channel_manager().CreateChannel(decoder_factory_); | |
| 394 return InitializeChannel(&channel_owner); | 403 return InitializeChannel(&channel_owner); |
| 395 } | 404 } |
| 396 | 405 |
| 397 int VoEBaseImpl::CreateChannel(const Config& config) { | 406 int VoEBaseImpl::CreateChannel(const Config& config) { |
| 398 rtc::CritScope cs(shared_->crit_sec()); | 407 rtc::CritScope cs(shared_->crit_sec()); |
| 399 if (!shared_->statistics().Initialized()) { | 408 if (!shared_->statistics().Initialized()) { |
| 400 shared_->SetLastError(VE_NOT_INITED, kTraceError); | 409 shared_->SetLastError(VE_NOT_INITED, kTraceError); |
| 401 return -1; | 410 return -1; |
| 402 } | 411 } |
| 403 voe::ChannelOwner channel_owner = | 412 voe::ChannelOwner channel_owner = |
| 404 shared_->channel_manager().CreateChannel(config); | 413 shared_->channel_manager().CreateChannel(config, decoder_factory_); |
| 405 return InitializeChannel(&channel_owner); | 414 return InitializeChannel(&channel_owner); |
| 406 } | 415 } |
| 407 | 416 |
| 408 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { | 417 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { |
| 409 if (channel_owner->channel()->SetEngineInformation( | 418 if (channel_owner->channel()->SetEngineInformation( |
| 410 shared_->statistics(), *shared_->output_mixer(), | 419 shared_->statistics(), *shared_->output_mixer(), |
| 411 *shared_->transmit_mixer(), *shared_->process_thread(), | 420 *shared_->transmit_mixer(), *shared_->process_thread(), |
| 412 *shared_->audio_device(), voiceEngineObserverPtr_, | 421 *shared_->audio_device(), voiceEngineObserverPtr_, |
| 413 &callbackCritSect_) != 0) { | 422 &callbackCritSect_) != 0) { |
| 414 shared_->SetLastError( | 423 shared_->SetLastError( |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 825 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 817 "AssociateSendChannel() failed to locate accociate_send_channel"); | 826 "AssociateSendChannel() failed to locate accociate_send_channel"); |
| 818 return -1; | 827 return -1; |
| 819 } | 828 } |
| 820 | 829 |
| 821 channel_ptr->set_associate_send_channel(ch); | 830 channel_ptr->set_associate_send_channel(ch); |
| 822 return 0; | 831 return 0; |
| 823 } | 832 } |
| 824 | 833 |
| 825 } // namespace webrtc | 834 } // namespace webrtc |
| OLD | NEW |