瀏覽代碼

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
     }
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
         _dataChannels[0].send(JSON.stringify({
1429
         _dataChannels[0].send(JSON.stringify({
1428
             'colibriClass': 'SelectedEndpointChangedEvent',
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
 function callSipButtonClicked()
1441
 function callSipButtonClicked()

+ 7
- 3
data_channels.js 查看文件

24
         // Sends 12 bytes binary message to the bridge
24
         // Sends 12 bytes binary message to the bridge
25
         //dataChannel.send(new ArrayBuffer(12));
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
     dataChannel.onerror = function (error)
36
     dataChannel.onerror = function (error)

+ 2
- 0
simulcast.js 查看文件

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

+ 11
- 4
videolayout.js 查看文件

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

Loading…
取消
儲存