Attempts to fix the resolution N/A problem.

This commit is contained in:
George Politis 2014-10-31 11:10:53 +01:00
parent f7880c96ce
commit 68e6afbd61
2 changed files with 63 additions and 6 deletions

View File

@ -233,6 +233,7 @@ SimulcastReceiver.prototype._remoteVideoSourceCache = '';
SimulcastReceiver.prototype._remoteMaps = { SimulcastReceiver.prototype._remoteMaps = {
msid2Quality: {}, msid2Quality: {},
ssrc2Msid: {}, ssrc2Msid: {},
msid2ssrc: {},
receivingVideoStreams: {} receivingVideoStreams: {}
}; };
@ -308,6 +309,7 @@ SimulcastReceiver.prototype._updateRemoteMaps = function (lines) {
// (re) initialize the remote maps. // (re) initialize the remote maps.
this._remoteMaps.msid2Quality = {}; this._remoteMaps.msid2Quality = {};
this._remoteMaps.ssrc2Msid = {}; this._remoteMaps.ssrc2Msid = {};
this._remoteMaps.msid2ssrc = {};
var self = this; var self = this;
if (remoteVideoSources.groups && remoteVideoSources.groups.length !== 0) { if (remoteVideoSources.groups && remoteVideoSources.groups.length !== 0) {
@ -318,6 +320,7 @@ SimulcastReceiver.prototype._updateRemoteMaps = function (lines) {
videoSource = remoteVideoSources.sources[ssrc]; videoSource = remoteVideoSources.sources[ssrc];
self._remoteMaps.msid2Quality[videoSource.msid] = quality++; self._remoteMaps.msid2Quality[videoSource.msid] = quality++;
self._remoteMaps.ssrc2Msid[videoSource.ssrc] = videoSource.msid; self._remoteMaps.ssrc2Msid[videoSource.ssrc] = videoSource.msid;
self._remoteMaps.msid2ssrc[videoSource.msid] = videoSource.ssrc;
}); });
} }
}); });
@ -373,6 +376,57 @@ SimulcastReceiver.prototype.getReceivingVideoStream = function (stream) {
: stream; : stream;
}; };
SimulcastReceiver.prototype.getReceivingSSRC = function (jid) {
var resource = Strophe.getResourceFromJid(jid);
var ssrc = this._remoteMaps.receivingVideoStreams[resource];
// If we haven't receiving a "changed" event yet, then we must be receiving
// low quality (that the sender always streams).
if (!ssrc && connection.jingle) {
var session;
var i, j, k;
var keys = Object.keys(connection.jingle.sessions);
for (i = 0; i < keys.length; i++) {
var sid = keys[i];
if (ssrc) {
// stream found, stop.
break;
}
session = connection.jingle.sessions[sid];
if (session.remoteStreams) {
for (j = 0; j < session.remoteStreams.length; j++) {
var remoteStream = session.remoteStreams[j];
if (ssrc) {
// stream found, stop.
break;
}
var tracks = remoteStream.getVideoTracks();
if (tracks) {
for (k = 0; k < tracks.length; k++) {
var track = tracks[k];
var msid = [remoteStream.id, track.id].join(' ');
var _ssrc = this._remoteMaps.msid2ssrc[msid];
var _jid = ssrc2jid[_ssrc];
var quality = this._remoteMaps.msid2Quality[msid];
if (jid == _jid && quality == 0) {
ssrc = _ssrc;
// stream found, stop.
break;
}
}
}
}
}
}
}
return ssrc;
};
/** /**
* Gets the fully qualified msid (stream.id + track.id) associated to the * Gets the fully qualified msid (stream.id + track.id) associated to the
* SSRC. * SSRC.
@ -1063,6 +1117,11 @@ SimulcastManager.prototype.transformAnswer = function (desc) {
return this.simulcastSender.transformAnswer(desc); return this.simulcastSender.transformAnswer(desc);
}; };
SimulcastManager.prototype.getReceivingSSRC = function (jid) {
return this.simulcastReceiver.getReceivingSSRC(jid);
};
/** /**
* *
* @param lines * @param lines

View File

@ -8,8 +8,6 @@ var VideoLayout = (function (my) {
}; };
my.connectionIndicators = {}; my.connectionIndicators = {};
var displayedSsrcs = {};
my.changeLocalAudio = function(stream) { my.changeLocalAudio = function(stream) {
connection.jingle.localAudio = stream; connection.jingle.localAudio = stream;
@ -1587,9 +1585,8 @@ var VideoLayout = (function (my) {
if (updateFocusedVideoSrc) { if (updateFocusedVideoSrc) {
focusedVideoSrc = electedStreamUrl; focusedVideoSrc = electedStreamUrl;
} }
var ssrc = videoSrcToSsrc[selRemoteVideo.attr('src')];
displayedSsrcs[ssrc2jid[ssrc]] = ssrc; var jid = ssrc2jid[primarySSRC];
var jid = ssrc2jid[ssrc];
var videoId; var videoId;
if(jid == connection.emuc.myroomjid) if(jid == connection.emuc.myroomjid)
{ {
@ -1703,7 +1700,8 @@ var VideoLayout = (function (my) {
} }
else if(keys.length > 1) else if(keys.length > 1)
{ {
resolutionValue = this.resolution[displayedSsrcs[this.jid]]; var displayedSsrc = simulcast.getReceivingSSRC(this.jid);
resolutionValue = this.resolution[displayedSsrc];
} }
} }