Moves ssrc2jid global variable to the xmpp module.

This commit is contained in:
hristoterezov 2015-01-21 13:55:20 +02:00
parent 51277270fe
commit 248d7a3173
12 changed files with 41 additions and 26 deletions

1
app.js
View File

@ -1,7 +1,6 @@
/* jshint -W117 */ /* jshint -W117 */
/* application specific logic */ /* application specific logic */
var nickname = null; var nickname = null;
var ssrc2jid = {};
function init() { function init() {

View File

@ -25,15 +25,15 @@
<script src="service/RTC/MediaStreamTypes.js?v=1"></script> <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
<script src="service/xmpp/XMPPEvents.js?v=1"></script> <script src="service/xmpp/XMPPEvents.js?v=1"></script>
<script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script> <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
<script src="libs/modules/simulcast.bundle.js?v=4"></script> <script src="libs/modules/simulcast.bundle.js?v=5"></script>
<script src="libs/modules/connectionquality.bundle.js?v=2"></script> <script src="libs/modules/connectionquality.bundle.js?v=2"></script>
<script src="libs/modules/UI.bundle.js?v=7"></script> <script src="libs/modules/UI.bundle.js?v=8"></script>
<script src="libs/modules/statistics.bundle.js?v=3"></script> <script src="libs/modules/statistics.bundle.js?v=4"></script>
<script src="libs/modules/RTC.bundle.js?v=6"></script> <script src="libs/modules/RTC.bundle.js?v=6"></script>
<script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing --> <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
<script src="util.js?v=7"></script><!-- utility functions --> <script src="util.js?v=7"></script><!-- utility functions -->
<script src="libs/modules/xmpp.bundle.js?v=3"></script> <script src="libs/modules/xmpp.bundle.js?v=4"></script>
<script src="app.js?v=28"></script><!-- application logic --> <script src="app.js?v=29"></script><!-- application logic -->
<script src="libs/modules/API.bundle.js?v=1"></script> <script src="libs/modules/API.bundle.js?v=1"></script>
<script src="analytics.js?v=1"></script><!-- google analytics plugin --> <script src="analytics.js?v=1"></script><!-- google analytics plugin -->

View File

@ -6385,7 +6385,7 @@ var VideoLayout = (function (my) {
var msidParts = msid.split(' '); var msidParts = msid.split(' ');
var preload = (Strophe.getResourceFromJid(ssrc2jid[primarySSRC]) == largeVideoState.userResourceJid); var preload = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC)) == largeVideoState.userResourceJid);
if (preload) { if (preload) {
if (largeVideoState.preload) if (largeVideoState.preload)
@ -6445,7 +6445,7 @@ var VideoLayout = (function (my) {
var msidParts = msid.split(' '); var msidParts = msid.split(' ');
var selRemoteVideo = $(['#', 'remoteVideo_', sid, '_', msidParts[0]].join('')); var selRemoteVideo = $(['#', 'remoteVideo_', sid, '_', msidParts[0]].join(''));
var updateLargeVideo = (Strophe.getResourceFromJid(ssrc2jid[primarySSRC]) var updateLargeVideo = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC))
== largeVideoState.userResourceJid); == largeVideoState.userResourceJid);
var updateFocusedVideoSrc = (focusedVideoInfo && focusedVideoInfo.src && focusedVideoInfo.src != '' && var updateFocusedVideoSrc = (focusedVideoInfo && focusedVideoInfo.src && focusedVideoInfo.src != '' &&
(RTC.getVideoSrc(selRemoteVideo[0]) == focusedVideoInfo.src)); (RTC.getVideoSrc(selRemoteVideo[0]) == focusedVideoInfo.src));
@ -6467,7 +6467,7 @@ var VideoLayout = (function (my) {
RTC.attachMediaStream(selRemoteVideo, electedStream); RTC.attachMediaStream(selRemoteVideo, electedStream);
} }
var jid = ssrc2jid[primarySSRC]; var jid = xmpp.getJidFromSSRC(primarySSRC);
if (updateLargeVideo) { if (updateLargeVideo) {
VideoLayout.updateLargeVideo(RTC.getVideoSrc(selRemoteVideo[0]), null, VideoLayout.updateLargeVideo(RTC.getVideoSrc(selRemoteVideo[0]), null,

View File

@ -218,7 +218,7 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
{ {
var sid, electedStream; var sid, electedStream;
var i, j, k; var i, j, k;
var jid = ssrc2jid[ssrc]; var jid = xmpp.getJidFromSSRC(ssrc);
if(jid && RTC.remoteStreams[jid]) if(jid && RTC.remoteStreams[jid])
{ {
var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]; var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];

View File

@ -576,7 +576,7 @@ StatsCollector.prototype.processStatsReport = function () {
var ssrc = getStatValue(now, 'ssrc'); var ssrc = getStatValue(now, 'ssrc');
if(!ssrc) if(!ssrc)
continue; continue;
var jid = ssrc2jid[ssrc]; var jid = xmpp.getJidFromSSRC(ssrc);
if (!jid && (Date.now() - now.timestamp) < 3000) { if (!jid && (Date.now() - now.timestamp) < 3000) {
console.warn("No jid for ssrc: " + ssrc); console.warn("No jid for ssrc: " + ssrc);
continue; continue;
@ -777,7 +777,7 @@ StatsCollector.prototype.processAudioLevelReport = function ()
} }
var ssrc = getStatValue(now, 'ssrc'); var ssrc = getStatValue(now, 'ssrc');
var jid = ssrc2jid[ssrc]; var jid = xmpp.getJidFromSSRC(ssrc);
if (!jid && (Date.now() - now.timestamp) < 3000) if (!jid && (Date.now() - now.timestamp) < 3000)
{ {
console.warn("No jid for ssrc: " + ssrc); console.warn("No jid for ssrc: " + ssrc);

View File

@ -1313,6 +1313,7 @@ function sendKeyframe(pc) {
JingleSession.prototype.remoteStreamAdded = function (data) { JingleSession.prototype.remoteStreamAdded = function (data) {
var self = this; var self = this;
var thessrc; var thessrc;
var ssrc2jid = this.connection.emuc.ssrc2jid;
// look up an associated JID for a stream id // look up an associated JID for a stream id
if (data.stream.id && data.stream.id.indexOf('mixedmslabel') === -1) { if (data.stream.id && data.stream.id.indexOf('mixedmslabel') === -1) {
@ -3234,6 +3235,7 @@ module.exports = function(XMPP, eventEmitter) {
isOwner: false, isOwner: false,
role: null, role: null,
focusMucJid: null, focusMucJid: null,
ssrc2jid: {},
init: function (conn) { init: function (conn) {
this.connection = conn; this.connection = conn;
}, },
@ -3779,10 +3781,11 @@ module.exports = function(XMPP, eventEmitter) {
if(memeber.isFocus) if(memeber.isFocus)
return; return;
var self = this;
// Remove old ssrcs coming from the jid // Remove old ssrcs coming from the jid
Object.keys(ssrc2jid).forEach(function (ssrc) { Object.keys(this.ssrc2jid).forEach(function (ssrc) {
if (ssrc2jid[ssrc] == jid) { if (self.ssrc2jid[ssrc] == jid) {
delete ssrc2jid[ssrc]; delete self.ssrc2jid[ssrc];
} }
}); });
@ -3790,7 +3793,7 @@ module.exports = function(XMPP, eventEmitter) {
$(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) { $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
//console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc')); //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
var ssrcV = ssrc.getAttribute('ssrc'); var ssrcV = ssrc.getAttribute('ssrc');
ssrc2jid[ssrcV] = from; self.ssrc2jid[ssrcV] = from;
JingleSession.notReceivedSSRCs.push(ssrcV); JingleSession.notReceivedSSRCs.push(ssrcV);
@ -4806,6 +4809,11 @@ var XMPP = {
}, },
getMembers: function () { getMembers: function () {
return connection.emuc.members; return connection.emuc.members;
},
getJidFromSSRC: function (ssrc) {
if(!connection)
return null;
return connection.emuc.ssrc2jid[ssrc];
} }
}; };

View File

@ -2006,7 +2006,7 @@ var VideoLayout = (function (my) {
var msidParts = msid.split(' '); var msidParts = msid.split(' ');
var preload = (Strophe.getResourceFromJid(ssrc2jid[primarySSRC]) == largeVideoState.userResourceJid); var preload = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC)) == largeVideoState.userResourceJid);
if (preload) { if (preload) {
if (largeVideoState.preload) if (largeVideoState.preload)
@ -2066,7 +2066,7 @@ var VideoLayout = (function (my) {
var msidParts = msid.split(' '); var msidParts = msid.split(' ');
var selRemoteVideo = $(['#', 'remoteVideo_', sid, '_', msidParts[0]].join('')); var selRemoteVideo = $(['#', 'remoteVideo_', sid, '_', msidParts[0]].join(''));
var updateLargeVideo = (Strophe.getResourceFromJid(ssrc2jid[primarySSRC]) var updateLargeVideo = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC))
== largeVideoState.userResourceJid); == largeVideoState.userResourceJid);
var updateFocusedVideoSrc = (focusedVideoInfo && focusedVideoInfo.src && focusedVideoInfo.src != '' && var updateFocusedVideoSrc = (focusedVideoInfo && focusedVideoInfo.src && focusedVideoInfo.src != '' &&
(RTC.getVideoSrc(selRemoteVideo[0]) == focusedVideoInfo.src)); (RTC.getVideoSrc(selRemoteVideo[0]) == focusedVideoInfo.src));
@ -2088,7 +2088,7 @@ var VideoLayout = (function (my) {
RTC.attachMediaStream(selRemoteVideo, electedStream); RTC.attachMediaStream(selRemoteVideo, electedStream);
} }
var jid = ssrc2jid[primarySSRC]; var jid = xmpp.getJidFromSSRC(primarySSRC);
if (updateLargeVideo) { if (updateLargeVideo) {
VideoLayout.updateLargeVideo(RTC.getVideoSrc(selRemoteVideo[0]), null, VideoLayout.updateLargeVideo(RTC.getVideoSrc(selRemoteVideo[0]), null,

View File

@ -184,7 +184,7 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
{ {
var sid, electedStream; var sid, electedStream;
var i, j, k; var i, j, k;
var jid = ssrc2jid[ssrc]; var jid = xmpp.getJidFromSSRC(ssrc);
if(jid && RTC.remoteStreams[jid]) if(jid && RTC.remoteStreams[jid])
{ {
var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]; var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];

View File

@ -444,7 +444,7 @@ StatsCollector.prototype.processStatsReport = function () {
var ssrc = getStatValue(now, 'ssrc'); var ssrc = getStatValue(now, 'ssrc');
if(!ssrc) if(!ssrc)
continue; continue;
var jid = ssrc2jid[ssrc]; var jid = xmpp.getJidFromSSRC(ssrc);
if (!jid && (Date.now() - now.timestamp) < 3000) { if (!jid && (Date.now() - now.timestamp) < 3000) {
console.warn("No jid for ssrc: " + ssrc); console.warn("No jid for ssrc: " + ssrc);
continue; continue;
@ -645,7 +645,7 @@ StatsCollector.prototype.processAudioLevelReport = function ()
} }
var ssrc = getStatValue(now, 'ssrc'); var ssrc = getStatValue(now, 'ssrc');
var jid = ssrc2jid[ssrc]; var jid = xmpp.getJidFromSSRC(ssrc);
if (!jid && (Date.now() - now.timestamp) < 3000) if (!jid && (Date.now() - now.timestamp) < 3000)
{ {
console.warn("No jid for ssrc: " + ssrc); console.warn("No jid for ssrc: " + ssrc);

View File

@ -1312,6 +1312,7 @@ function sendKeyframe(pc) {
JingleSession.prototype.remoteStreamAdded = function (data) { JingleSession.prototype.remoteStreamAdded = function (data) {
var self = this; var self = this;
var thessrc; var thessrc;
var ssrc2jid = this.connection.emuc.ssrc2jid;
// look up an associated JID for a stream id // look up an associated JID for a stream id
if (data.stream.id && data.stream.id.indexOf('mixedmslabel') === -1) { if (data.stream.id && data.stream.id.indexOf('mixedmslabel') === -1) {

View File

@ -21,6 +21,7 @@ module.exports = function(XMPP, eventEmitter) {
isOwner: false, isOwner: false,
role: null, role: null,
focusMucJid: null, focusMucJid: null,
ssrc2jid: {},
init: function (conn) { init: function (conn) {
this.connection = conn; this.connection = conn;
}, },
@ -566,10 +567,11 @@ module.exports = function(XMPP, eventEmitter) {
if(memeber.isFocus) if(memeber.isFocus)
return; return;
var self = this;
// Remove old ssrcs coming from the jid // Remove old ssrcs coming from the jid
Object.keys(ssrc2jid).forEach(function (ssrc) { Object.keys(this.ssrc2jid).forEach(function (ssrc) {
if (ssrc2jid[ssrc] == jid) { if (self.ssrc2jid[ssrc] == jid) {
delete ssrc2jid[ssrc]; delete self.ssrc2jid[ssrc];
} }
}); });
@ -577,7 +579,7 @@ module.exports = function(XMPP, eventEmitter) {
$(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) { $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
//console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc')); //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
var ssrcV = ssrc.getAttribute('ssrc'); var ssrcV = ssrc.getAttribute('ssrc');
ssrc2jid[ssrcV] = from; self.ssrc2jid[ssrcV] = from;
JingleSession.notReceivedSSRCs.push(ssrcV); JingleSession.notReceivedSSRCs.push(ssrcV);

View File

@ -417,6 +417,11 @@ var XMPP = {
}, },
getMembers: function () { getMembers: function () {
return connection.emuc.members; return connection.emuc.members;
},
getJidFromSSRC: function (ssrc) {
if(!connection)
return null;
return connection.emuc.ssrc2jid[ssrc];
} }
}; };