// TaskQueue expects to be created/destroyed on the same thread. low_priority_worker_queue_.reset( new rtc::TaskQueue(task_queue_factory_->CreateTaskQueue( "rtc-low-prio", webrtc::TaskQueueFactory::Priority::LOW)));
// Load our audio codec lists. RTC_LOG(LS_VERBOSE) << "Supported send codecs in order of preference:"; send_codecs_ = CollectCodecs(encoder_factory_->GetSupportedEncoders()); for (const AudioCodec& codec : send_codecs_) { RTC_LOG(LS_VERBOSE) << ToString(codec); }
RTC_LOG(LS_VERBOSE) << "Supported recv codecs in order of preference:"; recv_codecs_ = CollectCodecs(decoder_factory_->GetSupportedDecoders()); for (const AudioCodec& codec : recv_codecs_) { RTC_LOG(LS_VERBOSE) << ToString(codec); }
#if defined(WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE) // No ADM supplied? Create a default one. if (!adm_) { adm_ = webrtc::AudioDeviceModule::Create( webrtc::AudioDeviceModule::kPlatformDefaultAudio, task_queue_factory_); } #endif// WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE RTC_CHECK(adm()); webrtc::adm_helpers::Init(adm());
// Set up AudioState. { webrtc::AudioState::Config config; if (audio_mixer_) { config.audio_mixer = audio_mixer_; } else { config.audio_mixer = webrtc::AudioMixerImpl::Create(); } config.audio_processing = apm_; config.audio_device_module = adm_; audio_state_ = webrtc::AudioState::Create(config); }
// Connect the ADM to our audio path. adm()->RegisterAudioCallback(audio_state()->audio_transport());
//指向AudioProcessing配置 webrtc::AudioProcessing* WebRtcVoiceEngine::apm()const{ RTC_DCHECK(worker_thread_checker_.IsCurrent()); return apm_.get(); } webrtc::AudioProcessing* ap = engine()->apm(); ... boolWebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in){ ... //默认配置 options.echo_cancellation 为true if (options.echo_cancellation) { // Check if platform supports built-in EC. Currently only supported on // Android and in combination with Java based audio layer. constbool built_in_aec = adm()->BuiltInAECIsAvailable();//开启硬件AEC就为true if (built_in_aec) { // Built-in EC exists on this device. Enable/Disable it according to the // echo_cancellation audio option. constbool enable_built_in_aec = *options.echo_cancellation; if (adm()->EnableBuiltInAEC(enable_built_in_aec) == 0 && enable_built_in_aec) { // Disable internal software EC if built-in EC is enabled, // i.e., replace the software EC with the built-in EC. options.echo_cancellation = false; RTC_LOG(LS_INFO) << "Disabling EC since built-in EC will be used instead"; } } } ... //如果编译android源码,默认启用AECM #elif defined(WEBRTC_ANDROID) use_mobile_software_aec = true; #endif ... //配置apm(AudioDeviceModule)参数 if (options.echo_cancellation) { apm_config.echo_canceller.enabled = *options.echo_cancellation; apm_config.echo_canceller.mobile_mode = use_mobile_software_aec; } ... ap->ApplyConfig(apm_config); returntrue; }
int16_tMapSetting(EchoControlMobileImpl::RoutingMode mode){ switch (mode) { case EchoControlMobileImpl::kQuietEarpieceOrHeadset: return0; case EchoControlMobileImpl::kEarpiece: return1; case EchoControlMobileImpl::kLoudEarpiece: return2; case EchoControlMobileImpl::kSpeakerphone: return3; case EchoControlMobileImpl::kLoudSpeakerphone: return4; } RTC_NOTREACHED(); return-1; }