瀏覽代碼

Merge pull request #539 from damencho/ui-container-management-and-fixes

Ui container management and fixes
j8
yanas 9 年之前
父節點
當前提交
20af89abfa

+ 16
- 0
modules/UI/videolayout/LargeContainer.js 查看文件

38
      */
38
      */
39
     onHoverOut (e) {
39
     onHoverOut (e) {
40
     }
40
     }
41
+
42
+    /**
43
+     * Update video stream.
44
+     * @param {JitsiTrack?} stream new stream
45
+     * @param {string} videoType video type
46
+     */
47
+    setStream (stream, videoType) {
48
+    }
49
+
50
+    /**
51
+     * Show or hide user avatar.
52
+     * @param {boolean} show
53
+     */
54
+    showAvatar (show) {
55
+    }
56
+
41
 }
57
 }

+ 16
- 7
modules/UI/videolayout/LargeVideo.js 查看文件

150
     return { horizontalIndent, verticalIndent };
150
     return { horizontalIndent, verticalIndent };
151
 }
151
 }
152
 
152
 
153
-export const VideoContainerType = "video";
153
+export const VideoContainerType = "camera";
154
 
154
 
155
 /**
155
 /**
156
  * Container for user video.
156
  * Container for user video.
332
     }
332
     }
333
 
333
 
334
     hide () {
334
     hide () {
335
+        // as the container is hidden/replaced by another container
336
+        // hide its avatar
337
+        this.showAvatar(false);
338
+
335
         // its already hidden
339
         // its already hidden
336
         if (!this.isVisible) {
340
         if (!this.isVisible) {
337
             return Promise.resolve();
341
             return Promise.resolve();
357
         this.state = VideoContainerType;
361
         this.state = VideoContainerType;
358
         this.videoContainer = new VideoContainer(() => this.resizeContainer(VideoContainerType));
362
         this.videoContainer = new VideoContainer(() => this.resizeContainer(VideoContainerType));
359
         this.addContainer(VideoContainerType, this.videoContainer);
363
         this.addContainer(VideoContainerType, this.videoContainer);
364
+        // use the same video container to handle and desktop tracks
365
+        this.addContainer("desktop", this.videoContainer);
360
 
366
 
361
         this.width = 0;
367
         this.width = 0;
362
         this.height = 0;
368
         this.height = 0;
413
     }
419
     }
414
 
420
 
415
     get id () {
421
     get id () {
416
-        return this.videoContainer.id;
422
+        let container = this.getContainer(this.state);
423
+        return container.id;
417
     }
424
     }
418
 
425
 
419
     scheduleLargeVideoUpdate () {
426
     scheduleLargeVideoUpdate () {
430
             this.newStreamData = null;
437
             this.newStreamData = null;
431
 
438
 
432
             console.info("hover in %s", id);
439
             console.info("hover in %s", id);
433
-            this.state = VideoContainerType;
434
-            this.videoContainer.setStream(stream, videoType);
440
+            this.state = videoType;
441
+            let container = this.getContainer(this.state);
442
+            container.setStream(stream, videoType);
435
 
443
 
436
             // change the avatar url on large
444
             // change the avatar url on large
437
             this.updateAvatar(Avatar.getAvatarUrl(id));
445
             this.updateAvatar(Avatar.getAvatarUrl(id));
439
             let isVideoMuted = stream ? stream.isMuted() : true;
447
             let isVideoMuted = stream ? stream.isMuted() : true;
440
 
448
 
441
             // show the avatar on large if needed
449
             // show the avatar on large if needed
442
-            this.videoContainer.showAvatar(isVideoMuted);
450
+            container.showAvatar(isVideoMuted);
443
 
451
 
444
             let promise;
452
             let promise;
445
 
453
 
449
                 this.showWatermark(true);
457
                 this.showWatermark(true);
450
                 promise = Promise.resolve();
458
                 promise = Promise.resolve();
451
             } else {
459
             } else {
452
-                promise = this.videoContainer.show();
460
+                promise = container.show();
453
             }
461
             }
454
 
462
 
455
             // resolve updateLargeVideo promise after everything is done
463
             // resolve updateLargeVideo promise after everything is done
529
      * @param enable <tt>true</tt> to enable, <tt>false</tt> to disable
537
      * @param enable <tt>true</tt> to enable, <tt>false</tt> to disable
530
      */
538
      */
531
     enableVideoProblemFilter (enable) {
539
     enableVideoProblemFilter (enable) {
532
-        this.videoContainer.$video.toggleClass("videoProblemFilter", enable);
540
+        let container = this.getContainer(this.state);
541
+        container.$video.toggleClass("videoProblemFilter", enable);
533
     }
542
     }
534
 
543
 
535
     /**
544
     /**

+ 1
- 2
modules/UI/videolayout/LocalVideo.js 查看文件

13
     this.videoSpanId = "localVideoContainer";
13
     this.videoSpanId = "localVideoContainer";
14
     this.container = $("#localVideoContainer").get(0);
14
     this.container = $("#localVideoContainer").get(0);
15
     this.bindHoverHandler();
15
     this.bindHoverHandler();
16
-    this.VideoLayout = VideoLayout;
17
     this.flipX = true;
16
     this.flipX = true;
18
     this.isLocal = true;
17
     this.isLocal = true;
19
     this.emitter = emitter;
18
     this.emitter = emitter;
22
             return APP.conference.localId;
21
             return APP.conference.localId;
23
         }
22
         }
24
     });
23
     });
25
-    SmallVideo.call(this);
24
+    SmallVideo.call(this, VideoLayout);
26
 }
25
 }
27
 
26
 
28
 LocalVideo.prototype = Object.create(SmallVideo.prototype);
27
 LocalVideo.prototype = Object.create(SmallVideo.prototype);

+ 1
- 2
modules/UI/videolayout/RemoteVideo.js 查看文件

11
     this.id = id;
11
     this.id = id;
12
     this.emitter = emitter;
12
     this.emitter = emitter;
13
     this.videoSpanId = `participant_${id}`;
13
     this.videoSpanId = `participant_${id}`;
14
-    this.VideoLayout = VideoLayout;
14
+    SmallVideo.call(this, VideoLayout);
15
     this.addRemoteVideoContainer();
15
     this.addRemoteVideoContainer();
16
     this.connectionIndicator = new ConnectionIndicator(this, id);
16
     this.connectionIndicator = new ConnectionIndicator(this, id);
17
     this.setDisplayName();
17
     this.setDisplayName();
18
     this.bindHoverHandler();
18
     this.bindHoverHandler();
19
     this.flipX = false;
19
     this.flipX = false;
20
     this.isLocal = false;
20
     this.isLocal = false;
21
-    SmallVideo.call(this);
22
 }
21
 }
23
 
22
 
24
 RemoteVideo.prototype = Object.create(SmallVideo.prototype);
23
 RemoteVideo.prototype = Object.create(SmallVideo.prototype);

+ 2
- 1
modules/UI/videolayout/SmallVideo.js 查看文件

5
 
5
 
6
 const RTCUIHelper = JitsiMeetJS.util.RTCUIHelper;
6
 const RTCUIHelper = JitsiMeetJS.util.RTCUIHelper;
7
 
7
 
8
-function SmallVideo() {
8
+function SmallVideo(VideoLayout) {
9
     this.isMuted = false;
9
     this.isMuted = false;
10
     this.hasAvatar = false;
10
     this.hasAvatar = false;
11
     this.isVideoMuted = false;
11
     this.isVideoMuted = false;
12
     this.videoStream = null;
12
     this.videoStream = null;
13
     this.audioStream = null;
13
     this.audioStream = null;
14
+    this.VideoLayout = VideoLayout;
14
 }
15
 }
15
 
16
 
16
 function setVisibility(selector, show) {
17
 function setVisibility(selector, show) {

+ 20
- 17
modules/UI/videolayout/VideoLayout.js 查看文件

16
 const RTCUIUtil = JitsiMeetJS.util.RTCUIHelper;
16
 const RTCUIUtil = JitsiMeetJS.util.RTCUIHelper;
17
 
17
 
18
 var remoteVideos = {};
18
 var remoteVideos = {};
19
-var remoteVideoTypes = {};
20
 var localVideoThumbnail = null;
19
 var localVideoThumbnail = null;
21
 
20
 
22
 var currentDominantSpeaker = null;
21
 var currentDominantSpeaker = null;
277
     /**
276
     /**
278
      * Return the type of the remote video.
277
      * Return the type of the remote video.
279
      * @param id the id for the remote video
278
      * @param id the id for the remote video
280
-     * @returns the video type video or screen.
279
+     * @returns {String} the video type video or screen.
281
      */
280
      */
282
     getRemoteVideoType (id) {
281
     getRemoteVideoType (id) {
283
-        return remoteVideoTypes[id];
282
+        let smallVideo = VideoLayout.getSmallVideo(id);
283
+        return smallVideo ? smallVideo.getVideoType() : null;
284
     },
284
     },
285
 
285
 
286
     handleVideoThumbClicked (noPinnedEndpointChangedEvent,
286
     handleVideoThumbClicked (noPinnedEndpointChangedEvent,
326
         this.updateLargeVideo(resourceJid);
326
         this.updateLargeVideo(resourceJid);
327
     },
327
     },
328
 
328
 
329
-
330
     /**
329
     /**
331
-     * Checks if container for participant identified by given id exists
332
-     * in the document and creates it eventually.
333
-     *
334
-     * @return Returns <tt>true</tt> if the peer container exists,
335
-     * <tt>false</tt> - otherwise
330
+     * Creates a remote video for participant for the given id.
331
+     * @param id the id of the participant to add
332
+     * @param {SmallVideo} smallVideo optional small video instance to add as a
333
+     * remote video, if undefined RemoteVideo will be created
336
      */
334
      */
337
-    addParticipantContainer (id) {
338
-        let remoteVideo = new RemoteVideo(id, VideoLayout, eventEmitter);
335
+    addParticipantContainer (id, smallVideo) {
336
+        let remoteVideo;
337
+        if(smallVideo)
338
+            remoteVideo = smallVideo;
339
+        else
340
+            remoteVideo = new RemoteVideo(id, VideoLayout, eventEmitter);
339
         remoteVideos[id] = remoteVideo;
341
         remoteVideos[id] = remoteVideo;
340
 
342
 
341
-        let videoType = remoteVideoTypes[id];
342
-        if (videoType) {
343
-            remoteVideo.setVideoType(videoType);
343
+        let videoType = VideoLayout.getRemoteVideoType(id);
344
+        if (!videoType) {
345
+            // make video type the default one (camera)
346
+            videoType = VideoContainerType;
344
         }
347
         }
348
+        remoteVideo.setVideoType(videoType);
345
 
349
 
346
         // In case this is not currently in the last n we don't show it.
350
         // In case this is not currently in the last n we don't show it.
347
         if (localLastNCount && localLastNCount > 0 &&
351
         if (localLastNCount && localLastNCount > 0 &&
752
     },
756
     },
753
 
757
 
754
     onVideoTypeChanged (id, newVideoType) {
758
     onVideoTypeChanged (id, newVideoType) {
755
-        if (remoteVideoTypes[id] === newVideoType) {
759
+        if (VideoLayout.getRemoteVideoType(id) === newVideoType) {
756
             return;
760
             return;
757
         }
761
         }
758
 
762
 
759
         console.info("Peer video type changed: ", id, newVideoType);
763
         console.info("Peer video type changed: ", id, newVideoType);
760
-        remoteVideoTypes[id] = newVideoType;
761
 
764
 
762
         var smallVideo;
765
         var smallVideo;
763
         if (APP.conference.isLocalId(id)) {
766
         if (APP.conference.isLocalId(id)) {
771
         } else {
774
         } else {
772
             return;
775
             return;
773
         }
776
         }
774
-
775
         smallVideo.setVideoType(newVideoType);
777
         smallVideo.setVideoType(newVideoType);
778
+
776
         if (this.isCurrentlyOnLarge(id)) {
779
         if (this.isCurrentlyOnLarge(id)) {
777
             this.updateLargeVideo(id, true);
780
             this.updateLargeVideo(id, true);
778
         }
781
         }

Loading…
取消
儲存