Просмотр исходного кода

Adds an option to advertise our SSRCs in presence to the MUC (as well as

Jingle) for backward compatibility with jirecon. Partially reverts
a1b0677442
j8
Boris Grozev 10 лет назад
Родитель
Сommit
932af962b2
2 измененных файлов: 63 добавлений и 0 удалений
  1. 18
    0
      modules/xmpp/JingleSessionPC.js
  2. 45
    0
      modules/xmpp/strophe.emuc.js

+ 18
- 0
modules/xmpp/JingleSessionPC.js Просмотреть файл

@@ -1406,10 +1406,28 @@ JingleSessionPC.prototype.setLocalDescription = function () {
1406 1406
 
1407 1407
     // Bind us as local SSRCs owner
1408 1408
     if (newssrcs.length > 0) {
1409
+
1410
+        if (config.advertiseSSRCsInPresence) {
1411
+            // This is only for backward compatibility with clients which
1412
+            // don't support getting sources from Jingle (i.e. jirecon).
1413
+            this.connection.emuc.clearPresenceMedia();
1414
+        }
1415
+
1409 1416
         for (i = 0; i < newssrcs.length; i++) {
1410 1417
             var ssrc = newssrcs[i].ssrc;
1411 1418
             var myJid = self.connection.emuc.myroomjid;
1412 1419
             self.ssrcOwners[ssrc] = myJid;
1420
+
1421
+            if (config.advertiseSSRCsInPresence) {
1422
+                // This is only for backward compatibility with clients which
1423
+                // don't support getting sources from Jingle (i.e. jirecon).
1424
+                this.connection.emuc.addMediaToPresence(
1425
+                    i+1, newssrcs[i].type, ssrc, newssrcs[i].direction);
1426
+            }
1427
+        }
1428
+
1429
+        if (config.advertiseSSRCsInPresence) {
1430
+            this.connection.emuc.sendPresence();
1413 1431
         }
1414 1432
     }
1415 1433
 };

+ 45
- 0
modules/xmpp/strophe.emuc.js Просмотреть файл

@@ -529,6 +529,31 @@ module.exports = function(XMPP, eventEmitter) {
529 529
                     .c('current').t(this.presMap['prezicurrent']).up().up();
530 530
             }
531 531
 
532
+            // This is only for backward compatibility with clients which
533
+            // don't support getting sources from Jingle (i.e. jirecon).
534
+            if (this.presMap['medians']) {
535
+                pres.c('media', {xmlns: this.presMap['medians']});
536
+                var sourceNumber = 0;
537
+                Object.keys(this.presMap).forEach(function (key) {
538
+                    if (key.indexOf('source') >= 0) {
539
+                        sourceNumber++;
540
+                    }
541
+                });
542
+                if (sourceNumber > 0) {
543
+                    for (var i = 1; i <= sourceNumber / 3; i++) {
544
+                        pres.c('source',
545
+                            {
546
+                                type: this.presMap['source' + i + '_type'],
547
+                                ssrc: this.presMap['source' + i + '_ssrc'],
548
+                                direction: this.presMap['source' + i + '_direction']
549
+                                || 'sendrecv'
550
+                            }
551
+                        ).up();
552
+                    }
553
+                }
554
+                pres.up();
555
+            }
556
+
532 557
             if(this.presMap["startMuted"] !== undefined)
533 558
             {
534 559
                 pres.c("startmuted", {audio: this.presMap["startMuted"].audio,
@@ -543,6 +568,26 @@ module.exports = function(XMPP, eventEmitter) {
543 568
         addDisplayNameToPresence: function (displayName) {
544 569
             this.presMap['displayName'] = displayName;
545 570
         },
571
+        // This is only for backward compatibility with clients which
572
+        // don't support getting sources from Jingle (i.e. jirecon).
573
+        addMediaToPresence: function (sourceNumber, mtype, ssrcs, direction) {
574
+            if (!this.presMap['medians'])
575
+                this.presMap['medians'] = 'http://estos.de/ns/mjs';
576
+
577
+            this.presMap['source' + sourceNumber + '_type'] = mtype;
578
+            this.presMap['source' + sourceNumber + '_ssrc'] = ssrcs;
579
+            this.presMap['source' + sourceNumber + '_direction'] = direction;
580
+        },
581
+        // This is only for backward compatibility with clients which
582
+        // don't support getting sources from Jingle (i.e. jirecon).
583
+        clearPresenceMedia: function () {
584
+            var self = this;
585
+            Object.keys(this.presMap).forEach(function (key) {
586
+                if (key.indexOf('source') != -1) {
587
+                    delete self.presMap[key];
588
+                }
589
+            });
590
+        },
546 591
         addDevicesToPresence: function (devices) {
547 592
             this.presMap['devices'] = devices;
548 593
         },

Загрузка…
Отмена
Сохранить