一、安装go
安装过程:
#下载安装包
wget https://golang.google.cn/dl/go1.15.1.linux-amd64.tar.gz
#执行解压
sudo tar -C /usr/local -xzf go1.15.1.linux-amd64.tar.gz
#添加到环境变量
export PATH=$PATH:/usr/local/go/bin
#测试是否成功
go version
二、安装依赖
#安装比较好安装的那些依赖
aptitude install libmicrohttpd-dev libjansson-dev \
libssl-dev libsrtp-dev libsofia-sip-ua-dev libglib2.0-dev \
libopus-dev libogg-dev libcurl4-openssl-dev liblua5.3-dev \
libconfig-dev pkg-config gengetopt libtool automake
安装libnice
安装这个东西,首先需要安装python3,meson和ninja,python正常情况应该都有了,所以需要安装meson
和ninja
meson的话,Linux自带版本较低,需要重新编译安装
sudo apt purge meson
#安装完成后的是0.55.1版
pip3 install meson
#安装后添加到环境变量
export PATH=~/.local/bin:$PATH
git clone https://gitlab.freedesktop.org/libnice/libnice
cd libnice
meson --prefix=/usr build && ninja -C build && sudo ninja -C build install
wget https://github.com/cisco/libsrtp/archive/v2.2.0.tar.gz
tar xfv v2.2.0.tar.gz
cd libsrtp-2.2.0
./configure --prefix=/usr --enable-openssl --libdir=/usr/lib64
make shared_library && sudo make install
安装usrsctp
git clone https://github.com/sctplab/usrsctp
cd usrsctp
./bootstrap
./configure --prefix=/usr --libdir=/usr/lib64 && make && sudo make install
安装libwebsockets
git clone https://libwebsockets.org/repo/libwebsockets
# 或 git clone https://github.com/warmcat/libwebsockets.git
cd libwebsockets
# If you want the stable version of libwebsockets, uncomment the next line
# git checkout v3.2-stable
mkdir build
cd build
# See https://github.com/meetecho/janus-gateway/issues/732 re: LWS_MAX_SMP
cmake -DLWS_MAX_SMP=1 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
make && sudo make install
安装paho.mqtt.c
git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
make && sudo make install
安装rabbitmq-c
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 ..
make && sudo make install
安装graphviz
aptitude install doxygen graphviz
三、安装janus
#更改/etc/ld.so.conf,添加下面一行
/usr/lib64/
#执行/sbin/ldconfig更新相关配置
sudo /sbin/ldconfig
git clone https://github.com/meetecho/janus-gateway.git
cd janus-gateway
sh autogen.sh
./configure --prefix=/opt/janus
make && sudo make install
sudo make config
# 运行
cd /opt/janus/bin
./janus
四、测试
测试的时候主要是进行了局域网测试,是没有问题的,后来下午把上述步骤整个又在我的华为云上执行了一番,安装到了我的华为云上,然后就出现了问题,具体原因似乎好像是由于NAT穿透失败,也就是内网<->公网的问题,有待解决,还一个问题就是https的问题,好在以前申请了一个证书,这会用上了,有关证书的配置,稍等再起一贴。
局域网测试步骤比较简单,在janus的源代码中有一个html文件夹,该文件夹中,主要包含了一些html文件和css文件和js文件,这里主要测试一下视频的问题,所以:
- 直接打开videoroomtest.html文件
- 然后点击start就可以跳转到昵称输入页面,输入昵称后
- 进入到视频房间,同时浏览器会提示是否允许运行摄像头和麦克风,选择允许就可以看到效果了
因为局域网测试主要是使用http,所以在打开上述网页之前,需要修改一下videoroomtest.js文件
var server = null;
if(window.location.protocol === 'http:')
server = "http://" + window.location.hostname + ":8088/janus";
else
server = "https://" + window.location.hostname + ":8089/janus";
//在第50行增加如下代码
//如果测试连接的电脑和janus不在一台电脑上,比如是树莓派,
//localhost也可以替换成安装janus的主机ip地址,这样的话就可以使用树莓派进行连接了
server = "http://localhost:8088/janus";
var janus = null;
var sfutest = null;
var opaqueId = "videoroomtest-"+Janus.randomString(12);