Pārlūkot izejas kodu

Adopts XEP-0343 for DTLS/SCTP Jingle signaling.

j8
paweldomas 11 gadus atpakaļ
vecāks
revīzija
be42629a63

+ 2
- 2
libs/colibri/colibri.focus.js Parādīt failu

423
                                 else
423
                                 else
424
                                 {
424
                                 {
425
                                     var sctpmap = SDPUtil.find_line(media, 'a=sctpmap:' + mline.fmt[0]);
425
                                     var sctpmap = SDPUtil.find_line(media, 'a=sctpmap:' + mline.fmt[0]);
426
-                                    var sctpPort = SDPUtil.parse_sctpmap(sctpmap);
426
+                                    var sctpPort = SDPUtil.parse_sctpmap(sctpmap)[0];
427
                                     elem.c("sctpconnection",
427
                                     elem.c("sctpconnection",
428
                                         {
428
                                         {
429
                                             initiator: 'true',
429
                                             initiator: 'true',
712
             change.c('sctpconnection', {
712
             change.c('sctpconnection', {
713
                 endpoint: $(this.channels[participant][channel]).attr('endpoint'),
713
                 endpoint: $(this.channels[participant][channel]).attr('endpoint'),
714
                 expire: self.channelExpire,
714
                 expire: self.channelExpire,
715
-                port: SDPUtil.parse_sctpmap(sctpmap)
715
+                port: SDPUtil.parse_sctpmap(sctpmap)[0]
716
             });
716
             });
717
         }
717
         }
718
         // now add transport
718
         // now add transport

+ 34
- 28
libs/strophe/strophe.jingle.sdp.js Parādīt failu

179
                 bundle.splice(bundle.indexOf(mid), 1);
179
                 bundle.splice(bundle.indexOf(mid), 1);
180
             }
180
             }
181
         }
181
         }
182
-        // Sctp
183
-        if (SDPUtil.find_line(this.media[i], 'a=sctpmap:').length)
184
-        {
185
-            for (j = 0; j < mline.fmt.length; j++)
186
-            {
187
-                var sctpmap = SDPUtil.find_line(
188
-                    this.media[i], 'a=sctpmap:' + mline.fmt[j]);
189
-                if (sctpmap)
190
-                {
191
-                    elem.c('sctp',
192
-                        {
193
-                            xmlns: 'http://jitsi.org/ns/sctp',
194
-                            port : SDPUtil.parse_sctpmap(sctpmap)
195
-                        });
196
-                    elem.up();
197
-                }
198
-            }
199
-        }
200
 
182
 
201
         if (SDPUtil.find_line(this.media[i], 'a=rtpmap:').length)
183
         if (SDPUtil.find_line(this.media[i], 'a=rtpmap:').length)
202
         {
184
         {
327
     var self = this;
309
     var self = this;
328
     elem.c('transport');
310
     elem.c('transport');
329
 
311
 
312
+    // XEP-0343 DTLS/SCTP
313
+    if (SDPUtil.find_line(this.media[mediaindex], 'a=sctpmap:').length)
314
+    {
315
+        var sctpmap = SDPUtil.find_line(
316
+            this.media[i], 'a=sctpmap:', self.session);
317
+        if (sctpmap)
318
+        {
319
+            var sctpAttrs = SDPUtil.parse_sctpmap(sctpmap);
320
+            elem.c('sctpmap',
321
+                {
322
+                    xmlns: 'urn:xmpp:jingle:transports:dtls-sctp:1',
323
+                    number: sctpAttrs[0], /* SCTP port */
324
+                    protocol: sctpAttrs[1], /* protocol */
325
+                });
326
+            // Optional stream count attribute
327
+            if (sctpAttrs.length > 2)
328
+                elem.attrs({ streams: sctpAttrs[2]});
329
+            elem.up();
330
+        }
331
+    }
330
     // XEP-0320
332
     // XEP-0320
331
     var fingerprints = SDPUtil.find_lines(this.media[mediaindex], 'a=fingerprint:', this.session);
333
     var fingerprints = SDPUtil.find_lines(this.media[mediaindex], 'a=fingerprint:', this.session);
332
     fingerprints.forEach(function(line) {
334
     fingerprints.forEach(function(line) {
461
         ssrc = desc.attr('ssrc'),
463
         ssrc = desc.attr('ssrc'),
462
         self = this,
464
         self = this,
463
         tmp;
465
         tmp;
464
-    var sctp = null;
465
-    if (!desc.length)
466
-    {
467
-        sctp = content.find('sctp');
468
-    }
466
+    var sctp = content.find(
467
+        '>transport>sctpmap[xmlns="urn:xmpp:jingle:transports:dtls-sctp:1"]');
469
 
468
 
470
     tmp = { media: desc.attr('media') };
469
     tmp = { media: desc.attr('media') };
471
     tmp.port = '1';
470
     tmp.port = '1';
474
         tmp.port = '0';
473
         tmp.port = '0';
475
     }
474
     }
476
     if (content.find('>transport>fingerprint').length || desc.find('encryption').length) {
475
     if (content.find('>transport>fingerprint').length || desc.find('encryption').length) {
477
-        if (sctp)
476
+        if (sctp.length)
478
             tmp.proto = 'DTLS/SCTP';
477
             tmp.proto = 'DTLS/SCTP';
479
         else
478
         else
480
             tmp.proto = 'RTP/SAVPF';
479
             tmp.proto = 'RTP/SAVPF';
481
     } else {
480
     } else {
482
         tmp.proto = 'RTP/AVPF';
481
         tmp.proto = 'RTP/AVPF';
483
     }
482
     }
484
-    if (!sctp)
483
+    if (!sctp.length)
485
     {
484
     {
486
         tmp.fmt = desc.find('payload-type').map(
485
         tmp.fmt = desc.find('payload-type').map(
487
             function () { return this.getAttribute('id'); }).get();
486
             function () { return this.getAttribute('id'); }).get();
489
     }
488
     }
490
     else
489
     else
491
     {
490
     {
492
-        media += 'm=application 1 DTLS/SCTP ' + sctp.attr('port') + '\r\n';
493
-        media += 'a=sctpmap:' + sctp.attr('port') + ' webrtc-datachannel\r\n';
491
+        media += 'm=application 1 DTLS/SCTP ' + sctp.attr('number') + '\r\n';
492
+        media += 'a=sctpmap:' + sctp.attr('number') +
493
+            ' ' + sctp.attr('protocol');
494
+
495
+        var streamCount = sctp.attr('streams');
496
+        if (streamCount)
497
+            media += ' ' + streamCount + '\r\n';
498
+        else
499
+            media += '\r\n';
494
     }
500
     }
495
 
501
 
496
     media += 'c=IN IP4 0.0.0.0\r\n';
502
     media += 'c=IN IP4 0.0.0.0\r\n';
497
-    if (!sctp)
503
+    if (!sctp.length)
498
         media += 'a=rtcp:1 IN IP4 0.0.0.0\r\n';
504
         media += 'a=rtcp:1 IN IP4 0.0.0.0\r\n';
499
     tmp = content.find('>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]');
505
     tmp = content.find('>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]');
500
     if (tmp.length) {
506
     if (tmp.length) {

+ 6
- 2
libs/strophe/strophe.jingle.sdp.util.js Parādīt failu

93
     /**
93
     /**
94
      * Parses SDP line "a=sctpmap:..." and extracts SCTP port from it.
94
      * Parses SDP line "a=sctpmap:..." and extracts SCTP port from it.
95
      * @param line eg. "a=sctpmap:5000 webrtc-datachannel"
95
      * @param line eg. "a=sctpmap:5000 webrtc-datachannel"
96
-     * @returns SCTP port number
96
+     * @returns [SCTP port number, protocol, streams]
97
      */
97
      */
98
     parse_sctpmap: function (line)
98
     parse_sctpmap: function (line)
99
     {
99
     {
100
         var parts = line.substring(10).split(' ');
100
         var parts = line.substring(10).split(' ');
101
-        return parts[0];// SCTP port
101
+        var sctpPort = parts[0];
102
+        var protocol = parts[1];
103
+        // Stream count is optional
104
+        var streamCount = parts.length > 2 ? parts[2] : null;
105
+        return [sctpPort, protocol, streamCount];// SCTP port
102
     },
106
     },
103
     build_rtpmap: function (el) {
107
     build_rtpmap: function (el) {
104
         var line = 'a=rtpmap:' + el.getAttribute('id') + ' ' + el.getAttribute('name') + '/' + el.getAttribute('clockrate');
108
         var line = 'a=rtpmap:' + el.getAttribute('id') + ' ' + el.getAttribute('name') + '/' + el.getAttribute('clockrate');

Notiek ielāde…
Atcelt
Saglabāt