本文只表述本人所采用的方法,并且编译成功m75版本(转载请在行首注明原创链接)
前提:阿里云上购买香港ecs,按量_4核4g_winserver_2019,按量_弹性公网_国际版_250M(服务器安装东西免流量费)
主步骤:
1、下载chrome
2、下载同步deptool,设置环境变量
3、下载webrtc
4、下载vs2017
5、下载win debuger
6、同步webrtc
7、变更ecs为12核12G,弹性公网改为国内版(下载编译好的库很快)
8、编译webrtc
9、变更ecs为1核2G
10、打包lib、exe,并下载回自己本机
步骤明细:
下载webrtc
gclient
mkdir webrtc-checkout
cd webrtc-checkout
fetch --nohooks webrtc
同步webrtc
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
gclient sync
编译webrtc:
cd src
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
git checkout -b my_m75 refs/remotes/branch-heads/m75
git checkout my_m75
gclient sync
x86
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
gn gen out/x86 --args="is_debug=false rtc_include_tests=false target_cpu=\"x86\" is_clang=false"
ninja -C out/x86 >tmp_log 2>err_log
x64
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
gn gen out/x64 --args=" is_debug=false rtc_include_tests=false target_cpu=\"x64\" is_clang=false"
ninja -C out/x64 >tmp_log 2>err_log
附打包脚本:webrtc_copy.bat
if exist reports_lib (
rd /s /q reports_lib
md reports_lib
) else (
md reports_lib
)
for /f "delims=" %%i in ('dir /b /a-d /s "*.lib"') do (
echo %%i
xcopy %%i reports_lib /-y
)
if exist reports_exe (
rd /s /q reports_exe
md reports_exe
) else (
md reports_exe
)
for /f "delims=" %%i in ('dir /b /a-d /s "*.exe"') do (
echo %%i
xcopy %%i reports_exe /-y
)
遇到的问题(PC端采集视频 -> 微信端播放视频):
1、可以使用代理下载?不建议用代理,直接用香港的服务器。用代理成功率低,下载12G的东西,中断一下就报错。
2、能否编译dynamic_crt或者设置is_component_build?不能。官方不支持该类型,如果修改BUILD.gn会报错,侥幸不报错,也不排除有其它问题。
3、win10上使用32位webrtc库,全出现未知异常,建议使用64位库。
4、webrtc支持哪些平台?测试可用版本:android8.10、ios12.2、weixin7.03,其中ios在移动4g不支持ipv6(需要用turn),android端微信从wifi切换移动4g没清candidate缓存导致stun失败。
5、webrtc没声音?注意关闭echo_cancellation选项,因为消除回音默认要开启播放器。
6、webrtc生成编译gn gen out/步骤报错?注意,deptool的版本要保持和webrtc版本差不多时间。
7、编译一次耗时多久(本人熟悉阿里云)?最快下载20分钟,编译5分钟,打包传回5分钟
8、阿里云费用多少?5元内。ecs按量是按秒算(停机不收费),服务器安装这些不需要流量费,传回本地大概200M流量 。
9、编译参数说明:is_debug=false 编译release版本; rtc_include_tests=false不编译单元测试程序省时间; target_cpu=\"x64\" 编译64位程序;is_clang=false 不使用clang编译而用vs2017
参考资料:
https://webrtc.org/native-code/development/
本公司网址:https://www.hatlead.com/