根据WebRTC m94 android版本编译 mediasoup-client-android
编译webrtc
准备工作
-
编译环境 Ubuntu 18.04
-
webrtc 需求科学上网,署理一定要安稳!!! 署理一定要安稳!!! 署理一定要安稳!!!
-
装置 depot_tools(需求用到depot_tools工具来下载webrtc源码)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
- 把depot_tools添加到path中去
将depot_tools的途径追加到用户目录的.bashrc文件中 xxx换成你的用户名
export WEBRTC_DEPOT_TOOLS=/home/xxx/webRTC_Source/depot_tools
export PATH=$PATH:$WEBRTC_DEPOT_TOOLS
- 使变量生效, 指令行履行
source ~/.bashrc
下载源码
- 下载
参考官网 Development | WebRTC
mkdir webrtc_android
cd webrtc_android
fetch --nohooks webrtc_android
gclient sync
如果fetch –nohooks webrtc_android 履行失利 直接履行gclient sync即可
- 切换到安稳分支
我切换到m94分支
cd src
git checkout -b m94 branch-heads/4606
/*同步代码*/
cd ..
gclient sync --nohooks
gclient runhooks
如果有履行失利,gclient sync –nohooks、gclient runhooks 哪个失利,重新履行哪个
- 装置编译 WebRTC 所需的依靠
cd src
./build/install-build-deps.sh
./build/install-build-deps-android.sh
编译
编译aar
./tools_webrtc/android/build_aar.py
./tools_webrtc/android/build_aar.py -h : 检查有哪些编译参数
编译libwebrtc.a 和 libwebrtc.jar
- 默许不会编译 webrtc 模块,我们需求在/tools_webrtc/android/build_aar.py 文件中加入 ‘:webrtc’
TARGETS = [
':webrtc',
'sdk/android:libwebrtc',
'sdk/android:libjingle_peerconnection_so',
]
- 如果需求开启h264,需求添加licenses
修改 tools_webrtc/libs/generate_licenses.py 如下,添加 LICENSE
'openh264':['third_party/openh264/src/LICENSE'],
'ffmpeg':['third_party/ffmpeg/LICENSE.md'],
位置如下
'g722': ['modules/third_party/g722/LICENSE'],
'fft4g': ['common_audio/third_party/fft4g/LICENSE'],
'spl_sqrt_floor': ['common_audio/third_party/spl_sqrt_floor/LICENSE'],
+ 'openh264':['third_party/openh264/src/LICENSE'],
+ 'ffmpeg':['third_party/ffmpeg/LICENSE.md'],
# TODO(bugs.webrtc.org/1110): Remove this hack. This is not a lib.
- 编译指令
./tools_webrtc/android/build_aar.py --extra-gn-args 'is_debug=false is_component_build=false is_clang=true rtc_include_tests=false rtc_use_h264=true rtc_enable_protobuf=false use_rtti=true use_custom_libcxx=false' --build-dir ./out/release-build/m94/
- 可能会遇到的问题
ModuleNotFoundError: No module named 'dataclasses'
缺少python依靠
//python2
sudo apt install python-pip
pip install dataclasses
//python3
sudo apt install python3-pip
pip3 install dataclasses
- 输出途径
out/release-build/m94/armeabi-v7a/obj/libwebrtc.a
out/release-build/m94/armeabi-v7a/lib.java/sdk/android/libwebrtc.jar
至此WebRTC编译完结,复制出libwebrtc.a libwebrtc.jar 备用
编译mediasoup
下载
mediasoup-client-android m94 编译
下载地址
git clone https://github.com/haiyangwu/mediasoup-client-android.git
git checkout -b 340 3.4.0-beta
编译
将编译好的 各个abi的libwebrtc.a 和libwebrtc.jar 导入mediasoup-client-android的 mediasoup-client/deps/webrtc/lib 目录中替换
用Android Studio 翻开, 开端编译吧。。。
mediasoup 320版本编译
WebRTC m84编译
libmediasoupclient 对应的WebRTC版本是 branch-heads/4147
cd src
git checkout -b m84 branch-heads/4147
/*同步代码*/
cd ..
gclient sync --nohooks
gclient runhooks
编译和m94版本相似
libmediasoupclient编译
- 下载libmediasoupclient
- 切换分支 320
git clone https://github.com/versatica/libmediasoupclient
git checkout -b 320 3.2.0
mediasoup-client-android m84 编译
下载地址
git clone https://github.com/haiyangwu/mediasoup-client-android.git
git checkout -b 320 59315929fb2be499c474dd21a4e95b6b69116d80
- 将下载好的libmediasoupclient 320分支复制到mediasoup-client-android/mediasoup-client/deps目录下
- 删除SendTransport::ProduceData 相关的办法
- 将webrtc 84分支的头文件导入到mediasoup-client-android/mediasoup-client/deps/webrtc/src目录下
能够从webrtc源码中导出
cd ~/webrtc/android/src
mkdir -p ~/m84/include/third_party/
cp -r api/ ~/m84/include/
cp -r audio/ ~/m84/include/
cp -r base/ ~/m84/include/
cp -r build_overrides/ ~/m84/include/
cp -r call/ ~/m84/include/
cp -r common_audio/ ~/m84/include/
cp -r common_video/ ~/m84/include/
cp -r logging/ ~/m84/include/
cp -r media/ ~/m84/include/
cp -r modules/ ~/m84/include/
cp -r p2p/ ~/m84/include/
cp -r pc/ ~/m84/include/
cp -r rtc_base/ ~/m84/include/
cp -r rtc_tools/ ~/m84/include/
cp -r sdk/ ~/m84/include/
cp -r stats/ ~/m84/include/
cp -r style-guide/ ~/m84/include/
cp -r system_wrappers/ ~/m84/include/
cp -r test/ ~/m84/include/
cp -r third_party/abseil-cpp/ ~/m84/include/third_party/
cp -r tools_webrtc/ ~/m84/include/
cp -r video/ ~/m84/include/
cp .clang-format ~/m84/include/
cp .git-blame-ignore-revs ~/m84/include/
cp .gitignore ~/m84/include/
cp .vpython ~/m84/include/
cp abseil-in-webrtc.md ~/m84/include/
cp AUTHORS ~/m84/include/
cp BUILD.gn ~/m84/include/
cp codereview.settings ~/m84/include/
cp CODE_OF_CONDUCT.md ~/m84/include/
cp common_types.h ~/m84/include/
cp DEPS ~/m84/include/
cp ENG_REVIEW_OWNERS ~/m84/include/
cp LICENSE ~/m84/include/
cp license_template.txt ~/m84/include/
cp native-api.md ~/m84/include/
cp OWNERS ~/m84/include/
cp PATENTS ~/m84/include/
cp PRESUBMIT.py ~/m84/include/
cp presubmit_test.py ~/m84/include/
cp presubmit_test_mocks.py ~/m84/include/
cp pylintrc ~/m84/include/
cp README.chromium ~/m84/include/
cp README.md ~/m84/include/
cp style-guide.md ~/m84/include/
cp WATCHLISTS ~/m84/include/
cp webrtc.gni ~/m84/include/
cp whitespace.txt ~/m84/include/
用Android Studio 翻开, 开端编译吧。。。
参考文档
- Development | WebRTC
- mediasoup documentation_v3
- ubuntu 设置 vpn 客户端
- mediasoup-client-android
- webrtc-android-build