标签:
本文主要介绍ICE与SDP交互过程中的一些知识,支持原创,文章来博客园RTC.Blacker,转载请说明出处。
用过libjingle模块的同学都知道连接过程中candidate的获取与连接流程,一边获取candidate,一边进行连接,所以整个过程很快,
但我们有时候用一些其他基于webrtc的产品来测试时发现很久才能看到对方的画面,这是啥原因呢?是不是程序有漏洞?
不是的,主要是他们采用了不同类型的ICE,详细区别见下图:
如上:右边就是libjingle所采用的ICE连接模式,左边是传统模式,主要差别就是candidate获取与建立连接的时间点不一样。
以下是traditional ICE下SDP交互的例子:
sdpOffer:v=0 o=- 1610437942022958275 2 IN IP4 127.0.0.1 s=- t=0 0 a=group:BUNDLE audio video a=msid-semantic: WMS WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs m=audio 49290 RTP/SAVPF 111 103 104 9 0 8 106 105 13 126 c=IN IP4 43.251.159.28 a=rtcp:49290 IN IP4 43.251.159.28 a=candidate:4011286938 1 udp 2122260223 172.16.36.4 49290 typ host generation 0 a=candidate:4011286938 2 udp 2122260223 172.16.36.4 49290 typ host generation 0 a=candidate:3671821981 1 udp 2122194687 192.168.232.1 49291 typ host generation 0 a=candidate:3671821981 2 udp 2122194687 192.168.232.1 49291 typ host generation 0 a=candidate:209874304 1 udp 2122129151 192.168.234.1 49292 typ host generation 0 a=candidate:209874304 2 udp 2122129151 192.168.234.1 49292 typ host generation 0 a=candidate:430735571 1 udp 2122063615 192.168.1.102 49293 typ host generation 0 a=candidate:430735571 2 udp 2122063615 192.168.1.102 49293 typ host generation 0 a=candidate:2710871402 1 tcp 1518280447 172.16.36.4 0 typ host tcptype active generation 0 a=candidate:2710871402 2 tcp 1518280447 172.16.36.4 0 typ host tcptype active generation 0 a=candidate:2488824429 1 tcp 1518214911 192.168.232.1 0 typ host tcptype active generation 0 a=candidate:2488824429 2 tcp 1518214911 192.168.232.1 0 typ host tcptype active generation 0 a=candidate:1107399024 1 tcp 1518149375 192.168.234.1 0 typ host tcptype active generation 0 a=candidate:1107399024 2 tcp 1518149375 192.168.234.1 0 typ host tcptype active generation 0 a=candidate:1462729763 1 tcp 1518083839 192.168.1.102 0 typ host tcptype active generation 0 a=candidate:1462729763 2 tcp 1518083839 192.168.1.102 0 typ host tcptype active generation 0 a=candidate:1179184719 1 udp 1686052607 43.251.159.28 49290 typ srflx raddr 172.16.36.4 rport 49290 generation 0 a=candidate:1179184719 2 udp 1686052607 43.251.159.28 49290 typ srflx raddr 172.16.36.4 rport 49290 generation 0 a=ice-ufrag:8HnoGRmjieejKco5 a=ice-pwd:acjBERhAuMGJhSKh+QV1RfYc a=fingerprint:sha-256 42:01:CE:4C:B3:00:75:C1:3D:71:91:85:55:D9:89:16:1F:F8:DC:13:45:C6:01:20:73:50:3F:68:F7:9B:42:A3 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=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:126 telephone-event/8000 a=maxptime:60 a=ssrc:914767615 cname:I7njJbRyQNJXY+i8 a=ssrc:914767615 msid:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs fbe366c6-6ac9-44b2-866f-0c629c9d2e45 a=ssrc:914767615 mslabel:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs a=ssrc:914767615 label:fbe366c6-6ac9-44b2-866f-0c629c9d2e45 m=video 49290 RTP/SAVPF 100 116 117 96 c=IN IP4 43.251.159.28 a=rtcp:49290 IN IP4 43.251.159.28 a=candidate:4011286938 1 udp 2122260223 172.16.36.4 49290 typ host generation 0 a=candidate:4011286938 2 udp 2122260223 172.16.36.4 49290 typ host generation 0 a=candidate:3671821981 1 udp 2122194687 192.168.232.1 49291 typ host generation 0 a=candidate:3671821981 2 udp 2122194687 192.168.232.1 49291 typ host generation 0 a=candidate:209874304 1 udp 2122129151 192.168.234.1 49292 typ host generation 0 a=candidate:209874304 2 udp 2122129151 192.168.234.1 49292 typ host generation 0 a=candidate:430735571 1 udp 2122063615 192.168.1.102 49293 typ host generation 0 a=candidate:430735571 2 udp 2122063615 192.168.1.102 49293 typ host generation 0 a=candidate:2710871402 1 tcp 1518280447 172.16.36.4 0 typ host tcptype active generation 0 a=candidate:2710871402 2 tcp 1518280447 172.16.36.4 0 typ host tcptype active generation 0 a=candidate:2488824429 1 tcp 1518214911 192.168.232.1 0 typ host tcptype active generation 0 a=candidate:2488824429 2 tcp 1518214911 192.168.232.1 0 typ host tcptype active generation 0 a=candidate:1107399024 1 tcp 1518149375 192.168.234.1 0 typ host tcptype active generation 0 a=candidate:1107399024 2 tcp 1518149375 192.168.234.1 0 typ host tcptype active generation 0 a=candidate:1462729763 1 tcp 1518083839 192.168.1.102 0 typ host tcptype active generation 0 a=candidate:1462729763 2 tcp 1518083839 192.168.1.102 0 typ host tcptype active generation 0 a=candidate:1179184719 1 udp 1686052607 43.251.159.28 49290 typ srflx raddr 172.16.36.4 rport 49290 generation 0 a=candidate:1179184719 2 udp 1686052607 43.251.159.28 49290 typ srflx raddr 172.16.36.4 rport 49290 generation 0 a=ice-ufrag:8HnoGRmjieejKco5 a=ice-pwd:acjBERhAuMGJhSKh+QV1RfYc a=fingerprint:sha-256 42:01:CE:4C:B3:00:75:C1:3D:71:91:85:55:D9:89:16:1F:F8:DC:13:45:C6:01:20:73:50:3F:68:F7:9B:42:A3 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=sendrecv a=rtcp-mux 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=rtpmap:116 red/90000 a=rtpmap:117 ulpfec/90000 a=rtpmap:96 rtx/90000 a=fmtp:96 apt=100 a=ssrc-group:FID 1771045130 811642261 a=ssrc:1771045130 cname:I7njJbRyQNJXY+i8 a=ssrc:1771045130 msid:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs 79fdc2d6-85c1-4d67-bd7e-44bbe6334926 a=ssrc:1771045130 mslabel:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs a=ssrc:1771045130 label:79fdc2d6-85c1-4d67-bd7e-44bbe6334926 a=ssrc:811642261 cname:I7njJbRyQNJXY+i8 a=ssrc:811642261 msid:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs 79fdc2d6-85c1-4d67-bd7e-44bbe6334926 a=ssrc:811642261 mslabel:WPIpgsjC7ygH2f9MdWrqxrkG26wUHzt3zzLs a=ssrc:811642261 label:79fdc2d6-85c1-4d67-bd7e-44bbe6334926
sdpAnser:v=0 o=- 1610437942022958275 0 IN IP4 0.0.0.0 s=Kurento Media Server c=IN IP4 0.0.0.0 t=0 0 a=group:BUNDLE audio video m=audio 49350 RTP/SAVPF 111 0 c=IN IP4 115.28.63.56 a=rtpmap:111 opus/48000/2 a=rtpmap:0 PCMU/8000 a=sendrecv a=rtcp:49350 IN IP4 115.28.63.56 a=rtcp-mux a=ssrc:4085612173 cname:user2766977916@host-c2a1d0bb a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time a=mid:audio a=ice-ufrag:k69i a=ice-pwd:2OEh/hwoKondNA67xmXQ1s a=fingerprint:sha-256 00:C2:77:EF:2C:B1:73:01:10:29:3D:53:AB:81:29:59:F3:AA:9A:EB:91:B9:A8:F1:16:12:2D:6C:5A:5D:78:B2 a=candidate:1 1 UDP 2013266431 115.28.63.56 49350 typ host a=candidate:2 1 UDP 2013266431 10.144.37.152 58353 typ host m=video 49350 RTP/SAVPF 100 c=IN IP4 115.28.63.56 b=AS:500 a=rtpmap:100 VP8/90000 a=sendrecv 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:49350 IN IP4 115.28.63.56 a=rtcp-mux a=ssrc:1728895 cname:user2766977916@host-c2a1d0bb a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time a=mid:video a=ice-ufrag:k69i a=ice-pwd:2OEh/hwoKondNA67xmXQ1s a=fingerprint:sha-256 00:C2:77:EF:2C:B1:73:01:10:29:3D:53:AB:81:29:59:F3:AA:9A:EB:91:B9:A8:F1:16:12:2D:6C:5A:5D:78:B2 a=candidate:1 1 UDP 2013266431 115.28.63.56 49350 typ host a=candidate:2 1 UDP 2013266431 10.144.37.152 58353 typ host SDP answer received, setting remote description
搞懂了这两者的区别,相信对你理解ICE和SDP会有所帮助!
Android IOS WebRTC 音视频开发总结(三十)
标签:
原文地址:http://www.cnblogs.com/lingyunhu/p/rtc30.html