windows 10 webrtc 下载与编译以及遇到的问题

下载:

1、由于webrtc 源码在 墙外,所以需要科学上网(自行解决)。当然现在webrtc 有国内的镜像地址:https://webrtc.org.cn/mirror 内附编译下载教程自行查阅(下载后只包含M79 和最新的master 分支),由于个人项目需要M72 版本,所以需要科学上网。

 

2、需要在windows 上安装git(version 2.23.0.windows.1),然后配置环境变量,后续需要在 “命令提示符” 中使用

 

3、下载depot_tools

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

下载depot-tools之后解压,把解压目录设置到环境变量里面 (PATH)

 

环境变量中添加下面两项

DEPOT_TOOLS_WIN_TOOL_WIN_TOOLCHAIN = 0

 

4、下载WebRTC源码

创建文件夹

$mkdir webrtc_wins

$cd webrtc_src

 

获取源码

$fetch --nohooks webrtc

$gclient sync

 

将分支定位到m72

$cd src

$git checkout -b m72 refs/remotes/branch-heads/72

$gclient sync

 

 

 

编译

1、编译前需要配置一下环境

Visual Studio Community 2017 version 15.9.15

需要安装的单个组件如下图:

 

打开cmd设置临时环境变量

$set GYP_MSVS_OVERRIDE_PATH=D:\Program Files (x86)\Microsoft Visual Studio\2017\Community

$set DEPOT_TOOLS_WIN_TOOLCHAIN=0

$set GYP_GENERATORS=msvs-ninja,ninja

$set GYP_MSVS_VERSON=2017

$set DEPOT_TOOLS_UPDATE=0

 

然后执行:

$cd src

$gn gen out/Default --ide=vs2017

$ninja -C out/Default

 

编译支持h264:

$gn gen out/Debug_h264 --args="is_component_build=false rtc_use_h264=true proprietary_codecs=true ffmpeg_branding=\"Chrome\"" --ide=vs2017

$ninja -C out/Debug_h264

 

遇到的问题:

问题:gclient sync 或者 fetch --nohooks webrtcmingl卡住 或443 timeout,应该是代理网络没有设置好

如果没有对版本的特殊要求建议采用webrtc 国内镜像

解决:执行 set http_proxy=http://127.0.0.1:1080

set https_proxy=https://127.0.0.1:1080

然后通过 curl 测试相关地址的网络

 

问题:Failed download_from_google_storage --no_resume --platform=win32 --no_auth

--bucket chromium-gn -s src/buildtools/linux32/gn.sha1

NOTICE: You have PROXY values set in your environment, but gsutil in

depot_tools does not (yet) obey them.

Also, --no_auth prevents the normal BOTO_CONFIG environment variable from

being used.

To use a proxy in this situation, please supply those settings in a .boto

file pointed to by the NO_AUTH_BOTO_CONFIG environment var.

解决:随便找个地方生成一个文本文件,比如 D:\boto.cfg

在该文件中输入下面的内容(假设代理服务器是 http://http.proxy.com:1080):

[Boto]

proxy= http://http.proxy.com

proxy_port = 1080

 

然后设置环境变量

set NO_AUTH_BOTO_CONFIG=D:\boto.cfg

再执行 gclient sync

 

问题:“UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position 7: ordi” 这个问题是因为同时安装了python2和python3导致的

解决:执行 python -m pip install --upgrade pip

 

问题:Python中使用Win32api报错的问题,No module named win32file

解决:pip install pypiwin32或pip3 install pypiwin32 或 python -m pip install pypiwin32

 

问题:webrtc编译debug库调用链接出现 error LNK2038: 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“0”不匹配值“2”(main.obj 中) 错误

解决:在编译时添加 enable_iterator_debugging = true

 

相关参数解析:

is_debug 是否是Debug版,默认true,false:表示编译Release版。

target_os 平台类型,可以取值win、android、ios、linux等,这里取win,表示Windows平台。

target_cpu cpu类型,Windows下可以取x86、x64

is_component_build 是否使用动态运行期库,这里取false,使用静态运行期库,Release版本将对应MT,Debug版将对应MTd。

proprietary_codecs 是否使用版权编码,也就是H264,这里取true。

rtc_use_h264 是否使用H264,这里取true,注意Windows平台编码使用OpenH264,解码使用ffmpeg。

ffmpeg_branding ffmpeg的分支名,这里采用Chrome的分支。

is_clang 是否采用clang编译器编译,默认设置为true

所有编译参数描述请直接查阅源码中src 目录下 的webrtc.gni 文件

欢迎关注、点赞、收藏、留言,一起讨论学习,共同成长。