libwebrtc: C++ Wrapper for WebRTC Desktop and Embedded Systems

Summary
libwebrtc is a C++ wrapper designed for WebRTC binary releases, primarily supporting Flutter-WebRTC desktop applications. It simplifies the integration of WebRTC functionalities across Windows, Linux, and various embedded systems, offering pre-compiled binaries and a clear compilation guide.
Repository Info
Introduction
libwebrtc is a robust C++ wrapper built to facilitate the use of WebRTC binary releases. With a focus on desktop and embedded environments, it serves as a crucial component for projects like flutter-webrtc, enabling WebRTC capabilities on Windows, Linux, and ARM-based embedded systems. This repository provides the necessary tools and instructions to compile and integrate WebRTC into your C++ applications, abstracting away much of the complexity of the underlying WebRTC library.
This project is written in C++, is licensed under MIT, and is actively maintained by the webrtc-sdk organization. It has garnered significant community interest, boasting over 610 stars and 119 forks.
Installation and Compilation Guide
Getting libwebrtc set up involves synchronizing the WebRTC source code and then compiling the wrapper. The following steps outline the process for both Windows and Linux environments.
1. Create Checkout Directory
mkdir libwebrtc_build
cd libwebrtc_build
2. Create .gclient Configuration
Configure gclient to fetch the correct WebRTC branch (m137_release).
solutions = [
{
"name" : 'src',
"url" : 'https://github.com/webrtc-sdk/webrtc.git@m137_release',
"deps_file" : 'DEPS',
"managed" : False,
"custom_deps" : {
},
"custom_vars": {},
},
]
target_os = ['win'] # Change to ['linux'] for Linux compilation
3. Synchronize Source Code
gclient sync
4. Clone libwebrtc and Apply Patch
Navigate into the src directory, clone libwebrtc, and apply the necessary audio source patch.
cd src
git clone https://github.com/webrtc-sdk/libwebrtc
git apply libwebrtc/patchs/custom_audio_source_m137.patch
5. Modify BUILD.gn
Add libwebrtc to the group("default") in src/BUILD.gn:
diff --git a/BUILD.gn b/BUILD.gn
index e60d7dd0bd..b9b6acab8b 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -29,7 +29,7 @@ if (!build_with_chromium) {
# 'ninja default' and then 'ninja all', the second build should do no work.
group("default") {
testonly = true
- deps = [ ":webrtc" ]
+ deps = [ ":webrtc","//libwebrtc", ]
if (rtc_build_examples) {
deps += [ "examples" ]
}
6. Compile for Windows
Requires Visual Studio Community 2022. Set up environment variables and generate GN files, then compile.
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_MSVS_VERSION=2022
set GYP_GENERATORS=ninja,msvs-ninja
set GYP_MSVS_OVERRIDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2022\Community
cd src
gn gen out-debug/Windows-x64 --args="target_os=\"win\" target_cpu=\"x64\" is_component_build=false is_clang=true is_debug=true rtc_use_h264=true ffmpeg_branding=\"Chrome\" rtc_include_tests=false rtc_build_examples=false libwebrtc_desktop_capture=true" --ide=vs2022
ninja -C out-debug/Windows-x64 libwebrtc
7. Compile for Linux
Ensure target_os = ['linux'] in your .gclient file and re-run gclient sync. Then, generate GN files and compile.
export ARCH=x64 # x86, x64, arm, arm64
cd src
gn gen out-debug/Linux-$ARCH --args="target_os=\"linux\" target_cpu=\"$ARCH\" is_debug=true rtc_include_tests=false rtc_use_h264=true ffmpeg_branding=\"Chrome\" is_component_build=false use_rtti=true use_custom_libcxx=false rtc_enable_protobuf=false"
ninja -C out-debug/Linux-x64 libwebrtc
Why Use libwebrtc?
libwebrtc offers several compelling advantages for developers working with WebRTC:
- Simplified Integration: It acts as a C++ wrapper, abstracting the complexities of the raw WebRTC library, making it easier to integrate into your projects.
- Cross-Platform Support: Provides binaries and compilation guides for major desktop operating systems, including Windows (x86, x64) and Linux (x86, x64, armv7, arm64), as well as embedded Linux.
- Flutter-WebRTC Compatibility: Specifically designed to support
flutter-webrtcdesktop versions, bridging the gap between Flutter applications and native WebRTC functionalities. - Optimized for Binary Releases: Focuses on providing a wrapper for binary releases, streamlining the deployment process for applications that need WebRTC capabilities.
Links
- GitHub Repository: https://github.com/webrtc-sdk/libwebrtc