Fixes problems with the adaptive simulcast.

This commit is contained in:
George Politis 2014-09-16 15:43:41 +02:00
parent 7f341d0d8a
commit f2f91ff7cf
4 changed files with 30 additions and 12 deletions

15
app.js
View File

@ -1422,15 +1422,20 @@ $(document).bind('fatalError.jingle',
} }
); );
$(document).bind("video.selected", function(event, isPresentation, userJid) { function onSelectedEndpointChanged(userJid)
if (!isPresentation && _dataChannels && _dataChannels.length != 0) { {
console.log('selected endpoint changed: ', userJid);
if (_dataChannels && _dataChannels.length != 0) {
_dataChannels[0].send(JSON.stringify({ _dataChannels[0].send(JSON.stringify({
'colibriClass': 'SelectedEndpointChangedEvent', 'colibriClass': 'SelectedEndpointChangedEvent',
'selectedEndpoint': (isPresentation || !userJid) 'selectedEndpoint': (!userJid || userJid == null)
// TODO(gp) hmm.. I wonder which one of the Strophe methods to use.. ? null : Strophe.getResourceFromJid(userJid)
? null : userJid.split('/')[1]
})); }));
} }
}
$(document).bind("selectedendpointchanged", function(event, userJid) {
onSelectedEndpointChanged(userJid);
}); });
function callSipButtonClicked() function callSipButtonClicked()

View File

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

View File

@ -839,11 +839,13 @@ function Simulcast() {
var ssrc = simulcastLayer.primarySSRC; var ssrc = simulcastLayer.primarySSRC;
var simulcast = new Simulcast(); var simulcast = new Simulcast();
simulcast._startLocalVideoStream(ssrc); simulcast._startLocalVideoStream(ssrc);
$(document).trigger('simulcastlayerstarted');
}); });
$(document).bind('stopsimulcastlayer', function(event, simulcastLayer) { $(document).bind('stopsimulcastlayer', function(event, simulcastLayer) {
var ssrc = simulcastLayer.primarySSRC; var ssrc = simulcastLayer.primarySSRC;
var simulcast = new Simulcast(); var simulcast = new Simulcast();
simulcast._stopLocalVideoStream(ssrc); simulcast._stopLocalVideoStream(ssrc);
$(document).trigger('simulcastlayerstopped');
}); });
}()); }());

View File

@ -3,6 +3,7 @@ var VideoLayout = (function (my) {
var currentDominantSpeaker = null; var currentDominantSpeaker = null;
var lastNCount = config.channelLastN; var lastNCount = config.channelLastN;
var lastNEndpointsCache = []; var lastNEndpointsCache = [];
var largeVideoNewSrc = '';
my.changeLocalAudio = function(stream) { my.changeLocalAudio = function(stream) {
connection.jingle.localAudio = stream; connection.jingle.localAudio = stream;
@ -113,6 +114,7 @@ var VideoLayout = (function (my) {
console.log('hover in', newSrc); console.log('hover in', newSrc);
if ($('#largeVideo').attr('src') != newSrc) { if ($('#largeVideo').attr('src') != newSrc) {
largeVideoNewSrc = newSrc;
var isVisible = $('#largeVideo').is(':visible'); var isVisible = $('#largeVideo').is(':visible');
@ -120,6 +122,11 @@ var VideoLayout = (function (my) {
// changed. // changed.
var isDesktop = isVideoSrcDesktop(newSrc); var isDesktop = isVideoSrcDesktop(newSrc);
var userJid = getJidFromVideoSrc(newSrc);
// we want the notification to trigger even if userJid is undefined,
// or null.
$(document).trigger("selectedendpointchanged", [userJid]);
$('#largeVideo').fadeOut(300, function () { $('#largeVideo').fadeOut(300, function () {
var oldSrc = $(this).attr('src'); var oldSrc = $(this).attr('src');
@ -213,7 +220,7 @@ var VideoLayout = (function (my) {
// Triggers a "video.selected" event. The "false" parameter indicates // Triggers a "video.selected" event. The "false" parameter indicates
// this isn't a prezi. // this isn't a prezi.
$(document).trigger("video.selected", [false, userJid]); $(document).trigger("video.selected", [false]);
VideoLayout.updateLargeVideo(videoSrc, 1); VideoLayout.updateLargeVideo(videoSrc, 1);
@ -1298,7 +1305,7 @@ var VideoLayout = (function (my) {
} }
}); });
$(document).bind('startsimulcastlayer', function(event, simulcastLayer) { $(document).bind('simulcastlayerstarted', function(event) {
var localVideoSelector = $('#' + 'localVideo_' + connection.jingle.localVideo.id); var localVideoSelector = $('#' + 'localVideo_' + connection.jingle.localVideo.id);
var simulcast = new Simulcast(); var simulcast = new Simulcast();
var stream = simulcast.getLocalVideoStream(); var stream = simulcast.getLocalVideoStream();
@ -1309,7 +1316,7 @@ var VideoLayout = (function (my) {
localVideoSrc = $(localVideoSelector).attr('src'); localVideoSrc = $(localVideoSelector).attr('src');
}); });
$(document).bind('stopsimulcastlayer', function(event, simulcastLayer) { $(document).bind('simulcastlayerstopped', function(event) {
var localVideoSelector = $('#' + 'localVideo_' + connection.jingle.localVideo.id); var localVideoSelector = $('#' + 'localVideo_' + connection.jingle.localVideo.id);
var simulcast = new Simulcast(); var simulcast = new Simulcast();
var stream = simulcast.getLocalVideoStream(); var stream = simulcast.getLocalVideoStream();
@ -1377,7 +1384,7 @@ var VideoLayout = (function (my) {
var selRemoteVideo = $(['#', 'remoteVideo_', session.sid, '_', msidParts[0]].join('')); var selRemoteVideo = $(['#', 'remoteVideo_', session.sid, '_', msidParts[0]].join(''));
var updateLargeVideo = (ssrc2jid[videoSrcToSsrc[selRemoteVideo.attr('src')]] var updateLargeVideo = (ssrc2jid[videoSrcToSsrc[selRemoteVideo.attr('src')]]
== ssrc2jid[videoSrcToSsrc[$('#largeVideo').attr('src')]]); == ssrc2jid[videoSrcToSsrc[largeVideoNewSrc]]);
var updateFocusedVideoSrc = (selRemoteVideo.attr('src') == focusedVideoSrc); var updateFocusedVideoSrc = (selRemoteVideo.attr('src') == focusedVideoSrc);
var electedStreamUrl = webkitURL.createObjectURL(electedStream); var electedStreamUrl = webkitURL.createObjectURL(electedStream);