将 SIP 与 webRTC 连接

Connect SIP with webRTC

我已经通过 SIP 成功注册,但无法连接到 webRTC。

任何人都可以知道我们如何将 SIP 与 webRTC 连接起来吗?

请帮助我们,我们有麻烦了。

SIP 和 WebRTC 是不同的协议(或者在 WebRTC 的情况下是不同的协议系列)。 WebRTC 不包括 SIP,因此您无法直接将 SIP 客户端连接到 WebRTC 服务器,反之亦然。

你可以做的是使用一个能理解这两种协议的服务器,比如 Asterisk 或 FreeSWITCH,作为桥梁。

为了在SIP和Webrtc之间进行互操作,您需要解决2层问题:

  1. 使用相同的技术在同一台服务器上注册(使用 SIP)
  2. 使用相同的技术设置媒体会话(使用具有所需功能的 SDP)

最后,Webrtc 和 SIP 都使用 SDP 来设置媒体会话,您需要关注在 Webrtc 代理和 SIP 代理端的 SDP 中具有相同的功能支持。

为了实现这一点,您需要:

  • 在 webrtc 代理端,将 webrtc 代理注册到 SIP 服务。
  • 在 sip 代理端,了解将由 webrtc 代理发送的 SDP 设置。

如果我是对的,根据你的问题,你已经将 webrtc 代理注册到 SIP 服务?无论如何,一个您可能已经使用过的解决方案是使用 javascript SIP 堆栈,例如 JsSIP。该堆栈正在为 webrtc 代理实现缺少的 SIP 协议层。它可用于通过 websocket 将 REGISTER 发送到 SIP 服务,例如 kamailio。 JsSIP 还可以使用 Webrtc 生成的 SDP 发送 INVITE。

注册 webrtc 代理后,您可以调用 SIP 代理。

下一步将是让 SIP 代理能够与 Webrtc 发送的 SDP 进行互操作。 Webrtc 的 SDP 需要实现和协商许多功能。否则Webrtc端SDP协商会失败

webrtc 对 SDP 的要求是: - 将 OPUS 编解码器用于音频(PCMU 或 PCMA 也可以工作) - 视频使用 VP8、VP9、H264。 (取决于浏览器?) - 使用 UDP/TLS/RTP/SAVPF 配置文件(而不是 RTP/AVP) - 使用 DTLS 进行媒体加密 - 使用 GOOG-REMB、TMMBR、PLI、NACK 等 RTCP 反馈 - 对 RTP 和 RTCP 使用多路复用(使用相同的套接字) - 对音频和视频流使用多路复用(使用相同的套接字) - 使用 ICE 与 LOCAL、STUN 和 TURN 候选人建立和验证流 - 一些其他编解码器或可选扩展,如 "ssrc" 和 "extmap" 属性...

这是使用 JsSIP 和当前 Chrome:

来自 webrtc 的 SDP 示例
INVITE sip:antisip@sip.antisip.com SIP/2.0
Via: SIP/2.0/WSS 23g0dst83l03.invalid;branch=z9hG4bK9183549
Max-Forwards: 69
To: <sip:antisip@sip.antisip.com>
From: "test61" <sip:test61@sip.antisip.com>;tag=ug27evkg8b
Call-ID: fgk6v33jjsmcqkec4hnk
CSeq: 1493 INVITE
Proxy-Authorization: Digest algorithm=MD5, username="test61", realm="sip.antisip.com", nonce="XhRyf14UcVN1NxxGnK1M2SSNNMCCeN28/hp17aOPbPRx6h7r++W5Ng==", uri="sip:antisip@sip.antisip.com", response="801f72fe7a2d95aa21b8b7ab7eb45930", qop=auth, cnonce="bka9v71mqbqu", nc=00000001
Contact: <sip:test61@sip.antisip.com;gr=urn:uuid:01542fc1-e3d6-4e92-a032-5c5378bff6c1>
Content-Type: application/sdp
Session-Expires: 90
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: timer,gruu,ice,replaces,outbound
User-Agent: JsSIP 3.3.11
Content-Length: 9992

v=0
o=- 6413630617983761779 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1
a=msid-semantic: WMS WUvtnpqd3NIpvzakhMqR4QQ308BUCsNHi75U
m=audio 62668 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126
c=IN IP4 90.66.179.60
a=rtcp:62672 IN IP4 90.66.179.60
a=candidate:3769397851 1 udp 2122262783 2a01:cb14:7c1:7f00:1d76:e7d4:3237:e96f 62665 typ host generation 0 network-id 3
a=candidate:2805962766 1 udp 2122197247 2a01:cb14:7c1:7f00:f961:60c1:70f1:25a0 62666 typ host generation 0 network-id 4
a=candidate:2999745851 1 udp 2122129151 192.168.56.1 62667 typ host generation 0 network-id 1
a=candidate:4077567720 1 udp 2122063615 192.168.1.10 62668 typ host generation 0 network-id 2
a=candidate:3769397851 2 udp 2122262782 2a01:cb14:7c1:7f00:1d76:e7d4:3237:e96f 62669 typ host generation 0 network-id 3
a=candidate:2805962766 2 udp 2122197246 2a01:cb14:7c1:7f00:f961:60c1:70f1:25a0 62670 typ host generation 0 network-id 4
a=candidate:2999745851 2 udp 2122129150 192.168.56.1 62671 typ host generation 0 network-id 1
a=candidate:4077567720 2 udp 2122063614 192.168.1.10 62672 typ host generation 0 network-id 2
a=candidate:85641020 1 udp 1685855999 90.66.179.60 62668 typ srflx raddr 192.168.1.10 rport 62668 generation 0 network-id 2
a=candidate:85641020 2 udp 1685855998 90.66.179.60 62672 typ srflx raddr 192.168.1.10 rport 62672 generation 0 network-id 2
a=candidate:2922352299 1 tcp 1518283007 2a01:cb14:7c1:7f00:1d76:e7d4:3237:e96f 9 typ host tcptype active generation 0 network-id 3
a=candidate:3921437950 1 tcp 1518217471 2a01:cb14:7c1:7f00:f961:60c1:70f1:25a0 9 typ host tcptype active generation 0 network-id 4
a=candidate:4233069003 1 tcp 1518149375 192.168.56.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:3179889176 1 tcp 1518083839 192.168.1.10 9 typ host tcptype active generation 0 network-id 2
a=candidate:2922352299 2 tcp 1518283006 2a01:cb14:7c1:7f00:1d76:e7d4:3237:e96f 9 typ host tcptype active generation 0 network-id 3
a=candidate:3921437950 2 tcp 1518217470 2a01:cb14:7c1:7f00:f961:60c1:70f1:25a0 9 typ host tcptype active generation 0 network-id 4
a=candidate:4233069003 2 tcp 1518149374 192.168.56.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:3179889176 2 tcp 1518083838 192.168.1.10 9 typ host tcptype active generation 0 network-id 2
a=ice-ufrag:8hGn
a=ice-pwd:7nXTzHnYYJqjFn/PuIQs0M74
a=ice-options:trickle
a=fingerprint:sha-256 BC:82:61:35:EA:5B:A5:26:05:82:04:D8:59:4C:38:5D:C9:2A:A2:FB:3C:D1:4D:B3:F0:30:51:15:12:35:09:53
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:WUvtnpqd3NIpvzakhMqR4QQ308BUCsNHi75U 40826d93-0424-428b-9d5e-c75e8529f908
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:1958040920 cname:YJ7EvDTAqjZBMG5q
a=ssrc:1958040920 msid:WUvtnpqd3NIpvzakhMqR4QQ308BUCsNHi75U 40826d93-0424-428b-9d5e-c75e8529f908
a=ssrc:1958040920 mslabel:WUvtnpqd3NIpvzakhMqR4QQ308BUCsNHi75U
a=ssrc:1958040920 label:40826d93-0424-428b-9d5e-c75e8529f908
m=video 62676 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 90.66.179.60
a=rtcp:62680 IN IP4 90.66.179.60
a=candidate:3769397851 1 udp 2122262783 2a01:cb14:7c1:7f00:1d76:e7d4:3237:e96f 62673 typ host generation 0 network-id 3
a=candidate:2805962766 1 udp 2122197247 2a01:cb14:7c1:7f00:f961:60c1:70f1:25a0 62674 typ host generation 0 network-id 4
a=candidate:2999745851 1 udp 2122129151 192.168.56.1 62675 typ host generation 0 network-id 1
a=candidate:4077567720 1 udp 2122063615 192.168.1.10 62676 typ host generation 0 network-id 2
a=candidate:3769397851 2 udp 2122262782 2a01:cb14:7c1:7f00:1d76:e7d4:3237:e96f 62677 typ host generation 0 network-id 3
a=candidate:2805962766 2 udp 2122197246 2a01:cb14:7c1:7f00:f961:60c1:70f1:25a0 62678 typ host generation 0 network-id 4
a=candidate:2999745851 2 udp 2122129150 192.168.56.1 62679 typ host generation 0 network-id 1
a=candidate:4077567720 2 udp 2122063614 192.168.1.10 62680 typ host generation 0 network-id 2
a=candidate:85641020 1 udp 1685855999 90.66.179.60 62676 typ srflx raddr 192.168.1.10 rport 62676 generation 0 network-id 2
a=candidate:85641020 2 udp 1685855998 90.66.179.60 62680 typ srflx raddr 192.168.1.10 rport 62680 generation 0 network-id 2
a=candidate:2922352299 1 tcp 1518283007 2a01:cb14:7c1:7f00:1d76:e7d4:3237:e96f 9 typ host tcptype active generation 0 network-id 3
a=candidate:3921437950 1 tcp 1518217471 2a01:cb14:7c1:7f00:f961:60c1:70f1:25a0 9 typ host tcptype active generation 0 network-id 4
a=candidate:4233069003 1 tcp 1518149375 192.168.56.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:3179889176 1 tcp 1518083839 192.168.1.10 9 typ host tcptype active generation 0 network-id 2
a=candidate:2922352299 2 tcp 1518283006 2a01:cb14:7c1:7f00:1d76:e7d4:3237:e96f 9 typ host tcptype active generation 0 network-id 3
a=candidate:3921437950 2 tcp 1518217470 2a01:cb14:7c1:7f00:f961:60c1:70f1:25a0 9 typ host tcptype active generation 0 network-id 4
a=candidate:4233069003 2 tcp 1518149374 192.168.56.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:3179889176 2 tcp 1518083838 192.168.1.10 9 typ host tcptype active generation 0 network-id 2
a=ice-ufrag:8hGn
a=ice-pwd:7nXTzHnYYJqjFn/PuIQs0M74
a=ice-options:trickle
a=fingerprint:sha-256 BC:82:61:35:EA:5B:A5:26:05:82:04:D8:59:4C:38:5D:C9:2A:A2:FB:3C:D1:4D:B3:F0:30:51:15:12:35:09:53
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:WUvtnpqd3NIpvzakhMqR4QQ308BUCsNHi75U 654d0876-4021-4443-924c-80a0a5395492
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 1470715227 2811192556
a=ssrc:1470715227 cname:YJ7EvDTAqjZBMG5q
a=ssrc:1470715227 msid:WUvtnpqd3NIpvzakhMqR4QQ308BUCsNHi75U 654d0876-4021-4443-924c-80a0a5395492
a=ssrc:1470715227 mslabel:WUvtnpqd3NIpvzakhMqR4QQ308BUCsNHi75U
a=ssrc:1470715227 label:654d0876-4021-4443-924c-80a0a5395492
a=ssrc:2811192556 cname:YJ7EvDTAqjZBMG5q
a=ssrc:2811192556 msid:WUvtnpqd3NIpvzakhMqR4QQ308BUCsNHi75U 654d0876-4021-4443-924c-80a0a5395492
a=ssrc:2811192556 mslabel:WUvtnpqd3NIpvzakhMqR4QQ308BUCsNHi75U
a=ssrc:2811192556 label:654d0876-4021-4443-924c-80a0a5395492

如果您希望与 SIP 代理互操作,则此 SIP 代理必须符合 SDP 中的大部分功能。

调用没有所有功能的基本 SIP 用户代理的解决方法是在中间有一个网关(例如 asterisk 或 freeswitch?)。但是,此解决方案不会是最好的,因为您将失去 SDP 中所有功能的优势(端到端加密、最佳媒体路径、实时带宽协商、视频丢失管理等...)

使用 Janus WebRTC 服务器 - janus-webrtc-gateway-as-a-sip-gateway

How to use Janus for for SIP to WEBRTC