webrtc在c++环境下开发方法

(1)在官方网站下下载webrtc。

(2)下载depot_tools,并配进环境变量,比如:

在.bashrc添加

export PATH=/root/webrtc_all/depot_tools/:$PATH

(3)编译:

gn gen out/linux/
ninja -C out/linux/

以上可以完成webrtc的原生操作。

添加自己程序的方法:

(4)在src/video下面新建test.cc,内容如下:

#include 
using namespace std;
int main()
{
  cout<<"hahaha"<

(5)在src/video的build.gn中,添加:

rtc_executable("test") {
    testonly = true
    sources = [
      "test.cc",
    ]
    deps = [      
    ]
    if (!build_with_chromium && is_clang) {
      # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
      suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
    }
  }

这一步的deps中,可以添加需要的库,比如可以参考video_loopback的deps,可以写出视频采集编码发送的实例。

(6)在src的build.gn中,添加video:test

deps += [
        ":rtc_unittests",
        ":video_engine_tests",
        ":webrtc_nonparallel_tests",
        ":webrtc_perf_tests",
        "common_audio:common_audio_unittests",
        "common_video:common_video_unittests",
        "media:rtc_media_unittests",
        "modules:modules_tests",
        "modules:modules_unittests",
        "modules/audio_coding:audio_coding_tests",
        "modules/audio_processing:audio_processing_tests",
        "modules/remote_bitrate_estimator:bwe_simulations_tests",
        "modules/rtp_rtcp:test_packet_masks_metrics",
        "modules/video_capture:video_capture_internal_impl",
        "ortc:ortc_unittests",
        "pc:peerconnection_unittests",
        "pc:rtc_pc_unittests",
        "rtc_base:rtc_base_tests_utils",
        "stats:rtc_stats_unittests",
        "system_wrappers:system_wrappers_unittests",
        "test",
        "video:screenshare_loopback",
        "video:sv_loopback",
        "video:video_loopback",
        "voice_engine:voice_engine_unittests",
        "video:test",
      ]

(7)继续编译

ninja -C out/linux/

(8)在out/linux下,查看结果:

test,可以运行。




你可能感兴趣的:(ubuntu,c++)