preface

With the impact of COVID-19, the demand for audio and video has exploded in the past two years. In the field of audio and video, WebRTC can be said to be a treasure house, including the whole process of audio and video collection, coding and decoding, transmission and rendering. This paper mainly records the whole process of compiling WebRTC on Windows platform.

Install VS.

Under Windows development and debugging program we are generally using the universe’s strongest IDE – Visual Studio, webRTC also support us to generate VS projects. The installation process of VS is not described here (VS2017 or VS2019 is recommended). Note that the following three items must be checked when installing VS:

  • Windows 10 SDK(10.0.18362) or above Windows 10 SDK(M84 version of WebRTC source code requires 10.0.18362 or above Windows 10 SDK).
  • Visual C++ ATL for x86 and x64.
  • Visual C++ MFC for x86 and x64.

Windows 10 SDK (10.0.18362) is not included in the VS2017 installation option. You can download from the Windows 10 SDK or install VS2019 directly.

After installing VS, you also need to install the SDK debugging tools. The method is:

  • Open control Panel -> Programs & Features, go to Windows Software Development Kit, right mouse button -> Changes.
  • On the screen that opens, select Change and click Next.
  • Select Debugging Tools For Windows and click Change.

Set the agent

For well-known reasons, a proxy tool is required to download the WebRTC source code.

The set http_proxy = 127.0.0.1:7777 set https_proxy = 127.0.0.1:7777Copy the code

Installation tool depot_tools

Git clone get depot_tools

Git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git # installation on Windows gclient compile toolsCopy the code

Configure the Path of the depot_tools directory to the system environment variable Path and set it to the first.

Download webrTC source code

mkdir webrtc-checkout
cd webrtc-checkout
fetch --nohooks webrtc
gclient sync
Copy the code

By default, the latest source code is downloaded. If you want to switch to the specified branch, you can use the following command:

Git checkout branch-heads/m79 gclient sync # Or forced to switch to specify a commit (b484ec0082948ae086c2ba4142b4d2bf8bc4dd4b is battered cia-issued m79 last the commit id) gclient sync - r b484ec0082948ae086c2ba4142b4d2bf8bc4dd4b --forceCopy the code

Information on all releases of WebrTC can be obtained here

compile

GYP_MSVS_VERSON=2017 set VS2019_install =C: Program Files (x86)\Microsoft Visual Studio\2017\Community GYP_MSVS_OVERRIDE_PATH=C: Program Files (x86)\Microsoft Visual Studio\2017\Community # GYP_MSVS_VERSON=2019 set vs2019_install=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community set GYP_MSVS_OVERRIDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community set GYP_GENERATORS=msvs-ninja,ninja Set DEPOT_TOOLS_WIN_TOOLCHAIN=0  gn gen out\Release-vs2017 --ide=vs2017 --args="is_debug=false target_os=\"win\" target_cpu=\"x64\" is_component_build=false is_clang=false use_lld=false treat_warnings_as_errors=false use_rtti=true Rtc_include_tests =false rtc_build_examples=false" Ninja -c out\Release -vs2019 #  gn gen out\Release-vs2019 --ide=vs2019 --args="is_debug=false target_os=\"win\" target_cpu=\"x64\" is_component_build=false is_clang=false use_lld=false treat_warnings_as_errors=false use_rtti=true rtc_include_tests=false rtc_build_examples=false" ninja -C out\Release-vs2019Copy the code

Ps:

  • Compile with PYTHon2!
  • Environment variables can also be set to system environment variables.

After a successful compilation, the all.sln solution file is generated under SRC \out\ XXXX \. Open to debug webrTC projects. Generate a static library — webrtc.lib in the SRC \out\ XXXX \obj directory. Reference the static library in other projects, including related header files, and use the functionality of WebrTC externally.

Windows extracts all header files from webrTC

Execute the following script in the SRC sibling directory of webrTC

echo off :: Set sourcePath=.src :: Set resulePath=.include xcopy %sourcePath% *. H %resulePath% /s /e /c /y /r pauseCopy the code

other

  • Error LNK2038: mismatch of “_ITERATOR_DEBUG_LEVEL” detected: value “0” does not match value “2” Solution: This error occurs only in the debug version. Add the compilation parameter enable_iterator_debugging=true in the debug compilation.

  • WebrTC

    • Is_component_build — Whether to use dynamic runtime libraries, set false to use static runtime libraries, the Release version will correspond to MT, the Debug version will correspond to MTd.
    • Proprietary_codecs — Whether the proprietary encoding is used, that is, H264.
    • Rtc_use_h264 — Whether to use H264. Note that Windows platform encoding uses OpenH264 and decoding uses FFMPEG.
    • Ffmpeg_branding – Ffmpeg branch name, using the Chrome branch.
    • Rtc_build_ssl — Whether BoringSSL is compiled.
    • Rtc_ssl_root — The OpenSSL header path, which will be written to the generated NINJA file.
    • Use_custom_libcxx — whether to use the built-in libcxx as the default c++ standard library.
    • Rtc_libvpx_build_vp9 — Whether vp9 codec is supported.
    • Symbol_level — Symbol level. Setting this to 0 reduces the library size.
  • Proprietary_codecs =true rtc_use_h264=true ffmpeg_branding=”Chrome” is_clang=true USe_lld =false The compilation option is required for compiling WEbrTC to add H264 support Treat_warnings_as_errors =false (ffmpeg has some problems using vc++, so clang must be mandatory).

  • Compiling webrTC using OpenSSL requires adding the compile option [rtc_build_ssl=false rtc_ssl_root=”C: Program Files\ openSSL-win64 \include”].