瀏覽代碼

fix(sdp): update data channel to RFC format

This PR switches to generating sctp-port based SDP.
It also adds support for parsing sctp-port, but can handle
fallback to old-style sctpmap as well.
Fixes: #1778
dev1
Nils Ohlmeier 3 年之前
父節點
當前提交
0f3ccc7f25
共有 3 個檔案被更改,包括 23 行新增26 行删除
  1. 16
    13
      modules/sdp/SDP.js
  2. 3
    0
      modules/sdp/SDPUtil.js
  3. 4
    13
      modules/sdp/SampleSdpStrings.js

+ 16
- 13
modules/sdp/SDP.js 查看文件

@@ -351,10 +351,21 @@ SDP.prototype.transportToJingle = function(mediaindex, elem) {
351 351
     elem.c('transport');
352 352
 
353 353
     // XEP-0343 DTLS/SCTP
354
+    const sctpport
355
+        = SDPUtil.findLine(this.media[mediaindex], 'a=sctp-port:', this.session);
354 356
     const sctpmap
355 357
         = SDPUtil.findLine(this.media[mediaindex], 'a=sctpmap:', this.session);
356 358
 
357
-    if (sctpmap) {
359
+    if (sctpport) {
360
+        const sctpAttrs = SDPUtil.parseSCTPPort(sctpport);
361
+
362
+        elem.c('sctpmap', {
363
+            xmlns: 'urn:xmpp:jingle:transports:dtls-sctp:1',
364
+            number: sctpAttrs, /* SCTP port */
365
+            protocol: 'webrtc-datachannel' /* protocol */
366
+        });
367
+        elem.up();
368
+    } else if (sctpmap) {
358 369
         const sctpAttrs = SDPUtil.parseSCTPMap(sctpmap);
359 370
 
360 371
         elem.c('sctpmap', {
@@ -556,22 +567,14 @@ SDP.prototype.jingle2media = function(content) {
556 567
         media.port = '0';
557 568
     }
558 569
     if (transport.find('>fingerprint[xmlns="urn:xmpp:jingle:apps:dtls:0"]').length) {
559
-        media.proto = sctp.length ? 'DTLS/SCTP' : 'UDP/TLS/RTP/SAVPF';
570
+        media.proto = sctp.length ? 'UDP/DTLS/SCTP' : 'UDP/TLS/RTP/SAVPF';
560 571
     } else {
561 572
         media.proto = 'UDP/TLS/RTP/SAVPF';
562 573
     }
563 574
     if (sctp.length) {
564
-        sdp += `m=application ${media.port} DTLS/SCTP ${
565
-            sctp.attr('number')}\r\n`;
566
-        sdp += `a=sctpmap:${sctp.attr('number')} ${sctp.attr('protocol')}`;
567
-
568
-        const streamCount = sctp.attr('streams');
569
-
570
-        if (streamCount) {
571
-            sdp += ` ${streamCount}\r\n`;
572
-        } else {
573
-            sdp += '\r\n';
574
-        }
575
+        sdp += `m=application ${media.port} UDP/DTLS/SCTP webrtc-datachannel\r\n`;
576
+        sdp += `a=sctp-port:${sctp.attr('number')}\r\n`;
577
+        sdp += 'a=max-message-size:262144\r\n';
575 578
     } else {
576 579
         media.fmt
577 580
             = desc

+ 3
- 0
modules/sdp/SDPUtil.js 查看文件

@@ -112,6 +112,9 @@ const SDPUtil = {
112 112
 
113 113
         return [ sctpPort, protocol, streamCount ];// SCTP port
114 114
     },
115
+    parseSCTPPort(line) {
116
+        return line.substring(12);
117
+    },
115 118
     buildRTPMap(el) {
116 119
         let line
117 120
             = `a=rtpmap:${el.getAttribute('id')} ${el.getAttribute('name')}/${

+ 4
- 13
modules/sdp/SampleSdpStrings.js 查看文件

@@ -37,7 +37,7 @@ const baseAudioMLineSdp = ''
37 37
 
38 38
 // A basic sdp application mline
39 39
 const baseDataMLineSdp = ''
40
-+ 'm=application 9 DTLS/SCTP 5000\r\n'
40
++ 'm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\n'
41 41
 + 'c=IN IP4 0.0.0.0\r\n'
42 42
 + 'b=AS:30\r\n'
43 43
 + 'a=setup:passive\r\n'
@@ -45,7 +45,8 @@ const baseDataMLineSdp = ''
45 45
 + 'a=ice-ufrag:adPg\r\n'
46 46
 + 'a=ice-pwd:Xsr05Mq8S7CR44DAnusZE26F\r\n'
47 47
 + 'a=fingerprint:sha-256 6A:39:DE:11:24:AD:2E:4E:63:D6:69:D3:85:05:53:C7:3C:38:A4:B7:91:74:C0:91:44:FC:94:63:7F:01:AB:A9\r\n'
48
-+ 'a=sctpmap:5000 webrtc-datachannel 1024\r\n';
48
++ 'a=sctp-port:5000\r\n'
49
++ 'a=max-message-size:262144\r\n';
49 50
 
50 51
 // A basic sdp video mline with a single stream
51 52
 const plainVideoMLineSdp = ''
@@ -257,17 +258,7 @@ const flexFecVideoMLineSdp = ''
257 258
 + 'a=ssrc:116623191 cname:mT86hcsCZwQBPh6R\r\n'
258 259
 + 'a=ssrc:116623191 msid:a2548ae2-32e8-4b09-89bc-b11f3e49ac5a b3e3d760-6b1b-48bd-8519-9d6261311d28\r\n'
259 260
 + 'a=ssrc:116623191 mslabel:a2548ae2-32e8-4b09-89bc-b11f3e49ac5a\r\n'
260
-+ 'a=ssrc:116623191 label:b3e3d760-6b1b-48bd-8519-9d6261311d28\r\n'
261
-+ 'm=application 9 DTLS/SCTP 5000\r\n'
262
-+ 'c=IN IP4 0.0.0.0\r\n'
263
-+ 'b=AS:30\r\n'
264
-+ 'a=ice-ufrag:aLBh\r\n'
265
-+ 'a=ice-pwd:7IeqrWG5ryCW2X47Lso8XYdK\r\n'
266
-+ 'a=ice-options:trickle\r\n'
267
-+ 'a=fingerprint:sha-256 78:3C:F9:96:85:FB:20:25:F8:2F:AB:37:8B:8B:17:29:EF:54:7B:7C:17:2E:90:02:8A:A1:8F:A7:F9:C5:F2:90\r\n'
268
-+ 'a=setup:active\r\n'
269
-+ 'a=mid:data\r\n'
270
-+ 'a=sctpmap:5000 webrtc-datachannel 1024\r\n';
261
++ 'a=ssrc:116623191 label:b3e3d760-6b1b-48bd-8519-9d6261311d28\r\n';
271 262
 
272 263
 const recvOnlyAudioMline = ''
273 264
 + 'm=audio 54405 RTP/SAVPF 111 103 104 126\r\n'

Loading…
取消
儲存