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

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 файла, в които са добавени 45 реда и са изтрити 41 реда
  1. 5
    15
      JitsiConference.js
  2. 7
    0
      modules/RTC/JitsiRemoteTrack.js
  3. 25
    3
      modules/RTC/RTC.js
  4. 0
    6
      modules/xmpp/ChatRoom.js
  5. 8
    17
      modules/xmpp/JingleSessionPC.js

+ 5
- 15
JitsiConference.js Целия файл

1053
         //FIXME: Maybe remove event should not be associated with the conference.
1053
         //FIXME: Maybe remove event should not be associated with the conference.
1054
         conference.statistics.addAudioLevelListener(function (ssrc, level) {
1054
         conference.statistics.addAudioLevelListener(function (ssrc, level) {
1055
             var userId = null;
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
                 return;
1059
                 return;
1059
 
1060
 
1060
-            conference.rtc.setAudioLevel(jid, level);
1061
+            conference.rtc.setAudioLevel(resource, level);
1061
         });
1062
         });
1062
         conference.statistics.addConnectionStatsListener(function (stats) {
1063
         conference.statistics.addConnectionStatsListener(function (stats) {
1063
             var ssrc2resolution = stats.resolution;
1064
             var ssrc2resolution = stats.resolution;
1074
                     return;
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
                 if (!id) {
1079
                 if (!id) {
1090
                     return;
1080
                     return;
1091
                 }
1081
                 }

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

71
     return false;
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
  * Changes the video type of the track
82
  * Changes the video type of the track
76
  * @param type the new video type("camera", "desktop")
83
  * @param type the new video type("camera", "desktop")

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

262
     this.localStreams.push(this.localVideo);
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
         return;
267
         return;
268
-    var resource = Strophe.getResourceFromJid(jid);
269
     if(this.remoteStreams[resource] && this.remoteStreams[resource][JitsiTrack.AUDIO])
268
     if(this.remoteStreams[resource] && this.remoteStreams[resource][JitsiTrack.AUDIO])
270
         this.remoteStreams[resource][JitsiTrack.AUDIO].setAudioLevel(audioLevel);
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
 module.exports = RTC;
295
 module.exports = RTC;

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

661
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
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
  * Returns true if the recording is supproted and false if not.
665
  * Returns true if the recording is supproted and false if not.
672
  */
666
  */

+ 8
- 17
modules/xmpp/JingleSessionPC.js Целия файл

40
     this.switchstreams = false;
40
     this.switchstreams = false;
41
     this.addingStreams = false;
41
     this.addingStreams = false;
42
 
42
 
43
-    this.wait = true;
44
     /**
43
     /**
45
      * A map that stores SSRCs of local streams
44
      * A map that stores SSRCs of local streams
46
      * @type {{}} maps media type('audio' or 'video') to SSRC number
45
      * @type {{}} maps media type('audio' or 'video') to SSRC number
47
      */
46
      */
48
     this.localStreamsSSRC = {};
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
     this.ssrcOwners = {};
56
     this.ssrcOwners = {};
50
-    this.ssrcVideoTypes = {};
51
 
57
 
52
     this.webrtcIceUdpDisable = !!this.service.options.webrtcIceUdpDisable;
58
     this.webrtcIceUdpDisable = !!this.service.options.webrtcIceUdpDisable;
53
     this.webrtcIceTcpDisable = !!this.service.options.webrtcIceTcpDisable;
59
     this.webrtcIceTcpDisable = !!this.service.options.webrtcIceTcpDisable;
557
     return this.localStreamsSSRC[mediaType];
563
     return this.localStreamsSSRC[mediaType];
558
 };
564
 };
559
 
565
 
560
-JingleSessionPC.prototype.getSsrcOwner = function (ssrc) {
561
-    return this.ssrcOwners[ssrc];
562
-};
563
-
564
 JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
566
 JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
565
     //logger.log('setting remote description... ', desctype);
567
     //logger.log('setting remote description... ', desctype);
566
     this.remoteSDP = new SDP('');
568
     this.remoteSDP = new SDP('');
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
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1470
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32

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