使用janus搭建webrtc视频会议服务器-基于centos7 和janus 最新0.10.10版本

最近在搞webrtc相关的东西,调研了几款webrtc服务器,在比较了各自的优缺点之后,选择了 janus,主要因为其基于c语言 ,插件化开发,适合功能扩展,部署也很方便。

由于webrtc服务器有很多,用哪个的都有,搞janus 的不太多,所以建了个janus群,欢迎大家进群交流讨论  709487187

本文所述的环境为 centos7  janus 版本为0.10.10

1.运行以下脚本,源码安装janus,注意,如果有的库版本过低会报错,需要重新安装高版本。此脚本是基于纯净的centos系统

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 
  yum provides '*/applydeltarpm' 
  yum install deltarpm -y 
  yum update -y 
  yum install wget git -y
  cd etc/yum.repos.d  
  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo  
  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo  
  yum clean all 
  yum makecache 
  yum list | grep epel-release.noarch 
  yum install epel-release.noarch  -y 
  wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo  
  yum clean all 
  yum makecache  
  yum install -y  jansson-devel libwebsockets-devel.x86_64 \
       openssl-devel libsrtp-devel sofia-sip-devel glib2-devel libsrtp-devel.x86_64 \
        opus-devel libogg-devel libcurl-devel pkgconfig gengetopt  \
       libconfig-devel libtool autoconf automake cmake make meson librabbitmq-devel.x86_64 \
       gnutls-devel.x86_64 texinfo gtk-doc.x86_64 
  yum install epel-release -y 
  yum update -y 
  yum install -y https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm 
  yum install -y ffmpeg-devel.x86_64
  yum clean all && rm -rf /var/cache/yum/*
  cd /usr/local/src
   wget https://github.com/cisco/libsrtp/archive/v2.0.0.tar.gz 
   tar xfv v2.0.0.tar.gz 
   cd libsrtp-2.0.0 
   ./configure --prefix=/usr --enable-openssl 
   make shared_library 
   make install 
   cd /usr/local/src 
   wget ftp://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.72.tar.gz 
   tar xfv libmicrohttpd-0.9.72.tar.gz 
   cd libmicrohttpd-0.9.72 
   ./configure 
   make 
   make install 
   cd /usr/local/src 
   git clone --branch 0.1.18  https://github.com/libnice/libnice.git
   cd libnice 
   meson --prefix=/usr build 
   ninja -C build   
   ninja -C build install 
   cd /usr/local/src 
   git clone --branch 0.9.5.0 https://github.com/sctplab/usrsctp 
   cd usrsctp 
   ./bootstrap 
   ./configure --prefix=/usr 
   make 
   make install 
   ldconfig 
  cd /usr/local/src 
  git clone --branch v0.10.10 https://github.com/meetecho/janus-gateway.git 
   cd janus-gateway 
    ./autogen.sh 
    export  PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH 
  ./configure --prefix=/usr/local/janus    --enable-post-processing   --enable-rest  --enable-websockets   
   make  
   make install  
   make configs 
   make clean

2.安装nginx,并修改nginx配置文件,配置好demos位置以及证书和key的路径,通过域名访问需要支持https,否则会有chrome无法调用摄像头的问题。如果没有证书使用ip地址测试也是可以的

   server{
   listen 80;
   listen 8080;
   listen *:443 ssl;
   server_name localhost;
   location / {
    root /usr/local/demos;
    index index.html index.htm index.php;
   }

   location /jauns {
   proxy_set_header Host $host:$server_port;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_pass http://192.168.0.170:8088/janus;    #janus服务器ip地址
}

  ssl_certificate /usr/local/certs/cert.pem;
  ssl_certificate_key /usr/local/certs/cert.key;

然后重启nginx

用 浏览器打开demo文件,效果如下图,其中localvideo,video1为当前机器打开的两个页面,video2为手机

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值