第
2
页 共
1
16
页
目录
1
工具
...............................................................................................................................................4
1.1 depot_tools..................................................................................................................... 4
1.1.1 目标.......................................................................................................................... 4
1.1.2 Chromium................................................................................................................. 4
1.1.3 使用说明在这儿...................................................................................................... 4
1.1.4
下载
.......................................................................................................................... 4
1.1.5
使用
.......................................................................................................................... 4
1.1.6 具体使用例子:.........................................................................................................5
1.2 Gyp
工具
.........................................................................................................................5
1.3 Python 工具....................................................................................................................5
1.4 本地集成开发环境(IDE)..........................................................................................5
1.4.1 Visual studio............................................................................................................. 5
1.4.2 Kdevelop.................................................................................................................11
1.4.3 Eclipse.................................................................................................................... 12
2 Webrtc........................................................................................................................................ 12
2.1
下载、编译
...................................................................................................................12
2.1.1 Windows 下............................................................................................................ 12
2.1.2 ubuntu 下编译........................................................................................................ 16
2.1.3
编译
Android(
只能在
linux
下
).............................................................................19
3 webrtc
开发
................................................................................................................................ 19
3.1 开发 P2P 视频软件需要处理的问题.......................................................................... 19
3.1.1
用户列的获取、交换、信令的交换
.................................................................... 19
3.1.2 P2P 通信.................................................................................................................19
3.1.3 多媒体处理............................................................................................................ 20
3.2 webrtc 架构:.............................................................................................................. 20
3.2.1 WebRTC
架构组件介绍
........................................................................................ 20
3.2.2 WebRTC 核心模块 API 介绍................................................................................ 22
3.2.3 webRTC 核心 API 详解.........................................................................................27
4 Libjingle
详细介绍
.....................................................................................................................35
4.1 重要组件....................................................................................................................... 35
4.1.1
信号
........................................................................................................................ 35
4.1.2
线程和消息
............................................................................................................ 35
4.1.3 名称转换................................................................................................................ 35
4.1.4 Ssl 支持.................................................................................................................. 35
4.1.5
连接
........................................................................................................................ 35
4.1.6
传输,通道,连接
................................................................................................ 36
4.1.7 候选项.................................................................................................................... 36
4.1.8
数据包
.................................................................................................................... 36
4.2 如何工作....................................................................................................................... 36
4.2.1 Application 模块.................................................................................................... 37
4.2.2 XMPP Messaging Component 模块...................................................................... 37
4.2.3 Session Logic and management commponent
模块
...............................................38
4.2.4 Peer to peer Component 模块................................................................................ 38
第
3
页 共
1
16
页
4.2.5
其他
........................................................................................................................ 39
4.3 建立 l
ibjingle 应用程序............................................................................................... 39
5 代码分析..................................................................................................................................... 39
5.1
音频通道建立过程
.......................................................................................................39
5.2
音频接收播放过程
.......................................................................................................40
5.3 视频接收播放过程.......................................................................................................43
6
协议
:............................................................................................................................................45
6.1 XMPP 协议...................................................................................................................45
6.1.1 原理介绍................................................................................................................ 45
6.1.2 XMPP 协议网络架构............................................................................................ 46
6.1.3 XMPP
协议的组成
................................................................................................ 48
6.1.4 Xmpp 介绍............................................................................................................. 49
6.1.5 协议内容................................................................................................................ 49
6.2 Stun
协议
...................................................................................................................... 52
6.2.1 P2P 实现的原理.....................................................................................................53
6.2.2 P2P
的常用实现
.....................................................................................................55
6.2.3 Stun URI.................................................................................................................58
6.2.4 内容........................................................................................................................ 58
6.2.5 中文内容................................................................................................................ 59
6.2.6 开源服务器............................................................................................................ 61
6.2.7
公开的免费
STUN
服务器
................................................................................... 61
6.3 Turn 协议......................................................................................................................62
6.3.1 概念........................................................................................................................ 62
6.3.2 Turn uri...................................................................................................................63
6.3.3
开源服务器工程
.................................................................................................... 63
6.3.4 开源库.................................................................................................................... 63
6.4 交互式连接建立(Interactive Connectivity Establishment).................................... 63
6.4.1 IETF 规格...............................................................................................................68
6.4.2
开源工程:
............................................................................................................ 69
6.5 XEP-0166 Jingle.......................................................................................................... 70
6.5.1 绪论........................................................................................................................ 71
6.5.2
需求
........................................................................................................................ 72
6.6 Sctp
协议
.......................................................................................................................95
6.7 Rtp 协议........................................................................................................................98
7
附件
...........................................................................................................................................100
7.1 Gyp 工具.....................................................................................................................100
7.2 Google test 程序......................................................................................................... 102
7.3 Webrtc 库介绍........................................................................................................... 103
7.4 webrtc
代码相关基础知识
........................................................................................ 104
7.5 STUN 和 TURN 技术浅析........................................................................................ 106
7.6 基于 ICE 的 VoIP 穿越 NAT 改进方案................................................................... 107
7.7 ubuntu
安装使用
stuntman.......................................................................................112
7.8 一个开源的 ICE 库——libnice 介绍........................................................................112
7.9 4 种利用 TURN 穿越对称型 NAT 方案的设计与实现...........................................114
7.10 基于 ICE 方式 SIP 信令穿透 Symmetric_NAT 技术研究..................................... 115
第
4
页 共
1
16
页
1 工
具:
1
.1 depot_tools:
chromium 自己整了一套开发工具系统,原来叫 gclient(名字好像让位给 google 桌面客户端了) ,现
在改名 depot_tools。
1.1.1 目标:
Wrapper script for checking out and updating source code from multiple SCM repository
locations.
chromium 使用了(目前 @159834)107 个代码仓库的代码,这些分散在多个代码仓库,chromiun 不需要
某些仓库的东西,google 就封装个工具,这个工具既支持 svn,也支持 git,不光能 down 代码,也支持
了
p
atch
c
pplint,pylint
a
pply_issue
j
unction
c
odereview
1.1.2 chromium 使用它来
更新 chromium 代码
生成工程文件,windows 上生产 sln,mac 生产 xcode 工程,linux 生成 scons 或者 makefile
其
他的 patch,codereview,管理分散开发人员的修改
1
.1.3 使用说明在这儿
h
ttp://www.chromium.org/developers/how-tos/depottools
1.1.4 下载:
1.1.4.1 linux 下:
s
udo apt-get install git
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
1
.1.4.2 window 下:
已装 cygwin:
g
it clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
无 cygwin:
https://src.chromium.org/svn/trunk/tools/depot_tools.zip
1.1.5 使用:
1
.1.5.1 用 gclient 获取代码
首先会更新 depot_tools,有两种 bat 和 sh,目的都一样
更
新 depot_tools,然后运行 python 版 gclient.py,参数都传给 gclient.py
这里解决了鸡生蛋还是蛋生鸡的问题,更新了 gclient.py
生
成.gclient 文件,gclient 指定了某个版本的 chromium·代码
执
行 gclient sync,更新代码,生成工程文件,这里使用了另一个工具 GYP
1.1.5.2 gclient 命令:
Commands are:
cleanup Cleans up all working copies.
config Create a .gclient file in the current directory.
diff Displays local diff for every dependencies.
fetch Fetches upstream commits for all modules.
help Prints list of commands or help for a specific command.
hookinfo Output the hooks that would be run by `gclient runhooks`
pack Generate a patch which can be applied at the root of the tree.
第
5
页 共
1
16
页
r
ecurse Operates on all the entries.
revert Revert all modifications in every dependencies.
revinfo Output revision info mapping for the client and its dependencies.
runhooks Runs hooks for files that have been modified in the local working copy.
status Show modification status for every dependencies.
sync Checkout/update all modules.
update Alias for the sync command. Deprecated.
Prints list of commands or help for a specific command.
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-j JOBS, --jobs=JOBS Specify how many SCM commands can run in parallel;
default=8
-v, --verbose Produces additional output for diagnostics. Can be
used up to three times for more logging info.
--gclientfile=CONFIG_FILENAME
Specify an alternate .gclient file
--spec=SPEC create a gclient file containing the provided string.
Due to Cygwin/Python brokenness, it probably can't
contain any newlines.
1.1.6 具体使用例子:
1
.1.6.1 安装工具
h
ttp://www.chromium.org/developers/how-tos/install-depot-tools
1
.1.6.2 .配置
主要是写
.gclient 和 DEPS python 语法(精确点就是 json 语法+“#”型注释,list 最末元素可以有,执行时使用
python 的 eval 来解释的)
.gclient
1
.2 Gyp 工具
G
yp 工具简介见附件。Google 自己搞的玩意。Webrtc 不是直接用的 gyp,而是又封装了一下。
Webrtc 中的 gyp 工具是 build/ gyp_chromium
1
.3 Python 工具
整
个 webrtc 工程是由 python 程序进行维护。而整个 webrtc 工程现在处理一个完全不稳定的阶段。所以需
要了解一些基本的 python 语法知识。
1
.4 本地集成开发环境(IDE)
工欲善其事,必先利其器。所以下面介绍下本地集成开发环境。
1
.4.1 Visual studio
一般的在 windows 本地开发环境(IDE)是 visual studio。然而 webrtc 默认的是 ninja。
虽然可以手工生成 vs 工程,但是经常出现兼容性问题。所以下面介绍下 vs 加 ninja 开发环境。
Webrtc
默认生成的工程位于源码根目录下的
out
目录中。
打开 vs2012: