• AudioOptions


    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是否适应延迟重传 audio_jitter_buffer_enable_rtx_handling

    10、键盘检测 typing_detection

    11、残留回声检测 residual_echo_detector

    12、音频网络适配器 audio_network_adaptor_config

    1. // 设置音频参数
    2. bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {
    3. RTC_DCHECK_RUN_ON(&worker_thread_checker_);
    4. RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::ApplyOptions: "
    5. << options_in.ToString();
    6. AudioOptions options = options_in; // 选项在下面进行了修改
    7. // 设置和调整回声消除器选项。不使用硬件 AEC 时,默认使用桌面 AEC。
    8. bool use_mobile_software_aec = false;
    9. #if defined(WEBRTC_IOS)
    10. if (options.ios_force_software_aec_HACK &&
    11. *options.ios_force_software_aec_HACK) {
    12. // 在ios上强制软件回声消除
    13. options.echo_cancellation = true;
    14. RTC_LOG(LS_WARNING)
    15. << "Force software AEC on iOS. May conflict with platform AEC.";
    16. } else {
    17. // 默认使用VPIO内置的回声消除
    18. options.echo_cancellation = false;
    19. RTC_LOG(LS_INFO) << "Always disable AEC on iOS. Use built-in instead.";
    20. }
    21. #elif defined(WEBRTC_ANDROID)
    22. use_mobile_software_aec = true;
    23. #endif
    24. // Android 的噪声抑制选项
    25. #if defined(WEBRTC_ANDROID)
    26. options.typing_detection = false;
    27. options.experimental_ns = false;
    28. #endif
    29. // 设置和调整增益控制选项.
    30. #if defined(WEBRTC_IOS)
    31. // iOS平台使用VIPIO内置的降噪。
    32. options.auto_gain_control = false;
    33. options.experimental_agc = false;
    34. RTC_LOG(LS_INFO) << "Always disable AGC on iOS. Use built-in instead.";
    35. #elif defined(WEBRTC_ANDROID)
    36. // Android平台关闭试验性AGC.
    37. options.experimental_agc = false;
    38. #endif
    39. #if defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID)
    40. // 移动端(ios android)
    41. // 如果设置了"WebRTC-Audio-MinimizeResamplingOnMobile"则关闭AGC。
    42. // 然后如果开启降噪且未开启回声消除则关闭高通滤波器。。
    43. // (https://bugs.chromium.org/p/webrtc/issues/detail?id=6181).
    44. if (minimized_remsampling_on_mobile_trial_enabled_) {
    45. options.auto_gain_control = false;
    46. RTC_LOG(LS_INFO) << "Disable AGC according to field trial.";
    47. if (!(options.noise_suppression.value_or(false) ||
    48. options.echo_cancellation.value_or(false))) {
    49. // If possible, turn off the high-pass filter.
    50. RTC_LOG(LS_INFO)
    51. << "Disable high-pass filter in response to field trial.";
    52. options.highpass_filter = false;
    53. }
    54. }
    55. #endif
    56. if (options.echo_cancellation) {
    57. // 目前只有android支持内置aec
    58. // 如果支持内置aec而且开启回声消除echo_cancellation和未开启use_delay_agnostic_aec
    59. // 且内置EnableBuiltInAEC时关闭软件回声消除从而使用平台内置回声消除。
    60. const bool built_in_aec = adm()->BuiltInAECIsAvailable();
    61. // 除了Android平台为true,其他平台默认为false
    62. if (built_in_aec) {
    63. // 此设备上存在内置 EC。 根据 echo_cancellation 音频选项启用/禁用它
    64. const bool enable_built_in_aec = *options.echo_cancellation;
    65. if (adm()->EnableBuiltInAEC(enable_built_in_aec) == 0 &&
    66. enable_built_in_aec) {
    67. // 如果启用内置 EC,则禁用内部软件 EC,即将软件 EC 替换为内置 EC
    68. options.echo_cancellation = false;
    69. RTC_LOG(LS_INFO)
    70. << "Disabling EC since built-in EC will be used instead";
    71. }
    72. }
    73. }
    74. // 判断是否支持平台内置agc,如果支持则关闭软件agc
    75. if (options.auto_gain_control) {
    76. bool built_in_agc_avaliable = adm()->BuiltInAGCIsAvailable();
    77. if (built_in_agc_avaliable) {
    78. if (adm()->EnableBuiltInAGC(*options.auto_gain_control) == 0 &&
    79. *options.auto_gain_control) {
    80. // 如果启用了内置 AGC,则禁用内部软件 AGC,即将软件 AGC 替换为内置 AGC
    81. options.auto_gain_control = false;
    82. RTC_LOG(LS_INFO)
    83. << "Disabling AGC since built-in AGC will be used instead";
    84. }
    85. }
    86. }
    87. // 如果支持平台内置降噪则关闭软件降噪
    88. if (options.noise_suppression) {
    89. if (adm()->BuiltInNSIsAvailable()) {
    90. bool builtin_ns = *options.noise_suppression;
    91. if (adm()->EnableBuiltInNS(builtin_ns) == 0 && builtin_ns) {
    92. // 如果启用了内置 NS,则禁用内部软件 NS
    93. // 即用内置 NS 替换软件 NS
    94. options.noise_suppression = false;
    95. RTC_LOG(LS_INFO)
    96. << "Disabling NS since built-in NS will be used instead";
    97. }
    98. }
    99. }
    100. // 立体声通道交换
    101. if (options.stereo_swapping) {
    102. RTC_LOG(LS_INFO) << "Stereo swapping enabled? " << *options.stereo_swapping;
    103. audio_state()->SetStereoChannelSwapping(*options.stereo_swapping);
    104. }
    105. // jitter buffer最大包数设置
    106. if (options.audio_jitter_buffer_max_packets) {
    107. RTC_LOG(LS_INFO) << "NetEq capacity is "
    108. << *options.audio_jitter_buffer_max_packets;
    109. audio_jitter_buffer_max_packets_ =
    110. std::max(20, *options.audio_jitter_buffer_max_packets);
    111. }
    112. // jitter buffer加速设置
    113. if (options.audio_jitter_buffer_fast_accelerate) {
    114. RTC_LOG(LS_INFO) << "NetEq fast mode? "
    115. << *options.audio_jitter_buffer_fast_accelerate;
    116. audio_jitter_buffer_fast_accelerate_ =
    117. *options.audio_jitter_buffer_fast_accelerate;
    118. }
    119. // jitter buffer最小延迟(毫秒)
    120. if (options.audio_jitter_buffer_min_delay_ms) {
    121. RTC_LOG(LS_INFO) << "NetEq minimum delay is "
    122. << *options.audio_jitter_buffer_min_delay_ms;
    123. audio_jitter_buffer_min_delay_ms_ =
    124. *options.audio_jitter_buffer_min_delay_ms;
    125. }
    126. if (options.audio_jitter_buffer_enable_rtx_handling) {
    127. RTC_LOG(LS_INFO) << "NetEq handle reordered packets? "
    128. << *options.audio_jitter_buffer_enable_rtx_handling;
    129. audio_jitter_buffer_enable_rtx_handling_ =
    130. *options.audio_jitter_buffer_enable_rtx_handling;
    131. }
    132. webrtc::AudioProcessing* ap = apm();
    133. if (!ap) {
    134. RTC_LOG(LS_INFO)
    135. << "No audio processing module present. No software-provided effects "
    136. "(AEC, NS, AGC, ...) are activated";
    137. return true;
    138. }
    139. if (options.experimental_ns) {
    140. experimental_ns_ = options.experimental_ns;
    141. }
    142. webrtc::AudioProcessing::Config apm_config = ap->GetConfig();
    143. #if !(defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS))
    144. if (experimental_ns_.has_value()) {
    145. apm_config.transient_suppression.enabled = experimental_ns_.value();
    146. }
    147. #endif
    148. if (options.echo_cancellation) {
    149. apm_config.echo_canceller.enabled = *options.echo_cancellation;
    150. apm_config.echo_canceller.mobile_mode = use_mobile_software_aec;
    151. }
    152. if (options.auto_gain_control) {
    153. const bool enabled = *options.auto_gain_control;
    154. apm_config.gain_controller1.enabled = enabled;
    155. #if defined(WEBRTC_IOS) || defined(WEBRTC_ANDROID)
    156. apm_config.gain_controller1.mode =
    157. apm_config.gain_controller1.kFixedDigital;
    158. #else
    159. apm_config.gain_controller1.mode =
    160. apm_config.gain_controller1.kAdaptiveAnalog;
    161. #endif
    162. }
    163. if (options.tx_agc_target_dbov) {
    164. apm_config.gain_controller1.target_level_dbfs = *options.tx_agc_target_dbov;
    165. }
    166. if (options.tx_agc_digital_compression_gain) {
    167. apm_config.gain_controller1.compression_gain_db =
    168. *options.tx_agc_digital_compression_gain;
    169. }
    170. if (options.tx_agc_limiter) {
    171. apm_config.gain_controller1.enable_limiter = *options.tx_agc_limiter;
    172. }
    173. if (options.highpass_filter) {
    174. apm_config.high_pass_filter.enabled = *options.highpass_filter;
    175. }
    176. // 残留回声检测
    177. if (options.residual_echo_detector) {
    178. apm_config.residual_echo_detector.enabled = *options.residual_echo_detector;
    179. }
    180. if (options.noise_suppression) {
    181. const bool enabled = *options.noise_suppression;
    182. apm_config.noise_suppression.enabled = enabled;
    183. apm_config.noise_suppression.level =
    184. webrtc::AudioProcessing::Config::NoiseSuppression::Level::kHigh;
    185. RTC_LOG(LS_INFO) << "NS set to " << enabled;
    186. }
    187. // 键盘声音检测
    188. if (options.typing_detection) {
    189. RTC_LOG(LS_INFO) << "Typing detection is enabled? "
    190. << *options.typing_detection;
    191. apm_config.voice_detection.enabled = *options.typing_detection;
    192. }
    193. ap->ApplyConfig(apm_config);
    194. return true;
    195. }

  • 相关阅读:
    vue3如何写全局样式
    地级市-空气流动系数数据-更新至2019(含10米风速、边界高度等)
    [Node] Node.js Webpack和打包过程
    用hadoop-eclipse-plugins-2.6.0来配置hadoop-3.3.6
    力扣每日一题-第31天-13.罗马数组转整数
    java计算机毕业设计高校请假管理系统MyBatis+系统+LW文档+源码+调试部署
    文举论金:黄金原油全面走势分析策略独家指导
    elasticsearch 索引write.lock报错解决 —— 筑梦之路
    搭建confluence
    合宙AIR105(四): SPI, MAX7219 8x8LED驱动
  • 原文地址:https://blog.csdn.net/qq_15821883/article/details/126015797