交互详情
代码语言:javascript复制sequenceDiagram
participant A as 用户A
participant WS as WS
participant B as 用户B
A->>WS: 1. 创建offer并发送 sdp type:offer
WS->>B: 2. sdp type:offer
B->>WS: 3. sdp type:answer
WS->>A: 4. sdp type:answer
A->>WS: 1. 发送candidate
WS->>B: 2. 发送candidate
B->>WS: 3. 发送candidate
WS->>A: 4. 发送candidate
B->>A: 连接
交互的数据
1 创建offer并发送
代码语言:javascript复制{"type":"offer","sdp":"v=0rno=- 72532 0 IN IP4 127.0.0.1rns=sipsorceryrnt=0 0rna=group:BUNDLE 0rnm=video 9 UDP/TLS/RTP/SAVP 96 100rnc=IN IP4 0.0.0.0rna=ice-ufrag:SEFWrna=ice-pwd:ZWIYQSXNKGKSEUCBULXIQQCQrna=fingerprint:sha-256 7B:8E:55:E3:27:F2:B3:30:E9:2C:A0:87:E2:C9:1F:70:F6:A7:52:97:F6:F6:04:4B:F0:2A:04:87:FD:CA:9E:B7rna=setup:actpassrna=candidate:950637637 1 udp 2113937663 192.168.3.56 62710 typ host generation 0rna=ice-options:ice2,tricklerna=mid:0rna=rtpmap:96 VP8/90000rna=rtpmap:100 H264/90000rna=fmtp:100 packetization-mode=1rna=rtcp-muxrna=rtcp:9 IN IP4 0.0.0.0rna=end-of-candidatesrna=sendrecvrna=ssrc:1819341444 cname:6fef90ad-0e6b-4af4-9220-377c2faf01d8rn"}
2 响应
代码语言:javascript复制{"type":"answer","sdp":"v=0rno=- 8100819546663100148 2 IN IP4 127.0.0.1rns=-rnt=0 0rna=group:BUNDLE 0rna=msid-semantic: WMS 0eb90fdc-f221-409a-8cc2-10015551f1d1rnm=video 9 UDP/TLS/RTP/SAVP 96 100rnc=IN IP4 0.0.0.0rna=rtcp:9 IN IP4 0.0.0.0rna=ice-ufrag:Kz3Xrna=ice-pwd:ci0C3HqUXi/oTbiOqzjxdNKFrna=ice-options:tricklerna=fingerprint:sha-256 4D:2B:B6:60:B9:F2:C5:9C:D9:7C:DC:7C:DA:E4:1A:A0:B6:79:D7:9D:66:9A:99:05:09:56:A4:43:FF:B3:48:E3rna=setup:activerna=mid:0rna=sendrecvrna=msid:0eb90fdc-f221-409a-8cc2-10015551f1d1 c32f714c-b627-4313-be6d-15fbbc7d8656rna=rtcp-muxrna=rtpmap:96 VP8/90000rna=rtpmap:100 H264/90000rna=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01frna=ssrc:2948904417 cname:ufqrpgnhfhKdMI5crna=ssrc:2948904417 msid:0eb90fdc-f221-409a-8cc2-10015551f1d1 c32f714c-b627-4313-be6d-15fbbc7d8656rn"}
3 并发送candidate
代码语言:javascript复制{"candidate":"candidate:388572998 1 udp 2113937151 bd043a02-be83-461c-84d3-6ab8d12290c5.local 62712 typ host generation 0 ufrag Z/Ju network-cost 999","sdpMid":"0","sdpMLineIndex":0,"usernameFragment":"Z/Ju"}
SDP数据
代码语言:javascript复制v=0
o=- 72532 0 IN IP4 127.0.0.1
s=sipsorcery
t=0 0
a=group:BUNDLE 0
m=video 9 UDP/TLS/RTP/SAVP 96 100
c=IN IP4 0.0.0.0
a=ice-ufrag:SEFW
a=ice-pwd:ZWIYQSXNKGKSEUCBULXIQQCQ
a=fingerprint:sha-256 7B:8E:55:E3:27:F2:B3:30:E9:2C:A0:87:E2:C9:1F:70:F6:A7:52:97:F6:F6:04:4B:F0:2A:04:87:FD:CA:9E:B7
a=setup:actpass
a=candidate:950637637 1 udp 2113937663 192.168.3.56 62710 typ host generation 0
a=ice-options:ice2,trickle
a=mid:0
a=rtpmap:96 VP8/90000
a=rtpmap:100 H264/90000
a=fmtp:100 packetization-mode=1
a=rtcp-mux
a=rtcp:9 IN IP4 0.0.0.0
a=end-of-candidates
a=sendrecv
a=ssrc:1819341444 cname:6fef90ad-0e6b-4af4-9220-377c2faf01d8
可以看出
在SDP阶段,双方交换了各种支持的编码和IP
回发
代码语言:javascript复制v=0
o=- 8100819546663100148 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS 0eb90fdc-f221-409a-8cc2-10015551f1d1
m=video 9 UDP/TLS/RTP/SAVP 96 100
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:Kz3X
a=ice-pwd:ci0C3HqUXi/oTbiOqzjxdNKF
a=ice-options:trickle
a=fingerprint:sha-256 4D:2B:B6:60:B9:F2:C5:9C:D9:7C:DC:7C:DA:E4:1A:A0:B6:79:D7:9D:66:9A:99:05:09:56:A4:43:FF:B3:48:E3
a=setup:active
a=mid:0
a=sendrecv
a=msid:0eb90fdc-f221-409a-8cc2-10015551f1d1 c32f714c-b627-4313-be6d-15fbbc7d8656
a=rtcp-mux
a=rtpmap:96 VP8/90000
a=rtpmap:100 H264/90000
a=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=ssrc:2948904417 cname:ufqrpgnhfhKdMI5c
a=ssrc:2948904417 msid:0eb90fdc-f221-409a-8cc2-10015551f1d1 c32f714c-b627-4313-be6d-15fbbc7d8656