#author("2025-08-11T12:18:58+00:00","default:iseki","iseki") #author("2025-08-11T12:27:11+00:00","default:iseki","iseki") * Janus [[WebRTC]] Server ** Build (Rocky Linux 9) *** ツール dnf -y install jansson-devel libconfig-devel libmicrohttpd-devel meson ninja-build -- [[meson]]: [[cmake]] みたいなビルド設定ツール -- [[ninja]]: [[make]] みたいな ビルドツール dnf install libnice libnice-devel dnf install libwebsockets libwebsockets-devel dnf install usrsctp usrsctp-devel **** libsrtp2 (SRTP: Secure Real-time Transport Protocol) <pre> #git clone https://github.com/cisco/libsrtp.git # このままだと libsrtp3 がダウンロードされる git clone --branch v2.5.0 --depth 1 https://github.com/cisco/libsrtp.git libsrtp cd libsrtp ./configure --prefix=/usr/local --enable-openssl make -j"$(nproc)" make install </pre> **** 最新版 - libnice <pre> git clone https://gitlab.freedesktop.org/libnice/libnice.git cd libnice/ meson setup build --prefix=/usr/local ninja -C build ninja -C build install </pre> -libwebsocket <pre> git clone https://github.com/warmcat/libwebsockets.git cd libwebsockets mkdir -p build && cd build cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 -DCMAKE_INSTALL_PREFIX=/usr/local .. make -j"$(nproc)" make install </pre> *** Janus <pre> git clone https://github.com/meetecho/janus-gateway.git cd janus-gateway ./autogen.sh ./configure --prefix=/usr/local --enable-rest --enable-websockets --enable-data-channels --disable-rabbitmq --disable-mqtt --disable-docs --enable-libsrtp2 make -j"$(nproc)" make install make configs </pre> ** 設定 *** 設定ファイル **** /usr/local/etc/janus/janus.jcfg api_secret = "" # Janus REST API 用の認証キー admin_secret = "" # Janus 管理用 API の認証キー - [[coturn]] を使用するなら,以下を追加 <pre> nat: { stun_server = "janus.jogrid.net" stun_port = 3478 #nice_debug = "nice_debug option is NOT SUPPORTED ANYMORE! Please set NICE_DEBUG and G_MESSAGES_DEBUG env vars when starting Janus" #full_trickle = true #ice_nomination = "regular" #ice_consent_freshness = true #ice_keepalive_conncheck = true #ice_lite = true #ice_tcp = true </pre> **** /usr/local/etc/janus/janus.transport.http.jcfg (デフォルト) http = true port = 8088 # for REST **** /usr/local/etc/janus/janus.transport.websockets.jcfg (デフォルト) ws = true ws_port = 8188 # for Web Socket **** /usr/local/etc/janus/janus.plugin.audiobridge.jcfg <pre> general: { # 必要に応じて設定(例) # string_ids = true # rtp_port_range = "50000-60000" # local_ip = "1.2.3.4" # events = true } room-1234: { description = "Demo Room" is_private = false secret = "room-secret" # ルーム操作用パスワード pin = "room-pin" # 参加時パスワード(必要なら) sampling_rate = 48000 # or 16000 spatial_audio = true audiolevel_ext = true audiolevel_event = true audio_active_packets = 100 audio_level_average = 25 record = false # record_dir = "/var/recordings/" # record_file = "room-1234.wav" # allow_rtp_participants = false # rtp_forward_* = ... # 外部RTP転送を使う場合のみ } </pre> *** Systemd **** janus.service <pre> [Unit] Description=Janus WebRTC Server After=network.target [Service] Type=simple ExecStart=/usr/local/bin/janus -F /usr/local/etc/janus Restart=on-failure User=root [Install] WantedBy=multi-user.target </pre> *** Apache で HTTPS, WSS リバースプロキシ - [[Virtual Host の設定>Apache/Configuration-2.4/VirtualHost]] **** 仮想ホスト設定(WSS対応) - [[certbot]] の設定 - [[conf.d/janus.conf>Apache/Configuration-2.4/VirtualHost]] ** STUN/TURN([[coturn]]) *** 設定 - see [[coturn]] ** TEST *** Janus の単体疎通テスト **** REST (8088) curl http://localhost:8088/janus/info **** WS (8188) printf '%s\n' '{"janus":"info","transaction":"t1"}' | websocat -H='Sec-WebSocket-Protocol: janus-protocol' - ws://127.0.0.1:8188/janus **** WSS printf '%s\n' '{"janus":"info","transaction":"t1"}' | websocat --text -H='Sec-WebSocket-Protocol: janus-protocol' - wss://janus.jogrid.net/janusws *** Coturn の STUN/TURN 動作確認 - see [[coturn]] *** Janus + Coturn 経由の WebRTC 動作確認 *** ICE 候補の種類を確認(ブラウザ DevTools) ** for OpenSimulator *** OpenSim.ini <pre> [JanusVoice] ; …略… IceServers = [ {"urls":["stun:stun.l.google.com:19302"]}, {"urls":["turn:janus.jogrid.net:3478"], "username":"<TURNユーザ>", "credential":"<パス>"}, {"urls":["turns:janus.jogrid.net:5349"], "username":"<TURNユーザ>", "credential":"<パス>"} ] </pre> #br #br