内容简介:房间测试地址:https://webrtc.xxx.com/videoroomtest.html 比较简单这里就不贴图了,最后祝福大家新年快乐janus 的demo 对浏览器兼容不是很好本文主要参考:https://github.com/meetecho/janus-gateway
一、基础资源
- 操作系统:centos 7.3
- 服务器IP:内网(192.168.10.17),外网(124.160.xxx.xxx)
- 域名:webrtc.xxx.com (带https证书)
- 防火墙开放端口:tcp/udp 3478 3480-3500 7000-9000 443
- 内网域名绑定:/etc/hosts => 192.168.10.17 webrtc.xxx.com (由于本机内部访问外网IP不通)
二、域名证书
- mkdir /cert
- 将域名证书放在/cert目录下,分别命名为cert.pem,key.pem
- 如果是domain.crt,domain.key 可以根据以下命令生成pem证书
- openssl rsa -in server.key -text > key.pem
- openssl x509 -inform PEM -in server.crt > cert.pem
三、依赖包安装
- yum -y install epel-release nginx
- yum -y install libmicrohttpd-devel jansson-devel openssl-devel libsrtp-devel sofia-sip-devel glib2-devel opus-devel libogg-devel libcurl-devel pkgconfig gengetopt libconfig-devel libtool autoconf automake
- yum -y install libnice libnice-devel
- yum -y install libwebsockets libwebsockets-devel
- yum -y install doxygen graphviz
- yum -y install cmake
wget https://github.com/cisco/libsrtp/archive/v1.5.4.tar.gz ./configure --prefix=/usr --enable-openssl --libdir=/usr/lib64 make shared_library && sudo make install
git clone https://github.com/sctplab/usrsctp ./bootstrap ./configure --prefix=/usr --libdir=/usr/lib64 && make && sudo make install
git clone https://github.com/alanxz/rabbitmq-c cd rabbitmq-c git submodule init git submodule update mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib64 .. make && sudo make install
git clone https://github.com/meetecho/janus-gateway.git cd janus-gateway sh autogen.sh ./configure --prefix=/opt/janus --enable-websockets make make install make configs
STUN\TURN服务器 cd /root/webrtc wget http://coturn.net/turnserver/v4.5.0.7/turnserver-4.5.0.7.tar.gz tar xvfz turnserver-4.5.0.7.tar.gz cd /root/webrtc/turnserver-4.5.0.7 ./configure make install vim /usr/local/etc/turnserver.conf
relay-device=bond0 listening-ip=192.168.10.17 #内网IP listening-port=3478 tls-listening-port=5349 relay-ip=192.168.10.17 external-ip=124.160.xxx.xxx #外网IP relay-threads=50 lt-cred-mech cert=/cert/cert.pem pkey=/cert/key.pem user=xie:123456 min-port=3480 max-port=3500 realm=webrtc.xxx.com
nginx 配置 vim /etc/nginx/conf.d/janus.conf server { listen 443 ssl; server_name webrt.xxx.com; ssl_certificate /etc/nginx/ssl/xxx.com.crt; ssl_certificate_key /etc/nginx/ssl/xxx.com.key; charset utf-8; root /opt/janus/share/janus/demos; index index.php index.html index.htm; access_log /var/log/nginx/access.log main; location / { } }
四、Janus环境配置(变动部分)
vim /opt/janus/etc/janus/janus.jcfg certificates: cert_pem = "/cert/cert.pem" cert_key = "/cert/key.pem" nat: turn_server = "webrtc.xxx.com" #turn_server = "192.168.10.17" turn_port = 3478 turn_type = "udp" turn_user = "xie" turn_pwd = "123456" ice_enforce_list = "bond0"
vim /opt/janus/etc/janus/janus.transport.http.jcfg general: https = true admin: admin_https = true certificates: cert_pem = "/cert/cert.pem" cert_key = "/cert/key.pem"
vim /opt/janus/etc/janus/janus.transport.websockets.jcfg general: wss = true admin: admin_wss = true certificates: cert_pem = "/cert/cert.pem" cert_key = "/cert/key.pem"
五、启动相关软件
a.启动STUN\TURN服务器
- /usr/local/bin/turnserver -c /usr/local/etc/turnserver.conf -o
- 非常重要,telnet 内网/外网/域名 IP 3478 端口 都要通才行
- iCE测试地址:https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
b.启动janus-gateway server
- /opt/janus/bin/janus -b
c.启动nginx
- systemctl restart nginx
六、两个pc之间测试
房间测试地址:https://webrtc.xxx.com/videoroomtest.html 比较简单这里就不贴图了,最后祝福大家新年快乐
janus 的demo 对浏览器兼容不是很好
本文主要参考:https://github.com/meetecho/janus-gateway
以上所述就是小编给大家介绍的《Webrtc服务器搭建多对多(Janus WebRTC Server) SFU模式》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 搭建Redis主从+哨兵模式
- RabbitMQ默认集群模式搭建配置实现步骤
- TypeScript重写设计模式库的搭建
- redis的主从模式搭建及注意事项
- 低代码搭建平台码良更新,正式支持 pc 模式
- 深入剖析Redis系列(三) - Redis集群模式搭建与原理详解
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。