1. easyWebRTC
官网:http://easyrtc.com/ GitHub地址: https://github.com/priologic/easyrtc
2. 安装easyWebRTC
2.1 安装node.js和npm
官网:https://nodejs.org/en/
Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world.
备注:npm为Node.js的包管理器。
使用包管理器安装node.js文档见:https://nodejs.org/en/download/package-manager/
Centos7上具体指令:
- ”curl –silent –location https://rpm.nodesource.com/setup_5.x |bash -“ 或者
“curl –silent –location https://rpm.nodesource.com/setup |bash -” - yum install gcc-c++ make# or: yum groupinstall ‘Development Tools’
- yum -y install nodejs
yum install npm
2.2 安装EasyWebRTC
- 使用Git clone相关工程,git clone https://github.com/priologic/easyrtc #或者安装仅仅直接下载server_example代码
- 下载server_example样例 https://github.com/priologic/easyrtc/tree/master/server_example
-
npm install # 安装相关依赖包,运行的目录需要和server_example同级目录,而不是在 server_example 目录下
- ls -hl node_modules # npm install 下载相关的包,包括:async colors underscore
- [server_example]# node server.js # 在server_exmple 目录下运行:
info – EasyRTC: Starting EasyRTC Server (v1.0.15) on Node (v5.6.0)
debug – EasyRTC: Emitting event ‘startup’
debug – EasyRTC: Running func ‘onStartup’
debug – EasyRTC: Configuring Http server
debug – EasyRTC: Setting up demos to be accessed from ‘/demos/’
debug – EasyRTC: Setting up API files to be accessed from ‘/easyrtc/’
debug – EasyRTC: Configuring Socket server
debug – EasyRTC: Creating application: ‘default’
debug – EasyRTC: [default] Room [default] Running func ‘onRoomCreate’
debug – EasyRTC: Creating room: ‘default’ with options: {}
info – EasyRTC: EasyRTC Server Ready For Connections (v1.0.15)
Initiated
表明WebRTC服务器启动成功! - 测试,服务器默认启动端口为8080: http://ip:8080/demos/,选择测试的类型即可。
2.3 测试NAT穿越
穿越服务器采用开源服务器 coturn。进一步阅读:WebRTC Nat穿越开源服务器
coturn使用了libevent2,所以要先安装libevent。
$ yum install libevent-devel.x86_64 # 可以先使用 yum list libevent* 进行查找
2.3.1 RPM包安装
- rpm包 CentOS7.1 5.4.0.3 版本下载 rpm包 或者 wget http://turnserver.open-sys.org/downloads/v4.5.0.3/turnserver-4.5.0.3-CentOS7.1-x86_64.tar.gz
2.3.2 源代码安装
- 源码下载 wget http://turnserver.open-sys.org/downloads/v4.5.0.3/turnserver-4.5.0.3.tar.gz
- ./configure && make && make install # 默认安装在 /usr/local/bin目录中
- 修改配置文件,默认样本文件在 /usr/local/etc/turnserver.conf
listening-port=3478
listening-ip=114.215.172.10
relay-ip=114.215.172.10
relay-threads=1
min-port=65500
max-port=65535
verbose
fingerprint
lt-cred-mech
realm=pano
max-bps=100000
log-file=stdout
user=hello:hello - 测试:turnutils_stunclient -p 3478 114.215.172.10,结果如下:
0: IPv4. UDP reflexive addr: 114.215.172.10:53252
3. ios webrtc
- https://webrtc.org/native-code/ios/
- 第五章Webrtc的ios框架编译
- Bowser 可以从Appstore下载,支持webrtc的ios版本浏览器 Github地址: https://github.com/EricssonResearch/Bowser
4. android webrtc
4. 其他知识
WebRTC不同浏览器的实现有所不同,Google开源的adapter.js用于消除浏览器的区别。参见 https://webrtc.org/web-apis/interop/ 。WebRTC的规范也在演进中,例如获取getUserMedia 旧的方式为 navigator.getUserMedia() ,新的推荐使用方式为:https://developers.google.com/web/updates/2015/10/media-devices
[source lang=”javasctript”]
navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) {
var videoTracks = stream.getVideoTracks();
console.log(‘Got stream with constraints:’, constraints);
console.log(‘Using video device: ‘ + videoTracks[0].label);
stream.onended = function() {
console.log(‘Stream ended’);
};
window.stream = stream; // make variable available to console
video.srcObject = stream;
})
.catch(function(error) {
// …
}
[/source]
参考文档:* 为推荐阅读的级别
- Getting Started with WebRTC ***
- W3C getUserMedia标准
- Google Web Developer
- WebRTC Samples ***
- RTC.Blacker ****
- 常见的WebRTC样例 https://www.webrtc-experiment.com/
- Testing with Wireshark
- HTML5 WebSocket 中文
- easyrtc-server在ubuntu14.04上的安装方法
- 最简单的WebRTC示例 原文: WebRTC系列(1)-最简单的WebRTC示例
- webrtc学习: 部署stun和turn服务器
- 部署rfc5766-turn-server--谷歌推荐的开源穿透服务器
- Centos安装turn stun 服务器
- Linux服务器上监控网络带宽的18个常用命令
- Install & test coturn
- (译)WebRTC实战: STUN, TURN, Signaling ***
- Android IOS WebRTC 音视频开发总结(十三)– ice原理
- 第六章-WebRTC服务器搭建 *