この資料は時雨堂オープンソースのお手伝いをしてくれている人に向けた講義資料です。 WebRTC についてと、時雨堂の WebRTC 関連の自社製品を一通り紹介をしていきます。
- お手伝いをお願いしたタイミングでまずは講義を受けてもらいます
- お手伝いをする上で WebRTC に詳しい必要はありません
- 2-3 時間を予定しています
- ホワイトボードの写真撮影、講義の録画/録音可能です
- ただし公開は禁止
- 随時質問は受け付けます
基本的には資料化してあるので、それをベースに説明していきます
- WebRTC の概要
- P2P と SFU の違い
- WebRTC に利用されてるプロトコル
- SDP
- RTP/RTCP
- DTLS
- SRTP/SRTCP
- SCTP
- STUN/TURN/ICE
- WebSocket
- WebRTC の使い所
- WebRTC の現状と未来
SDP はハンドシェイクプロトコルなので、お互いが通信をするための取り決めを決めるためのプロトコルです。 テキストプロトコルなのでなれると普通に読めます。ざっくり説明していきます。
v=0 o=- 2596122128061893517 2 IN IP4 127.0.0.1 s=- t=0 0 a=group:BUNDLE 0 1 a=msid-semantic: WMS hqwNn2s1lW5579bb31CLnxTiNS2CoNGedmkb m=audio 54483 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126 c=IN IP4 192.168.3.8 a=rtcp:9 IN IP4 0.0.0.0 a=candidate:3006760579 1 udp 2122260223 192.168.3.8 54483 typ host generation 0 network-id 1 network-cost 10 a=candidate:4256463475 1 tcp 1518280447 192.168.3.8 9 typ host tcptype active generation 0 network-id 1 network-cost 10 a=ice-ufrag:7r/b a=ice-pwd:+c6vofzINhsd7VDdrsW+8jIF a=ice-options:trickle a=fingerprint:sha-256 07:C5:66:87:71:B9:AC:30:C5:63:30:CB:3C:A7:26:EC:F1:38:A0:39:40:74:1A:25:F6:96:CE:EF:85:6D:13:4B a=setup:actpass a=mid:0 a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id a=sendrecv a=msid:hqwNn2s1lW5579bb31CLnxTiNS2CoNGedmkb bde7c343-190d-4c08-975d-d5f286a14bbb a=rtcp-mux a=rtpmap:111 opus/48000/2 a=rtcp-fb:111 transport-cc a=fmtp:111 minptime=10;useinbandfec=1 a=rtpmap:103 ISAC/16000 a=rtpmap:104 ISAC/32000 a=rtpmap:9 G722/8000 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:106 CN/32000 a=rtpmap:105 CN/16000 a=rtpmap:13 CN/8000 a=rtpmap:110 telephone-event/48000 a=rtpmap:112 telephone-event/32000 a=rtpmap:113 telephone-event/16000 a=rtpmap:126 telephone-event/8000 a=ssrc:1366015286 cname:uafxx4DoFucTlTJa a=ssrc:1366015286 msid:hqwNn2s1lW5579bb31CLnxTiNS2CoNGedmkb bde7c343-190d-4c08-975d-d5f286a14bbb a=ssrc:1366015286 mslabel:hqwNn2s1lW5579bb31CLnxTiNS2CoNGedmkb a=ssrc:1366015286 label:bde7c343-190d-4c08-975d-d5f286a14bbb m=video 63975 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123 119 114 115 116 c=IN IP4 192.168.3.8 a=rtcp:9 IN IP4 0.0.0.0 a=candidate:3006760579 1 udp 2122260223 192.168.3.8 63975 typ host generation 0 network-id 1 network-cost 10 a=candidate:4256463475 1 tcp 1518280447 192.168.3.8 9 typ host tcptype active generation 0 network-id 1 network-cost 10 a=ice-ufrag:7r/b a=ice-pwd:+c6vofzINhsd7VDdrsW+8jIF a=ice-options:trickle a=fingerprint:sha-256 07:C5:66:87:71:B9:AC:30:C5:63:30:CB:3C:A7:26:EC:F1:38:A0:39:40:74:1A:25:F6:96:CE:EF:85:6D:13:4B a=setup:actpass a=mid:1 a=extmap:14 urn:ietf:params:rtp-hdrext:toffset a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time a=extmap:13 urn:3gpp:video-orientation a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01 a=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing a=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07 a=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/color-space a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id a=sendrecv a=msid:hqwNn2s1lW5579bb31CLnxTiNS2CoNGedmkb a29bae58-075e-4c06-8382-21507d3babf8 a=rtcp-mux a=rtcp-rsize a=rtpmap:96 VP8/90000 a=rtcp-fb:96 goog-remb a=rtcp-fb:96 transport-cc a=rtcp-fb:96 ccm fir a=rtcp-fb:96 nack a=rtcp-fb:96 nack pli a=rtpmap:97 rtx/90000 a=fmtp:97 apt=96 a=rtpmap:98 VP9/90000 a=rtcp-fb:98 goog-remb a=rtcp-fb:98 transport-cc a=rtcp-fb:98 ccm fir a=rtcp-fb:98 nack a=rtcp-fb:98 nack pli a=fmtp:98 profile-id=0 a=rtpmap:99 rtx/90000 a=fmtp:99 apt=98 a=rtpmap:100 VP9/90000 a=rtcp-fb:100 goog-remb a=rtcp-fb:100 transport-cc a=rtcp-fb:100 ccm fir a=rtcp-fb:100 nack a=rtcp-fb:100 nack pli a=fmtp:100 profile-id=2 a=rtpmap:101 rtx/90000 a=fmtp:101 apt=100 a=rtpmap:102 H264/90000 a=rtcp-fb:102 goog-remb a=rtcp-fb:102 transport-cc a=rtcp-fb:102 ccm fir a=rtcp-fb:102 nack a=rtcp-fb:102 nack pli a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f a=rtpmap:122 rtx/90000 a=fmtp:122 apt=102 a=rtpmap:127 H264/90000 a=rtcp-fb:127 goog-remb a=rtcp-fb:127 transport-cc a=rtcp-fb:127 ccm fir a=rtcp-fb:127 nack a=rtcp-fb:127 nack pli a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f a=rtpmap:121 rtx/90000 a=fmtp:121 apt=127 a=rtpmap:125 H264/90000 a=rtcp-fb:125 goog-remb a=rtcp-fb:125 transport-cc a=rtcp-fb:125 ccm fir a=rtcp-fb:125 nack a=rtcp-fb:125 nack pli a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f a=rtpmap:107 rtx/90000 a=fmtp:107 apt=125 a=rtpmap:108 H264/90000 a=rtcp-fb:108 goog-remb a=rtcp-fb:108 transport-cc a=rtcp-fb:108 ccm fir a=rtcp-fb:108 nack a=rtcp-fb:108 nack pli a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f a=rtpmap:109 rtx/90000 a=fmtp:109 apt=108 a=rtpmap:124 H264/90000 a=rtcp-fb:124 goog-remb a=rtcp-fb:124 transport-cc a=rtcp-fb:124 ccm fir a=rtcp-fb:124 nack a=rtcp-fb:124 nack pli a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032 a=rtpmap:120 rtx/90000 a=fmtp:120 apt=124 a=rtpmap:123 H264/90000 a=rtcp-fb:123 goog-remb a=rtcp-fb:123 transport-cc a=rtcp-fb:123 ccm fir a=rtcp-fb:123 nack a=rtcp-fb:123 nack pli a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032 a=rtpmap:119 rtx/90000 a=fmtp:119 apt=123 a=rtpmap:114 red/90000 a=rtpmap:115 rtx/90000 a=fmtp:115 apt=114 a=rtpmap:116 ulpfec/90000 a=ssrc-group:FID 950913525 1638148977 a=ssrc:950913525 cname:uafxx4DoFucTlTJa a=ssrc:950913525 msid:hqwNn2s1lW5579bb31CLnxTiNS2CoNGedmkb a29bae58-075e-4c06-8382-21507d3babf8 a=ssrc:950913525 mslabel:hqwNn2s1lW5579bb31CLnxTiNS2CoNGedmkb a=ssrc:950913525 label:a29bae58-075e-4c06-8382-21507d3babf8 a=ssrc:1638148977 cname:uafxx4DoFucTlTJa a=ssrc:1638148977 msid:hqwNn2s1lW5579bb31CLnxTiNS2CoNGedmkb a29bae58-075e-4c06-8382-21507d3babf8 a=ssrc:1638148977 mslabel:hqwNn2s1lW5579bb31CLnxTiNS2CoNGedmkb a=ssrc:1638148977 label:a29bae58-075e-4c06-8382-21507d3babf8
RTP は音声や映像を運ぶためのプロトコルです。 RTCP は RTP をコントロールするためのプロトコルです。 RTP は UDP ベースでさらに ACK がないので、パケロスやら遅延に気づけないので RTCP を使ってそれを知ります。
RTP は一方向ですが、 RTCP は双方向です。
データグラム向けの TLS です。音声や映像では DTLS を使って MasterSecret を取得してそれを使って暗号化をします。 DTLS 自体はあくまで MasterSecret にしか利用しません。
RTP/RTCP を DTLS で取得した MasterSecret を利用して暗号化する際に利用するプロトコルです。
SRTP を複合すると RTP が出てきます。
データチャネルで利用されてるプロトコルです。UDP や TCP のいいところどりプロトコルです。 ただし世界中全てのルーターが対応しているわけではないので、基本的にインターナルでしか使われません。
そのためデータチャネルでは UDP の上に DTLS 、さらにそのうえに SCTP を乗せています。
NAT 超えのためのプロトコルです。 STUN は自分の相手から見た IP アドレスを知るための仕組みです。 TURN はトンネルプロトコルで UDP を TCP や TLS に乗せて送ってくれます。
ICE は STUN/TURN を利用するための仕組みです。 ICE = STUN + TURN くらいの気持ちで覚えておいて良いです。
- WebRTC P2P ができること
- WebRTC P2P ができないこと
- なぜ Ayame なのか
- Ayame のミッション
- Ayame の特徴
- Momo の開発体制
- Ayame Plus について
- WebRTC SFU ができること
- WebRTC SFU Sora とは
- サーバ Offer
- マルチストリーム
- スポットライト
- 録画
- サイマルキャスト
- Sora の仕組み
- Erlang/OTP
- 1 から実装
- Sora Labo について
- WebRTC Native Client Momo とは
- なぜ Momo なのか
- Momo のミッション
- Momo の特徴
- 1 バイナリ完結型
- Ayame / Sora 両方に対応
- SDL による送受信
- Momo の開発体制
- Azuki とは
- 据え置き型の常時音声映像共有ソフトウェア
- なぜ Azuki を作るのか
- 既存の製品が高すぎる
- サポートなしでいいから使いたい人向け