您的位置:首页 > 其它

WEBRTC SDP

2016-07-19 23:07 633 查看

本端SDP形成

1.发起CreateOffer请求 或CreateAnswer响应

2.PeerConnection::CreateOffer->PeerConnection::GetOptionsForOffer[获取SDP媒体属性]

3.WebRtcSession::CreateOffer[每个PeerConnection一个WebRtcSession]

4.WebRtcSessionDescriptionFactory::CreateOffer->WebRtcSessionDescriptionFactory::InternalCreateOffer

5.MediaSessionDescriptionFactory::CreateOffer->GetCodecsToOffer[获取音视频数据的所支持的编码]

 MediaSessionDescriptionFactory::AddDataContentForOffer->FilterDataCodecs->

 set_protocol(kMediaProtocolSctp)->CreateMediaContentOffer->MediaContentDescriptionImpl::AddCodecs

 SessionDescription::AddContent->MediaSessionDescriptionFactory::AddTransportOffer

6.JsepSessionDescription::Initialize(SessionDescription* description)[Offer SDP已创建]

7.WebRtcSessionDescriptionFactory::PostCreateSessionDescriptionSucceeded->

 Post(this, MSG_CREATE_SESSIONDESCRIPTION_SUCCESS)[生成SDP已成功]->

 CreateSessionDescriptionObserver::OnSuccess(SessionDescriptionInterface* desc)[回调给用户]

 |OnFailure(const std::string& error)[错误返回]

设置本端SDP

注:用户主动调用PeerConnection::CreateOffer 通过回调OnSuccess拿到了SDP对象,之后需要设置本端SDP

1.PeerConnection::SetLocalDescription->

2.WebRtcSession::SetLocalDescription->WebRtcSession::ValidateSessionDescription[合法性校验]->

 VerifyCrypto-ValidateBundleSettings

3.Post(MSG_SET_SESSIONDESCRIPTION_SUCCESS)[设置SDP已成功]->

 SetSessionDescriptionObserver::OnSuccess()[回调给用户]

4.WebRtcSession::MaybeStartGathering->TransportController::MaybeStartGathering->

5.P2PTransportChannel::MaybeStartGathering 

Offer对象转换成SDP字符串(需要发给对端)

1.JsepSessionDescription::ToString

2.SdpSerialize[webrtcsdp.cc]->

接收对端SDP

1.CreateSessionDescription(const std::string& sdp)->JsepSessionDescription::Initialize->

2.SdpDeserialize->ParseMediaDescription->

3.ParseContentDescription->ParseContent->

4.以数据通道为例AddSctpDataCodec->MediaContentDescriptionImpl::AddCodec[google-sctp-data 90000 ]

5.SessionDescription::AddContent

const char NS_JINGLE_RTP[] = "urn:xmpp:jingle:apps:rtp:1";

sctp 的data 对应得ContentInfos中的type必须为NS_JINGLE_DRAFT_SCTP

const char NS_JINGLE_DRAFT_SCTP[] = "google:jingle:sctp";

SCTP 去掉DTLS 出现如下错误:

(channel.cc:2195): Setting local data description

(channel.cc:867): Failure in SetLocalContent with action 2

(webrtcsession.cc:327): Failed to set local answer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set remote data description recv parameters..

(conductor.cc:104): OnFailure Failed to set local answer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set remote data description recv parameters..

将bool IsDtlsSctp(const std::string& protocol) {

  // This intentionally excludes "SCTP" and "SCTP/DTLS".

  return protocol.find(cricket::kMediaProtocolDtlsSctp) != std::string::npos;

  //return protocol.find(cricket::kMediaProtocolSctp) != std::string::npos;//add by sjz

}

将kMediaProtocolDtlsSctp改为kMediaProtocolSctp

a=sctpmap:5000 webrtc-datachannel 1024

 ========================sdp================================

local:

v=0

o=- 8900646765147570832 2 IN IP4 127.0.0.1

s=-

t=0 0

a=group:BUNDLE audio video

a=msid-semantic: WMS stream_label

m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 127 126

c=IN IP4 0.0.0.0

a=rtcp:9 IN IP4 0.0.0.0

a=ice-ufrag:qiC7

a=ice-pwd:97xpdM9B0N8ox6jbS2PI+0G7

a=fingerprint:sha-256 A8:C7:B8:88:DE:B9:F6:70:A3:6E:9D:C7:FD:41:4C:1E:61:9F:B7:E1:92:5F:0A:4C:48:FD:9E:D6:B7:B2:C9:55

a=setup:actpass

a=mid:audio

a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level

a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv

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:102 ILBC/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:127 red/8000

a=rtpmap:126 telephone-event/8000

a=ssrc:3486011156 cname:RS5piJcFSbw2XOoP

a=ssrc:3486011156 msid:stream_label audio_label

a=ssrc:3486011156 mslabel:stream_label

a=ssrc:3486011156 label:audio_label

m=video 9 UDP/TLS/RTP/SAVPF 100 101 116 117 96 97 98

c=IN IP4 0.0.0.0

a=rtcp:9 IN IP4 0.0.0.0

a=ice-ufrag:qiC7

a=ice-pwd:97xpdM9B0N8ox6jbS2PI+0G7

a=fingerprint:sha-256 A8:C7:B8:88:DE:B9:F6:70:A3:6E:9D:C7:FD:41:4C:1E:61:9F:B7:E1:92:5F:0A:4C:48:FD:9E:D6:B7:B2:C9:55

a=setup:actpass

a=mid:video

a=extmap:2 urn:ietf:params:rtp-hdrext:toffset

a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 urn:3gpp:video-orientation

a=sendrecv

a=rtcp-mux

a=rtcp-rsize

a=rtpmap:100 VP8/90000

a=rtcp-fb:100 ccm fir

a=rtcp-fb:100 nack

a=rtcp-fb:100 nack pli

a=rtcp-fb:100 goog-remb

a=rtcp-fb:100 transport-cc

a=rtpmap:101 VP9/90000

a=rtcp-fb:101 ccm fir

a=rtcp-fb:101 nack

a=rtcp-fb:101 nack pli

a=rtcp-fb:101 goog-remb

a=rtcp-fb:101 transport-cc

a=rtpmap:116 red/90000

a=rtpmap:117 ulpfec/90000

a=rtpmap:96 rtx/90000

a=fmtp:96 apt=100

a=rtpmap:97 rtx/90000

a=fmtp:97 apt=101

a=rtpmap:98 rtx/90000

a=fmtp:98 apt=116

a=ssrc-group:FID 3678723866 3268471119

a=ssrc:3678723866 cname:RS5piJcFSbw2XOoP

a=ssrc:3678723866 msid:stream_label video_label

a=ssrc:3678723866 mslabel:stream_label

a=ssrc:3678723866 label:video_label

a=ssrc:3268471119 cname:RS5piJcFSbw2XOoP

a=ssrc:3268471119 msid:stream_label video_label

a=ssrc:3268471119 mslabel:stream_label

a=ssrc:3268471119 label:video_label

{

   "candidate" : "candidate:430735571 1 udp 2122260223 192.168.1.102 59637 typ host generation 0 ufrag pa+u network-id 3 network-cost 50",

   "sdpMLineIndex" : 0,

   "sdpMid" : "audio"

}

remote:

v=0

o=- 5895813448736697051 2 IN IP4 127.0.0.1

s=-

t=0 0

a=group:BUNDLE audio video

a=msid-semantic: WMS

m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 127 126

c=IN IP4 0.0.0.0

a=rtcp:9 IN IP4 0.0.0.0

a=ice-ufrag:1MuA

a=ice-pwd:YAf0BbrY4nSGW5iQ3faC1MVC

a=fingerprint:sha-256 C3:A8:1B:82:A4:2C:93:4C:F6:67:9E:E4:F3:00:7B:D1:BB:56:4D:D4:C1:9E:34:E7:82:73:D9:D0:AF:02:D2:D2

a=setup:active

a=mid:audio

a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level

a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=recvonly

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:102 ILBC/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:127 red/8000

a=rtpmap:126 telephone-event/8000

m=video 9 UDP/TLS/RTP/SAVPF 100 101 116 117 96 97 98

c=IN IP4 0.0.0.0

a=rtcp:9 IN IP4 0.0.0.0

a=ice-ufrag:1MuA

a=ice-pwd:YAf0BbrY4nSGW5iQ3faC1MVC

a=fingerprint:sha-256 C3:A8:1B:82:A4:2C:93:4C:F6:67:9E:E4:F3:00:7B:D1:BB:56:4D:D4:C1:9E:34:E7:82:73:D9:D0:AF:02:D2:D2

a=setup:active

a=mid:video

a=extmap:2 urn:ietf:params:rtp-hdrext:toffset

a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 urn:3gpp:video-orientation

a=recvonly

a=rtcp-mux

a=rtcp-rsize

a=rtpmap:100 VP8/90000

a=rtcp-fb:100 ccm fir

a=rtcp-fb:100 nack

a=rtcp-fb:100 nack pli

a=rtcp-fb:100 goog-remb

a=rtcp-fb:100 transport-cc

a=rtpmap:101 VP9/90000

a=rtcp-fb:101 ccm fir

a=rtcp-fb:101 nack

a=rtcp-fb:101 nack pli

a=rtcp-fb:101 goog-remb

a=rtcp-fb:101 transport-cc

a=rtpmap:116 red/90000

a=rtpmap:117 ulpfec/90000

a=rtpmap:96 rtx/90000

a=fmtp:96 apt=100

a=rtpmap:97 rtx/90000

a=fmtp:97 apt=101

a=rtpmap:98 rtx/90000

a=fmtp:98 apt=116

============auido and data=============

v=0

o=- 1390922805343918830 2 IN IP4 127.0.0.1

s=-

t=0 0

a=group:BUNDLE audio data

a=msid-semantic: WMS

m=audio 9 RTP/AVPF 111 8

c=IN IP4 0.0.0.0

a=rtcp:9 IN IP4 0.0.0.0

a=ice-ufrag:ShBp

a=ice-pwd:a7DnyIUa0qvcB4yEmzOZBC3c

a=mid:audio

a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level

a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=recvonly

a=rtcp-mux

a=rtpmap:111 opus/48000/2

a=rtcp-fb:111 transport-cc

a=fmtp:111 minptime=10;useinbandfec=1

a=rtpmap:8 PCMA/8000

m=application 9 SCTP 5000

c=IN IP4 0.0.0.0

b=AS:30

a=ice-ufrag:ShBp

a=ice-pwd:a7DnyIUa0qvcB4yEmzOZBC3c

a=mid:data

a=sctpmap:5000 webrtc-datachannel 1024
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  WEBRTC