Преглед изворни кода

Fixes problems with the adaptive simulcast.

j8
George Politis пре 11 година
родитељ
комит
f2f91ff7cf
4 измењених фајлова са 30 додато и 12 уклоњено
  1. 10
    5
      app.js
  2. 7
    3
      data_channels.js
  3. 2
    0
      simulcast.js
  4. 11
    4
      videolayout.js

+ 10
- 5
app.js Прегледај датотеку

@@ -1422,15 +1422,20 @@ $(document).bind('fatalError.jingle',
1422 1422
     }
1423 1423
 );
1424 1424
 
1425
-$(document).bind("video.selected", function(event, isPresentation, userJid) {
1426
-    if (!isPresentation && _dataChannels && _dataChannels.length != 0) {
1425
+function onSelectedEndpointChanged(userJid)
1426
+{
1427
+    console.log('selected endpoint changed: ', userJid);
1428
+    if (_dataChannels && _dataChannels.length != 0) {
1427 1429
         _dataChannels[0].send(JSON.stringify({
1428 1430
             'colibriClass': 'SelectedEndpointChangedEvent',
1429
-            'selectedEndpoint': (isPresentation || !userJid)
1430
-                // TODO(gp) hmm.. I wonder which one of the Strophe methods to use..
1431
-                ? null : userJid.split('/')[1]
1431
+            'selectedEndpoint': (!userJid || userJid == null)
1432
+                ? null : Strophe.getResourceFromJid(userJid)
1432 1433
         }));
1433 1434
     }
1435
+}
1436
+
1437
+$(document).bind("selectedendpointchanged", function(event, userJid) {
1438
+    onSelectedEndpointChanged(userJid);
1434 1439
 });
1435 1440
 
1436 1441
 function callSipButtonClicked()

+ 7
- 3
data_channels.js Прегледај датотеку

@@ -24,9 +24,13 @@ function onDataChannel(event)
24 24
         // Sends 12 bytes binary message to the bridge
25 25
         //dataChannel.send(new ArrayBuffer(12));
26 26
 
27
-        // TODO(gp) we are supposed to tell the bridge about video selections
28
-        // so that it can do adaptive simulcast, What if a video selection has
29
-        // been made while the data channels are down or broken?
27
+        // when the data channel becomes available, tell the bridge about video
28
+        // selections so that it can do adaptive simulcast,
29
+        var largeVideoSrc = $('#largeVideo').attr('src');
30
+        var userJid = getJidFromVideoSrc(largeVideoSrc);
31
+        // we want the notification to trigger even if userJid is undefined,
32
+        // or null.
33
+        onSelectedEndpointChanged(userJid);
30 34
     };
31 35
 
32 36
     dataChannel.onerror = function (error)

+ 2
- 0
simulcast.js Прегледај датотеку

@@ -839,11 +839,13 @@ function Simulcast() {
839 839
         var ssrc = simulcastLayer.primarySSRC;
840 840
         var simulcast = new Simulcast();
841 841
         simulcast._startLocalVideoStream(ssrc);
842
+        $(document).trigger('simulcastlayerstarted');
842 843
     });
843 844
 
844 845
     $(document).bind('stopsimulcastlayer', function(event, simulcastLayer) {
845 846
         var ssrc = simulcastLayer.primarySSRC;
846 847
         var simulcast = new Simulcast();
847 848
         simulcast._stopLocalVideoStream(ssrc);
849
+        $(document).trigger('simulcastlayerstopped');
848 850
     });
849 851
 }());

+ 11
- 4
videolayout.js Прегледај датотеку

@@ -3,6 +3,7 @@ var VideoLayout = (function (my) {
3 3
     var currentDominantSpeaker = null;
4 4
     var lastNCount = config.channelLastN;
5 5
     var lastNEndpointsCache = [];
6
+    var largeVideoNewSrc = '';
6 7
 
7 8
     my.changeLocalAudio = function(stream) {
8 9
         connection.jingle.localAudio = stream;
@@ -113,6 +114,7 @@ var VideoLayout = (function (my) {
113 114
         console.log('hover in', newSrc);
114 115
 
115 116
         if ($('#largeVideo').attr('src') != newSrc) {
117
+            largeVideoNewSrc = newSrc;
116 118
 
117 119
             var isVisible = $('#largeVideo').is(':visible');
118 120
 
@@ -120,6 +122,11 @@ var VideoLayout = (function (my) {
120 122
             // changed.
121 123
             var isDesktop = isVideoSrcDesktop(newSrc);
122 124
 
125
+            var userJid = getJidFromVideoSrc(newSrc);
126
+            // we want the notification to trigger even if userJid is undefined,
127
+            // or null.
128
+            $(document).trigger("selectedendpointchanged", [userJid]);
129
+
123 130
             $('#largeVideo').fadeOut(300, function () {
124 131
                 var oldSrc = $(this).attr('src');
125 132
 
@@ -213,7 +220,7 @@ var VideoLayout = (function (my) {
213 220
 
214 221
         // Triggers a "video.selected" event. The "false" parameter indicates
215 222
         // this isn't a prezi.
216
-        $(document).trigger("video.selected", [false, userJid]);
223
+        $(document).trigger("video.selected", [false]);
217 224
 
218 225
         VideoLayout.updateLargeVideo(videoSrc, 1);
219 226
 
@@ -1298,7 +1305,7 @@ var VideoLayout = (function (my) {
1298 1305
         }
1299 1306
     });
1300 1307
 
1301
-    $(document).bind('startsimulcastlayer', function(event, simulcastLayer) {
1308
+    $(document).bind('simulcastlayerstarted', function(event) {
1302 1309
         var localVideoSelector = $('#' + 'localVideo_' + connection.jingle.localVideo.id);
1303 1310
         var simulcast = new Simulcast();
1304 1311
         var stream = simulcast.getLocalVideoStream();
@@ -1309,7 +1316,7 @@ var VideoLayout = (function (my) {
1309 1316
         localVideoSrc = $(localVideoSelector).attr('src');
1310 1317
     });
1311 1318
 
1312
-    $(document).bind('stopsimulcastlayer', function(event, simulcastLayer) {
1319
+    $(document).bind('simulcastlayerstopped', function(event) {
1313 1320
         var localVideoSelector = $('#' + 'localVideo_' + connection.jingle.localVideo.id);
1314 1321
         var simulcast = new Simulcast();
1315 1322
         var stream = simulcast.getLocalVideoStream();
@@ -1377,7 +1384,7 @@ var VideoLayout = (function (my) {
1377 1384
                 var selRemoteVideo = $(['#', 'remoteVideo_', session.sid, '_', msidParts[0]].join(''));
1378 1385
 
1379 1386
                 var updateLargeVideo = (ssrc2jid[videoSrcToSsrc[selRemoteVideo.attr('src')]]
1380
-                    == ssrc2jid[videoSrcToSsrc[$('#largeVideo').attr('src')]]);
1387
+                    == ssrc2jid[videoSrcToSsrc[largeVideoNewSrc]]);
1381 1388
                 var updateFocusedVideoSrc = (selRemoteVideo.attr('src') == focusedVideoSrc);
1382 1389
 
1383 1390
                 var electedStreamUrl = webkitURL.createObjectURL(electedStream);

Loading…
Откажи
Сачувај