AudioOptions
生活随笔
收集整理的這篇文章主要介紹了
AudioOptions
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
01、回音降噪 echo_cancellation
02、自動增益控制 auto_gain_control
03、噪聲抑制 noise_suppression
04、 高通濾波器 highpass_filter
05、立體聲交換 stereo_swapping
06、NetEq容量 audio_jitter_buffer_max_packets
07、NetEq快速模式 audio_jitter_buffer_fast_accelerate
08、jitter buffer最小延遲 audio_jitter_buffer_min_delay_ms
09、itter buffer是否適應(yīng)延遲重傳 audio_jitter_buffer_enable_rtx_handling
10、鍵盤檢測 typing_detection
11、殘留回聲檢測 residual_echo_detector
12、音頻網(wǎng)絡(luò)適配器 audio_network_adaptor_config
// 設(shè)置音頻參數(shù) bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {RTC_DCHECK_RUN_ON(&worker_thread_checker_);RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::ApplyOptions: "<< options_in.ToString();AudioOptions options = options_in; // 選項在下面進(jìn)行了修改// 設(shè)置和調(diào)整回聲消除器選項。不使用硬件 AEC 時,默認(rèn)使用桌面 AEC。bool use_mobile_software_aec = false;#if defined(WEBRTC_IOS)if (options.ios_force_software_aec_HACK &&*options.ios_force_software_aec_HACK) {// 在ios上強(qiáng)制軟件回聲消除options.echo_cancellation = true;RTC_LOG(LS_WARNING)<< "Force software AEC on iOS. May conflict with platform AEC.";} else {// 默認(rèn)使用VPIO內(nèi)置的回聲消除options.echo_cancellation = false;RTC_LOG(LS_INFO) << "Always disable AEC on iOS. Use built-in instead.";} #elif defined(WEBRTC_ANDROID)use_mobile_software_aec = true; #endif// Android 的噪聲抑制選項 #if defined(WEBRTC_ANDROID)options.typing_detection = false;options.experimental_ns = false; #endif// 設(shè)置和調(diào)整增益控制選項. #if defined(WEBRTC_IOS)// iOS平臺使用VIPIO內(nèi)置的降噪。options.auto_gain_control = false;options.experimental_agc = false;RTC_LOG(LS_INFO) << "Always disable AGC on iOS. Use built-in instead."; #elif defined(WEBRTC_ANDROID)// Android平臺關(guān)閉試驗性AGC.options.experimental_agc = false; #endif#if defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID)// 移動端(ios android)// 如果設(shè)置了"WebRTC-Audio-MinimizeResamplingOnMobile"則關(guān)閉AGC。// 然后如果開啟降噪且未開啟回聲消除則關(guān)閉高通濾波器。。// (https://bugs.chromium.org/p/webrtc/issues/detail?id=6181).if (minimized_remsampling_on_mobile_trial_enabled_) {options.auto_gain_control = false;RTC_LOG(LS_INFO) << "Disable AGC according to field trial.";if (!(options.noise_suppression.value_or(false) ||options.echo_cancellation.value_or(false))) {// If possible, turn off the high-pass filter.RTC_LOG(LS_INFO)<< "Disable high-pass filter in response to field trial.";options.highpass_filter = false;}} #endifif (options.echo_cancellation) {// 目前只有android支持內(nèi)置aec// 如果支持內(nèi)置aec而且開啟回聲消除echo_cancellation和未開啟use_delay_agnostic_aec// 且內(nèi)置EnableBuiltInAEC時關(guān)閉軟件回聲消除從而使用平臺內(nèi)置回聲消除。const bool built_in_aec = adm()->BuiltInAECIsAvailable();// 除了Android平臺為true,其他平臺默認(rèn)為falseif (built_in_aec) {// 此設(shè)備上存在內(nèi)置 EC。 根據(jù) echo_cancellation 音頻選項啟用/禁用它const bool enable_built_in_aec = *options.echo_cancellation;if (adm()->EnableBuiltInAEC(enable_built_in_aec) == 0 &&enable_built_in_aec) {// 如果啟用內(nèi)置 EC,則禁用內(nèi)部軟件 EC,即將軟件 EC 替換為內(nèi)置 ECoptions.echo_cancellation = false;RTC_LOG(LS_INFO)<< "Disabling EC since built-in EC will be used instead";}}}// 判斷是否支持平臺內(nèi)置agc,如果支持則關(guān)閉軟件agcif (options.auto_gain_control) {bool built_in_agc_avaliable = adm()->BuiltInAGCIsAvailable();if (built_in_agc_avaliable) {if (adm()->EnableBuiltInAGC(*options.auto_gain_control) == 0 &&*options.auto_gain_control) {// 如果啟用了內(nèi)置 AGC,則禁用內(nèi)部軟件 AGC,即將軟件 AGC 替換為內(nèi)置 AGCoptions.auto_gain_control = false;RTC_LOG(LS_INFO)<< "Disabling AGC since built-in AGC will be used instead";}}}// 如果支持平臺內(nèi)置降噪則關(guān)閉軟件降噪if (options.noise_suppression) {if (adm()->BuiltInNSIsAvailable()) {bool builtin_ns = *options.noise_suppression;if (adm()->EnableBuiltInNS(builtin_ns) == 0 && builtin_ns) {// 如果啟用了內(nèi)置 NS,則禁用內(nèi)部軟件 NS// 即用內(nèi)置 NS 替換軟件 NSoptions.noise_suppression = false;RTC_LOG(LS_INFO)<< "Disabling NS since built-in NS will be used instead";}}}// 立體聲通道交換if (options.stereo_swapping) {RTC_LOG(LS_INFO) << "Stereo swapping enabled? " << *options.stereo_swapping;audio_state()->SetStereoChannelSwapping(*options.stereo_swapping);}// jitter buffer最大包數(shù)設(shè)置if (options.audio_jitter_buffer_max_packets) {RTC_LOG(LS_INFO) << "NetEq capacity is "<< *options.audio_jitter_buffer_max_packets;audio_jitter_buffer_max_packets_ =std::max(20, *options.audio_jitter_buffer_max_packets);}// jitter buffer加速設(shè)置if (options.audio_jitter_buffer_fast_accelerate) {RTC_LOG(LS_INFO) << "NetEq fast mode? "<< *options.audio_jitter_buffer_fast_accelerate;audio_jitter_buffer_fast_accelerate_ =*options.audio_jitter_buffer_fast_accelerate;}// jitter buffer最小延遲(毫秒)if (options.audio_jitter_buffer_min_delay_ms) {RTC_LOG(LS_INFO) << "NetEq minimum delay is "<< *options.audio_jitter_buffer_min_delay_ms;audio_jitter_buffer_min_delay_ms_ =*options.audio_jitter_buffer_min_delay_ms;}if (options.audio_jitter_buffer_enable_rtx_handling) {RTC_LOG(LS_INFO) << "NetEq handle reordered packets? "<< *options.audio_jitter_buffer_enable_rtx_handling;audio_jitter_buffer_enable_rtx_handling_ =*options.audio_jitter_buffer_enable_rtx_handling;}webrtc::AudioProcessing* ap = apm();if (!ap) {RTC_LOG(LS_INFO)<< "No audio processing module present. No software-provided effects ""(AEC, NS, AGC, ...) are activated";return true;}if (options.experimental_ns) {experimental_ns_ = options.experimental_ns;}webrtc::AudioProcessing::Config apm_config = ap->GetConfig();#if !(defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS))if (experimental_ns_.has_value()) {apm_config.transient_suppression.enabled = experimental_ns_.value();} #endifif (options.echo_cancellation) {apm_config.echo_canceller.enabled = *options.echo_cancellation;apm_config.echo_canceller.mobile_mode = use_mobile_software_aec;}if (options.auto_gain_control) {const bool enabled = *options.auto_gain_control;apm_config.gain_controller1.enabled = enabled; #if defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID)apm_config.gain_controller1.mode =apm_config.gain_controller1.kFixedDigital; #elseapm_config.gain_controller1.mode =apm_config.gain_controller1.kAdaptiveAnalog; #endif}if (options.tx_agc_target_dbov) {apm_config.gain_controller1.target_level_dbfs = *options.tx_agc_target_dbov;}if (options.tx_agc_digital_compression_gain) {apm_config.gain_controller1.compression_gain_db =*options.tx_agc_digital_compression_gain;}if (options.tx_agc_limiter) {apm_config.gain_controller1.enable_limiter = *options.tx_agc_limiter;}if (options.highpass_filter) {apm_config.high_pass_filter.enabled = *options.highpass_filter;}// 殘留回聲檢測if (options.residual_echo_detector) {apm_config.residual_echo_detector.enabled = *options.residual_echo_detector;}if (options.noise_suppression) {const bool enabled = *options.noise_suppression;apm_config.noise_suppression.enabled = enabled;apm_config.noise_suppression.level =webrtc::AudioProcessing::Config::NoiseSuppression::Level::kHigh;RTC_LOG(LS_INFO) << "NS set to " << enabled;}// 鍵盤聲音檢測if (options.typing_detection) {RTC_LOG(LS_INFO) << "Typing detection is enabled? "<< *options.typing_detection;apm_config.voice_detection.enabled = *options.typing_detection;}ap->ApplyConfig(apm_config);return true; }總結(jié)
以上是生活随笔為你收集整理的AudioOptions的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 分组后取每组最新的数据
- 下一篇: lucus