icon-attention デザイン新しくしました。

icon-calendar 2019年5月12日

【WebRTC】セッション記述プロトコル:SDPについて

未分類

SDPとは?

SDP(Session Description Protocol)とはIP電話機やWebRTCなどで
通信を行う際、お互いがどのような映像・音声のコーデックを使えるかなどの
情報をやりとりするためのプロトコルです。

コーデックというのは、映像や音声を送受信するときに、そのままのデータを
渡すと容量が大きすぎるため、ある程度圧縮してから送るのですが、
その圧縮と解凍をしてくれるものです。(エンコード+デコード=コーデック)

様々な種類の圧縮の仕方があるため、圧縮と解凍の仕方を合わせなければなりません。

今回、WebRTCを勉強する機会があったのでその記述方法をまとめていきます。

SDPの中身

v=0
o=- 5857680321754400137 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS io1ttp3fJNqDMVyJXb1BmL99EhK7sW2f4hc4
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:SZTl
a=ice-pwd:w3TGgO1Uyos3GU7V6U3AMW7i
a=ice-options:trickle
a=fingerprint:sha-256 0F:1D:9E:60:E5:4B:39:AB:72:9E:81:C1:10:5C:5D:DC:7E:2B:B7:F6:59:1F:C4:FB:28:74:A8:3C:FB:23:98:F0
a=setup:active
a=mid:0
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:13 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:12 urn:3gpp:video-orientation
a=extmap:2 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:6 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:3 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv
a=msid:io1ttp3fJNqDMVyJXb1BmL99EhK7sW2f4hc4 8e379d68-3afd-4f44-b44f-74cbae500336
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 red/90000
a=rtpmap:120 rtx/90000
a=fmtp:120 apt=124
a=rtpmap:123 ulpfec/90000
a=ssrc-group:FID 3985486965 1159696126
a=ssrc:3985486965 cname:HgrSdJEZYNlZ0Ryg
a=ssrc:1159696126 cname:HgrSdJEZYNlZ0Ryg

 

このように1行ごとにfield=valueの形になっていることが分かります。

各フィールドの意味

v SDPのバージョンを指定します。現在は0しかありません。※必須項目です。
o <ユーザー名> <セッションID> <バージョン> <ネットワークタイプ> <アドレスタイプ> <アドレス>
の構造になっています。ユーザー名は送り先が認証が必要な場合に使い、特に設定しなければ「-」となります。
※必須項目です。
s セッション名。SIPやWebRTCでは使わないので「-」である場合がほとんどです。※必須項目です。
t <セッションの開始時間> <セッションの停止時間>の構造でNTP時間値あたえる。
今回は設定しないので「0 0」となっている。※必須項目です。
a <属性>あるいは<属性>:<値>で自由にセッション開始に必要な情報を送ります。
rtp:mapでコーデックをマッピング、rtcp-fb:<mapした番号>でそのコーデックの情報を記述。
m <メディア> <ポート> <トランスポート> <format一覧>の構造になっています。
メディアはvideoやaudioなどの通信するものの種類です。※必須項目です。
c <ネットワークタイプ> <アドレスタイプ> <接続アドレス>の構造になっています。