Переглянути джерело

Leaves ssrcOwners for local use in JingleSessionPC, uses remote streams from RTC for ssrc mapping to resources. For local video/audio stream ssrc to resource we use JingleSessionPC.localStreamsSSRC.

dev1
damencho 9 роки тому
джерело
коміт
f3cb890a27

+ 5
- 15
JitsiConference.js Переглянути файл

@@ -1053,11 +1053,12 @@ function setupListeners(conference) {
1053 1053
         //FIXME: Maybe remove event should not be associated with the conference.
1054 1054
         conference.statistics.addAudioLevelListener(function (ssrc, level) {
1055 1055
             var userId = null;
1056
-            var jid = conference.room.getJidBySSRC(ssrc);
1057
-            if (!jid)
1056
+
1057
+            var resource = conference.rtc.getResourceBySSRC(ssrc);
1058
+            if (!resource)
1058 1059
                 return;
1059 1060
 
1060
-            conference.rtc.setAudioLevel(jid, level);
1061
+            conference.rtc.setAudioLevel(resource, level);
1061 1062
         });
1062 1063
         conference.statistics.addConnectionStatsListener(function (stats) {
1063 1064
             var ssrc2resolution = stats.resolution;
@@ -1074,18 +1075,7 @@ function setupListeners(conference) {
1074 1075
                     return;
1075 1076
                 }
1076 1077
 
1077
-                var jid = conference.room.getJidBySSRC(ssrc);
1078
-                if (!jid) {
1079
-                    return;
1080
-                }
1081
-
1082
-                var id;
1083
-                if (jid === conference.room.session.me) {
1084
-                    id = conference.myUserId();
1085
-                } else {
1086
-                    id = Strophe.getResourceFromJid(jid);
1087
-                }
1088
-
1078
+                var id = conference.rtc.getResourceBySSRC(ssrc);
1089 1079
                 if (!id) {
1090 1080
                     return;
1091 1081
                 }

+ 7
- 0
modules/RTC/JitsiRemoteTrack.js Переглянути файл

@@ -71,6 +71,13 @@ JitsiRemoteTrack.prototype.isLocal = function () {
71 71
     return false;
72 72
 };
73 73
 
74
+/**
75
+ * Return false;
76
+ */
77
+JitsiRemoteTrack.prototype.getSSRC = function () {
78
+    return this.ssrc;
79
+};
80
+
74 81
 /**
75 82
  * Changes the video type of the track
76 83
  * @param type the new video type("camera", "desktop")

+ 25
- 3
modules/RTC/RTC.js Переглянути файл

@@ -262,12 +262,34 @@ RTC.prototype.switchVideoStreams = function (newStream) {
262 262
     this.localStreams.push(this.localVideo);
263 263
 };
264 264
 
265
-RTC.prototype.setAudioLevel = function (jid, audioLevel) {
266
-    if(!jid)
265
+RTC.prototype.setAudioLevel = function (resource, audioLevel) {
266
+    if(!resource)
267 267
         return;
268
-    var resource = Strophe.getResourceFromJid(jid);
269 268
     if(this.remoteStreams[resource] && this.remoteStreams[resource][JitsiTrack.AUDIO])
270 269
         this.remoteStreams[resource][JitsiTrack.AUDIO].setAudioLevel(audioLevel);
271 270
 };
272 271
 
272
+/**
273
+ * Searches in localStreams(session stores ssrc for audio and video) and
274
+ * remoteStreams for the ssrc and returns the corresponding resource.
275
+ * @param ssrc the ssrc to check.
276
+ */
277
+RTC.prototype.getResourceBySSRC = function (ssrc) {
278
+    if(ssrc == this.room.session.localStreamsSSRC.video
279
+        || ssrc == this.room.session.localStreamsSSRC.audio) {
280
+        return Strophe.getResourceFromJid(this.room.myroomjid);
281
+    }
282
+
283
+    var resultResource = null;
284
+    $.each(this.remoteStreams, function (resource, remoteTracks) {
285
+        if((remoteTracks[JitsiTrack.AUDIO]
286
+                && remoteTracks[JitsiTrack.AUDIO].getSSRC() == ssrc)
287
+            || (remoteTracks[JitsiTrack.VIDEO]
288
+                && remoteTracks[JitsiTrack.AUDIO].getSSRC() == ssrc))
289
+            resultResource = resource;
290
+    });
291
+
292
+    return resultResource;
293
+};
294
+
273 295
 module.exports = RTC;

+ 0
- 6
modules/xmpp/ChatRoom.js Переглянути файл

@@ -661,12 +661,6 @@ ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
661 661
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
662 662
 };
663 663
 
664
-ChatRoom.prototype.getJidBySSRC = function (ssrc) {
665
-    if (!this.session)
666
-        return null;
667
-    return this.session.getSsrcOwner(ssrc);
668
-};
669
-
670 664
 /**
671 665
  * Returns true if the recording is supproted and false if not.
672 666
  */

+ 8
- 17
modules/xmpp/JingleSessionPC.js Переглянути файл

@@ -40,14 +40,20 @@ function JingleSessionPC(me, sid, connection, service) {
40 40
     this.switchstreams = false;
41 41
     this.addingStreams = false;
42 42
 
43
-    this.wait = true;
44 43
     /**
45 44
      * A map that stores SSRCs of local streams
46 45
      * @type {{}} maps media type('audio' or 'video') to SSRC number
47 46
      */
48 47
     this.localStreamsSSRC = {};
48
+    /**
49
+     * A map that stores SSRCs of remote streams. And is used only locally
50
+     * We store the mapping when jingle is received, and later is used
51
+     * onaddstream webrtc event where we have only the ssrc
52
+     * FIXME: This map got filled and never cleaned and can grow durring long
53
+     * conference
54
+     * @type {{}} maps SSRC number to jid
55
+     */
49 56
     this.ssrcOwners = {};
50
-    this.ssrcVideoTypes = {};
51 57
 
52 58
     this.webrtcIceUdpDisable = !!this.service.options.webrtcIceUdpDisable;
53 59
     this.webrtcIceTcpDisable = !!this.service.options.webrtcIceTcpDisable;
@@ -557,10 +563,6 @@ JingleSessionPC.prototype.getLocalSSRC = function (mediaType) {
557 563
     return this.localStreamsSSRC[mediaType];
558 564
 };
559 565
 
560
-JingleSessionPC.prototype.getSsrcOwner = function (ssrc) {
561
-    return this.ssrcOwners[ssrc];
562
-};
563
-
564 566
 JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
565 567
     //logger.log('setting remote description... ', desctype);
566 568
     this.remoteSDP = new SDP('');
@@ -1463,17 +1465,6 @@ JingleSessionPC.prototype.setLocalDescription = function () {
1463 1465
         }
1464 1466
 
1465 1467
     });
1466
-
1467
-    logger.log('new ssrcs', newssrcs);
1468
-
1469
-    // Bind us as local SSRCs owner
1470
-    if (newssrcs.length > 0) {
1471
-        for (i = 0; i < newssrcs.length; i++) {
1472
-            var ssrc = newssrcs[i].ssrc;
1473
-            var myJid = self.me;
1474
-            self.ssrcOwners[ssrc] = myJid;
1475
-        }
1476
-    }
1477 1468
 }
1478 1469
 
1479 1470
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32

Завантаження…
Відмінити
Зберегти