WebRTC的native层语音处理

来源:互联网 发布:淘宝卖家在哪里登录 编辑:程序博客网 时间:2024/06/05 15:18

跨平台WebRTC

WebRTC是google开源的一个免插件实时视频通信技术,其分为web开发和native开发;目前支持chrome,firefox,Android,iOS,opera,edge。是一个真正意义上的跨平台免插件实时视频通信技术。

如果是视频应用的开发一般是基于web的,需要HTML5,JavaScript,json,websocket等这些基本编程基础,此外还需要掌握一些网络通信协议。

如果是将webRTC移植到浏览器则需要native层的开发,当然也可以对native层代码进行二次开发。


native层的安装编译

http://blog.csdn.NET/shichaog/article/details/50246155


native层语音算法测试程序

请务必完成上述连接中的内容

如果像使用native层的aec,aecm,agc,ns,vad等之类的语音处理模块,则在完成上述连接中的步骤后,即可找到一个可执行的测试文件audioproc,该而进行文件可以完成上述相关算法的测试。该文件的位置是:

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. webrtc-checkout/src/out/Debug$ ./audioproc  

使用help选项该文件的输出如下:

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. gsc@gsc-250:~/webrtc-checkout/src/out/Debug$ ./audioproc --help  
  2. Usage: process_test [options] [-pb PROTOBUF_FILE]  
  3.   [-ir REVERSE_FILE] [-i PRIMARY_FILE] [-o OUT_FILE]  
  4. process_test is a test application for AudioProcessing.  
  5.   
  6. When a protobuf debug file is available, specify it with -pb. Alternately,  
  7. when -ir or -i is used, the specified files will be processed directly in  
  8. a simulation mode. Otherwise the full set of legacy test files is expected  
  9. to be present in the working directory. OUT_FILE should be specified  
  10. without extension to support both raw and wav output.  
  11.   
  12. Options  
  13. General configuration (only used for the simulation mode):  
  14.   -fs SAMPLE_RATE_HZ  
  15.   -ch CHANNELS_IN CHANNELS_OUT  
  16.   -rch REVERSE_CHANNELS  
  17.   
  18. Component configuration:  
  19. All components are disabled by default. Each block below begins with a  
  20. flag to enable the component with default settings. The subsequent flags  
  21. in the block are used to provide configuration settings.  
  22.   
  23.   -aec     Echo cancellation  
  24.   --drift_compensation  
  25.   --no_drift_compensation  
  26.   --no_echo_metrics  
  27.   --no_delay_logging  
  28.   --aec_suppression_level LEVEL  [0 - 2]  
  29.   --extended_filter  
  30.   --no_reported_delay  
  31.   
  32.   -aecm    Echo control mobile  
  33.   --aecm_echo_path_in_file FILE  
  34.   --aecm_echo_path_out_file FILE  
  35.   --no_comfort_noise  
  36.   --routing_mode MODE  [0 - 4]  
  37.   
  38.   -agc     Gain control  
  39.   --analog  
  40.   --adaptive_digital  
  41.   --fixed_digital  
  42.   --target_level LEVEL  
  43.   --compression_gain GAIN  
  44.   --limiter  
  45.   --no_limiter  
  46.   
  47.   -hpf     High pass filter  
  48.   
  49.   -ns      Noise suppression  
  50.   --ns_low  
  51.   --ns_moderate  
  52.   --ns_high  
  53.   --ns_very_high  
  54.   --ns_prob_file FILE  
  55.   
  56.   -vad     Voice activity detection  
  57.   --vad_out_file FILE  
  58.   
  59.   -expns   Experimental noise suppression  
  60.   
  61.  Level metrics (enabled by default)  
  62.   --no_level_metrics  
  63.   
  64. Modifiers:  
  65.   --noasm            Disable SSE optimization.  
  66.   --add_delay DELAY  Add DELAY ms to input value.  
  67.   --delay DELAY      Override input delay with DELAY ms.  
  68.   --perf             Measure performance.  
  69.   --quiet            Suppress text output.  
  70.   --no_progress      Suppress progress.  
  71.   --raw_output       Raw output instead of WAV file.  
  72.   --debug_file FILE  Dump a debug recording.  

为什么是该audioproc?

这可以从ninja这个编译器的编译过程可以看出来。

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. gsc@gsc-250:~/webrtc-checkout/src/out/Debug/obj/webrtc/modules$ pwd  
  2. /home/gsc/webrtc-checkout/src/out/Debug/obj/webrtc/modules  
  3. gsc@gsc-250:~/webrtc-checkout/src/out/Debug/obj/webrtc/modules$ grep -nR "audioproc.process_test.o"  
  4. audioproc.ninja:87:build obj/webrtc/modules/audio_processing/test/audioproc.process_test.o: $  
  5. audioproc.ninja:97:    obj/webrtc/modules/audio_processing/test/audioproc.process_test.o $  

首先找到上面grep出现文件。打开该文件可见下面的内容:

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1.  87 build obj/webrtc/modules/audio_processing/test/audioproc.process_test.o: $  
  2.  88     cxx ../../webrtc/modules/audio_processing/test/process_test.cc || $  
  3.  89     obj/webrtc/modules/audioproc.compile_depends.stamp  
  4.  90   
  5.  91 ldflags = -Wl,-z,now -Wl,-z,relro -Wl,--fatal-warnings -Wl,-z,defs -pthread $  
  6.  92     -Wl,-z,noexecstack -fPIC -fuse-ld=gold $  
  7.  93     -B/home/gsc/webrtc-checkout/src/third_party/binutils/Linux_x64/Release/bin $  
  8.  94     -Wl,--disable-new-dtags -m64 -Wl,--detect-odr-violations -Wl,--icf=all  
  9.  95 libs =  -lrt -lm  
  10.  96 build audioproc: link $  
  11.  97     obj/webrtc/modules/audio_processing/test/audioproc.process_test.o $  
  12.  98     obj/webrtc/modules/libaudio_processing.a $  
  13.  99     obj/webrtc/modules/libaudioproc_debug_proto.a $  
  14. 100     obj/webrtc/modules/libaudioproc_test_utils.a $  
  15. 101     obj/webrtc/modules/libaudioproc_protobuf_utils.a $  
  16. 102     obj/chromium/src/testing/libgtest.a $  
  17. 103     obj/webrtc/system_wrappers/libsystem_wrappers.a $  
  18. 104     obj/webrtc/test/libtest_support.a $  
  19. 105     obj/webrtc/base/librtc_base_approved.a obj/webrtc/libwebrtc_common.a $  
  20. 106     obj/webrtc/common_audio/libcommon_audio.a $  
  21. 107     obj/chromium/src/third_party/openmax_dl/dl/libopenmax_dl.a $  
  22. 108     obj/webrtc/common_audio/libcommon_audio_sse2.a $  
  23. 109     obj/webrtc/modules/libisac.a $  
  24. 110     obj/webrtc/modules/libaudio_decoder_interface.a $  
  25. 111     obj/webrtc/modules/libaudio_encoder_interface.a $  
  26. 112     obj/webrtc/modules/libisac_common.a $  
  27. 113     obj/chromium/src/third_party/protobuf/libprotobuf_lite.a $  
  28. 114     obj/webrtc/modules/libaudio_processing_sse2.a $  
  29. 115     obj/webrtc/system_wrappers/libfield_trial_default.a $  
  30. 116     obj/webrtc/system_wrappers/libmetrics_default.a $  
  31. 117     obj/chromium/src/testing/libgmock.a  
  32. 118   ld = $ldxx  


第87行指示该.o文件编译来源于process_test.cc,再根据96,97行可知包含编译生成的文件audioproc.process_test.o 经过连接后会生成audioproc这个文件,这个文件的作用见前一节。这时再来看那个cc文件。


[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. 1141 }  // namespace  
  2. 1142 }  // namespace webrtc  
  3. 1143   
  4. 1144 int main(int argc, char* argv[]) {  
  5. 1145   webrtc::void_main(argc, argv);  
  6. 1146   
  7. 1147   // Optional, but removes memory leak noise from Valgrind.  
  8. 1148   google::protobuf::ShutdownProtobufLibrary();  
  9. 1149   return 0;  
  10. 1150 }  
  11.   
  12.  136 // void function for gtest.  
  13.  137 void void_main(int argc, char* argv[]) {  
  14.  138   if (argc > 1 && strcmp(argv[1], "--help") == 0) {  
  15.  139     usage();  
  16.  140     return;  
  17.  141   }  
  18.  142   
  19.  143   if (argc < 2) {  
  20.  144     printf("Did you mean to run without arguments?\n");  
  21.  145     printf("Try `process_test --help' for more information.\n\n");  
  22.  146   }  
  23.  147   
  24.  148   rtc::scoped_ptr<AudioProcessing> apm(AudioProcessing::Create());  
  25.  149   ASSERT_TRUE(apm.get() != NULL);  
  26.  150   
  27.  151   const char* pb_filename = NULL;  
  28.  152   const char* far_filename = NULL;  
  29.  153   const char* near_filename = NULL;  
  30.  154   std::string out_filename;  
  31.  155   const char* vad_out_filename = NULL;  
  32.  156   const char* ns_prob_filename = NULL;  
  33.  157   const char* aecm_echo_path_in_filename = NULL;  
  34.  158   const char* aecm_echo_path_out_filename = NULL;  
  35.  159   
  36.  160   int32_t sample_rate_hz = 16000;  
  37.  161   
  38.  162   int num_capture_input_channels = 1;  
  39.  163   int num_capture_output_channels = 1;  

文件的内容就不叙述了,该main函数就是整个测试的入口。


这里又引出来一个目录

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. gsc@gsc-250:~/webrtc-checkout/src/webrtc/modules/audio_processing/test$  

audio_processing就是这个目录,而test就是测试文件所在的目录

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. 总结如下:编译,测试  
  2. python webrtc/build/gyp_webrtc  
  3. ninja -C out/Debug   
  4.  ./nonlinear_beamformer_test -i out2.wav -mic_positions "1.0 1.0 1.0 2.0 2.2 2.2 1.1 1.2 0" out.wav  
0 0
原创粉丝点击