Centos7 / ubuntuでコンパイルするJanusサーバー

UbuntuでのJanusServerビルドノート

 

1はじめに

Janusは、C言語を介してWebRTCをサポートするゲートウェイを実装するオープンソースです。Janus自体は実装が非常に簡単で、さまざまなビジネスロジックをサポートするプラグインメカニズムを提供し、公式プラグインを使用して効率的なメディアサーバーサービスを実装するために使用できます。 。

この記事では主に、Ubuntu 16.04でjanusサーバーを構築して、公式のjanusデモブラウザーとAndroid APPデモ(janus-gateway-android)の間でオーディオおよびビデオ通話を実装する方法を紹介します。

ブラウザがオーディオとビデオのキャプチャを開く場合は、HTTPS暗号化アクセスが必要です。

レンダリングは次のとおりです。

 

 

Janus公式ウェブサイト:https//janus.conf.meetecho.com/index.html

参照ドキュメント:https//github.com/meetecho/janus-gateway

2Janusをダウンロードしてコンパイルします

Janus Serverをコンパイルして実行するには、いくつかのサードパーティライブラリに依存する必要があります。これらの依存ライブラリは、主にUbuntuのaptitudeを介してインストールされます。まず、aptitudeをインストールします。

sudo apt-get install aptitude

2.1コマンドインストールの依存関係

依存関係キットは、適性を介してUbuntuの下にバッチでインストールされます。速度を上げるために、Ubuntuミラーソース(/etc/apt/source.list)でNetEase163などの一部の国内ミラーソースを使用しないことをお勧めします。ツールキットのダウンロードが失敗する場合でも、公式のミラーソースを使用することをお勧めします。

バッチインストールコマンド:

sudo aptitude install libmicrohttpd-dev libjansson-dev libnice-dev \
    libssl1.0.1-dev libsrtp-dev libsofia-sip-ua-dev libglib2.3.4-dev \
    libopus-dev libogg-dev libcurl4-openssl-dev pkg-config gengetopt \
    libtool automake

sudo apt install cmake
sudo aptitude install libconfig-dev
sudo aptitude install libssl-dev
sudo aptitude install doxygen graphviz

# ffmpeg库 支持--enable-post-processing
sudo aptitude install libavcodec-dev libavformat-dev libswscale-dev libavutil-dev

ツールキットのダウンロードに失敗した場合は、ミラーソースを公式アドレスに変更してコマンドを実行してください

sudo apt-get update && sudo apt-get upgrade

ミラーソースを更新するには、完了後に再インストールします。

付録:アンインストールコマンド

apt-get remove 会删除软件包而保留软件的配置文件
apt-get purge 会同时清除软件包和软件的配置文件

パッケージ検索コマンド

查找软件包
apt-cache search 软件包名
显示软件包的详细信息
apt-cache show 软件包名

オーディオとビデオの高度な開発学習ビデオ学習教材+ホームページqunアクセス

 

2.2ソースコードのインストールの依存関係

2.2.1WebSocketをインストールする

janusはWebSocketをサポートしますオプションです。インストールされていない場合、janusのコンパイル時にWebSocketリンクリクエストはデフォルトでサポートされません。AndroidAPPデモがブラウザ(HTTP)ビデオ通話と通信できることを期待しているため、AndroidAPPデモはWebSocketを介してjanusと通信します。 、したがって、janusをコンパイルするときにWebSocketをサポートする必要があります。

次のコマンドを順番に実行して、ダウンロード、コンパイル、およびインストールします。

git clone https://github.com/warmcat/libwebsockets.git
cd libwebsockets
git branch -a 查看选择最新的稳定版本,目前的是remotes/origin/v3.2-stable
git checkout v3.2-stable 切换到最新稳定版本
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
make && sudo make install

インストールが成功した後、janusが再度コンパイルされると、janusはデフォルトでWebSocketの統合を増やすか、コンパイルパラメーター--enable-websocketsを追加してWebSocketスイッチをオンにするか、-disable-websocketsを追加してWebSocketスイッチをオフにします。 WebSocketスイッチ。

 

2.2.2libsrtpをインストールします

Janusには少なくともバージョン1.5のlibsrtpが必要です。libsrtpがシステムにすでにインストールされている場合は、最初にそれをアンインストールし、新しいバージョンを手動でインストールします。ここでは、libsrtp 2.2をインストールし、次のコマンドを順番に実行します。

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/local --enable-openssl  #centos7
./configure --prefix=/usr --enable-openssl        #ubuntu
make shared_library && sudo make install

 

2.2.3libusrsctpをインストールします

libusrsctpQuest--enable-data-channels

git clone https://github.com/Kurento/libusrsctp.git
cd libusrsctp
./bootstrap
./configure
make
sudo make install

2.2.4libmicrohttpdをインストールします

libmicrohttpd続き--enable-rest

wget https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.71.tar.gz
tar zxf libmicrohttpd-0.9.71.tar.gz
cd libmicrohttpd-0.9.71/
./configure
make
sudo make install

2.3Janusのコンパイル

JanusソースコードをGitからダウンロードし、コンパイルしてインストールします。

git clone https://github.com/meetecho/janus-gateway.git
git tag 查看当前的 tag,选择最新稳定的版本v0.10.4
git  checkout v0.10.4
sh autogen.sh
#./configure --prefix=/opt/janus --enable-websockets --enable-post-processing --enable-docs --enable-rest --enable-data-channels  #需要ffmpeg
./configure --prefix=/opt/janus PKG_CONFIG_PATH=/usr/local/lib/pkgconfig --enable-websockets --enable-data-channels     #不需要安装ffmpeg
make
sudo make install

インストールを行うときは、janusを/ opt / janusパスにインストールします。したがって、プラグインのライブラリは/ opt / janus / lib / janus / pluginsにあります。

configureが正常に実行されると、janusでサポートされているプロトコルとプラグインが次のように出力されます。

ompiler:                  gcc
libsrtp version:           2.x
SSL/crypto library:        OpenSSL
DTLS set-timeout:          not available
Mutex implementation:      GMutex (native futex on Linux)
DataChannels support:      yes
Recordings post-processor: yes
TURN REST API client:      yes
Doxygen documentation:     yes
Transports:
    REST (HTTP/HTTPS):     yes
    WebSockets:            yes
    RabbitMQ:              no
    MQTT:                  no
    Unix Sockets:          yes
    Nanomsg:               no
Plugins:
    Echo Test:             yes
    Streaming:             yes
    Video Call:            yes
    SIP Gateway:           yes
    NoSIP (RTP Bridge):    yes
    Audio Bridge:          yes
    Video Room:            yes
    Voice Mail:            yes
    Record&Play:           yes
    Text Room:             yes
    Lua Interpreter:       no
    Duktape Interpreter:   no
Event handlers:
    Sample event handler:  yes
    WebSocket ev. handler: yes
    RabbitMQ event handler:no
    MQTT event handler:    no
    Nanomsg event handler: no
    GELF event handler:    yes
External loggers:
    JSON file logger:      no
JavaScript modules:        no

3janusを構成して実行します

3.1nginxを構成する

主にWebアクセスを提供するために使用されるnginxをインストールします。

証明書を生成する

mkdir -p ~/cert
cd ~/cert
# CA私钥
openssl genrsa -out key.pem 2048
# 自签名证书
openssl req -new -x509 -key key.pem -out cert.pem -days 1095

nginxをインストールします

#下载nginx 1.15.8版本
wget http://nginx.org/download/nginx-1.15.8.tar.gz
tar xvzf nginx-1.15.8.tar.gz
cd nginx-1.15.8/


# 配置,一定要支持https
./configure --with-http_ssl_module 

# 编译
make

#安装
sudo make install 

nginx構成ファイルを変更します

/usr/local/nginx/conf/nginx.conf

janusが配置されているディレクトリをポイントします/ opt / janus / share / janus / demos

# HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  localhost;
                # 配置相应的key
        ssl_certificate      /home/ubuntu/cert/cert.pem;
        ssl_certificate_key  /home/ubuntu/cert/key.pem;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
                # 指向janus demo所在目录
        location / {
            root   /opt/janus/share/janus/demos;
            index  index.html index.htm;
        }
    }

nginxを起動します

sudo / usr / local / nginx / sbin / nginx

次に合格

https://111.229.231.225/

インターフェースにはアクセスできますが、現時点では通常の通話はできません。

 

 

3.2coturnをインストールして開始します

sudo apt-get install libssl-dev
sudo apt-get install libevent-dev


#git clone https://github.com/coturn/coturn 
#cd coturn
# 提供另一种安装方式turnserver是coturn的升级版本
wget http://coturn.net/turnserver/v4.5.0.7/turnserver-4.5.0.7.tar.gz
tar xfz turnserver-4.5.0.7.tar.gz
cd turnserver-4.5.0.7
 
./configure 
make 
sudo make install

起動

sudo nohup turnserver -L 0.0.0.0 --min-port 30000 --max-port 60000  -a -u lqf:123456 -v -f -r nort.gov &

セキュリティグループのポートを開く必要があります。

TCP / UDP 3478

UDP 30000-60000

3.3janusのjcfgファイルを構成します

janus構成

janusインストールディレクトリは/ opt / janusにあります

。/置き場

。/等

./include

./lib

。/共有

実行可能ファイル

janus構成ファイル

janusヘッダーファイル

janusライブラリ

スクリプトやドキュメントを保存します。Webデモもここにあります

ビデオルームを構成する

最初にビデオルームを構成します

構成する必要のあるファイルは次のとおりです(ディレクトリ/ opt / janus / etc / janus):

そしてオープン8088,8089; 8188,8989

まず、.sampleサフィックスが付いたファイルをjcfgサフィックスにコピーします

# 进到对应的目录
cd /opt/janus/etc/janus
# 拷贝文件
sudo cp janus.jcfg.sample janus.jcfg
sudo cp janus.transport.http.jcfg.sample janus.transport.http.jcfg
sudo cp janus.transport.websockets.jcfg.sample janus.transport.websockets.jcfg
sudo cp janus.plugin.videoroom.jcfg.sample janus.plugin.videoroom.jcfg
sudo cp janus.transport.pfunix.jcfg.sample janus.transport.pfunix.jcfg
sudo cp janus.plugin.streaming.jcfg.sample janus.plugin.streaming.jcfg
sudo cp janus.plugin.recordplay.jcfg.sample janus.plugin.recordplay.jcfg
sudo cp janus.plugin.voicemail.jcfg.sample janus.plugin.voicemail.jcfg
sudo cp janus.plugin.sip.jcfg.sample janus.plugin.sip.jcfg
sudo cp janus.plugin.nosip.jcfg.sample janus.plugin.nosip.jcfg
sudo cp janus.plugin.textroom.jcfg.sample  janus.plugin.textroom.jcfg
sudo cp janus.plugin.echotest.jcfg.sample janus.plugin.echotest.jcfg

 

janus.jcfgを構成します

# 大概237行
stun_server = "111.229.231.225"
        stun_port = 3478
        nice_debug = false

#大概274行
# credentials to authenticate...
        turn_server = "111.229.231.225"
        turn_port = 3478
        turn_type = "udp"
        turn_user = "lqf"
        turn_pwd = "123456"

janus.transport.http.jcfgを構成します

general: {
        #events = true                                  # Whether to notify event handlers about transport events (default=true)
        json = "indented"                               # Whether the JSON messages should be indented (default),
                                                                        # plain (no indentation) or compact (no indentation and no spaces)
        base_path = "/janus"                    # Base path to bind to in the web server (plain HTTP only)
        threads = "unlimited"                   # unlimited=thread per connection, number=thread pool
        http = true                                             # Whether to enable the plain HTTP interface
        port = 8088                                             # Web server HTTP port
        #interface = "eth0"                             # Whether we should bind this server to a specific interface only
        #ip = "192.168.0.1"                             # Whether we should bind this server to a specific IP address (v4 or v6) only
        https = true                                    # Whether to enable HTTPS (default=false)
        secure_port = 8089                              # Web server HTTPS port, if enabled
        #secure_interface = "eth0"              # Whether we should bind this server to a specific interface only
        #secure_ip = "192.168.0.1"              # Whether we should bind this server to a specific IP address (v4 or v6) only
        #acl = "127.,192.168.0."                # Only allow requests coming from this comma separated list of addresses
}

certificates: {
        cert_pem = "/home/ubuntu/cert/cert.pem"
        cert_key = "/home/ubuntu/cert/key.pem"
        #cert_pwd = "secretpassphrase"
        #ciphers = "PFS:-VERS-TLS1.0:-VERS-TLS1.1:-3DES-CBC:-ARCFOUR-128"
}

 

 

 

 

janus.transport.websockets.jcfgを構成します

general: {
        #events = true                                  # Whether to notify event handlers about transport events (default=true)
        json = "indented"                               # Whether the JSON messages should be indented (default),
                                                                        # plain (no indentation) or compact (no indentation and no spaces)
        #pingpong_trigger = 30                  # After how many seconds of idle, a PING should be sent
        #pingpong_timeout = 10                  # After how many seconds of not getting a PONG, a timeout should be detected

        ws = true                                               # Whether to enable the WebSockets API
        ws_port = 8188                                  # WebSockets server port
        #ws_interface = "eth0"                  # Whether we should bind this server to a specific interface only
        #ws_ip = "192.168.0.1"                  # Whether we should bind this server to a specific IP address only
        wss = true                                              # Whether to enable secure WebSockets
        wss_port = 8989                         # WebSockets server secure port, if enabled
        #wss_interface = "eth0"                 # Whether we should bind this server to a specific interface only
        #wss_ip = "192.168.0.1"                 # Whether we should bind this server to a specific IP address only
        #ws_logging = "err,warn"                # libwebsockets debugging level as a comma separated list of things
                                                                        # to debug, supported values: err, warn, notice, info, debug, parser,
                                                                        # header, ext, client, latency, user, count (plus 'none' and 'all')
        #ws_acl = "127.,192.168.0."             # Only allow requests coming from this comma separated list of addresses
}

certificates: {
        cert_pem = "/home/ubuntu/cert/cert.pem"
        cert_key = "/home/ubuntu/cert/key.pem"
        #cert_pwd = "secretpassphrase"
}

3.4デフォルトでWebページでサポートされているwssプロトコルを変更する

/opt/janus/share/janus/demos/videoroomtest.jsファイルを変更します

それは(45行目)でした

var server = null;
if(window.location.protocol === 'http:')
        server = "http://" + window.location.hostname + ":8088/janus";
else
        server = "https://" + window.location.hostname + ":8089/janus";

デフォルトのhttpsプロトコルをwssに変更します

var server = "wss://" + window.location.hostname + ":8989";

3.5Janusを実行する

WebSocketのwsポート番号は8188と8989です。このポート番号を覚えておいてください。AndroidAPPデモで使用します。

Janusを開始します。

/opt/janus/bin/janus --debug-level=5 --log-file=$HOME/janus-log

必要に応じて、次の2つの起動パラメータを追加するかどうかを選択できます。

 

 

Webscoketはwsおよびwssを開始する必要があります(セキュアws、http-httpsに類似)。

3.6クラウドサーバーのポート開放

 

 

3.7WebおよびWeb呼び出しのテスト

https://111.229.231.225/videoroomtest.html

2つの同一のWebページを開き、[開始]をクリックし、名前を入力して、音声通話とビデオ通話のテストを開始します。

 

 

4ビデオ通話共同デバッグテスト

共同デバッグには、PCの下のブラウザとAndroidAPPデモを使用します。

4.1Webデモを開始する

このようにして、https: //111.229.231.225から外部にアクセスできます ホームページに入った後、videoRoomを見つけて開始します。

4.2 AndroidAPPデモを開始する

4.2.1ソースコードのダウンロード

git clone https://github.com/pcgpcgpcg/janus-gateway-android.git

4.2.2シグナリングアドレスの変更

janus-gateway-androidは、EchoTestとVideoRoomの2つのデモテストをサポートしています。EchoTestはデフォルトで有効になっています。このデモは、サーバーに接続し、ローカルテストのためにデータをローカルに送り返すためのものです。他のユーザーに変更する必要があります。 (ブラウザ)ビデオ通話を行うには、別のテストケースVideoRoomを有効にし、次のようにコードを変更する必要があります。APP
デモはWebSocket経由でJanusサーバーに接続するため、VideoRoomTest.javaのroomUrlアドレスをWebSocketに変更します。起動したJanusサーバーのアドレスとIPJanusサーバーのアドレスであり、ポートのデフォルトは8188です。

 

 

次に、39.106.100.180を検索し、独自のIPに置き換えます。

といった

 

 

4.2.3build.gradleを変更する

 

 

プラス

maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://developer.huawei.com/repo/' }
jcenter { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }

そうしないと、一部のコンポーネントをダウンロードできません。

4.2.4コンパイルしてインストールする


AndroidStudioを介してAndroidマシンにコンパイルしてインストールします。

インストール後

 

 

4.3共同デバッグテスト

Janus Serverは、デフォルトで2つのビデオルームを開きます。1234と5678は、それぞれVP8とVP9ビデオエンコーダーを使用するため、BrowerとAndroid APP Demoを使用して共同デバッグテストを実行するときに、ルームIDを設定する必要はありません。

効果画像:

 

 

付録

linux-オーディオとビデオのmjrファイルを組み合わせて生成する方法。

janus-gatewayを使用してWebブラウザで録音しています。録音が完了すると、オーディオとビデオの2つのファイルが生成されます。どちらもmjr形式です。これら2つのファイルを組み合わせて作成する方法単一のファイル?

ベストアンサー

私は同じニーズに取り組んでいます。

デフォルトのjanus-gatewayインストールを実行した場合、次の手順を見逃すだけです。

gitソースをダウンロードしたフォルダーで実行します。

./configure --enable-post-processing

その後

make
(sudo) make install

次に、オーディオ/ビデオ形式に変換するファイルごとに次のコマンドを実行します。

./janus-pp-rec /opt/janus/share/janus/recordings/video.mjr /opt/janus/share/janus/recordings/video.webm
./janus-pp-rec /opt/janus/share/janus/recordings/audio.mjr /opt/janus/share/janus/recordings/audio.opus

ffmpegがインストールされていない場合は、これを実行してください(私はUbuntuを使用していますが、ffmpegはすでに他のディストリビューションのapt-getリポジトリにある可能性があります)

sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install ffmpeg

次に、最後にオーディオとビデオをマージします。

(sudo) ffmpeg -i audio.opus -i video.webm  -c:v copy -c:a opus -strict experimental mergedoutput.webm

そこから、cron上のすべてのmjrファイルを自動的に変換するシェルスクリプトを作成できます。

2020年8月27日に投稿

おすすめ

転載: blog.csdn.net/hyl999/article/details/114257491