Browse Source

Fixes an issue which could cause last-n settings to not be respected by new channel allocations.

master
Lyubomir Marinov 11 years ago
parent
commit
777475c9ce
1 changed files with 30 additions and 38 deletions
  1. 30
    38
      libs/colibri/colibri.focus.js

+ 30
- 38
libs/colibri/colibri.focus.js View File

@@ -201,8 +201,8 @@ ColibriFocus.prototype.setRecording = function(state, token, callback) {
201 201
 
202 202
 ColibriFocus.prototype._makeConference = function () {
203 203
     var self = this;
204
-    var elem = $iq({to: this.bridgejid, type: 'get'});
205
-    elem.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri'});
204
+    var elem = $iq({ to: this.bridgejid, type: 'get' });
205
+    elem.c('conference', { xmlns: 'http://jitsi.org/protocol/colibri' });
206 206
 
207 207
     this.media.forEach(function (name) {
208 208
         var elemName;
@@ -216,11 +216,11 @@ ColibriFocus.prototype._makeConference = function () {
216 216
         else
217 217
         {
218 218
             elemName = 'channel';
219
-            if (('video' === name) && (this.channelLastN >= 0))
220
-                elemAttrs['last-n'] = this.channelLastN;
219
+            if (('video' === name) && (self.channelLastN >= 0))
220
+                elemAttrs['last-n'] = self.channelLastN;
221 221
         }
222 222
 
223
-        elem.c('content', {name: name});
223
+        elem.c('content', { name: name });
224 224
 
225 225
         elem.c(elemName, elemAttrs);
226 226
         elem.attrs({ endpoint: self.myMucResource });
@@ -655,9 +655,7 @@ ColibriFocus.prototype.addNewParticipant = function (peer) {
655 655
         {
656 656
             console.error('local description not ready yet, postponing', peer);
657 657
         }
658
-        window.setTimeout(function () {
659
-            self.addNewParticipant(peer);
660
-        }, 250);
658
+        window.setTimeout(function () { self.addNewParticipant(peer); }, 250);
661 659
         return;
662 660
     }
663 661
     var index = this.channels.length;
@@ -665,7 +663,9 @@ ColibriFocus.prototype.addNewParticipant = function (peer) {
665 663
     this.peers.push(peer);
666 664
 
667 665
     var elem = $iq({to: this.bridgejid, type: 'get'});
668
-    elem.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri', id: this.confid});
666
+    elem.c(
667
+        'conference',
668
+        { xmlns: 'http://jitsi.org/protocol/colibri', id: this.confid });
669 669
     var localSDP = new SDP(this.peerconnection.localDescription.sdp);
670 670
     localSDP.media.forEach(function (media, channel) {
671 671
         var name = SDPUtil.parse_mid(SDPUtil.find_line(media, 'a=mid:'));
@@ -685,11 +685,11 @@ ColibriFocus.prototype.addNewParticipant = function (peer) {
685 685
         else
686 686
         {
687 687
             elemName = 'channel';
688
-            if (('video' === name) && (this.channelLastN >= 0))
689
-                elemAttrs['last-n'] = this.channelLastN;
688
+            if (('video' === name) && (self.channelLastN >= 0))
689
+                elemAttrs['last-n'] = self.channelLastN;
690 690
         }
691 691
 
692
-        elem.c('content', {name: name});
692
+        elem.c('content', { name: name });
693 693
         elem.c(elemName, elemAttrs);
694 694
         elem.up(); // end of channel/sctpconnection
695 695
         elem.up(); // end of content
@@ -817,12 +817,7 @@ ColibriFocus.prototype.addSource = function (elem, fromJid) {
817 817
     if (!this.peerconnection.localDescription)
818 818
     {
819 819
         console.warn("addSource - localDescription not ready yet")
820
-        setTimeout(function()
821
-            {
822
-                self.addSource(elem, fromJid);
823
-            },
824
-            200
825
-        );
820
+        setTimeout(function() { self.addSource(elem, fromJid); }, 200);
826 821
         return;
827 822
     }
828 823
 
@@ -863,12 +858,7 @@ ColibriFocus.prototype.removeSource = function (elem, fromJid) {
863 858
     if (!self.peerconnection.localDescription)
864 859
     {
865 860
         console.warn("removeSource - localDescription not ready yet");
866
-        setTimeout(function()
867
-            {
868
-                self.removeSource(elem, fromJid);
869
-            },
870
-            200
871
-        );
861
+        setTimeout(function() { self.removeSource(elem, fromJid); }, 200);
872 862
         return;
873 863
     }
874 864
 
@@ -1009,11 +999,13 @@ ColibriFocus.prototype.sendIceCandidate = function (candidate) {
1009 999
     }
1010 1000
     if (this.drip_container.length === 0) {
1011 1001
         // start 20ms callout
1012
-        window.setTimeout(function () {
1013
-            if (self.drip_container.length === 0) return;
1014
-            self.sendIceCandidates(self.drip_container);
1015
-            self.drip_container = [];
1016
-        }, 20);
1002
+        window.setTimeout(
1003
+            function () {
1004
+                if (self.drip_container.length === 0) return;
1005
+                self.sendIceCandidates(self.drip_container);
1006
+                self.drip_container = [];
1007
+            },
1008
+            20);
1017 1009
     }
1018 1010
     this.drip_container.push(candidate);
1019 1011
 };
@@ -1210,17 +1202,17 @@ ColibriFocus.prototype.setChannelLastN = function (channelLastN) {
1210 1202
         this.channelLastN = channelLastN;
1211 1203
 
1212 1204
         // Update/patch the existing channels.
1213
-        var patch = $iq({ to:this.bridgejid, type:'set' });
1205
+        var patch = $iq({ to: this.bridgejid, type: 'set' });
1214 1206
 
1215 1207
         patch.c(
1216 1208
             'conference',
1217
-            { xmlns:'http://jitsi.org/protocol/colibri', id:this.confid });
1218
-        patch.c('content', { name:'video' });
1209
+            { xmlns: 'http://jitsi.org/protocol/colibri', id: this.confid });
1210
+        patch.c('content', { name: 'video' });
1219 1211
         patch.c(
1220 1212
             'channel',
1221 1213
             {
1222
-                id:$(this.mychannel[1 /* video */]).attr('id'),
1223
-                'last-n':this.channelLastN
1214
+                id: $(this.mychannel[1 /* video */]).attr('id'),
1215
+                'last-n': this.channelLastN
1224 1216
             });
1225 1217
         patch.up(); // end of channel
1226 1218
         for (var p = 0; p < this.channels.length; p++)
@@ -1228,18 +1220,18 @@ ColibriFocus.prototype.setChannelLastN = function (channelLastN) {
1228 1220
             patch.c(
1229 1221
                 'channel',
1230 1222
                 {
1231
-                    id:$(this.channels[p][1 /* video */]).attr('id'),
1232
-                    'last-n':this.channelLastN
1223
+                    id: $(this.channels[p][1 /* video */]).attr('id'),
1224
+                    'last-n': this.channelLastN
1233 1225
                 });
1234 1226
             patch.up(); // end of channel
1235 1227
         }
1236 1228
         this.connection.sendIQ(
1237 1229
             patch,
1238 1230
             function (res) {
1239
-                console.info('Set channel last-n succeeded: ', res);
1231
+                console.info('Set channel last-n succeeded:', res);
1240 1232
             },
1241 1233
             function (err) {
1242
-                console.error('Set channel last-n failed: ', err);
1234
+                console.error('Set channel last-n failed:', err);
1243 1235
             });
1244 1236
     }
1245 1237
 };

Loading…
Cancel
Save