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

View File

@ -24,9 +24,13 @@ function onDataChannel(event)
// Sends 12 bytes binary message to the bridge
//dataChannel.send(new ArrayBuffer(12));
// TODO(gp) we are supposed to tell the bridge about video selections
// so that it can do adaptive simulcast, What if a video selection has
// been made while the data channels are down or broken?
// when the data channel becomes available, tell the bridge about video
// selections so that it can do adaptive simulcast,
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)

View File

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

View File

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