webrtc linux 和 android 版本下载与编译

来源:互联网 发布:社交网络信息 综述 编辑:程序博客网 时间:2024/06/18 10:03

背景

我目前使用的是豆荚vpn代理才能访问webrtc开源项目,通过给开发环境配置代理可以顺利完成其源码的下载。

安装depot_tools

mkdir webrtccd webrtcgit clone https://chromium.googlesource.com/chromium/tools/depot_tools.gitexport PATH="$PATH:/home/suirui/webrtc/depot_tools"

下载源码

mkdir webrtc-checkoutcd webrtc-checkoutfetch --nohooks webrtcsolutions = [  {    "url": "https://chromium.googlesource.com/external/webrtc.git",    "managed": False,    "name": "src",    "deps_file": "DEPS",    "custom_deps": {},  },]target_os = ["android", "unix"]

这里需要加入 linux 和 android 的下载选项, target_os

同步代码

gclient sync

问题

  • 下载过程中遇到类似
 Failed to fetch file gs://chromium-binutils/5e71702981e5f3b45632f2f209eb3a85d65ca764 for /home/suirui/webrtc/webrtc-source/src/third_party/binutils/Linux_x64/binutils.tar.bz2, skipping. [Err: /home/suirui/webrtc/depot_tools/external_bin/gsutil/gsutil_4.26/gsutil/third_party/boto/boto/pyami/config.py:69: UserWarning: Unable to load AWS_CREDENTIAL_FILE ()
 Failed to fetch file gs://chromium-android-tools/play-services/10.2.0/31843001b7ce94fbdf71f2a9db76b28548a795fa for /tmp/tmpgymXSg/LICENSE, skipping. [Err: Failure: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed.]Traceback (most recent call last):  File "src/build/android/play_services/update.py", line 526, in <module>    sys.exit(main(sys.argv[1:]))  File "src/build/android/play_services/update.py", line 96, in main    return args.func(args)  File "src/build/android/play_services/update.py", line 191, in Download    config.version_number)):  File "src/build/android/play_services/update.py", line 381, in _CheckLicenseAgreement    with open(expected_license_path) as license_file:IOError: [Errno 2] No such file or directory: '/tmp/tmpgymXSg/LICENSE'Error: Command '/usr/bin/python src/build/android/play_services/update.py download' returned non-zero exit status 1

wget的方式

使用wget的方式获取wget --no-check-certificate https://storage.googleapis.com/chromium-webrtc-resources/a5e8c268936d7c8d03edd708c675254474aed944 -O /home/suirui/webrtc/webrtc-source/src/resources/audio_coding/F01_tlm10.OUT20

原因是由于使用vpn这种情况我们对gs://(Google云存储)的访问权限受限制
将”gs://”替换成”https://storage.googleapis.com/“,即通过HTTPS协议进行下载

这里可以参考参考”http://www.idom.me/articles/843.html“博客写的方法, 可以根据dep的内容进行下载, 里边也配有脚本

修改下载脚本

这里参考”https://segmentfault.com/a/1190000009443082”

所有的下载都会通过depot_tools下download_from_google_storage.py
在depot_tools文件夹下添加download_helper.py脚本

import urllib2import oshttpsPrefix = "https://storage.googleapis.com/"gsPrefix = "gs://"def download_gs_to_file(url, fileName):    download_http_to_file(url.replace(gsPrefix, httpsPrefix), fileName)def download_http_to_file(url, fileName):    path=os.path.dirname(fileName)    if not os.path.exists(path):        os.makedirs(path)    response = urllib2.urlopen(url)    CHUNK = 16 * 1024    with open(fileName, 'wb') as f:        while True:            chunk = response.read(CHUNK)            if not chunk:                break            f.write(chunk)    print ('download ......ok')if __name__ == "__main__":    print ('This is main of module "hello.py"')    download_gs_to_file('gs://chromium-android-tools/play-services/10.2.0/31843001b7ce94fbdf71f2a9db76b28548a795fa', '/tmp/tmpl1RB43/LICENSE')

这里通过urllib2来自动下载
然后将download_helper.py脚本添加到download_from_google_storage.py

diff --git a/download_from_google_storage.py b/download_from_google_storage.pyindex c9f5f67..177982d 100755--- a/download_from_google_storage.py+++ b/download_from_google_storage.py@@ -19,6 +19,7 @@ import threading import time import subprocess2+import download_helper GSUTIL_DEFAULT_PATH = os.path.join(@@ -239,20 +240,6 @@ def _downloader_worker_thread(thread_num, q, force, base_url,           continue     # Check if file exists.     file_url = '%s/%s' % (base_url, input_sha1_sum)-    (code, _, err) = gsutil.check_call('ls', file_url)-    if code != 0:-      if code == 404:-        out_q.put('%d> File %s for %s does not exist, skipping.' % (-            thread_num, file_url, output_filename))-        ret_codes.put((1, 'File %s for %s does not exist.' % (-            file_url, output_filename)))-      else:-        # Other error, probably auth related (bad ~/.boto, etc).-        out_q.put('%d> Failed to fetch file %s for %s, skipping. [Err: %s]' % (-            thread_num, file_url, output_filename, err))-        ret_codes.put((1, 'Failed to fetch file %s for %s. [Err: %s]' % (-            file_url, output_filename, err)))-      continue     # Fetch the file.     out_q.put('%d> Downloading %s...' % (thread_num, output_filename))     try:@@ -262,7 +249,7 @@ def _downloader_worker_thread(thread_num, q, force, base_url,       if os.path.exists(output_filename):         out_q.put('%d> Warning: deleting %s failed.' % (             thread_num, output_filename))-    code, _, err = gsutil.check_call('cp', file_url, output_filename)+    download_helper.download_gs_to_file(file_url, output_filename)     if code != 0:       out_q.put('%d> %s' % (thread_num, err))       ret_codes.put((code, err))

下载的过程中会出现下面错误:

Exception in thread Thread-1:Traceback (most recent call last):  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner    self.run()  File "/usr/lib/python2.7/threading.py", line 754, in run    self.__target(*self.__args, **self.__kwargs)  File "/home/suirui/webrtc/depot_tools/download_from_google_storage.py", line 253, in _downloader_worker_thread    if code != 0:UnboundLocalError: local variable 'code' referenced before assignment

这个跟 code的 定义有关, 还不知道代表什么意思, 我暂时忽略了

同步完成后, 删除修改在运行一遍

gclient  runhooks 

编译

编译生成ninja文件

gn gen --args='target_os="android" target_cpu="arm"' out/Android_Default    To build for ARM64: use target_cpu="arm64"    To build for 32-bit x86: use target_cpu="x86"    To build for 64-bit x64: use target_cpu="x64"#编译需要依赖的库sudo ./install-build-deps-android.sh #设置android 环境. build/android/envsetup.shninja -C out/Android_Default

linux 版本编译

不用指定target os 直接在ubuntu 上编译gn gen  out/Linux_Defaultninja -C out/Linux_Default

成果

linux 版本和windows版本可以互相连通, android版本目前还没有试

image

联系

qq:690759587 h264学习过程交流 191884149

原创粉丝点击