Stores info from last presence received for participant and dispatch it if any on creating remote streams to reflect video muted state. Race condition detected by tests where we miss presence info cause stream was not created when we receive presence packet.

This commit is contained in:
damencho 2015-09-02 16:05:00 -05:00
parent 59b26fdf07
commit 6b94d3fe47
6 changed files with 20054 additions and 19991 deletions

View File

@ -20,7 +20,7 @@
<script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
<script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
<script src="interface_config.js?v=5"></script>
<script src="libs/app.bundle.js?v=133"></script>
<script src="libs/app.bundle.js?v=134"></script>
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
<link rel="stylesheet" href="css/font.css?v=7"/>
<link rel="stylesheet" href="css/toastr.css?v=1">

File diff suppressed because it is too large Load Diff

View File

@ -8,10 +8,11 @@ var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
* the peerjid, etc.
* @param sid the session id
* @param ssrc the ssrc corresponding to this MediaStream
* @param mute the whether this MediaStream is muted
*
* @constructor
*/
function MediaStream(data, sid, ssrc, browser, eventEmitter) {
function MediaStream(data, sid, ssrc, browser, eventEmitter, mute) {
// XXX(gp) to minimize headaches in the future, we should build our
// abstractions around tracks and not streams. ORTC is track based API.
@ -30,7 +31,7 @@ function MediaStream(data, sid, ssrc, browser, eventEmitter) {
this.ssrc = ssrc;
this.type = (this.stream.getVideoTracks().length > 0)?
MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
this.muted = false;
this.muted = mute;
this.eventEmitter = eventEmitter;
}

View File

@ -96,9 +96,18 @@ var RTC = {
}
},
createRemoteStream: function (data, sid, thessrc) {
var remoteStream = new MediaStream(data, sid, thessrc,
RTCBrowserType.getBrowserType(), eventEmitter);
var jid = data.peerjid || APP.xmpp.myJid();
// check the video muted state from last stored presence if any
var muted = false;
var pres = APP.xmpp.getLastPresence(jid);
if(pres != null && pres.videoMuted) {
muted = pres.videoMuted;
}
var remoteStream = new MediaStream(data, sid, thessrc,
RTCBrowserType.getBrowserType(), eventEmitter, muted);
if(!this.remoteStreams[jid]) {
this.remoteStreams[jid] = {};
}

View File

@ -14,6 +14,7 @@ module.exports = function(XMPP, eventEmitter) {
list_members: [], // so we can elect a new focus
presMap: {},
preziMap: {},
lastPresenceMap: {},
joined: false,
isOwner: false,
role: null,
@ -135,6 +136,9 @@ module.exports = function(XMPP, eventEmitter) {
$(document).trigger('presentationremoved.muc', [from, url]);
}
// store the last presence for participant
this.lastPresenceMap[from] = {};
// Parse audio info tag.
var audioMuted = $(pres).find('>audiomuted');
if (audioMuted.length) {
@ -145,8 +149,9 @@ module.exports = function(XMPP, eventEmitter) {
// Parse video info tag.
var videoMuted = $(pres).find('>videomuted');
if (videoMuted.length) {
eventEmitter.emit(XMPPEvents.PARTICIPANT_VIDEO_MUTED,
from, (videoMuted.text() === "true"));
var value = (videoMuted.text() === "true");
this.lastPresenceMap[from].videoMuted = value;
eventEmitter.emit(XMPPEvents.PARTICIPANT_VIDEO_MUTED, from, value);
}
var startMuted = $(pres).find('>startmuted');
@ -309,6 +314,11 @@ module.exports = function(XMPP, eventEmitter) {
eventEmitter.emit(XMPPEvents.KICKED);
}
}
if (this.lastPresenceMap[from] != null) {
delete this.lastPresenceMap[from];
}
return true;
},
onPresenceError: function (pres) {

View File

@ -336,6 +336,11 @@ var XMPP = {
return null;
return Strophe.getResourceFromJid(connection.emuc.myroomjid);
},
getLastPresence: function (from) {
if(!connection)
return null;
return connection.emuc.lastPresenceMap[from];
},
disposeConference: function (onUnload) {
var handler = connection.jingle.activecall;
if (handler && handler.peerconnection) {