Fixes race condition for the mute status for the remote tracks.
This commit is contained in:
parent
338f79127b
commit
bf9d580dae
|
@ -1000,6 +1000,10 @@ function JitsiRemoteTrack(RTC, data, sid, ssrc, eventEmitter) {
|
|||
this.videoType = data.videoType;
|
||||
this.ssrc = ssrc;
|
||||
this.muted = false;
|
||||
if((this.type === JitsiTrack.AUDIO && data.audiomuted)
|
||||
|| (this.type === JitsiTrack.VIDEO && data.videomuted)) {
|
||||
this.muted = true
|
||||
}
|
||||
this.eventEmitter = eventEmitter;
|
||||
var self = this;
|
||||
if(this.stream)
|
||||
|
@ -1389,7 +1393,7 @@ RTC.prototype.removeLocalStream = function (stream) {
|
|||
|
||||
RTC.prototype.createRemoteStream = function (data, sid, thessrc) {
|
||||
var remoteStream = new JitsiRemoteTrack(this, data, sid, thessrc,
|
||||
RTCBrowserType.getBrowserType(), this.eventEmitter);
|
||||
this.eventEmitter);
|
||||
if(!data.peerjid)
|
||||
return;
|
||||
var jid = data.peerjid;
|
||||
|
@ -4158,8 +4162,21 @@ var parser = {
|
|||
}
|
||||
};
|
||||
|
||||
function ChatRoom(connection, jid, password, XMPP, options)
|
||||
{
|
||||
/**
|
||||
* Returns array of JS objects from the presence JSON associated with the passed nodeName
|
||||
* @param pres the presence JSON
|
||||
* @param nodeName the name of the node (videomuted, audiomuted, etc)
|
||||
*/
|
||||
function filterNodeFromPresenceJSON(pres, nodeName){
|
||||
var res = [];
|
||||
for(var i = 0; i < pres.length; i++)
|
||||
if(pres[i].tagName === nodeName)
|
||||
res.push(pres[i]);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function ChatRoom(connection, jid, password, XMPP, options) {
|
||||
this.eventEmitter = new EventEmitter();
|
||||
this.xmpp = XMPP;
|
||||
this.connection = connection;
|
||||
|
@ -4179,6 +4196,7 @@ function ChatRoom(connection, jid, password, XMPP, options)
|
|||
this.initPresenceMap();
|
||||
this.session = null;
|
||||
var self = this;
|
||||
this.lastPresences = {};
|
||||
}
|
||||
|
||||
ChatRoom.prototype.initPresenceMap = function () {
|
||||
|
@ -4293,6 +4311,7 @@ ChatRoom.prototype.onPresence = function (pres) {
|
|||
$(pres).find(">x").remove();
|
||||
var nodes = [];
|
||||
parser.packet2JSON(pres, nodes);
|
||||
this.lastPresences[from] = nodes;
|
||||
for(var i = 0; i < nodes.length; i++)
|
||||
{
|
||||
var node = nodes[i];
|
||||
|
@ -4399,6 +4418,7 @@ ChatRoom.prototype.setSubject = function (subject) {
|
|||
|
||||
ChatRoom.prototype.onParticipantLeft = function (jid) {
|
||||
|
||||
delete this.lastPresences[jid];
|
||||
this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
|
||||
|
||||
this.moderator.onMucMemberLeft(jid);
|
||||
|
@ -4690,6 +4710,19 @@ ChatRoom.prototype.removeListener = function (type, listener) {
|
|||
};
|
||||
|
||||
ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
|
||||
if(this.lastPresences[data.peerjid])
|
||||
{
|
||||
var pres = this.lastPresences[data.peerjid];
|
||||
var audiomuted = filterNodeFromPresenceJSON(pres, "audiomuted");
|
||||
var videomuted = filterNodeFromPresenceJSON(pres, "videomuted");
|
||||
data.videomuted = ((videomuted.length > 0
|
||||
&& videomuted[0]
|
||||
&& videomuted[0]["value"] === "true")? true : false);
|
||||
data.audiomuted = ((audiomuted.length > 0
|
||||
&& audiomuted[0]
|
||||
&& audiomuted[0]["value"] === "true")? true : false);
|
||||
}
|
||||
|
||||
this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ function JitsiRemoteTrack(RTC, data, sid, ssrc, eventEmitter) {
|
|||
this.videoType = data.videoType;
|
||||
this.ssrc = ssrc;
|
||||
this.muted = false;
|
||||
if((this.type === JitsiTrack.AUDIO && data.audiomuted)
|
||||
|| (this.type === JitsiTrack.VIDEO && data.videomuted)) {
|
||||
this.muted = true
|
||||
}
|
||||
this.eventEmitter = eventEmitter;
|
||||
var self = this;
|
||||
if(this.stream)
|
||||
|
|
|
@ -184,7 +184,7 @@ RTC.prototype.removeLocalStream = function (stream) {
|
|||
|
||||
RTC.prototype.createRemoteStream = function (data, sid, thessrc) {
|
||||
var remoteStream = new JitsiRemoteTrack(this, data, sid, thessrc,
|
||||
RTCBrowserType.getBrowserType(), this.eventEmitter);
|
||||
this.eventEmitter);
|
||||
if(!data.peerjid)
|
||||
return;
|
||||
var jid = data.peerjid;
|
||||
|
|
|
@ -39,8 +39,21 @@ var parser = {
|
|||
}
|
||||
};
|
||||
|
||||
function ChatRoom(connection, jid, password, XMPP, options)
|
||||
{
|
||||
/**
|
||||
* Returns array of JS objects from the presence JSON associated with the passed nodeName
|
||||
* @param pres the presence JSON
|
||||
* @param nodeName the name of the node (videomuted, audiomuted, etc)
|
||||
*/
|
||||
function filterNodeFromPresenceJSON(pres, nodeName){
|
||||
var res = [];
|
||||
for(var i = 0; i < pres.length; i++)
|
||||
if(pres[i].tagName === nodeName)
|
||||
res.push(pres[i]);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function ChatRoom(connection, jid, password, XMPP, options) {
|
||||
this.eventEmitter = new EventEmitter();
|
||||
this.xmpp = XMPP;
|
||||
this.connection = connection;
|
||||
|
@ -60,6 +73,7 @@ function ChatRoom(connection, jid, password, XMPP, options)
|
|||
this.initPresenceMap();
|
||||
this.session = null;
|
||||
var self = this;
|
||||
this.lastPresences = {};
|
||||
}
|
||||
|
||||
ChatRoom.prototype.initPresenceMap = function () {
|
||||
|
@ -174,6 +188,7 @@ ChatRoom.prototype.onPresence = function (pres) {
|
|||
$(pres).find(">x").remove();
|
||||
var nodes = [];
|
||||
parser.packet2JSON(pres, nodes);
|
||||
this.lastPresences[from] = nodes;
|
||||
for(var i = 0; i < nodes.length; i++)
|
||||
{
|
||||
var node = nodes[i];
|
||||
|
@ -280,6 +295,7 @@ ChatRoom.prototype.setSubject = function (subject) {
|
|||
|
||||
ChatRoom.prototype.onParticipantLeft = function (jid) {
|
||||
|
||||
delete this.lastPresences[jid];
|
||||
this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
|
||||
|
||||
this.moderator.onMucMemberLeft(jid);
|
||||
|
@ -571,6 +587,19 @@ ChatRoom.prototype.removeListener = function (type, listener) {
|
|||
};
|
||||
|
||||
ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
|
||||
if(this.lastPresences[data.peerjid])
|
||||
{
|
||||
var pres = this.lastPresences[data.peerjid];
|
||||
var audiomuted = filterNodeFromPresenceJSON(pres, "audiomuted");
|
||||
var videomuted = filterNodeFromPresenceJSON(pres, "videomuted");
|
||||
data.videomuted = ((videomuted.length > 0
|
||||
&& videomuted[0]
|
||||
&& videomuted[0]["value"] === "true")? true : false);
|
||||
data.audiomuted = ((audiomuted.length > 0
|
||||
&& audiomuted[0]
|
||||
&& audiomuted[0]["value"] === "true")? true : false);
|
||||
}
|
||||
|
||||
this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue