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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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(AudioDeviceModule* external_adm, |
215 AudioProcessing* audioproc) { | 216 AudioProcessing* audioproc, |
217 std::shared_ptr<AudioDecoderFactory> decoder_factory) { | |
216 rtc::CritScope cs(shared_->crit_sec()); | 218 rtc::CritScope cs(shared_->crit_sec()); |
217 WebRtcSpl_Init(); | 219 WebRtcSpl_Init(); |
218 if (shared_->statistics().Initialized()) { | 220 if (shared_->statistics().Initialized()) { |
219 return 0; | 221 return 0; |
220 } | 222 } |
221 if (shared_->process_thread()) { | 223 if (shared_->process_thread()) { |
222 shared_->process_thread()->Start(); | 224 shared_->process_thread()->Start(); |
223 } | 225 } |
224 | 226 |
225 // Create an internal ADM if the user has not added an external | 227 // 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 = | 370 bool agc_enabled = |
369 agc->mode() == GainControl::kAdaptiveAnalog && agc->is_enabled(); | 371 agc->mode() == GainControl::kAdaptiveAnalog && agc->is_enabled(); |
370 if (shared_->audio_device()->SetAGC(agc_enabled) != 0) { | 372 if (shared_->audio_device()->SetAGC(agc_enabled) != 0) { |
371 LOG_F(LS_ERROR) << "Failed to set agc to enabled: " << agc_enabled; | 373 LOG_F(LS_ERROR) << "Failed to set agc to enabled: " << agc_enabled; |
372 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR); | 374 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR); |
373 // TODO(ajm): No error return here due to | 375 // TODO(ajm): No error return here due to |
374 // https://code.google.com/p/webrtc/issues/detail?id=1464 | 376 // https://code.google.com/p/webrtc/issues/detail?id=1464 |
375 } | 377 } |
376 #endif | 378 #endif |
377 | 379 |
380 if (decoder_factory) | |
381 decoder_factory_ = std::move(decoder_factory); | |
382 else | |
383 decoder_factory_ = CreateBuiltinAudioDecoderFactory(); | |
kwiberg-webrtc
2016/05/17 13:33:48
?:
ossu
2016/05/17 14:25:35
That is... punctuation!
If it's a question, my ans
kwiberg-webrtc
2016/05/18 03:06:35
Oh, nothing so subtle! I was jus suggesting
dec
| |
384 | |
378 return shared_->statistics().SetInitialized(); | 385 return shared_->statistics().SetInitialized(); |
379 } | 386 } |
380 | 387 |
381 int VoEBaseImpl::Terminate() { | 388 int VoEBaseImpl::Terminate() { |
382 rtc::CritScope cs(shared_->crit_sec()); | 389 rtc::CritScope cs(shared_->crit_sec()); |
383 return TerminateInternal(); | 390 return TerminateInternal(); |
384 } | 391 } |
385 | 392 |
386 int VoEBaseImpl::CreateChannel() { | 393 int VoEBaseImpl::CreateChannel() { |
387 rtc::CritScope cs(shared_->crit_sec()); | 394 rtc::CritScope cs(shared_->crit_sec()); |
388 if (!shared_->statistics().Initialized()) { | 395 if (!shared_->statistics().Initialized()) { |
389 shared_->SetLastError(VE_NOT_INITED, kTraceError); | 396 shared_->SetLastError(VE_NOT_INITED, kTraceError); |
390 return -1; | 397 return -1; |
391 } | 398 } |
392 | 399 |
393 voe::ChannelOwner channel_owner = shared_->channel_manager().CreateChannel(); | 400 voe::ChannelOwner channel_owner = |
401 shared_->channel_manager().CreateChannel(decoder_factory_); | |
394 return InitializeChannel(&channel_owner); | 402 return InitializeChannel(&channel_owner); |
395 } | 403 } |
396 | 404 |
397 int VoEBaseImpl::CreateChannel(const Config& config) { | 405 int VoEBaseImpl::CreateChannel(const Config& config) { |
398 rtc::CritScope cs(shared_->crit_sec()); | 406 rtc::CritScope cs(shared_->crit_sec()); |
399 if (!shared_->statistics().Initialized()) { | 407 if (!shared_->statistics().Initialized()) { |
400 shared_->SetLastError(VE_NOT_INITED, kTraceError); | 408 shared_->SetLastError(VE_NOT_INITED, kTraceError); |
401 return -1; | 409 return -1; |
402 } | 410 } |
403 voe::ChannelOwner channel_owner = | 411 voe::ChannelOwner channel_owner = |
404 shared_->channel_manager().CreateChannel(config); | 412 shared_->channel_manager().CreateChannel(config, decoder_factory_); |
405 return InitializeChannel(&channel_owner); | 413 return InitializeChannel(&channel_owner); |
406 } | 414 } |
407 | 415 |
408 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { | 416 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { |
409 if (channel_owner->channel()->SetEngineInformation( | 417 if (channel_owner->channel()->SetEngineInformation( |
410 shared_->statistics(), *shared_->output_mixer(), | 418 shared_->statistics(), *shared_->output_mixer(), |
411 *shared_->transmit_mixer(), *shared_->process_thread(), | 419 *shared_->transmit_mixer(), *shared_->process_thread(), |
412 *shared_->audio_device(), voiceEngineObserverPtr_, | 420 *shared_->audio_device(), voiceEngineObserverPtr_, |
413 &callbackCritSect_) != 0) { | 421 &callbackCritSect_) != 0) { |
414 shared_->SetLastError( | 422 shared_->SetLastError( |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 824 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
817 "AssociateSendChannel() failed to locate accociate_send_channel"); | 825 "AssociateSendChannel() failed to locate accociate_send_channel"); |
818 return -1; | 826 return -1; |
819 } | 827 } |
820 | 828 |
821 channel_ptr->set_associate_send_channel(ch); | 829 channel_ptr->set_associate_send_channel(ch); |
822 return 0; | 830 return 0; |
823 } | 831 } |
824 | 832 |
825 } // namespace webrtc | 833 } // namespace webrtc |
OLD | NEW |