Ver código fonte

Fixes race condition for the mute status for the remote tracks.

release-8443
hristoterezov 10 anos atrás
pai
commit
cbe183f0f4
4 arquivos alterados com 72 adições e 6 exclusões
  1. 36
    3
      lib-jitsi-meet.js
  2. 4
    0
      modules/RTC/JitsiRemoteTrack.js
  3. 1
    1
      modules/RTC/RTC.js
  4. 31
    2
      modules/xmpp/ChatRoom.js

+ 36
- 3
lib-jitsi-meet.js Ver arquivo

@@ -1000,6 +1000,10 @@ function JitsiRemoteTrack(RTC, data, sid, ssrc, eventEmitter) {
1000 1000
     this.videoType = data.videoType;
1001 1001
     this.ssrc = ssrc;
1002 1002
     this.muted = false;
1003
+    if((this.type === JitsiTrack.AUDIO && data.audiomuted)
1004
+      || (this.type === JitsiTrack.VIDEO && data.videomuted)) {
1005
+        this.muted = true
1006
+    }
1003 1007
     this.eventEmitter = eventEmitter;
1004 1008
     var self = this;
1005 1009
     if(this.stream)
@@ -1389,7 +1393,7 @@ RTC.prototype.removeLocalStream = function (stream) {
1389 1393
 
1390 1394
 RTC.prototype.createRemoteStream = function (data, sid, thessrc) {
1391 1395
     var remoteStream = new JitsiRemoteTrack(this, data, sid, thessrc,
1392
-        RTCBrowserType.getBrowserType(), this.eventEmitter);
1396
+        this.eventEmitter);
1393 1397
     if(!data.peerjid)
1394 1398
         return;
1395 1399
     var jid = data.peerjid;
@@ -4158,8 +4162,21 @@ var parser = {
4158 4162
     }
4159 4163
 };
4160 4164
 
4161
-function ChatRoom(connection, jid, password, XMPP, options)
4162
-{
4165
+/**
4166
+ * Returns array of JS objects from the presence JSON associated with the passed nodeName
4167
+ * @param pres the presence JSON
4168
+ * @param nodeName the name of the node (videomuted, audiomuted, etc)
4169
+ */
4170
+function filterNodeFromPresenceJSON(pres, nodeName){
4171
+    var res = [];
4172
+    for(var i = 0; i < pres.length; i++)
4173
+        if(pres[i].tagName === nodeName)
4174
+            res.push(pres[i]);
4175
+
4176
+    return res;
4177
+}
4178
+
4179
+function ChatRoom(connection, jid, password, XMPP, options) {
4163 4180
     this.eventEmitter = new EventEmitter();
4164 4181
     this.xmpp = XMPP;
4165 4182
     this.connection = connection;
@@ -4179,6 +4196,7 @@ function ChatRoom(connection, jid, password, XMPP, options)
4179 4196
     this.initPresenceMap();
4180 4197
     this.session = null;
4181 4198
     var self = this;
4199
+    this.lastPresences = {};
4182 4200
 }
4183 4201
 
4184 4202
 ChatRoom.prototype.initPresenceMap = function () {
@@ -4293,6 +4311,7 @@ ChatRoom.prototype.onPresence = function (pres) {
4293 4311
     $(pres).find(">x").remove();
4294 4312
     var nodes = [];
4295 4313
     parser.packet2JSON(pres, nodes);
4314
+    this.lastPresences[from] = nodes;
4296 4315
     for(var i = 0; i < nodes.length; i++)
4297 4316
     {
4298 4317
         var node = nodes[i];
@@ -4399,6 +4418,7 @@ ChatRoom.prototype.setSubject = function (subject) {
4399 4418
 
4400 4419
 ChatRoom.prototype.onParticipantLeft = function (jid) {
4401 4420
 
4421
+    delete this.lastPresences[jid];
4402 4422
     this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
4403 4423
 
4404 4424
     this.moderator.onMucMemberLeft(jid);
@@ -4690,6 +4710,19 @@ ChatRoom.prototype.removeListener = function (type, listener) {
4690 4710
 };
4691 4711
 
4692 4712
 ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
4713
+    if(this.lastPresences[data.peerjid])
4714
+    {
4715
+        var pres = this.lastPresences[data.peerjid];
4716
+        var audiomuted = filterNodeFromPresenceJSON(pres, "audiomuted");
4717
+        var videomuted = filterNodeFromPresenceJSON(pres, "videomuted");
4718
+        data.videomuted = ((videomuted.length > 0
4719
+            && videomuted[0]
4720
+            && videomuted[0]["value"] === "true")? true : false);
4721
+        data.audiomuted = ((audiomuted.length > 0
4722
+            && audiomuted[0]
4723
+            && audiomuted[0]["value"] === "true")? true : false);
4724
+    }
4725
+
4693 4726
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
4694 4727
 }
4695 4728
 

+ 4
- 0
modules/RTC/JitsiRemoteTrack.js Ver arquivo

@@ -19,6 +19,10 @@ function JitsiRemoteTrack(RTC, data, sid, ssrc, eventEmitter) {
19 19
     this.videoType = data.videoType;
20 20
     this.ssrc = ssrc;
21 21
     this.muted = false;
22
+    if((this.type === JitsiTrack.AUDIO && data.audiomuted)
23
+      || (this.type === JitsiTrack.VIDEO && data.videomuted)) {
24
+        this.muted = true
25
+    }
22 26
     this.eventEmitter = eventEmitter;
23 27
     var self = this;
24 28
     if(this.stream)

+ 1
- 1
modules/RTC/RTC.js Ver arquivo

@@ -184,7 +184,7 @@ RTC.prototype.removeLocalStream = function (stream) {
184 184
 
185 185
 RTC.prototype.createRemoteStream = function (data, sid, thessrc) {
186 186
     var remoteStream = new JitsiRemoteTrack(this, data, sid, thessrc,
187
-        RTCBrowserType.getBrowserType(), this.eventEmitter);
187
+        this.eventEmitter);
188 188
     if(!data.peerjid)
189 189
         return;
190 190
     var jid = data.peerjid;

+ 31
- 2
modules/xmpp/ChatRoom.js Ver arquivo

@@ -39,8 +39,21 @@ var parser = {
39 39
     }
40 40
 };
41 41
 
42
-function ChatRoom(connection, jid, password, XMPP, options)
43
-{
42
+/**
43
+ * Returns array of JS objects from the presence JSON associated with the passed nodeName
44
+ * @param pres the presence JSON
45
+ * @param nodeName the name of the node (videomuted, audiomuted, etc)
46
+ */
47
+function filterNodeFromPresenceJSON(pres, nodeName){
48
+    var res = [];
49
+    for(var i = 0; i < pres.length; i++)
50
+        if(pres[i].tagName === nodeName)
51
+            res.push(pres[i]);
52
+
53
+    return res;
54
+}
55
+
56
+function ChatRoom(connection, jid, password, XMPP, options) {
44 57
     this.eventEmitter = new EventEmitter();
45 58
     this.xmpp = XMPP;
46 59
     this.connection = connection;
@@ -60,6 +73,7 @@ function ChatRoom(connection, jid, password, XMPP, options)
60 73
     this.initPresenceMap();
61 74
     this.session = null;
62 75
     var self = this;
76
+    this.lastPresences = {};
63 77
 }
64 78
 
65 79
 ChatRoom.prototype.initPresenceMap = function () {
@@ -174,6 +188,7 @@ ChatRoom.prototype.onPresence = function (pres) {
174 188
     $(pres).find(">x").remove();
175 189
     var nodes = [];
176 190
     parser.packet2JSON(pres, nodes);
191
+    this.lastPresences[from] = nodes;
177 192
     for(var i = 0; i < nodes.length; i++)
178 193
     {
179 194
         var node = nodes[i];
@@ -280,6 +295,7 @@ ChatRoom.prototype.setSubject = function (subject) {
280 295
 
281 296
 ChatRoom.prototype.onParticipantLeft = function (jid) {
282 297
 
298
+    delete this.lastPresences[jid];
283 299
     this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
284 300
 
285 301
     this.moderator.onMucMemberLeft(jid);
@@ -571,6 +587,19 @@ ChatRoom.prototype.removeListener = function (type, listener) {
571 587
 };
572 588
 
573 589
 ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
590
+    if(this.lastPresences[data.peerjid])
591
+    {
592
+        var pres = this.lastPresences[data.peerjid];
593
+        var audiomuted = filterNodeFromPresenceJSON(pres, "audiomuted");
594
+        var videomuted = filterNodeFromPresenceJSON(pres, "videomuted");
595
+        data.videomuted = ((videomuted.length > 0
596
+            && videomuted[0]
597
+            && videomuted[0]["value"] === "true")? true : false);
598
+        data.audiomuted = ((audiomuted.length > 0
599
+            && audiomuted[0]
600
+            && audiomuted[0]["value"] === "true")? true : false);
601
+    }
602
+
574 603
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
575 604
 }
576 605
 

Carregando…
Cancelar
Salvar