浏览代码

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,4 +38,20 @@ export default class LargeContainer {
38 38
      */
39 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,7 +150,7 @@ function getDesktopVideoPosition(videoWidth,
150 150
     return { horizontalIndent, verticalIndent };
151 151
 }
152 152
 
153
-export const VideoContainerType = "video";
153
+export const VideoContainerType = "camera";
154 154
 
155 155
 /**
156 156
  * Container for user video.
@@ -332,6 +332,10 @@ class VideoContainer extends LargeContainer {
332 332
     }
333 333
 
334 334
     hide () {
335
+        // as the container is hidden/replaced by another container
336
+        // hide its avatar
337
+        this.showAvatar(false);
338
+
335 339
         // its already hidden
336 340
         if (!this.isVisible) {
337 341
             return Promise.resolve();
@@ -357,6 +361,8 @@ export default class LargeVideoManager {
357 361
         this.state = VideoContainerType;
358 362
         this.videoContainer = new VideoContainer(() => this.resizeContainer(VideoContainerType));
359 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 367
         this.width = 0;
362 368
         this.height = 0;
@@ -413,7 +419,8 @@ export default class LargeVideoManager {
413 419
     }
414 420
 
415 421
     get id () {
416
-        return this.videoContainer.id;
422
+        let container = this.getContainer(this.state);
423
+        return container.id;
417 424
     }
418 425
 
419 426
     scheduleLargeVideoUpdate () {
@@ -430,8 +437,9 @@ export default class LargeVideoManager {
430 437
             this.newStreamData = null;
431 438
 
432 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 444
             // change the avatar url on large
437 445
             this.updateAvatar(Avatar.getAvatarUrl(id));
@@ -439,7 +447,7 @@ export default class LargeVideoManager {
439 447
             let isVideoMuted = stream ? stream.isMuted() : true;
440 448
 
441 449
             // show the avatar on large if needed
442
-            this.videoContainer.showAvatar(isVideoMuted);
450
+            container.showAvatar(isVideoMuted);
443 451
 
444 452
             let promise;
445 453
 
@@ -449,7 +457,7 @@ export default class LargeVideoManager {
449 457
                 this.showWatermark(true);
450 458
                 promise = Promise.resolve();
451 459
             } else {
452
-                promise = this.videoContainer.show();
460
+                promise = container.show();
453 461
             }
454 462
 
455 463
             // resolve updateLargeVideo promise after everything is done
@@ -529,7 +537,8 @@ export default class LargeVideoManager {
529 537
      * @param enable <tt>true</tt> to enable, <tt>false</tt> to disable
530 538
      */
531 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,7 +13,6 @@ function LocalVideo(VideoLayout, emitter) {
13 13
     this.videoSpanId = "localVideoContainer";
14 14
     this.container = $("#localVideoContainer").get(0);
15 15
     this.bindHoverHandler();
16
-    this.VideoLayout = VideoLayout;
17 16
     this.flipX = true;
18 17
     this.isLocal = true;
19 18
     this.emitter = emitter;
@@ -22,7 +21,7 @@ function LocalVideo(VideoLayout, emitter) {
22 21
             return APP.conference.localId;
23 22
         }
24 23
     });
25
-    SmallVideo.call(this);
24
+    SmallVideo.call(this, VideoLayout);
26 25
 }
27 26
 
28 27
 LocalVideo.prototype = Object.create(SmallVideo.prototype);

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

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

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

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

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

@@ -16,7 +16,6 @@ import PanelToggler from "../side_pannels/SidePanelToggler";
16 16
 const RTCUIUtil = JitsiMeetJS.util.RTCUIHelper;
17 17
 
18 18
 var remoteVideos = {};
19
-var remoteVideoTypes = {};
20 19
 var localVideoThumbnail = null;
21 20
 
22 21
 var currentDominantSpeaker = null;
@@ -277,10 +276,11 @@ var VideoLayout = {
277 276
     /**
278 277
      * Return the type of the remote video.
279 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 281
     getRemoteVideoType (id) {
283
-        return remoteVideoTypes[id];
282
+        let smallVideo = VideoLayout.getSmallVideo(id);
283
+        return smallVideo ? smallVideo.getVideoType() : null;
284 284
     },
285 285
 
286 286
     handleVideoThumbClicked (noPinnedEndpointChangedEvent,
@@ -326,22 +326,26 @@ var VideoLayout = {
326 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 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 350
         // In case this is not currently in the last n we don't show it.
347 351
         if (localLastNCount && localLastNCount > 0 &&
@@ -752,12 +756,11 @@ var VideoLayout = {
752 756
     },
753 757
 
754 758
     onVideoTypeChanged (id, newVideoType) {
755
-        if (remoteVideoTypes[id] === newVideoType) {
759
+        if (VideoLayout.getRemoteVideoType(id) === newVideoType) {
756 760
             return;
757 761
         }
758 762
 
759 763
         console.info("Peer video type changed: ", id, newVideoType);
760
-        remoteVideoTypes[id] = newVideoType;
761 764
 
762 765
         var smallVideo;
763 766
         if (APP.conference.isLocalId(id)) {
@@ -771,8 +774,8 @@ var VideoLayout = {
771 774
         } else {
772 775
             return;
773 776
         }
774
-
775 777
         smallVideo.setVideoType(newVideoType);
778
+
776 779
         if (this.isCurrentlyOnLarge(id)) {
777 780
             this.updateLargeVideo(id, true);
778 781
         }

正在加载...
取消
保存