Janus is an open source webRTC, providing many utilities for Chat, Videos / Audio call, Recorder or streamming. It is really a useful library for those who want to develop applications based on webRtc or websocket. In this article I would like to guide the steps to install janus on ubuntu / centos as well as macos. For more useful features of this library, you can refer to it here:
Install the necessary lib
In centos
Run the following command to install:
1 2 3 4 5 | yum <span class="token function">install</span> libmicrohttpd-devel jansson-devel libnice-devel openssl-devel libsrtp-devel sofia-sip-devel glib-devel opus-devel libogg-devel libcurl-devel lua-devel pkgconfig gengetopt libtool autoconf automake |
Sometimes we need to install epel-release
by command yum install epel-release
In ubuntu
1 2 3 4 5 | <span class="token function">aptitude</span> <span class="token function">install</span> libmicrohttpd-dev libjansson-dev libnice-dev libssl-dev libsrtp-dev libsofia-sip-ua-dev libglib2.0-dev libopus-dev libogg-dev libcurl4-openssl-dev liblua5.3-dev pkg-config gengetopt libtool automake |
In macos
1 2 3 4 | brew <span class="token function">install</span> jansson libnice openssl srtp libusrsctp libmicrohttpd libwebsockets cmake rabbitmq-c sofia-sip opus libogg <span class="token function">curl</span> glib pkg-config gengetopt autoconf automake libtool |
Install lib for websocket
Libsrtp
1 2 3 4 5 6 | <span class="token function">wget</span> https://github.com/cisco/libsrtp/archive/v2.1.0.tar.gz <span class="token function">tar</span> xfv v2.1.0.tar.gz <span class="token function">cd</span> libsrtp-2.1.0 ./configure --prefix <span class="token operator">=</span> /usr --enable-openssl <span class="token function">make</span> shared_library <span class="token operator">&&</span> <span class="token function">sudo</span> <span class="token function">make</span> <span class="token function">install</span> |
Libwebsockets
1 2 3 4 5 6 7 8 | <span class="token function">git</span> clone git://git.libwebsockets.org/libwebsockets <span class="token function">cd</span> libwebsockets <span class="token function">git</span> checkout v2.4-stable <span class="token function">mkdir</span> build <span class="token function">cd</span> build cmake -DLWS_MAX_SMP <span class="token operator">=</span> 1 -DCMAKE_INSTALL_PREFIX:PATH <span class="token operator">=</span> /usr -DCMAKE_C_FLAGS <span class="token operator">=</span> <span class="token string">"-fpic"</span> <span class="token punctuation">..</span> <span class="token function">make</span> <span class="token operator">&&</span> <span class="token function">sudo</span> <span class="token function">make</span> <span class="token function">install</span> |
Coming here is considered to be the necessary libraries, now you need to download janus to install on your computer
Install Janus
In linux (ubuntu and centos)
Run the following commands:
1 2 3 4 5 6 7 | <span class="token function">git</span> clone https://github.com/meetecho/janus-gateway.git <span class="token function">cd</span> janus-gateway sh autogen.sh ./configure --prefix <span class="token operator">=</span> /opt/janus <span class="token function">make</span> <span class="token function">make</span> <span class="token function">install</span> |
Generate config:
1 2 | <span class="token function">make</span> configs |
In Macos
Run the following commands:
1 2 3 4 5 6 7 | <span class="token function">git</span> clone https://github.com/meetecho/janus-gateway.git <span class="token function">cd</span> janus-gateway sh autogen.sh ./configure --prefix <span class="token operator">=</span> /usr/local/janus PKG_CONFIG_PATH <span class="token operator">=</span> /usr/local/opt/openssl/lib/pkgconfig <span class="token function">make</span> <span class="token function">make</span> <span class="token function">install</span> |
Generate config:
1 2 | <span class="token function">make</span> configs |
Note:
prefix
is where janus will be installed, you are free to change the installation location as you like
After installation is complete, you need to change a little config file to be able to call videos:
Change in /opt/janus/etc/janus/janus.cfg
file as follows:
1 2 3 4 5 6 7 8 | stun_server = stun1.l.google.com stun_port = 19302 turn_server = 13.250.13.83 turn_port = 3478 turn_type = udp turn_user = YzYNCouZM1mhqhmseWk6 turn_pwd = YzYNCouZM1mhqhmseWk6 |
This stun
information is from google, you can easily find it online or you can install your own server for security.
Run Janus server
Enter cd
into the installed janus directory (linux / centos at /opt/janus
and macos at /usr/local/janus
) and run the following command:
For dev environment:
1 2 | /bin/janus |
Each production field:
1 2 3 | <span class="token function">export</span> LD_LIBRARY_PATH <span class="token operator">=</span> /usr/lib64 <span class="token punctuation">;</span> /opt/janus/bin/janus -d 5 -6 <span class="token operator">></span> 2 <span class="token operator">></span> <span class="token operator">&</span> 1 <span class="token operator">&</span> |
/tmp/janus.log
is a/tmp/janus.log
file, janus will save all logs here
Besides janus there are many other configurations, you can go to github to see more configuration.
janus requires nginx
rtmp
module to be able to run livestream as well as other features, the next part i will guide you to install nginx with rtmp module
Install Nginx with rtmp module
This section must be built separately, not just install a command is done as usual nginx.
Install libs
1 2 | <span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> build-essential libpcre3 libpcre3-dev libssl-dev |
Install ngixn and hls
1 2 3 4 5 6 7 8 9 | <span class="token function">wget</span> http://nginx.org/download/nginx-1.15.1.tar.gz <span class="token function">wget</span> https://github.com/arut/nginx-rtmp-module/archive/master.zip <span class="token function">tar</span> -zxvf nginx-1.15.1.tar.gz unzip master.zip <span class="token function">cd</span> nginx-1.15.1 ./configure --with-http_ssl_module --add-module <span class="token operator">=</span> <span class="token punctuation">..</span> /nginx-rtmp-module-master <span class="token function">make</span> <span class="token function">sudo</span> <span class="token function">make</span> <span class="token function">install</span> |
Install the Nginx init scripts.
This section allows you to use the command like service nginx start ...
as usual:
1 2 3 4 | <span class="token function">sudo</span> <span class="token function">wget</span> https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx <span class="token function">sudo</span> <span class="token function">chmod</span> +x /etc/init.d/nginx <span class="token function">sudo</span> update-rc.d nginx defaults |
Refer
And other sources on the internet