https://github.com/meetecho/janus-gateway
Meetecho がメンテしているオープンなWebRTC Gateway Project. 今んところLinuxをサポート
- サーバーサイドLinuxとしてのふがほげ
- Raspberry PI用のふがほげ に使うのに便利そう
個人的に気に入っているのは
- libwebrtc.soに依存していない(webrtcスタックをスクラッチで書いてる)
- 独立した Open source (libwebrtc.soはchromiumの一部だし、いじるのつらぽ)
- ビデオエンコードはGStream に任せる感じになっているので、融通効きそう ってところ
- Install dependency libraries
sudo aptitude install libmicrohttpd-dev libjansson-dev libnice-dev \
libssl-dev libsrtp-dev libsofia-sip-ua-dev libglib2.0-dev \
libopus-dev libogg-dev libini-config-dev libcollection-dev \
pkg-config gengetopt libtool automake cmake
- Install libscrtp manually, cause it was 1.4.x
wget https://github.com/cisco/libsrtp/archive/v1.5.0.tar.gz
tar xfv v1.5.0.tar.gz
cd libsrtp-1.5.0
./configure --prefix=/usr --enable-openssl
make libsrtp.so; sudo make install
- Install libsctp, since I prefer it;-)
git clone https://github.com/sctplab/usrsctp
cd usrsctp
./bootstrap
./configure --prefix=/usr; make; sudo make install
- install libwebsocket
git clone git://git.libwebsockets.org/libwebsockets
cd libwebsockets
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
make; sudo make install
- note that I give up to install belows, since it fails fetching
aptitude install doxygen graphviz
git clone https://github.com/meetecho/janus-gateway.git
cd janus-gateway
sh autogen.sh
./configure --prefix=/opt/janus --disable-rabbitmq --disable-docs --disable-websockets
make
sudo make install
sudo make configs
これで、/opt/janus 以下に、諸々インストールされる ※ Dec 14, 2015にインストールしょうとしたら、websocket の library みつからんエラーが出るので。対処策として disableした
とりあえず大切なのは、
/opt/janus/bin/janus ... Janus (WebRTC Gateway) /opt/janus/etc/janus/janus.cfg ... config (なんか、イッパイサンプルのコンフィグがある)
- message while doing configure
RabbitMQ support: no
WebSockets support: yes
DataChannels support: yes
Recordings post-processor: no
TURN REST API client: no
Doxygen documentation: no
Plugins:
Echo Test: yes
Streaming: yes
Video Call: yes
SIP Gateway: yes
Audio Bridge: yes
Video Room: yes
Voice Mail: yes
Record&Play: yes
とりあえず、
$ /opt/janus/bin/janus
---------------------------------------------------
Starting Meetecho Janus (WebRTC Gateway) v0.0.9
---------------------------------------------------
Reading configuration from /opt/janus/etc/janus/janus.cfg
(以下省略)
って感じで動いたw まずは、一旦とめた
参考URL http://www.rs-online.com/designspark/electronics/blog/building-a-raspberry-pi-2-webrtc-camera
- gstreamerのインストール
sudo apt-get update
sudo apt-get install gstreamer1.0
- gstreamerで、H.264をjanusに送る(このストリームをJanusがWebRTC Gatewayとして中継する感じになる)
まず、gstreamerからのstreamを受けるために設定を変える
vi /opt/janus/etc/janus/janus.plugin.streaming.cfg
もともと書いてあった、[gstreamer-sample]の設定をコメントアウトし、以下を追加
[gst-rpwc]
type = rtp
id = 1
description = RPWC H264 test streaming
audio = no
video = yes
videoport = 8004
videopt = 96
videortpmap = H264/90000
videofmtp = profile-level-id=42e028\;packetization-mode=1
そんで、GStreamerをH.264 encodeするように動かし・・・
raspivid --verbose --nopreview -hf -vf --width 640 --height 480 --framerate 15 --bitrate 1000000 --profile baseline --timeout 0 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=127.0.0.1 port=8004
janusを動かす
/opt/janus/bin/janus
で、サンプルのhtmlアクセスするために、
$ cd /opt/janus/share/janus/demos
$ http-server <-- sudo npm -g install http-serverで入れてあるのが前提
Starting up http-server, serving ./ on: http://0.0.0.0:8081
Hit CTRL-C to stop the server
あとは、firefoxで
- [Start]
- [Streams List]で、[RPWC H264 Streaming...]を選択
- [Watch or Listen]をクリック すると、右側にWebRTCでRaspberry PI camの映像が!
※ Chromeだと接続できませんw(H.264サポートしてないのでw)
streamingが不安定だったので、色々調べたら rtp の timestamp が GStreamer 側で固定(更新されない)ことが問題だった
以下のようにGstreamer側で do-timestamp=true をつけると、幸せになれる