Parcourir la source

Adds a method setChannelLastN to ColibriFocus which sets the default value of the channel last-n attribute and updates/patches the existing channels with it.

j8
Lyubomir Marinov il y a 11 ans
Parent
révision
6a19d90420
1 fichiers modifiés avec 55 ajouts et 14 suppressions
  1. 55
    14
      libs/colibri/colibri.focus.js

+ 55
- 14
libs/colibri/colibri.focus.js Voir le fichier

@@ -58,6 +58,12 @@ function ColibriFocus(connection, bridgejid) {
58 58
         = ('number' === typeof(config.channelExpire))
59 59
             ? config.channelExpire
60 60
             : 15;
61
+    /**
62
+     * Default channel last-n value.
63
+     * @type {number}
64
+     */
65
+    this.channelLastN
66
+        = ('number' === typeof(config.channelLastN)) ? config.channelLastN : -1;
61 67
 
62 68
     // media types of the conference
63 69
     if (config.openSctp)
@@ -212,13 +218,8 @@ ColibriFocus.prototype._makeConference = function () {
212 218
         else
213 219
         {
214 220
             elemName = 'channel';
215
-            if ('video' === name)
216
-            {
217
-                // last-n
218
-                var lastN = config.channelLastN;
219
-                if ('undefined' !== typeof(lastN))
220
-                    elemAttrs['last-n'] = lastN;
221
-            }
221
+            if (('video' === name) && (this.channelLastN >= 0))
222
+                elemAttrs['last-n'] = this.channelLastN;
222 223
         }
223 224
 
224 225
         elem.c('content', {name: name});
@@ -686,13 +687,8 @@ ColibriFocus.prototype.addNewParticipant = function (peer) {
686 687
         else
687 688
         {
688 689
             elemName = 'channel';
689
-            if ('video' === name)
690
-            {
691
-                // last-n
692
-                var lastN = config.channelLastN;
693
-                if ('undefined' !== typeof(lastN))
694
-                    elemAttrs['last-n'] = lastN;
695
-            }
690
+            if (('video' === name) && (this.channelLastN >= 0))
691
+                elemAttrs['last-n'] = this.channelLastN;
696 692
         }
697 693
 
698 694
         elem.c('content', {name: name});
@@ -1205,3 +1201,48 @@ ColibriFocus.prototype.setRTCPTerminationStrategy = function (strategyFQN) {
1205 1201
     );
1206 1202
 };
1207 1203
 
1204
+/**
1205
+ * Sets the default value of the channel last-n attribute in this conference and
1206
+ * updates/patches the existing channels.
1207
+ */
1208
+ColibriFocus.prototype.setChannelLastN = function (channelLastN) {
1209
+    if (('number' === typeof(channelLastN))
1210
+            && (this.channelLastN !== channelLastN))
1211
+    {
1212
+        this.channelLastN = channelLastN;
1213
+
1214
+        // Update/patch the existing channels.
1215
+        var patch = $iq({ to:this.bridgejid, type:'set' });
1216
+
1217
+        patch.c(
1218
+            'conference',
1219
+            { xmlns:'http://jitsi.org/protocol/colibri', id:this.confid });
1220
+        patch.c('content', { name:'video' });
1221
+        patch.c(
1222
+            'channel',
1223
+            {
1224
+                id:$(this.mychannel[1 /* video */]).attr('id'),
1225
+                'last-n':this.channelLastN
1226
+            });
1227
+        patch.up(); // end of channel
1228
+        for (var p = 0; p < this.channels.length; p++)
1229
+        {
1230
+            patch.c(
1231
+                'channel',
1232
+                {
1233
+                    id:$(this.channels[p][1 /* video */]).attr('id'),
1234
+                    'last-n':this.channelLastN
1235
+                });
1236
+            patch.up(); // end of channel
1237
+        }
1238
+        this.connection.sendIQ(
1239
+            patch,
1240
+            function (res) {
1241
+                console.info('Set channel last-n succeeded: ', res);
1242
+            },
1243
+            function (err) {
1244
+                console.error('Set channel last-n failed: ', err);
1245
+            });
1246
+    }
1247
+};
1248
+

Chargement…
Annuler
Enregistrer