Преглед на файлове

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

release-8443
hristoterezov преди 10 години
родител
ревизия
cbe183f0f4
променени са 4 файла, в които са добавени 72 реда и са изтрити 6 реда
  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 Целия файл

1000
     this.videoType = data.videoType;
1000
     this.videoType = data.videoType;
1001
     this.ssrc = ssrc;
1001
     this.ssrc = ssrc;
1002
     this.muted = false;
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
     this.eventEmitter = eventEmitter;
1007
     this.eventEmitter = eventEmitter;
1004
     var self = this;
1008
     var self = this;
1005
     if(this.stream)
1009
     if(this.stream)
1389
 
1393
 
1390
 RTC.prototype.createRemoteStream = function (data, sid, thessrc) {
1394
 RTC.prototype.createRemoteStream = function (data, sid, thessrc) {
1391
     var remoteStream = new JitsiRemoteTrack(this, data, sid, thessrc,
1395
     var remoteStream = new JitsiRemoteTrack(this, data, sid, thessrc,
1392
-        RTCBrowserType.getBrowserType(), this.eventEmitter);
1396
+        this.eventEmitter);
1393
     if(!data.peerjid)
1397
     if(!data.peerjid)
1394
         return;
1398
         return;
1395
     var jid = data.peerjid;
1399
     var jid = data.peerjid;
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
     this.eventEmitter = new EventEmitter();
4180
     this.eventEmitter = new EventEmitter();
4164
     this.xmpp = XMPP;
4181
     this.xmpp = XMPP;
4165
     this.connection = connection;
4182
     this.connection = connection;
4179
     this.initPresenceMap();
4196
     this.initPresenceMap();
4180
     this.session = null;
4197
     this.session = null;
4181
     var self = this;
4198
     var self = this;
4199
+    this.lastPresences = {};
4182
 }
4200
 }
4183
 
4201
 
4184
 ChatRoom.prototype.initPresenceMap = function () {
4202
 ChatRoom.prototype.initPresenceMap = function () {
4293
     $(pres).find(">x").remove();
4311
     $(pres).find(">x").remove();
4294
     var nodes = [];
4312
     var nodes = [];
4295
     parser.packet2JSON(pres, nodes);
4313
     parser.packet2JSON(pres, nodes);
4314
+    this.lastPresences[from] = nodes;
4296
     for(var i = 0; i < nodes.length; i++)
4315
     for(var i = 0; i < nodes.length; i++)
4297
     {
4316
     {
4298
         var node = nodes[i];
4317
         var node = nodes[i];
4399
 
4418
 
4400
 ChatRoom.prototype.onParticipantLeft = function (jid) {
4419
 ChatRoom.prototype.onParticipantLeft = function (jid) {
4401
 
4420
 
4421
+    delete this.lastPresences[jid];
4402
     this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
4422
     this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
4403
 
4423
 
4404
     this.moderator.onMucMemberLeft(jid);
4424
     this.moderator.onMucMemberLeft(jid);
4690
 };
4710
 };
4691
 
4711
 
4692
 ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
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
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
4726
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
4694
 }
4727
 }
4695
 
4728
 

+ 4
- 0
modules/RTC/JitsiRemoteTrack.js Целия файл

19
     this.videoType = data.videoType;
19
     this.videoType = data.videoType;
20
     this.ssrc = ssrc;
20
     this.ssrc = ssrc;
21
     this.muted = false;
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
     this.eventEmitter = eventEmitter;
26
     this.eventEmitter = eventEmitter;
23
     var self = this;
27
     var self = this;
24
     if(this.stream)
28
     if(this.stream)

+ 1
- 1
modules/RTC/RTC.js Целия файл

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

+ 31
- 2
modules/xmpp/ChatRoom.js Целия файл

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
     this.eventEmitter = new EventEmitter();
57
     this.eventEmitter = new EventEmitter();
45
     this.xmpp = XMPP;
58
     this.xmpp = XMPP;
46
     this.connection = connection;
59
     this.connection = connection;
60
     this.initPresenceMap();
73
     this.initPresenceMap();
61
     this.session = null;
74
     this.session = null;
62
     var self = this;
75
     var self = this;
76
+    this.lastPresences = {};
63
 }
77
 }
64
 
78
 
65
 ChatRoom.prototype.initPresenceMap = function () {
79
 ChatRoom.prototype.initPresenceMap = function () {
174
     $(pres).find(">x").remove();
188
     $(pres).find(">x").remove();
175
     var nodes = [];
189
     var nodes = [];
176
     parser.packet2JSON(pres, nodes);
190
     parser.packet2JSON(pres, nodes);
191
+    this.lastPresences[from] = nodes;
177
     for(var i = 0; i < nodes.length; i++)
192
     for(var i = 0; i < nodes.length; i++)
178
     {
193
     {
179
         var node = nodes[i];
194
         var node = nodes[i];
280
 
295
 
281
 ChatRoom.prototype.onParticipantLeft = function (jid) {
296
 ChatRoom.prototype.onParticipantLeft = function (jid) {
282
 
297
 
298
+    delete this.lastPresences[jid];
283
     this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
299
     this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
284
 
300
 
285
     this.moderator.onMucMemberLeft(jid);
301
     this.moderator.onMucMemberLeft(jid);
571
 };
587
 };
572
 
588
 
573
 ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
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
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
603
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
575
 }
604
 }
576
 
605
 

Loading…
Отказ
Запис