放牧代码和思想
专注自然语言处理、机器学习算法
    This thing called love. Know I would've. Thrown it all away. Wouldn't hesitate.

纯脚本编译WebRTC For Android

目录

在WebRTC的范例工程中,有一个Android项目叫AppRTCDemo,可以实现广域网上的视频通话(VoIP)。这篇文章旨在演示AppRTCDemo的编译,平台以Windows为例,但同样适用于Mac和Linux。

切换到Linux环境

请明确你当前使用的是什么平台,如果是Linux,那么可以忽略这一步;否则,你需要一台虚拟机。我正在使用该死的Windows,我比较推荐vagran t,这是一款适合程序员使用的轻量级虚拟机,可以提供原汁原味的Linux控制台体验。

检出编译脚本

有一个开源项目叫webrtc-build-scripts,是一系列方便的编译脚本。检出后在webrtc-build-scripts\android可以看到核心脚本build.sh。

编译

顺序执行以下命令

# Boot up and provision the vagran t box ,Linux用户请忽略
vagran t up

# SSH into the vagran t box,Linux用户请忽略
vagran t ssh

# Source all the routines
source android/build.sh

# Install any dependencies needed
install_dependencies

# Setup jdk
install_jdk1_6

# Pull WebRTC
get_webrtc

# Build apprtc
build_apprtc

install_dependencies会触发依赖项下载,get_webrtc会触发webrtc下载,最好打开VPN并保持网络通畅。

如果出现

No command 'gclient' found, did you mean:
 Command 'jclient' from package 'julius' (multiverse)
gclient: command not found

请执行

pull_depot_tools

如果出现

__ running '/usr/bin/python trunk/build/gyp_chromium --depth=trunk trunk/all.gyp -Dextra_gyp_flag=0' in '/home/sojharo/Data/server' Updating projects from gyp files... Traceback (most recent call last): File "", line 1, in AssertionError: Point $JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h! gyp: Call to 'python -c "import os; dir=os.getenv('JAVA_HOME', '/usr/lib/jvm/java-6-sun'); assert os.path.exists(os.path.join(dir, 'include/jni.h')), 'Point \$JAVA_HOME or the java_home gyp variable to a directory containing include/jni.h!'; print dir"' returned exit status 1. while trying to load trunk/all.gyp Error: Command /usr/bin/python trunk/build/gyp_chromium --depth=trunk trunk/all.gyp -Dextra_gyp_flag=0 returned non-zero exit status 1 in /home/sojharo/Data/server

请重新执行

install_jdk1_6

编译结果

输出文件位于~/webrtc/src/talk/examples/android:

如果你是在虚拟机中,可以通过执行

cp -pr ~/webrtc/src/talk/examples/android /vagran t

将编译结果复制到宿主机里。

接下来在webrtc-build-scripts\android\android\bin中找到AppRTCDemo-debug.apk,可以跟 https://apprtc.appspot.com/ 一起测试。

在webrtc-build-scripts\android\android\libs中可以找到libjingle_peerconnection.jar和libjingle_peerconnection_so.so用于二次开发。

知识共享许可协议 知识共享署名-非商业性使用-相同方式共享码农场 » 纯脚本编译WebRTC For Android

评论 1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

我的作品

HanLP自然语言处理包《自然语言处理入门》