libmediasoupclient 是一个基于 libwebrtc 的 C++ 库,用于构建基于 mediasoup 的 C++ 客户端应用程序。
mediasoup broadcaster demo则是基于libmediasoupclient的应用程序,可在mediasoup-demo应用程序中为指定房间生成人造声音和视频。视频由一些向图像右下角移动的彩色矩形组成。
1、下载depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
2、设置环境变量
export PATH=$PATH:/home/user/depot_tools
3、下载webrtc
mkdir webrtc
cd webrtc
fetch --nohooks webrtc
gclient sync
cd src
git checkout -b m94 refs/remotes/branch-heads/4606
gclient sync
4、设置编译参数
gn gen out/m94 --args='is_debug=false is_component_build=false is_clang=false rtc_include_tests=false rtc_use_h264=true use_rtti=true use_custom_libcxx=false treat_warnings_as_errors=false use_ozone=true ffmpeg_branding="Chrome" proprietary_codecs=true use_glib=false rtc_use_dummy_audio_file_devices=true rtc_build_examples=false use_partition_alloc=false rtc_enable_protobuf=false rtc_build_json=true'
5、编译
# 清理原编译文件
gn clean out/m94
# 编译
ninja -C out/m94
6、检出webrtc头文件
mkdir /home/user/libwebrtc
find webrtc -name "*.h" | xargs -I {} cp --parents {} /home/user/libwebrtc
7、拷贝webrtc头文件和库文件到系统目录
mkdir /usr/local/include/webrtc
cp -r /home/user/libwebrtc/webrtc/src/* /usr/local/include/webrtc/
cp /home/user/webrtc/src/out/m94/obj/libwebrtc.a /usr/local/lib
1、下载
git clone https://github.com/versatica/libmediasoupclient.git
2、编译
cd libmediasoupclient
cmake . -Bbuild \
-DLIBWEBRTC_INCLUDE_PATH:PATH=/usr/local/include/webrtc \
-DLIBWEBRTC_BINARY_PATH:PATH=/usr/local/lib
make -C build/
3、安装
# 头文件:/usr/local/include/mediasoupclient/mediasoupclient.hpp
# 库文件:/usr/local/lib/libmediasoupclient.a
make install -C build/
1、安装openssl和pkg-config
apt install libssl-dev pkg-config
2、安装cpr
参考:GitHub - libcpr/cpr: C++ Requests: Curl for People, a spiritual port of Python Requests.
3、下载及编译mediasoup-broadcaster-demo
git clone https://github.com/versatica/mediasoup-broadcaster-demo.git
cmake . -Bbuild \
-DLIBWEBRTC_INCLUDE_PATH:PATH=/usr/local/include/webrtc \
-DLIBWEBRTC_BINARY_PATH:PATH=/usr/local/lib \
-DOPENSSL_INCLUDE_DIR:PATH=/usr/include/openssl \
-DCMAKE_USE_OPENSSL=ON
make -C build
4、运行demo
cd build
# 指定mediasoup服务器的地址
export SERVER_URL=https://192.168.0.127:4443
# 指定房间号
export ROOM_ID=llo3ybo1
# 局域网中需要禁用ssl,公网不用
export VERIFY_SSL=false
# 运行
./broadcaster
GitHub - versatica/mediasoup-broadcaster-demo: mediasoup broadcaster demo (libmediasoupclient)mediasoup broadcaster demo (libmediasoupclient). Contribute to versatica/mediasoup-broadcaster-demo development by creating an account on GitHub.https://github.com/versatica/mediasoup-broadcaster-demo/mediasoup :: Installationhttps://mediasoup.org/documentation/v3/libmediasoupclient/installation/