ソースを参照

Removes some global variables. Fixes recording.

master
hristoterezov 10年前
コミット
6c4a5bd2bc

+ 0
- 16
app.js ファイルの表示

@@ -1,23 +1,7 @@
1 1
 /* jshint -W117 */
2 2
 /* application specific logic */
3 3
 var nickname = null;
4
-var focusMucJid = null;
5 4
 var ssrc2jid = {};
6
-//TODO: this array must be removed when firefox implement multistream support
7
-var notReceivedSSRCs = [];
8
-
9
-var jid2Ssrc = {};
10
-
11
-/**
12
- * Indicates whether ssrc is camera video or desktop stream.
13
- * FIXME: remove those maps
14
- */
15
-var ssrc2videoType = {};
16
-/**
17
- * Currently focused video "src"(displayed in large video).
18
- * @type {String}
19
- */
20
-var focusedVideoInfo = null;
21 5
 
22 6
 function init() {
23 7
 

+ 5
- 5
index.html ファイルの表示

@@ -27,13 +27,13 @@
27 27
     <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
28 28
     <script src="libs/modules/simulcast.bundle.js?v=4"></script>
29 29
     <script src="libs/modules/connectionquality.bundle.js?v=2"></script>
30
-    <script src="libs/modules/UI.bundle.js?v=6"></script>
31
-    <script src="libs/modules/statistics.bundle.js?v=2"></script>
32
-    <script src="libs/modules/RTC.bundle.js?v=5"></script>
30
+    <script src="libs/modules/UI.bundle.js?v=7"></script>
31
+    <script src="libs/modules/statistics.bundle.js?v=3"></script>
32
+    <script src="libs/modules/RTC.bundle.js?v=6"></script>
33 33
     <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
34 34
     <script src="util.js?v=7"></script><!-- utility functions -->
35
-    <script src="libs/modules/xmpp.bundle.js?v=1"></script>
36
-    <script src="app.js?v=27"></script><!-- application logic -->
35
+    <script src="libs/modules/xmpp.bundle.js?v=2"></script>
36
+    <script src="app.js?v=28"></script><!-- application logic -->
37 37
     <script src="libs/modules/API.bundle.js?v=1"></script>
38 38
 
39 39
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->

+ 46
- 4
libs/modules/RTC.bundle.js ファイルの表示

@@ -240,11 +240,12 @@ module.exports = DataChannels;
240 240
 },{}],2:[function(require,module,exports){
241 241
 //var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
242 242
 
243
-function LocalStream(stream, type, eventEmitter)
243
+function LocalStream(stream, type, eventEmitter, videoType)
244 244
 {
245 245
     this.stream = stream;
246 246
     this.eventEmitter = eventEmitter;
247 247
     this.type = type;
248
+    this.videoType = videoType;
248 249
     var self = this;
249 250
     if(type == "audio")
250 251
     {
@@ -359,6 +360,7 @@ function MediaStream(data, sid, ssrc, browser) {
359 360
     this.ssrc = ssrc;
360 361
     this.type = (this.stream.getVideoTracks().length > 0)?
361 362
         MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
363
+    this.videoType = null;
362 364
     this.muted = false;
363 365
     if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
364 366
     {
@@ -493,6 +495,20 @@ var RTC = {
493 495
             function (stream, isUsingScreenStream, callback) {
494 496
                 self.changeLocalVideo(stream, isUsingScreenStream, callback);
495 497
             }, DesktopSharingEventTypes.NEW_STREAM_CREATED);
498
+        xmpp.addListener(XMPPEvents.CHANGED_STREAMS, function (jid, changedStreams) {
499
+            for(var i = 0; i < changedStreams.length; i++) {
500
+                var type = changedStreams[i].type;
501
+                if (type != "audio") {
502
+                    var peerStreams = self.remoteStreams[jid];
503
+                    if(!peerStreams)
504
+                        continue;
505
+                    var videoStream = peerStreams[MediaStreamType.VIDEO_TYPE];
506
+                    if(!videoStream)
507
+                        continue;
508
+                    videoStream.videoType = changedStreams[i].type;
509
+                }
510
+            }
511
+        })
496 512
         this.rtcUtils = new RTCUtils(this);
497 513
         this.rtcUtils.obtainAudioAndVideoPermissions();
498 514
     },
@@ -529,13 +545,39 @@ var RTC = {
529 545
     },
530 546
     changeLocalVideo: function (stream, isUsingScreenStream, callback) {
531 547
         var oldStream = this.localVideo.getOriginalStream();
532
-        var type = (isUsingScreenStream? "desktop" : "video");
533
-        RTC.localVideo = this.createLocalStream(stream, type, true);
548
+        var type = (isUsingScreenStream? "screen" : "video");
549
+        RTC.localVideo = this.createLocalStream(stream, "video", true, type);
534 550
         // Stop the stream to trigger onended event for old stream
535 551
         oldStream.stop();
536 552
         xmpp.switchStreams(stream, oldStream,callback);
537
-    }
553
+    },
554
+    /**
555
+     * Checks if video identified by given src is desktop stream.
556
+     * @param videoSrc eg.
557
+     * blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
558
+     * @returns {boolean}
559
+     */
560
+    isVideoSrcDesktop: function (jid) {
561
+        if(!jid)
562
+            return false;
563
+        var isDesktop = false;
564
+        var stream = null;
565
+        if (xmpp.myJid() &&
566
+            xmpp.myResource() === jid) {
567
+            // local video
568
+            stream = this.localVideo;
569
+        } else {
570
+            var peerStreams = this.remoteStreams[jid];
571
+            if(!peerStreams)
572
+                return false;
573
+            stream = peerStreams[MediaStreamType.VIDEO_TYPE];
574
+        }
538 575
 
576
+        if(stream)
577
+            isDesktop = (stream.videoType === "screen");
578
+
579
+        return isDesktop;
580
+    }
539 581
 };
540 582
 
541 583
 module.exports = RTC;

+ 18
- 62
libs/modules/UI.bundle.js ファイルの表示

@@ -59,9 +59,6 @@ function streamHandler(stream) {
59 59
         case "stream":
60 60
             VideoLayout.changeLocalStream(stream);
61 61
             break;
62
-        case "desktop":
63
-            VideoLayout.changeLocalVideo(stream);
64
-            break;
65 62
     }
66 63
 }
67 64
 
@@ -355,12 +352,7 @@ UI.onMucLeft = function (jid) {
355 352
         }
356 353
     }, 10);
357 354
 
358
-    // Unlock large video
359
-    if (focusedVideoInfo && focusedVideoInfo.jid === jid)
360
-    {
361
-        console.info("Focused video owner has left the conference");
362
-        focusedVideoInfo = null;
363
-    }
355
+    VideoLayout.participantLeft(jid);
364 356
 
365 357
 };
366 358
 
@@ -4402,6 +4394,11 @@ var largeVideoState = {
4402 4394
     updateInProgress: false,
4403 4395
     newSrc: ''
4404 4396
 };
4397
+/**
4398
+ * Currently focused video "src"(displayed in large video).
4399
+ * @type {String}
4400
+ */
4401
+var focusedVideoInfo = null;
4405 4402
 
4406 4403
 /**
4407 4404
  * Indicates if we have muted our audio before the conference has started.
@@ -4479,15 +4476,6 @@ function waitForRemoteVideo(selector, ssrc, stream, jid) {
4479 4476
     if (selector[0].currentTime > 0) {
4480 4477
         var videoStream = simulcast.getReceivingVideoStream(stream);
4481 4478
         RTC.attachMediaStream(selector, videoStream); // FIXME: why do i have to do this for FF?
4482
-
4483
-        // FIXME: add a class that will associate peer Jid, video.src, it's ssrc and video type
4484
-        //        in order to get rid of too many maps
4485
-        if (ssrc && jid) {
4486
-            jid2Ssrc[Strophe.getResourceFromJid(jid)] = ssrc;
4487
-        } else {
4488
-            console.warn("No ssrc given for jid", jid);
4489
-        }
4490
-
4491 4479
         videoactive(selector);
4492 4480
     } else {
4493 4481
         setTimeout(function () {
@@ -4879,43 +4867,6 @@ function createModeratorIndicatorElement(parentElement) {
4879 4867
 }
4880 4868
 
4881 4869
 
4882
-/**
4883
- * Checks if video identified by given src is desktop stream.
4884
- * @param videoSrc eg.
4885
- * blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
4886
- * @returns {boolean}
4887
- */
4888
-function isVideoSrcDesktop(jid) {
4889
-    // FIXME: fix this mapping mess...
4890
-    // figure out if large video is desktop stream or just a camera
4891
-
4892
-    if(!jid)
4893
-        return false;
4894
-    var isDesktop = false;
4895
-    if (xmpp.myJid() &&
4896
-        xmpp.myResource() === jid) {
4897
-        // local video
4898
-        isDesktop = desktopsharing.isUsingScreenStream();
4899
-    } else {
4900
-        // Do we have associations...
4901
-        var videoSsrc = jid2Ssrc[jid];
4902
-        if (videoSsrc) {
4903
-            var videoType = ssrc2videoType[videoSsrc];
4904
-            if (videoType) {
4905
-                // Finally there...
4906
-                isDesktop = videoType === 'screen';
4907
-            } else {
4908
-                console.error("No video type for ssrc: " + videoSsrc);
4909
-            }
4910
-        } else {
4911
-            console.error("No ssrc for jid: " + jid);
4912
-        }
4913
-    }
4914
-    return isDesktop;
4915
-}
4916
-
4917
-
4918
-
4919 4870
 var VideoLayout = (function (my) {
4920 4871
     my.connectionIndicators = {};
4921 4872
 
@@ -4958,7 +4909,7 @@ var VideoLayout = (function (my) {
4958 4909
 
4959 4910
     my.changeLocalVideo = function(stream) {
4960 4911
         var flipX = true;
4961
-        if(stream.type == "desktop")
4912
+        if(stream.videoType == "screen")
4962 4913
             flipX = false;
4963 4914
         var localVideo = document.createElement('video');
4964 4915
         localVideo.id = 'localVideo_' +
@@ -5141,11 +5092,8 @@ var VideoLayout = (function (my) {
5141 5092
 
5142 5093
             largeVideoState.newSrc = newSrc;
5143 5094
             largeVideoState.isVisible = $('#largeVideo').is(':visible');
5144
-            largeVideoState.isDesktop = isVideoSrcDesktop(resourceJid);
5145
-            if(jid2Ssrc[largeVideoState.userResourceJid] ||
5146
-                (xmpp.myResource() &&
5147
-                    largeVideoState.userResourceJid ===
5148
-                    xmpp.myResource())) {
5095
+            largeVideoState.isDesktop = RTC.isVideoSrcDesktop(resourceJid);
5096
+            if(largeVideoState.userResourceJid) {
5149 5097
                 largeVideoState.oldResourceJid = largeVideoState.userResourceJid;
5150 5098
             } else {
5151 5099
                 largeVideoState.oldResourceJid = null;
@@ -6520,7 +6468,6 @@ var VideoLayout = (function (my) {
6520 6468
                 }
6521 6469
 
6522 6470
                 var jid = ssrc2jid[primarySSRC];
6523
-                jid2Ssrc[jid] = primarySSRC;
6524 6471
 
6525 6472
                 if (updateLargeVideo) {
6526 6473
                     VideoLayout.updateLargeVideo(RTC.getVideoSrc(selRemoteVideo[0]), null,
@@ -6618,6 +6565,15 @@ var VideoLayout = (function (my) {
6618 6565
         }
6619 6566
     };
6620 6567
 
6568
+    my.participantLeft = function (jid) {
6569
+        // Unlock large video
6570
+        if (focusedVideoInfo && focusedVideoInfo.jid === jid)
6571
+        {
6572
+            console.info("Focused video owner has left the conference");
6573
+            focusedVideoInfo = null;
6574
+        }
6575
+    }
6576
+
6621 6577
     return my;
6622 6578
 }(VideoLayout || {}));
6623 6579
 

+ 1
- 1
libs/modules/statistics.bundle.js ファイルの表示

@@ -130,7 +130,7 @@ LocalStatsCollector.prototype.stop = function () {
130 130
 
131 131
 module.exports = LocalStatsCollector;
132 132
 },{}],2:[function(require,module,exports){
133
-/* global focusMucJid, ssrc2jid */
133
+/* global ssrc2jid */
134 134
 /* jshint -W117 */
135 135
 /**
136 136
  * Calculates packet lost percent using the number of lost packets and the

+ 27
- 24
libs/modules/xmpp.bundle.js ファイルの表示

@@ -54,6 +54,9 @@ function JingleSession(me, sid, connection, service) {
54 54
     this.videoMuteByUser = false;
55 55
 }
56 56
 
57
+//TODO: this array must be removed when firefox implement multistream support
58
+JingleSession.notReceivedSSRCs = [];
59
+
57 60
 JingleSession.prototype.initiate = function (peerjid, isInitiator) {
58 61
     var self = this;
59 62
     if (this.state !== null) {
@@ -1355,8 +1358,8 @@ JingleSession.prototype.remoteStreamAdded = function (data) {
1355 1358
     //TODO: this code should be removed when firefox implement multistream support
1356 1359
     if(RTC.getBrowserType() == RTCBrowserType.RTC_BROWSER_FIREFOX)
1357 1360
     {
1358
-        if((notReceivedSSRCs.length == 0) ||
1359
-            !ssrc2jid[notReceivedSSRCs[notReceivedSSRCs.length - 1]])
1361
+        if((JingleSession.notReceivedSSRCs.length == 0) ||
1362
+            !ssrc2jid[JingleSession.notReceivedSSRCs[JingleSession.notReceivedSSRCs.length - 1]])
1360 1363
         {
1361 1364
             // TODO(gp) limit wait duration to 1 sec.
1362 1365
             setTimeout(function(d) {
@@ -1367,7 +1370,7 @@ JingleSession.prototype.remoteStreamAdded = function (data) {
1367 1370
             return;
1368 1371
         }
1369 1372
 
1370
-        thessrc = notReceivedSSRCs.pop();
1373
+        thessrc = JingleSession.notReceivedSSRCs.pop();
1371 1374
         if (ssrc2jid[thessrc]) {
1372 1375
             data.peerjid = ssrc2jid[thessrc];
1373 1376
         }
@@ -3079,15 +3082,15 @@ function setRecordingToken(token) {
3079 3082
     recordingToken = token;
3080 3083
 }
3081 3084
 
3082
-function setRecording(state, token, callback) {
3085
+function setRecording(state, token, callback, connection) {
3083 3086
     if (useJirecon){
3084
-        this.setRecordingJirecon(state, token, callback);
3087
+        this.setRecordingJirecon(state, token, callback, connection);
3085 3088
     } else {
3086
-        this.setRecordingColibri(state, token, callback);
3089
+        this.setRecordingColibri(state, token, callback, connection);
3087 3090
     }
3088 3091
 }
3089 3092
 
3090
-function setRecordingJirecon(state, token, callback) {
3093
+function setRecordingJirecon(state, token, callback, connection) {
3091 3094
     if (state == recordingEnabled){
3092 3095
         return;
3093 3096
     }
@@ -3126,8 +3129,8 @@ function setRecordingJirecon(state, token, callback) {
3126 3129
 // Sends a COLIBRI message which enables or disables (according to 'state')
3127 3130
 // the recording on the bridge. Waits for the result IQ and calls 'callback'
3128 3131
 // with the new recording state, according to the IQ.
3129
-function setRecordingColibri(state, token, callback) {
3130
-    var elem = $iq({to: focusMucJid, type: 'set'});
3132
+function setRecordingColibri(state, token, callback, connection) {
3133
+    var elem = $iq({to: connection.emuc.focusMucJid, type: 'set'});
3131 3134
     elem.c('conference', {
3132 3135
         xmlns: 'http://jitsi.org/protocol/colibri'
3133 3136
     });
@@ -3151,7 +3154,7 @@ function setRecordingColibri(state, token, callback) {
3151 3154
 
3152 3155
 var Recording = {
3153 3156
     toggleRecording: function (tokenEmptyCallback,
3154
-                               startingCallback, startedCallback) {
3157
+                               startingCallback, startedCallback, connection) {
3155 3158
         if (!Moderator.isModerator()) {
3156 3159
             console.log(
3157 3160
                     'non-focus, or conference not yet organized:' +
@@ -3199,7 +3202,8 @@ var Recording = {
3199 3202
                 }
3200 3203
                 startedCallback(state);
3201 3204
 
3202
-            }
3205
+            },
3206
+            connection
3203 3207
         );
3204 3208
     }
3205 3209
 
@@ -3215,6 +3219,7 @@ module.exports = Recording;
3215 3219
 var bridgeIsDown = false;
3216 3220
 
3217 3221
 var Moderator = require("./moderator");
3222
+var JingleSession = require("./JingleSession");
3218 3223
 
3219 3224
 module.exports = function(XMPP, eventEmitter) {
3220 3225
     Strophe.addConnectionPlugin('emuc', {
@@ -3228,6 +3233,7 @@ module.exports = function(XMPP, eventEmitter) {
3228 3233
         joined: false,
3229 3234
         isOwner: false,
3230 3235
         role: null,
3236
+        focusMucJid: null,
3231 3237
         init: function (conn) {
3232 3238
             this.connection = conn;
3233 3239
         },
@@ -3400,7 +3406,7 @@ module.exports = function(XMPP, eventEmitter) {
3400 3406
                 this.list_members.push(from);
3401 3407
                 console.log('entered', from, member);
3402 3408
                 if (member.isFocus) {
3403
-                    focusMucJid = from;
3409
+                    this.focusMucJid = from;
3404 3410
                     console.info("Ignore focus: " + from + ", real JID: " + member.jid);
3405 3411
                 }
3406 3412
                 else {
@@ -3753,8 +3759,6 @@ module.exports = function(XMPP, eventEmitter) {
3753 3759
 
3754 3760
             API.triggerEvent("participantLeft", {jid: jid});
3755 3761
 
3756
-            delete jid2Ssrc[jid];
3757
-
3758 3762
             this.connection.jingle.terminateByJid(jid);
3759 3763
 
3760 3764
             if (this.getPrezi(jid)) {
@@ -3777,7 +3781,6 @@ module.exports = function(XMPP, eventEmitter) {
3777 3781
             Object.keys(ssrc2jid).forEach(function (ssrc) {
3778 3782
                 if (ssrc2jid[ssrc] == jid) {
3779 3783
                     delete ssrc2jid[ssrc];
3780
-                    delete ssrc2videoType[ssrc];
3781 3784
                 }
3782 3785
             });
3783 3786
 
@@ -3786,10 +3789,10 @@ module.exports = function(XMPP, eventEmitter) {
3786 3789
                 //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
3787 3790
                 var ssrcV = ssrc.getAttribute('ssrc');
3788 3791
                 ssrc2jid[ssrcV] = from;
3789
-                notReceivedSSRCs.push(ssrcV);
3792
+                JingleSession.notReceivedSSRCs.push(ssrcV);
3793
+
3790 3794
 
3791 3795
                 var type = ssrc.getAttribute('type');
3792
-                ssrc2videoType[ssrcV] = type;
3793 3796
 
3794 3797
                 var direction = ssrc.getAttribute('direction');
3795 3798
 
@@ -3822,7 +3825,7 @@ module.exports = function(XMPP, eventEmitter) {
3822 3825
 };
3823 3826
 
3824 3827
 
3825
-},{"./moderator":6}],9:[function(require,module,exports){
3828
+},{"./JingleSession":1,"./moderator":6}],9:[function(require,module,exports){
3826 3829
 /* jshint -W117 */
3827 3830
 
3828 3831
 var JingleSession = require("./JingleSession");
@@ -4202,7 +4205,7 @@ module.exports = function (XMPP) {
4202 4205
         },
4203 4206
         setMute: function (jid, mute) {
4204 4207
             console.info("set mute", mute);
4205
-            var iqToFocus = $iq({to: focusMucJid, type: 'set'})
4208
+            var iqToFocus = $iq({to: this.connection.emuc.focusMucJid, type: 'set'})
4206 4209
                 .c('mute', {
4207 4210
                     xmlns: 'http://jitsi.org/jitmeet/audio',
4208 4211
                     jid: jid
@@ -4221,7 +4224,7 @@ module.exports = function (XMPP) {
4221 4224
         },
4222 4225
         onMute: function (iq) {
4223 4226
             var from = iq.getAttribute('from');
4224
-            if (from !== focusMucJid) {
4227
+            if (from !== this.connection.emuc.focusMucJid) {
4225 4228
                 console.warn("Ignored mute from non focus peer");
4226 4229
                 return false;
4227 4230
             }
@@ -4264,7 +4267,7 @@ module.exports = function() {
4264 4267
                 var req = $iq(
4265 4268
                     {
4266 4269
                         type: 'set',
4267
-                        to: focusMucJid
4270
+                        to: this.connection.emuc.focusMucJid
4268 4271
                     }
4269 4272
                 );
4270 4273
                 req.c('dial',
@@ -4707,7 +4710,7 @@ var XMPP = {
4707 4710
     toggleRecording: function (tokenEmptyCallback,
4708 4711
                                startingCallback, startedCallback) {
4709 4712
         Recording.toggleRecording(tokenEmptyCallback,
4710
-            startingCallback, startedCallback);
4713
+            startingCallback, startedCallback, connection);
4711 4714
     },
4712 4715
     addToPresence: function (name, value, dontSend) {
4713 4716
         switch (name)
@@ -4737,7 +4740,7 @@ var XMPP = {
4737 4740
             connection.emuc.sendPresence();
4738 4741
     },
4739 4742
     sendLogs: function (data) {
4740
-        if(!focusMucJid)
4743
+        if(!connection.emuc.focusMucJid)
4741 4744
             return;
4742 4745
 
4743 4746
         var deflate = true;
@@ -4748,7 +4751,7 @@ var XMPP = {
4748 4751
         }
4749 4752
         content = Base64.encode(content);
4750 4753
         // XEP-0337-ish
4751
-        var message = $msg({to: focusMucJid, type: 'normal'});
4754
+        var message = $msg({to: connection.emuc.focusMucJid, type: 'normal'});
4752 4755
         message.c('log', { xmlns: 'urn:xmpp:eventlog',
4753 4756
             id: 'PeerConnectionStats'});
4754 4757
         message.c('message').t(content).up();

+ 2
- 1
modules/RTC/LocalStream.js ファイルの表示

@@ -1,10 +1,11 @@
1 1
 //var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
2 2
 
3
-function LocalStream(stream, type, eventEmitter)
3
+function LocalStream(stream, type, eventEmitter, videoType)
4 4
 {
5 5
     this.stream = stream;
6 6
     this.eventEmitter = eventEmitter;
7 7
     this.type = type;
8
+    this.videoType = videoType;
8 9
     var self = this;
9 10
     if(type == "audio")
10 11
     {

+ 1
- 0
modules/RTC/MediaStream.js ファイルの表示

@@ -32,6 +32,7 @@ function MediaStream(data, sid, ssrc, browser) {
32 32
     this.ssrc = ssrc;
33 33
     this.type = (this.stream.getVideoTracks().length > 0)?
34 34
         MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
35
+    this.videoType = null;
35 36
     this.muted = false;
36 37
     if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
37 38
     {

+ 43
- 3
modules/RTC/RTC.js ファイルの表示

@@ -106,6 +106,20 @@ var RTC = {
106 106
             function (stream, isUsingScreenStream, callback) {
107 107
                 self.changeLocalVideo(stream, isUsingScreenStream, callback);
108 108
             }, DesktopSharingEventTypes.NEW_STREAM_CREATED);
109
+        xmpp.addListener(XMPPEvents.CHANGED_STREAMS, function (jid, changedStreams) {
110
+            for(var i = 0; i < changedStreams.length; i++) {
111
+                var type = changedStreams[i].type;
112
+                if (type != "audio") {
113
+                    var peerStreams = self.remoteStreams[jid];
114
+                    if(!peerStreams)
115
+                        continue;
116
+                    var videoStream = peerStreams[MediaStreamType.VIDEO_TYPE];
117
+                    if(!videoStream)
118
+                        continue;
119
+                    videoStream.videoType = changedStreams[i].type;
120
+                }
121
+            }
122
+        })
109 123
         this.rtcUtils = new RTCUtils(this);
110 124
         this.rtcUtils.obtainAudioAndVideoPermissions();
111 125
     },
@@ -142,13 +156,39 @@ var RTC = {
142 156
     },
143 157
     changeLocalVideo: function (stream, isUsingScreenStream, callback) {
144 158
         var oldStream = this.localVideo.getOriginalStream();
145
-        var type = (isUsingScreenStream? "desktop" : "video");
146
-        RTC.localVideo = this.createLocalStream(stream, type, true);
159
+        var type = (isUsingScreenStream? "screen" : "video");
160
+        RTC.localVideo = this.createLocalStream(stream, "video", true, type);
147 161
         // Stop the stream to trigger onended event for old stream
148 162
         oldStream.stop();
149 163
         xmpp.switchStreams(stream, oldStream,callback);
150
-    }
164
+    },
165
+    /**
166
+     * Checks if video identified by given src is desktop stream.
167
+     * @param videoSrc eg.
168
+     * blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
169
+     * @returns {boolean}
170
+     */
171
+    isVideoSrcDesktop: function (jid) {
172
+        if(!jid)
173
+            return false;
174
+        var isDesktop = false;
175
+        var stream = null;
176
+        if (xmpp.myJid() &&
177
+            xmpp.myResource() === jid) {
178
+            // local video
179
+            stream = this.localVideo;
180
+        } else {
181
+            var peerStreams = this.remoteStreams[jid];
182
+            if(!peerStreams)
183
+                return false;
184
+            stream = peerStreams[MediaStreamType.VIDEO_TYPE];
185
+        }
186
+
187
+        if(stream)
188
+            isDesktop = (stream.videoType === "screen");
151 189
 
190
+        return isDesktop;
191
+    }
152 192
 };
153 193
 
154 194
 module.exports = RTC;

+ 1
- 9
modules/UI/UI.js ファイルの表示

@@ -58,9 +58,6 @@ function streamHandler(stream) {
58 58
         case "stream":
59 59
             VideoLayout.changeLocalStream(stream);
60 60
             break;
61
-        case "desktop":
62
-            VideoLayout.changeLocalVideo(stream);
63
-            break;
64 61
     }
65 62
 }
66 63
 
@@ -354,12 +351,7 @@ UI.onMucLeft = function (jid) {
354 351
         }
355 352
     }, 10);
356 353
 
357
-    // Unlock large video
358
-    if (focusedVideoInfo && focusedVideoInfo.jid === jid)
359
-    {
360
-        console.info("Focused video owner has left the conference");
361
-        focusedVideoInfo = null;
362
-    }
354
+    VideoLayout.participantLeft(jid);
363 355
 
364 356
 };
365 357
 

+ 17
- 53
modules/UI/videolayout/VideoLayout.js ファイルの表示

@@ -15,6 +15,11 @@ var largeVideoState = {
15 15
     updateInProgress: false,
16 16
     newSrc: ''
17 17
 };
18
+/**
19
+ * Currently focused video "src"(displayed in large video).
20
+ * @type {String}
21
+ */
22
+var focusedVideoInfo = null;
18 23
 
19 24
 /**
20 25
  * Indicates if we have muted our audio before the conference has started.
@@ -92,15 +97,6 @@ function waitForRemoteVideo(selector, ssrc, stream, jid) {
92 97
     if (selector[0].currentTime > 0) {
93 98
         var videoStream = simulcast.getReceivingVideoStream(stream);
94 99
         RTC.attachMediaStream(selector, videoStream); // FIXME: why do i have to do this for FF?
95
-
96
-        // FIXME: add a class that will associate peer Jid, video.src, it's ssrc and video type
97
-        //        in order to get rid of too many maps
98
-        if (ssrc && jid) {
99
-            jid2Ssrc[Strophe.getResourceFromJid(jid)] = ssrc;
100
-        } else {
101
-            console.warn("No ssrc given for jid", jid);
102
-        }
103
-
104 100
         videoactive(selector);
105 101
     } else {
106 102
         setTimeout(function () {
@@ -492,43 +488,6 @@ function createModeratorIndicatorElement(parentElement) {
492 488
 }
493 489
 
494 490
 
495
-/**
496
- * Checks if video identified by given src is desktop stream.
497
- * @param videoSrc eg.
498
- * blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
499
- * @returns {boolean}
500
- */
501
-function isVideoSrcDesktop(jid) {
502
-    // FIXME: fix this mapping mess...
503
-    // figure out if large video is desktop stream or just a camera
504
-
505
-    if(!jid)
506
-        return false;
507
-    var isDesktop = false;
508
-    if (xmpp.myJid() &&
509
-        xmpp.myResource() === jid) {
510
-        // local video
511
-        isDesktop = desktopsharing.isUsingScreenStream();
512
-    } else {
513
-        // Do we have associations...
514
-        var videoSsrc = jid2Ssrc[jid];
515
-        if (videoSsrc) {
516
-            var videoType = ssrc2videoType[videoSsrc];
517
-            if (videoType) {
518
-                // Finally there...
519
-                isDesktop = videoType === 'screen';
520
-            } else {
521
-                console.error("No video type for ssrc: " + videoSsrc);
522
-            }
523
-        } else {
524
-            console.error("No ssrc for jid: " + jid);
525
-        }
526
-    }
527
-    return isDesktop;
528
-}
529
-
530
-
531
-
532 491
 var VideoLayout = (function (my) {
533 492
     my.connectionIndicators = {};
534 493
 
@@ -571,7 +530,7 @@ var VideoLayout = (function (my) {
571 530
 
572 531
     my.changeLocalVideo = function(stream) {
573 532
         var flipX = true;
574
-        if(stream.type == "desktop")
533
+        if(stream.videoType == "screen")
575 534
             flipX = false;
576 535
         var localVideo = document.createElement('video');
577 536
         localVideo.id = 'localVideo_' +
@@ -754,11 +713,8 @@ var VideoLayout = (function (my) {
754 713
 
755 714
             largeVideoState.newSrc = newSrc;
756 715
             largeVideoState.isVisible = $('#largeVideo').is(':visible');
757
-            largeVideoState.isDesktop = isVideoSrcDesktop(resourceJid);
758
-            if(jid2Ssrc[largeVideoState.userResourceJid] ||
759
-                (xmpp.myResource() &&
760
-                    largeVideoState.userResourceJid ===
761
-                    xmpp.myResource())) {
716
+            largeVideoState.isDesktop = RTC.isVideoSrcDesktop(resourceJid);
717
+            if(largeVideoState.userResourceJid) {
762 718
                 largeVideoState.oldResourceJid = largeVideoState.userResourceJid;
763 719
             } else {
764 720
                 largeVideoState.oldResourceJid = null;
@@ -2133,7 +2089,6 @@ var VideoLayout = (function (my) {
2133 2089
                 }
2134 2090
 
2135 2091
                 var jid = ssrc2jid[primarySSRC];
2136
-                jid2Ssrc[jid] = primarySSRC;
2137 2092
 
2138 2093
                 if (updateLargeVideo) {
2139 2094
                     VideoLayout.updateLargeVideo(RTC.getVideoSrc(selRemoteVideo[0]), null,
@@ -2231,6 +2186,15 @@ var VideoLayout = (function (my) {
2231 2186
         }
2232 2187
     };
2233 2188
 
2189
+    my.participantLeft = function (jid) {
2190
+        // Unlock large video
2191
+        if (focusedVideoInfo && focusedVideoInfo.jid === jid)
2192
+        {
2193
+            console.info("Focused video owner has left the conference");
2194
+            focusedVideoInfo = null;
2195
+        }
2196
+    }
2197
+
2234 2198
     return my;
2235 2199
 }(VideoLayout || {}));
2236 2200
 

+ 1
- 1
modules/statistics/RTPStatsCollector.js ファイルの表示

@@ -1,4 +1,4 @@
1
-/* global focusMucJid, ssrc2jid */
1
+/* global ssrc2jid */
2 2
 /* jshint -W117 */
3 3
 /**
4 4
  * Calculates packet lost percent using the number of lost packets and the

+ 6
- 3
modules/xmpp/JingleSession.js ファイルの表示

@@ -53,6 +53,9 @@ function JingleSession(me, sid, connection, service) {
53 53
     this.videoMuteByUser = false;
54 54
 }
55 55
 
56
+//TODO: this array must be removed when firefox implement multistream support
57
+JingleSession.notReceivedSSRCs = [];
58
+
56 59
 JingleSession.prototype.initiate = function (peerjid, isInitiator) {
57 60
     var self = this;
58 61
     if (this.state !== null) {
@@ -1354,8 +1357,8 @@ JingleSession.prototype.remoteStreamAdded = function (data) {
1354 1357
     //TODO: this code should be removed when firefox implement multistream support
1355 1358
     if(RTC.getBrowserType() == RTCBrowserType.RTC_BROWSER_FIREFOX)
1356 1359
     {
1357
-        if((notReceivedSSRCs.length == 0) ||
1358
-            !ssrc2jid[notReceivedSSRCs[notReceivedSSRCs.length - 1]])
1360
+        if((JingleSession.notReceivedSSRCs.length == 0) ||
1361
+            !ssrc2jid[JingleSession.notReceivedSSRCs[JingleSession.notReceivedSSRCs.length - 1]])
1359 1362
         {
1360 1363
             // TODO(gp) limit wait duration to 1 sec.
1361 1364
             setTimeout(function(d) {
@@ -1366,7 +1369,7 @@ JingleSession.prototype.remoteStreamAdded = function (data) {
1366 1369
             return;
1367 1370
         }
1368 1371
 
1369
-        thessrc = notReceivedSSRCs.pop();
1372
+        thessrc = JingleSession.notReceivedSSRCs.pop();
1370 1373
         if (ssrc2jid[thessrc]) {
1371 1374
             data.peerjid = ssrc2jid[thessrc];
1372 1375
         }

+ 9
- 8
modules/xmpp/recording.js ファイルの表示

@@ -23,15 +23,15 @@ function setRecordingToken(token) {
23 23
     recordingToken = token;
24 24
 }
25 25
 
26
-function setRecording(state, token, callback) {
26
+function setRecording(state, token, callback, connection) {
27 27
     if (useJirecon){
28
-        this.setRecordingJirecon(state, token, callback);
28
+        this.setRecordingJirecon(state, token, callback, connection);
29 29
     } else {
30
-        this.setRecordingColibri(state, token, callback);
30
+        this.setRecordingColibri(state, token, callback, connection);
31 31
     }
32 32
 }
33 33
 
34
-function setRecordingJirecon(state, token, callback) {
34
+function setRecordingJirecon(state, token, callback, connection) {
35 35
     if (state == recordingEnabled){
36 36
         return;
37 37
     }
@@ -70,8 +70,8 @@ function setRecordingJirecon(state, token, callback) {
70 70
 // Sends a COLIBRI message which enables or disables (according to 'state')
71 71
 // the recording on the bridge. Waits for the result IQ and calls 'callback'
72 72
 // with the new recording state, according to the IQ.
73
-function setRecordingColibri(state, token, callback) {
74
-    var elem = $iq({to: focusMucJid, type: 'set'});
73
+function setRecordingColibri(state, token, callback, connection) {
74
+    var elem = $iq({to: connection.emuc.focusMucJid, type: 'set'});
75 75
     elem.c('conference', {
76 76
         xmlns: 'http://jitsi.org/protocol/colibri'
77 77
     });
@@ -95,7 +95,7 @@ function setRecordingColibri(state, token, callback) {
95 95
 
96 96
 var Recording = {
97 97
     toggleRecording: function (tokenEmptyCallback,
98
-                               startingCallback, startedCallback) {
98
+                               startingCallback, startedCallback, connection) {
99 99
         if (!Moderator.isModerator()) {
100 100
             console.log(
101 101
                     'non-focus, or conference not yet organized:' +
@@ -143,7 +143,8 @@ var Recording = {
143 143
                 }
144 144
                 startedCallback(state);
145 145
 
146
-            }
146
+            },
147
+            connection
147 148
         );
148 149
     }
149 150
 

+ 5
- 6
modules/xmpp/strophe.emuc.js ファイルの表示

@@ -6,6 +6,7 @@
6 6
 var bridgeIsDown = false;
7 7
 
8 8
 var Moderator = require("./moderator");
9
+var JingleSession = require("./JingleSession");
9 10
 
10 11
 module.exports = function(XMPP, eventEmitter) {
11 12
     Strophe.addConnectionPlugin('emuc', {
@@ -19,6 +20,7 @@ module.exports = function(XMPP, eventEmitter) {
19 20
         joined: false,
20 21
         isOwner: false,
21 22
         role: null,
23
+        focusMucJid: null,
22 24
         init: function (conn) {
23 25
             this.connection = conn;
24 26
         },
@@ -191,7 +193,7 @@ module.exports = function(XMPP, eventEmitter) {
191 193
                 this.list_members.push(from);
192 194
                 console.log('entered', from, member);
193 195
                 if (member.isFocus) {
194
-                    focusMucJid = from;
196
+                    this.focusMucJid = from;
195 197
                     console.info("Ignore focus: " + from + ", real JID: " + member.jid);
196 198
                 }
197 199
                 else {
@@ -544,8 +546,6 @@ module.exports = function(XMPP, eventEmitter) {
544 546
 
545 547
             API.triggerEvent("participantLeft", {jid: jid});
546 548
 
547
-            delete jid2Ssrc[jid];
548
-
549 549
             this.connection.jingle.terminateByJid(jid);
550 550
 
551 551
             if (this.getPrezi(jid)) {
@@ -568,7 +568,6 @@ module.exports = function(XMPP, eventEmitter) {
568 568
             Object.keys(ssrc2jid).forEach(function (ssrc) {
569 569
                 if (ssrc2jid[ssrc] == jid) {
570 570
                     delete ssrc2jid[ssrc];
571
-                    delete ssrc2videoType[ssrc];
572 571
                 }
573 572
             });
574 573
 
@@ -577,10 +576,10 @@ module.exports = function(XMPP, eventEmitter) {
577 576
                 //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
578 577
                 var ssrcV = ssrc.getAttribute('ssrc');
579 578
                 ssrc2jid[ssrcV] = from;
580
-                notReceivedSSRCs.push(ssrcV);
579
+                JingleSession.notReceivedSSRCs.push(ssrcV);
580
+
581 581
 
582 582
                 var type = ssrc.getAttribute('type');
583
-                ssrc2videoType[ssrcV] = type;
584 583
 
585 584
                 var direction = ssrc.getAttribute('direction');
586 585
 

+ 2
- 2
modules/xmpp/strophe.moderate.js ファイルの表示

@@ -18,7 +18,7 @@ module.exports = function (XMPP) {
18 18
         },
19 19
         setMute: function (jid, mute) {
20 20
             console.info("set mute", mute);
21
-            var iqToFocus = $iq({to: focusMucJid, type: 'set'})
21
+            var iqToFocus = $iq({to: this.connection.emuc.focusMucJid, type: 'set'})
22 22
                 .c('mute', {
23 23
                     xmlns: 'http://jitsi.org/jitmeet/audio',
24 24
                     jid: jid
@@ -37,7 +37,7 @@ module.exports = function (XMPP) {
37 37
         },
38 38
         onMute: function (iq) {
39 39
             var from = iq.getAttribute('from');
40
-            if (from !== focusMucJid) {
40
+            if (from !== this.connection.emuc.focusMucJid) {
41 41
                 console.warn("Ignored mute from non focus peer");
42 42
                 return false;
43 43
             }

+ 1
- 1
modules/xmpp/strophe.rayo.js ファイルの表示

@@ -21,7 +21,7 @@ module.exports = function() {
21 21
                 var req = $iq(
22 22
                     {
23 23
                         type: 'set',
24
-                        to: focusMucJid
24
+                        to: this.connection.emuc.focusMucJid
25 25
                     }
26 26
                 );
27 27
                 req.c('dial',

+ 3
- 3
modules/xmpp/xmpp.js ファイルの表示

@@ -323,7 +323,7 @@ var XMPP = {
323 323
     toggleRecording: function (tokenEmptyCallback,
324 324
                                startingCallback, startedCallback) {
325 325
         Recording.toggleRecording(tokenEmptyCallback,
326
-            startingCallback, startedCallback);
326
+            startingCallback, startedCallback, connection);
327 327
     },
328 328
     addToPresence: function (name, value, dontSend) {
329 329
         switch (name)
@@ -353,7 +353,7 @@ var XMPP = {
353 353
             connection.emuc.sendPresence();
354 354
     },
355 355
     sendLogs: function (data) {
356
-        if(!focusMucJid)
356
+        if(!connection.emuc.focusMucJid)
357 357
             return;
358 358
 
359 359
         var deflate = true;
@@ -364,7 +364,7 @@ var XMPP = {
364 364
         }
365 365
         content = Base64.encode(content);
366 366
         // XEP-0337-ish
367
-        var message = $msg({to: focusMucJid, type: 'normal'});
367
+        var message = $msg({to: connection.emuc.focusMucJid, type: 'normal'});
368 368
         message.c('log', { xmlns: 'urn:xmpp:eventlog',
369 369
             id: 'PeerConnectionStats'});
370 370
         message.c('message').t(content).up();

読み込み中…
キャンセル
保存