SimplewebRTC使用指南

本文档提供了SimpleWebRTC的详细使用指南,包括所需的NAT穿透服务器turnserver和信令服务器signalmaster的安装配置。同时介绍了如何配置SimpleWebRTC服务器,并概述了在不同网络环境下的工作流程。遵循指南,读者将能够成功部署并运行SimpleWebRTC应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SimplewebRTC使用指南

 

1.      软件:

NATs穿透服务器:turnserver   https://code.google.com/p/rfc5766-turn-server/

(也可以用restund代替turnserver  http://www.creytiv.com/restund.html)

信令服务器:nodejs:https://nodejs.org/

(也可以用socket.io代替nodejs)

signalmaster   https://github.com/andyet/signalmaster

SimpleWebRTC服务器: https://github.com/HenrikJoreteg/SimpleWebRTC

 

其他相应的软件及功能参考网址内描述

 

2.      功能安装与配置解释:

a) 安装最新版nodejs;利用nodejs npm程序安装相应的moudle扩展;

b) 安装turnserver服务;修改相应配置:

vim /etc/turnserver/turnserver.conf

配置端口:

19行处

listening-port = 3478

32行处

tls-listening-port=5349


配置监听ip(如果服务在nat后面此处配置内网地址)

listening-ip=192.168.88.120
 

配置外网到内网的转换地址:前面配置外网地址/后面配置内网地址端口映射需要相同比如3478外网的应该也是3478

external-ip=122.250.19.21/192.168.88.120

 

长认证模式:此模式配置后在配置文件中配置固定的用户名和密码即可不需要连接数据库

lt-cred-mech 

 

配置固定的用户名和密码用于信令服务器请求认证:

user=jeff:jeffabcdef

配置固定的认证域,此处必须配置否则stun认证报错:

realm=abc.org

其他配置默认即可!

no-stdout-log
log-file=/var/tmp/turn.log
syslog

c) 修改信令服务器配置signalmaster

vim /home/signalmaster-master/dev_config.json

端口默认8888,可以修改为别的端口,只需要跟simplewebrtc.bundle.js中配置相同即可,后面stun服务器和turn服务器配置为如上turnserver对应的地址和用户名密码即可;

修改server.js来调用此配置文件中相应的内容:

vim /home/signalmaster-master/server.js


 

d) 修改simplewebRTC配置:

vim ./js/simplewebrtc.bundle.js



其他simplewebRTC的修改需要根据需求来修改相应的html代码和js代码;

 

3.      整体流程:

配置完成并做完相应的端口映射后:

信令服务器路径:/home/signalmaster-master

启动信令服务:

nohup node /home/signalmaster-master/server.js(nohup作用为启动后退出终端仍然运行,自行百度脑补)

启动turn服务:

turnserver -c /etc/turnserver/turnserver.conf –daemon

上图为只有stun服务,当可以直接nat穿透时候的流程;

 

上图为当stun服务无法穿透的情况下 turn服务生效作为中间件来提供数据转换传输;

4.      参考网址:

http://simplewebrtc.com/

https://code.google.com/p/rfc5766-turn-server/

http://www.html5rocks.com/en/tutorials/webrtc/infrastructure/

https://github.com/HenrikJoreteg/SimpleWebRTC

http://blog.youkuaiyun.com/kl222/article/details/40154857

 

网页视频开发 webrtc ;(function () { var logger = { log: function (){}, warn: function (){}, error: function (){} }; // normalize environment var RTCPeerConnection = null, getUserMedia = null, attachMediaStream = null, reattachMediaStream = null, browser = null, webRTCSupport = true; if (navigator.mozGetUserMedia) { logger.log("This appears to be Firefox"); browser = "firefox"; // The RTCPeerConnection object. RTCPeerConnection = mozRTCPeerConnection; // The RTCSessionDescription object. RTCSessionDescription = mozRTCSessionDescription; // The RTCIceCandidate object. RTCIceCandidate = mozRTCIceCandidate; // Get UserMedia (only difference is the prefix). // Code from Adam Barth. getUserMedia = navigator.mozGetUserMedia.bind(navigator); // Attach a media stream to an element. attachMediaStream = function(element, stream) { element.mozSrcObject = stream; element.play(); }; reattachMediaStream = function(to, from) { to.mozSrcObject = from.mozSrcObject; to.play(); }; // Fake get{Video,Audio}Tracks MediaStream.prototype.getVideoTracks = function() { return []; }; MediaStream.prototype.getAudioTracks = function() { return []; }; } else if (navigator.webkitGetUserMedia) { browser = "chrome"; // The RTCPeerConnection object. RTCPeerConnection = webkitRTCPeerConnection; // Get UserMedia (only difference is the prefix). // Code from Adam Barth. getUserMedia = navigator.webkitGetUserMedia.bind(navigator); // Attach a media stream to an element. attachMediaStream = function(element, stream) { element.autoplay = true; element.src = webkitURL.createObjectURL(stream); }; reattachMediaStream = function(to, from) { to.src = from.src; }; // The representation of tracks in a stream is changed in M26. // Unify them for e
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值