Janus WebRTC Server

Janus WebRTC 服务器。(Janus WebRTC Server.)

Github星跟蹤圖

Janus WebRTC 服务器

Janus是一个开源的,通用的,由 Meetecho 设计和开发的 WebRTC 服务器。此版本的服务器是为 Linux 系统量身定制的,尽管它也可以在 MacOS 机器上编译和安装。 Windows 不受支持,但如果需要的话,Janus 会在 Windows 10 的 “Windows Subsystem for Linux” 中工作。

对于一些在线演示和文件,请确保您访问了项目网站

如果你有关于 Janus 的问题,或者希望与我们和其他用户讨论 Janus,请加入我们的 meetecho-janus 。如果遇到 bug,请在 github 上提交问题。不过,在打开问题之前请务必要阅读指引

依赖关系

要安装它,您需要满足以下依赖项:

  • Jansson
  • libnice
  • OpenSSL (至少 v1.0.1e)
  • libsrtp (建议至少 v1.5)
  • usrsctp (仅当您对数据通道感兴趣时才需要)
  • libmicrohttpd (至少 v0.9.59; 仅在您对 Janus API 的 REST 支持感兴趣时才需要)
  • libwebsockets (仅在您对 Janus API 的 WebSockets 支持感兴趣时才需要)
  • cmake (仅在您对 WebSockets 和/或 BoringSSL 支持感兴趣时才需要,因为它们正在使用它)
  • rabbitmq-c (仅当您对 Janus API 或事件的 RabbitMQ 支持感兴趣时才需要)
  • paho.mqtt.c (仅在您对 Janus API 或事件的 MQTT 支持感兴趣时才需要)
  • libcurl (仅在您对Janus API的Nanomsg支持感兴趣时才需要)
  • libcurl (仅当您对 TURN REST API 支持感兴趣时才需要)

有几个插件依赖于更多的库:

  • Sofia-SIP (仅 SIP 插件需要)
  • libopus (仅 AudioBridge 插件需要)
  • libogg (VoiceMail插件和/或后处理器,以及可选的 AudioBridge 和 Streaming 插件所需)
  • libcurl (仅当您对 Streaming 插件或示例事件处理程序插件中的 RTSP 支持感兴趣时才需要)
  • Lua (仅 Lua 插件需要)

另外,您需要以下库和工具:

所有这些库通常都可以在大多数最常见的发行版上使用。例如,在最近的 Fedora 上安装这些库非常简单:

yum 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

请注意,如果您尝试在 CentOS 机器上进行安装,则可能还必须安装 epel-release。

在 Ubuntu 或 Debian 上,需要这样做:

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
  • 注意:请注意,libopus 在您的发行版中可能无法开箱即用。在这种情况下,您将不得不手动安装它。

虽然 libnice 通常在大多数发行版中都是作为软件包提供的,但已知 Ubuntu 中的现成可用版本会引起问题。 因此,我们始终建议手动编译和安装 libnice 的主版本。 要构建 libnice,您需要 Python 3、Meson 和 Ninja:

git clone https://gitlab.freedesktop.org/libnice/libnice
cd libnice
meson --prefix=/usr build && ninja -C build && sudo ninja -C build install
  • 注意:确保首先删除发行版,否则会导致安装之间的冲突。 如果出于某种原因想要保留两者,则对于 libnice 的自定义安装,还可以运行 pkg-config --cflags --libs nice,以确保 Janus 可以找到正确的安装。 如果失败,则可能需要在编译 Janus 之前设置 PKG_CONFIG_PATH 环境变量,例如,export PKG_CONFIG_PATH=/path/to/libnice/lib/pkgconfig

如果您对编译示例事件处理程序插件感兴趣,则还需要安装 libcurl 的开发版本(通常在 Fedora/CentOS 上为 libcurl-devel,在 Ubuntu/Debian 上为 libcurl4-openssl-dev)。

如果您的发行版提供了 libsrtp 的 1.5 之前的版本,则必须卸载该版本并手动安装 1.5.x、1.6.x 或 2.x。 实际上,已知 1.4.x 会导致 WebRTC 出现多个问题。 1.5.4 版的安装非常简单:

wget https://github.com/cisco/libsrtp/archive/v1.5.4.tar.gz
tar xfv v1.5.4.tar.gz
cd libsrtp-1.5.4
./configure --prefix=/usr --enable-openssl
make shared_library && sudo make install

2.x 版的说明实际上是一样的。 请注意,下面的步骤是针对 2.2.0 版本的,但是可能还有更近期的版本可用:

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
make shared_library && sudo make install

注意 --enable-openssl 部分很重要,因为它需要 AES-GCM 支持。或者,您也可以传递 --enable-nss 来使 libsrtp 使用 NSS 而不是 OpenSSL。在启动 Janus 时,如果无法使用任何一个配置 libsrtp,可能会导致未定义的引用,因为我们将尝试使用不存在的方法。

Janus 配置脚本会自动检测您已安装的脚本,并自动链接到正确的库,如果两个都安装,则选择 2.x。如果要选择 1.5 或 1.6(不建议使用),则在配置 Janus 时强制使用 --disable-libsrtp2 强制其使用旧版本。

  • 注意:在安装 libsrtp 时,无论是哪个版本,如果要在 x86_64 发行版上进行安装,都可能需要将 --libdir=/usr/lib64 传递给 configure 脚本。

如果要使用 BoringSSL 而不是 OpenSSL(例如,因为要利用 --enable-dtls-settimeout),则必须手动将其安装到特定位置。使用以下步骤:

git clone https://boringssl.googlesource.com/boringssl
cd boringssl
# Don't barf on errors
sed -i s/" -Werror"//g CMakeLists.txt
# Build
mkdir -p build
cd build
cmake -DCMAKE_CXX_FLAGS="-lrt" ..
make
cd ..
# Install
sudo mkdir -p /opt/boringssl
sudo cp -R include /opt/boringssl/
sudo mkdir -p /opt/boringssl/lib
sudo cp build/ssl/libssl.a /opt/boringssl/lib/
sudo cp build/crypto/libcrypto.a /opt/boringssl/lib/
  • 注意:在安装libsrtp时,无论使用哪个版本,都可能需要通过 - libdir =/usr/lib64 如果您在x86_64发行版上进行安装,则需要配置脚本。

如果您想使用BoringSSL而不是OpenSSL(例如,因为 你想要利用 --enable-dtls-settimeout ),你会拥有 手动将其安装到特定位置。使用以下步骤:

git clone https://boringssl.googlesource.com/boringssl
cd boringssl
# Don't barf on errors
sed -i s/" -Werror"//g CMakeLists.txt
# Build
mkdir -p build
cd build
cmake -DCMAKE_CXX_FLAGS="-lrt" ..
make
cd ..
# Install
sudo mkdir -p /opt/boringssl
sudo cp -R include /opt/boringssl/
sudo mkdir -p /opt/boringssl/lib
sudo cp build/ssl/libssl.a /opt/boringssl/lib/
sudo cp build/crypto/libcrypto.a /opt/boringssl/lib/

安装库之后,您必须将附加的 --enable-boringssl 标志传递给 configure 脚本,因为默认情况下将假设使用 OpenSSL 来构建 Janus。 默认情况下,Janus 希望将 BoringSSL 安装在 /opt/boringssl 中 -- 如果安装在其他位置,则将路径传递到配置脚本,如下所示:--enable-boringssl=/path/to/boringssl 如果您使用的是 OpenSSL 并想切换到 BoringSSL,请确保在使用新的 BoringSSL 支持进行编译之前,还要在 Janus 文件夹中进行清理。 如果启用了 BoringSSL 支持,并且还希望 Janus 通过更快的重新传输来检测 DTLS 超时并对之作出反应,则也将 --enable-dtls-settimeout 传递给 configure 脚本。

关于数据通道支持所需的 usrsctp,它通常在存储库中不可用,因此如果您对它们感兴趣(支持是可选的),就必须手动安装它。这是一个非常简单和标准的过程:

git clone https://github.com/sctplab/usrsctp
cd usrsctp
./bootstrap
./configure --prefix=/usr && make && sudo make install
  • 注意:如果要在 x86_64 发行版上安装,则可能需要将 --libdir=/usr/lib64 传递给 configure 脚本。。

这同样适用于libwebsockets,这是可选的需要 WebSockets支持。如果你有兴趣支持WebSockets 控制Janus,作为替代(或替代)默认的平原 HTTP REST API,您必须手动安装它 这同样适用于 libwebsockets,这是可选的 WebSockets 支持所需要的。如果你对支持 WebSockets 来控制 Janus 感兴趣,作为默认的普通 HTTP REST API 的备选(或替代),你将不得不手动安装它:

git clone https://libwebsockets.org/repo/libwebsockets
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
  • 注意:如果由于任何原因无法访问 libwebsockets.org,则将第一行替换为以下内容:
    git clone https://github.com/warmcat/libwebsockets.git
        

Eclipse Paho MQTT C 客户端库也是如此,这是可选 MQTT 支持所必需的。 如果您希望将 MQTT 通道集成为 HTTP 和/或 WebSockets 的备选(或替代)以控制 Janus,或作为 Janus Events 的载体,则可以通过以下步骤安装最新版本:

git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
make && sudo make install
  • 注意:您可能想为库设置一个不同的安装路径,要实现这一点,请将最后一条命令替换为'sudo prefix=usr make install'。

如果您对 Nanomsg 支持感兴趣,则需要安装相关的 C 库。在几乎所有的存储库中,它通常都是一个容易安装的包。下面是一个如何在 Ubuntu 上安装它的例子:

aptitude install libnanomsg-dev

最后,rabbitmq-c 也是如此,这是可选的 RabbitMQ 支持所需要的。实际上,可以找到该库的几个不同版本,而且通常在大多数发行存储库中可用的版本都不是根据开发的当前状态进行更新的。因此,如果您对集成 RabbitMQ 队列作为 HTTP 和或 WebSockets 的备选(或替代)来控制 Janus 感兴趣,您可以通过以下步骤安装最新版本:

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
  • 注意:如果要在 x86_64 发行版上进行安装,则可能需要将 --libdir=/usr/lib64 传递给 configure 脚本。

最后,如果您也对构建 Janus 文档感兴趣,那么还需要一些额外的工具 :

在 Fedora 上:

yum install doxygen graphviz

在 Ubuntu/Debian 上:

aptitude install doxygen graphviz

编译

安装了所有依赖项后,获取代码:

git clone https://github.com/meetecho/janus-gateway.git
cd janus-gateway

然后,请使用:

sh autogen.sh

生成配置文件。 之后,像往常一样配置和编译以启动整个编译过程:

./configure --prefix=/opt/janus
make
make install

由于 Janus 需要核心及其模块的配置文件才能工作,因此您可能还需要安装要使用的默认配置文件,您可以通过这种方式进行安装:

make configs

请记住,只需执行一次,否则后续的make configs将覆盖您在此期间可能已修改的任何配置文件。

如果您已经安装了上述库,但是对数据通道,WebSocket,MQTT和/或RabbitMQ不感兴趣,则可以在配置时禁用它们:

./configure --disable-websockets --disable-data-channels --disable-rabbitmq --disable-mqtt

几乎所有外部模块和许多功能都有配置标志,因此您可能需要发出 ./configure --help 来挖掘可用的选项。 在进行配置后,将始终会显示要构建的内容的摘要,从而使您可以再次检查是否需要和不需要的内容。

如果可以使用 Doxygen 和 graphviz,则该过程还可以为您构建文档。 默认情况下,编译过程不会尝试构建文档,因此,如果您更喜欢构建文档,请使用 --enable-docs 配置选项:

./configure --enable-docs

您还可以有选择地启用/禁用其他功能(例如,您不关心的特定插件,或者是否要在后处理器中构建录音)。 配置更多信息时,请使用 --help 选项。。

在 MacOS 上构建

尽管上述大多数说明在 MacOS上 编译 Janus 时也可以使用,但在进行此操作时需要强调一些方面。

首先,您可以使用brew安装大多数依赖项:

brew install jansson libnice openssl srtp libusrsctp libmicrohttpd \
    libwebsockets cmake rabbitmq-c sofia-sip opus libogg curl glib \
    libconfig pkg-config gengetopt autoconf automake libtool

但是,对于 libwebsockets 而言,请确保安装的版本高于 2.4.1,否则您可能会遇到本文所述的问题。 如果 brew 不提供更新的版本,则必须手动安装该库。

请注意,在配置 Janus 时可能还需要提供自定义前缀和 PKG_CONFIG_PATH,例如:

./configure --prefix=/usr/local/janus PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig

其他所有工作方式与在 Linux 上完全相同。

配置并启动

要启动服务器,可以使用 janus 可执行文件。您可以在配置文件中配置一些东西:

<installdir>/etc/janus/janus.cfg

或在命令行上:

<installdir>/bin/janus --help
janus 0.3.0
用法:janus [选项] ...
-h,--help    打印帮助并退出
-V,--version    打印版本并退出
-b,--daemon    在后台启动Janus作为守护进程
                (default=off)
-p, --pid-file=path    启动 Janus 时打开指定的 PID 文件
            (default=none)
-N,--disable-stdout    禁用基于标准输出的日志记录(default=off)
-L,--log-file=path    记录到指定文件(仅 default=stdout)
-H  --cwd-path        Janus 守护进程的工作目录(default=/)
-i,--interface=ipaddress    使用的接口(将是公共 IP)
-P,--plugins-folder=path    插件文件夹(default=./plugins)
-C,--config=filename    要使用的配置文件
-F,--configs-folder=path    配置文件文件夹(default=./conf)
-c,--cert-pem=filename DTLS 证书
-k,--cert-key=filename DTLS 证书密钥
-K, --cert-pwd=text    DTLS证书密钥密码短语(如果需要)
-S,--stun-server=filename    如果需要,使用STUN服务器(:port)(例如,
Janus 在 NAT 的后面,default=none)
-1,--nat-1-1=ip    公开 IP 放入所有候选主机,
            假设有1:1的 NAT(例如亚马逊 EC2 实例,default=none)
-E,--ice-enforce-list=list    逗号分隔的仅用于 ICE 收集的接口列表; 支持部分字符串(例如eth0或eno1,wlan0,default=none)
-X,--ice-ignore-list=list    逗号分隔的 ICE 收集所忽略的接口或 IP 地址列表;支持部分字符串(例如 vmnet8,192.168.0.1,10.0.0.1 或 vmnet,192.168.,default=vmnet)
-6,--ipv6-candidates    是否启用 IPv6 候选项(实验)(default=off)
-l,--libnice-debug    是否启用 libnice 调试(default=off)
-I,--ice-lite        是否启用 ICE Lite 模式(default=off)
-T,--ice-tcp        是否启用ICE-TCP(警告:仅适用于 ICE Lite)
                (default=off)
-q,--max-nack-queue=number    无论 RTT,每个用户的 NACK 队列的最小大小
                (以毫秒为单位)
-t,--no-media-timer=number    Janus 通知您有关此消息的时间(以秒为单位),该时间应该没有媒体(音频或视频)被接收
-W, --slowlink-threshold=number    应该向用户触发“slowlink” Janus API 事件的丢失数据包(每秒)数                              
-r,--rtp-port-range=min-max    用于 RTP/RTCP 的端口范围(仅当已安装的 libnice 支持时才可用)
-d,--debug-level=1-7    调试/日志级别(0=禁用调试,7=最大调试级别;默认=4)
-D,--debug-timestamps    启用调试/日志记录时间戳(default=off)
-o,--disable-colors    禁用日志中的颜色(default=off)
-a,--apisecret=randomstring API 密钥需要通过的所有请求才能被 Janus 接受(在将 Janus API 请求包装在服务器中时很有用,默认情况下无用)
-A,--token-auth    为所有人启用基于令牌的身份验证请求(default=off)
-e,--event-handlers    启用事件处理程序(default=off)

(更多命令选项请参考自述文件)

通过命令行传递的选项优先于配置文件中指定的选项。 要启动服务器,只需运行:

<installdir>/bin/janus

这将启动服务器,并使其查看配置文件。

确保您已查看所有配置文件,以使 Janus 满足您的特定需求:每个配置文件均已记录在案,因此根据您的要求进行更改不难。该回购协议带有一些默认设置(假设您在安装服务器后进行配置),这对于常规部署来说很有意义,并且还包括一些用于所有插件的示例配置(例如,要监听的 Web 服务器,要创建的会议室,流挂载点以在启动时可用等)。

要测试它是否正常运行,您可以在 html 文件夹中使用此包随附的演示:这些与项目网站上在线提供的演示完全相同。只需将其包含在网络服务器中的文件复制,或使用用户空间网络服务器将html文件夹中的文件提供服务(例如,使用 php 或 python),然后在 Chrome 或 Firefox 中打开 index.html 页面。将提供利用不同插件的演示页面列表。如果您更改了任何与传输相关的配置,请记住在演示 JavaScript 文件中编辑传输/端口的详细信息。此外,这些演示还引用了预先配置的插件资源,因此,如果您添加一些新资源(例如,新的视频会议),则可能需要调整演示页面才能实际使用它们。

请务必查看所有配置文件, 以根据您的特定需求定制 janus:每个配置文件都有文档记录, 因此根据您的要求进行更改应该不会很困难。存储库附带了一些默认值 (假设您在安装服务器后出现了配置问题), 这些默认值对于通用部署来说往往是有意义的, 还包括了所有插件的一些示例配置 (例如, 要侦听的 web 服务器、会议室创建、流式安装点, 以便在启动时提供等)。

文档

有完整的文档记录。您可以在项目网站上找到用 Doxygen 自动生成的当前文档。

帮助我们!

欢迎任何想法、反馈!

@meetecho 开发

(The second edition revised by vz on 2020.07.22)

主要指標

概覽
名稱與所有者meetecho/janus-gateway
主編程語言C
編程語言C (語言數: 11)
平台Linux, Mac
許可證GNU General Public License v3.0
所有者活动
創建於2014-02-11 15:14:39
推送於2024-10-24 14:39:55
最后一次提交2024-10-24 14:08:19
發布數89
最新版本名稱v1.2.4 (發布於 2024-09-10 15:07:57)
第一版名稱v0.0.9 (發布於 2015-11-11 11:06:06)
用户参与
星數8.2k
關注者數379
派生數2.5k
提交數5.7k
已啟用問題?
問題數1919
打開的問題數12
拉請求數1214
打開的拉請求數16
關閉的拉請求數308
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

Janus WebRTC Server

Janus is an open source, general purpose, WebRTC server designed and developed by Meetecho. This version of the server is tailored for Linux systems, although it can be compiled for, and installed on, MacOS machines as well. Windows is not supported, but if that's a requirement, Janus is known to work in the "Windows Subsystem for Linux" on Windows 10.

For some online demos and documentations, make sure you pay the project website a visit!

To discuss Janus with us and other users, there's a Google Group called meetecho-janus that you can use. If you encounter bugs, though, please submit an issue on github instead.

Dependencies

To install it, you'll need to satisfy the following dependencies:

  • Jansson
  • libconfig
  • libnice (at least v0.1.15 suggested, master recommended)
  • OpenSSL (at least v1.0.1e)
  • libsrtp (at least v1.5 suggested)
  • usrsctp (only needed if you are interested in Data Channels)
  • libmicrohttpd (only needed if you are interested in REST support for the Janus API)
  • libwebsockets (only needed if you are interested in WebSockets support for the Janus API)
  • cmake (only needed if you are interested in WebSockets and/or BoringSSL support, as they make use of it)
  • rabbitmq-c (only needed if you are interested in RabbitMQ support for the Janus API or events)
  • paho.mqtt.c (only needed if you are interested in MQTT support for the Janus API or events)
  • nanomsg (only needed if you are interested in Nanomsg support for the Janus API)
  • libcurl (only needed if you are interested in the TURN REST API support)

A couple of plugins depend on a few more libraries:

  • Sofia-SIP (only needed for the SIP plugin)
  • libopus (only needed for the bridge plugin)
  • libogg (needed for the voicemail plugin and/or post-processor)
  • libcurl (only needed if you are interested in RTSP support in the Streaming plugin or in the sample Event Handler plugin)
  • Lua (only needed for the Lua plugin)

Additionally, you'll need the following libraries and tools:

All of those libraries are usually available on most of the most common distributions. Installing these libraries on a recent Fedora, for instance, is very simple:

yum 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

Notice that you may have to yum install epel-release as well if you're attempting an installation on a CentOS machine instead.

On Ubuntu or Debian, it would require something like this:

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
  • Note: please notice that libopus may not be available out of the box on Ubuntu or Debian, unless you're using a recent version (e.g., Ubuntu 14.04 LTS). In that case, you'll have to install it manually.

While libnice is typically available in most distros as a package, the version available out of the box in Ubuntu is known to cause problems. As such, we always recommend manually compiling and installing the master version of libnice. Installation of libnice master is quite straightforward:

git clone https://gitlab.freedesktop.org/libnice/libnice
cd libnice
./autogen.sh
./configure --prefix=/usr
make && sudo make install
  • Note: Make sure you remove the distro version first, or you'll cause conflicts between the installations. In case you want to keep both for some reason, for custom installations of libnice you can also run pkg-config --cflags --libs nice to make sure Janus can find the right installation. If that fails, you may need to set the PKG_CONFIG_PATH environment variable prior to compiling Janus, e.g., export PKG_CONFIG_PATH=/path/to/libnice/lib/pkgconfig

In case you're interested in compiling the sample Event Handler plugin, you'll need to install the development version of libcurl as well (usually libcurl-devel on Fedora/CentOS, libcurl4-openssl-dev on Ubuntu/Debian).

If your distro ships a pre-1.5 version of libsrtp, you'll have to uninstall that version and install 1.5.x, 1.6.x or 2.x manually. In fact, 1.4.x is known to cause several issues with WebRTC. Installation of version 1.5.4 is quite straightforward:

wget https://github.com/cisco/libsrtp/archive/v1.5.4.tar.gz
tar xfv v1.5.4.tar.gz
cd libsrtp-1.5.4
./configure --prefix=/usr --enable-openssl
make shared_library && sudo make install

The instructions for version 2.x are practically the same. Notice that the following steps are for version 2.2.0, but there may be more recent versions available:

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
make shared_library && sudo make install

The Janus configure script autodetects which one you have installed and links to the correct library automatically, choosing 2.x if both are installed. If you want 1.5 or 1.6 to be picked, pass --disable-libsrtp2 when configuring Janus to force it to use the older version instead.

  • Note: when installing libsrtp, no matter which version, you may need to pass --libdir=/usr/lib64 to the configure script if you're installing on a x86_64 distribution.

If you want to make use of BoringSSL instead of OpenSSL (e.g., because you want to take advantage of --enable-dtls-settimeout), you'll have to manually install it to a specific location. Use the following steps:

git clone https://boringssl.googlesource.com/boringssl
cd boringssl
# Don't barf on errors
sed -i s/" -Werror"//g CMakeLists.txt
# Build
mkdir -p build
cd build
cmake -DCMAKE_CXX_FLAGS="-lrt" ..
make
cd ..
# Install
sudo mkdir -p /opt/boringssl
sudo cp -R include /opt/boringssl/
sudo mkdir -p /opt/boringssl/lib
sudo cp build/ssl/libssl.a /opt/boringssl/lib/
sudo cp build/crypto/libcrypto.a /opt/boringssl/lib/

Once the library is installed, you'll have to pass an additional --enable-boringssl flag to the configure script, as by default Janus will be built assuming OpenSSL will be used. By default, Janus expects BoringSSL to be installed in /opt/boringssl -- if it's installed in another location, pass the path to the configure script as such: --enable-boringssl=/path/to/boringssl If you were using OpenSSL and want to switch to BoringSSL, make sure you also do a make clean in the Janus folder before compiling with the new BoringSSL support. If you enabled BoringSSL support and also want Janus to detect and react to DTLS timeouts with faster retransmissions, then pass --enable-dtls-settimeout to the configure script too.

For what concerns usrsctp, which is needed for Data Channels support, it is usually not available in repositories, so if you're interested in them (support is optional) you'll have to install it manually. It is a pretty easy and standard process:

git clone https://github.com/sctplab/usrsctp
cd usrsctp
./bootstrap
./configure --prefix=/usr && make && sudo make install
  • Note: you may need to pass --libdir=/usr/lib64 to the configure script if you're installing on a x86_64 distribution.

The same applies for libwebsockets, which is needed for the optional WebSockets support. If you're interested in supporting WebSockets to control Janus, as an alternative (or replacement) to the default plain HTTP REST API, you'll have to install it manually:

git clone https://libwebsockets.org/repo/libwebsockets
cd libwebsockets
# If you want the stable version of libwebsockets, uncomment the next line
# git checkout v2.4-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

The same applies for Eclipse Paho MQTT C client library, which is needed for the optional MQTT support. If you're interested in integrating MQTT channels as an alternative (or replacement) to HTTP and/or WebSockets to control Janus, or as a carrier of Janus Events, you can install the latest version with the following steps:

git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
make && sudo make install
  • Note: you may want to set up a different install path for the library, to achieve that, replace the last command by 'sudo prefix=/usr make install'.

In case you're interested in Nanomsg support, you'll need to install the related C library. It is usually available as an easily installable package in pretty much all repositories. The following is an example on how to install it on Ubuntu:

aptitude install libnanomsg-dev

Finally, the same can be said for rabbitmq-c as well, which is needed for the optional RabbitMQ support. In fact, several different versions of the library can be found, and the versions usually available in most distribution repositories are not up-do-date with respect to the current state of the development. As such, if you're interested in integrating RabbitMQ queues as an alternative (or replacement) to HTTP and/or WebSockets to control Janus, you can install the latest version with the following steps:

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
  • Note: you may need to pass --libdir=/usr/lib64 to the configure script if you're installing on a x86_64 distribution.

To conclude, should you be interested in building the Janus documentation as well, you'll need some additional tools too:

On Fedora:

yum install doxygen graphviz

On Ubuntu/Debian:

aptitude install doxygen graphviz

Compile

Once you have installed all the dependencies, get the code:

git clone https://github.com/meetecho/janus-gateway.git
cd janus-gateway

Then just use:

sh autogen.sh

to generate the configure file. After that, configure and compile as usual to start the whole compilation process:

./configure --prefix=/opt/janus
make
make install

Since Janus requires configuration files for both the core and its modules in order to work, you'll probably also want to install the default configuration files to use, which you can do this way:

make configs

Remember to only do this once, or otherwise a subsequent make configs will overwrite any configuration file you may have modified in the meanwhile.

If you've installed the above libraries but are not interested, for instance, in Data Channels, WebSockets, MQTT and/or RabbitMQ, you can disable them when configuring:

./configure --disable-websockets --disable-data-channels --disable-rabbitmq --disable-mqtt

There are configuration flags for pretty much all external modules and many of the features, so you may want to issue a ./configure --help to dig through the available options. A summary of what's going to be built will always appear after you do a configure, allowing you to double check if what you need and don't need is there.

If Doxygen and graphviz are available, the process can also build the documentation for you. By default the compilation process will not try to build the documentation, so if you instead prefer to build it, use the --enable-docs configuration option:

./configure --enable-docs

You can also selectively enable/disable other features (e.g., specific plugins you don't care about, or whether or not you want to build the recordings post-processor). Use the --help option when configuring for more info.

Building on MacOS

While most of the above instructions will work when compiling Janus on MacOS as well, there are a few aspects to highlight when doing that.

First of all, you can use brew to install most of the dependencies:

brew install jansson libnice openssl srtp libusrsctp libmicrohttpd \
	libwebsockets cmake rabbitmq-c sofia-sip opus libogg curl glib \
	libconfig pkg-config gengetopt autoconf automake libtool

For what concerns libwebsockets, though, make sure that the installed version is higher than 2.4.1, or you might encounter the problems described in this post. If brew doesn't provide a more recent version, you'll have to install the library manually.

Notice that you may need to provide a custom prefix and PKG_CONFIG_PATH when configuring Janus as well, e.g.:

./configure --prefix=/usr/local/janus PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig

Everything else works exactly the same way as on Linux.

Configure and start

To start the server, you can use the janus executable. There are several things you can configure, either in a configuration file:

<installdir>/etc/janus/janus.jcfg

or on the command line:

<installdir>/bin/janus --help

janus 0.8.2

Usage: janus [OPTIONS]...

-h, --help                    Print help and exit
-V, --version                 Print version and exit
-b, --daemon                  Launch Janus in background as a daemon
                              (default=off)
-p, --pid-file=path           Open the specified PID file when starting Janus
                              (default=none)
-N, --disable-stdout          Disable stdout based logging  (default=off)
-L, --log-file=path           Log to the specified file (default=stdout only)
-H  --cwd-path                Working directory for Janus daemon process
                              (default=/)
-i, --interface=ipaddress     Interface to use (will be the public IP)
-P, --plugins-folder=path     Plugins folder (default=./plugins)
-C, --config=filename         Configuration file to use
-F, --configs-folder=path     Configuration files folder (default=./conf)
-c, --cert-pem=filename       DTLS certificate
-k, --cert-key=filename       DTLS certificate key
-K, --cert-pwd=text           DTLS certificate key passphrase (if needed)
-S, --stun-server=filename    STUN server(:port) to use, if needed (e.g.,
							  Janus behind NAT, default=none)
-1, --nat-1-1=ip              Public IP to put in all host candidates,
                              assuming a 1:1 NAT is in place (e.g., Amazon
                              EC2 instances, default=none)
-E, --ice-enforce-list=list   Comma-separated list of the only interfaces to
                              use for ICE gathering; partial strings are
                              supported (e.g., eth0 or eno1,wlan0,
                              default=none)
-X, --ice-ignore-list=list    Comma-separated list of interfaces or IP
                              addresses to ignore for ICE gathering;
                              partial strings are supported (e.g.,
                              vmnet8,192.168.0.1,10.0.0.1 or
                              vmnet,192.168., default=vmnet)
-6, --ipv6-candidates         Whether to enable IPv6 candidates or not
                              (experimental)  (default=off)
-l, --libnice-debug           Whether to enable libnice debugging or not
                              (default=off)
-f, --full-trickle            Do full-trickle instead of half-trickle
                              (default=off)
-I, --ice-lite                Whether to enable the ICE Lite mode or not
                              (default=off)
-T, --ice-tcp                 Whether to enable ICE-TCP or not (warning: only
                              works with ICE Lite)
                              (default=off)
-q, --max-nack-queue=number   Maximum size of the NACK queue (in ms) per user
                              for retransmissions
-t, --no-media-timer=number   Time (in s) that should pass with no media
                              (audio or video) being received before Janus
                              notifies you about this
-W, --slowlink-threshold=number
                              Number of lost packets (per s) that should
                              trigger a 'slowlink' Janus API event to users
-r, --rtp-port-range=min-max  Port range to use for RTP/RTCP (only available
							  if the installed libnice supports it)
-B, --twcc-period=number      How often (in ms) to send TWCC feedback back to
                              senders, if negotiated (default=200ms)
-n, --server-name=name        Public name of this Janus instance
                              (default=MyJanusInstance)
-s, --session-timeout=number  Session timeout value, in seconds (default=60)
-m, --reclaim-session-timeout=number
                              Reclaim session timeout value, in seconds
                              (default=0)
-d, --debug-level=1-7         Debug/logging level (0=disable debugging,
                              7=maximum debug level; default=4)
-D, --debug-timestamps        Enable debug/logging timestamps  (default=off)
-o, --disable-colors          Disable color in the logging  (default=off)
-M, --debug-locks             Enable debugging of locks/mutexes (very
                              verbose!)  (default=off)
-a, --apisecret=randomstring  API secret all requests need to pass in order
                              to be accepted by Janus (useful when wrapping
                              Janus API requests in a server, none by
                              default)
-A, --token-auth              Enable token-based authentication for all
                              requests  (default=off)
-e, --event-handlers          Enable event handlers  (default=off)

Options passed through the command line have the precedence on those specified in the configuration file. To start the server, simply run:

<installdir>/bin/janus

This will start the server, and have it look at the configuration file.

Make sure you have a look at all of the configuration files, to tailor Janus to your specific needs: each configuration file is documented, so it shouldn't be hard to make changes according to your requirements. The repo comes with some defaults (assuming you issues make configs after installing the server) that tend to make sense for generic deployments, and also includes some sample configurations for all the plugins (e.g., web servers to listen on, conference rooms to create, streaming mountpoints to make available at startup, etc.).

To test whether it's working correctly, you can use the demos provided with this package in the html folder: these are exactly the same demos available online on the project website. Just copy the file it contains in a webserver, or use a userspace webserver to serve the files in the html folder (e.g., with php or python), and open the index.html page in either Chrome or Firefox. A list of demo pages exploiting the different plugins will be available. Remember to edit the transport/port details in the demo JavaScript files if you changed any transport-related configuration from its defaults. Besides, the demos refer to the pre-configured plugin resources, so if you add some new resources (e.g., a new videoconference) you may have to tweak the demo pages to actually use them.

Documentation

Janus is thoroughly documented. You can find the current documentation, automatically generated with Doxygen, on the project website.

Help us!

Any thought, feedback or (hopefully not!) insult is welcome!

Developed by @meetecho