Browse Source

ref(VideoLayout): reduce 'forceUpdate' usage

master
paweldomas 8 years ago
parent
commit
de2eee2e61

+ 8
- 0
modules/UI/videolayout/LargeVideoManager.js View File

@@ -523,6 +523,14 @@ export default class LargeVideoManager {
523 523
         return this.getContainer(this.state);
524 524
     }
525 525
 
526
+    /**
527
+     * Returns type of the current {@link LargeContainer}
528
+     * @return {string}
529
+     */
530
+    getCurrentContainerType() {
531
+        return this.state;
532
+    }
533
+
526 534
     /**
527 535
      * Remove Large container of specified type.
528 536
      * @param {string} type container type.

+ 1
- 3
modules/UI/videolayout/LocalVideo.js View File

@@ -113,9 +113,7 @@ LocalVideo.prototype.changeVideo = function (stream) {
113 113
         // when removing only the video element and we are on stage
114 114
         // update the stage
115 115
         if (this.isCurrentlyOnLargeVideo()) {
116
-            this.VideoLayout.updateLargeVideo(
117
-                this.id,
118
-                true /* force - stream removed for the same user ID */);
116
+            this.VideoLayout.updateLargeVideo(this.id);
119 117
         }
120 118
         stream.off(TrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
121 119
     };

+ 1
- 3
modules/UI/videolayout/RemoteVideo.js View File

@@ -432,9 +432,7 @@ RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
432 432
     // when removing only the video element and we are on stage
433 433
     // update the stage
434 434
     if (isVideo && this.isCurrentlyOnLargeVideo()) {
435
-        this.VideoLayout.updateLargeVideo(
436
-            this.id,
437
-            true /* force - same user ID, but removed video stream */);
435
+        this.VideoLayout.updateLargeVideo(this.id);
438 436
     } else {
439 437
         // Missing video stream will affect display mode
440 438
         this.updateView();

+ 8
- 0
modules/UI/videolayout/VideoContainer.js View File

@@ -254,6 +254,14 @@ export class VideoContainer extends LargeContainer {
254 254
         this.$videoBackground.toggleClass("videoProblemFilter", enable);
255 255
     }
256 256
 
257
+    /**
258
+     * Obtains media stream ID of the underlying {@link JitsiTrack}.
259
+     * @return {string|null}
260
+     */
261
+    getStreamID() {
262
+        return this.stream ? this.stream.getId() : null;
263
+    }
264
+
257 265
     /**
258 266
      * Get size of video element.
259 267
      * @returns {{width, height}}

+ 23
- 6
modules/UI/videolayout/VideoLayout.js View File

@@ -195,9 +195,9 @@ var VideoLayout = {
195 195
 
196 196
         localVideoThumbnail.changeVideo(stream);
197 197
 
198
-        /* force update if we're currently being displayed */
198
+        /* Update if we're currently being displayed */
199 199
         if (this.isCurrentlyOnLarge(localId)) {
200
-            this.updateLargeVideo(localId, true);
200
+            this.updateLargeVideo(localId);
201 201
         }
202 202
     },
203 203
 
@@ -761,7 +761,7 @@ var VideoLayout = {
761 761
         if (remoteVideo) {
762 762
             remoteVideo.updateView();
763 763
             if (remoteVideo.isCurrentlyOnLargeVideo()) {
764
-                this.updateLargeVideo(id, true);
764
+                this.updateLargeVideo(id);
765 765
             }
766 766
         }
767 767
     },
@@ -1010,8 +1010,26 @@ var VideoLayout = {
1010 1010
         if (!largeVideo) {
1011 1011
             return;
1012 1012
         }
1013
-        let isOnLarge = this.isCurrentlyOnLarge(id);
1014
-        let currentId = largeVideo.id;
1013
+        const currentContainer = largeVideo.getCurrentContainer();
1014
+        const currentContainerType = largeVideo.getCurrentContainerType();
1015
+        const currentId = largeVideo.id;
1016
+        const isOnLarge = this.isCurrentlyOnLarge(id);
1017
+        const smallVideo = this.getSmallVideo(id);
1018
+
1019
+        if (isOnLarge && !forceUpdate
1020
+                && LargeVideoManager.isVideoContainer(currentContainerType)
1021
+                && smallVideo) {
1022
+            const currentStreamId = currentContainer.getStreamID();
1023
+            const newStreamId
1024
+                = smallVideo.videoStream
1025
+                    ? smallVideo.videoStream.getId() : null;
1026
+
1027
+            // FIXME it might be possible to get rid of 'forceUpdate' argument
1028
+            if (currentStreamId !== newStreamId) {
1029
+                logger.debug('Enforcing large video update for stream change');
1030
+                forceUpdate = true;
1031
+            }
1032
+        }
1015 1033
 
1016 1034
         if (!isOnLarge || forceUpdate) {
1017 1035
             let videoType = this.getRemoteVideoType(id);
@@ -1020,7 +1038,6 @@ var VideoLayout = {
1020 1038
                 eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
1021 1039
             }
1022 1040
 
1023
-            let smallVideo = this.getSmallVideo(id);
1024 1041
             let oldSmallVideo;
1025 1042
             if (currentId) {
1026 1043
                 oldSmallVideo = this.getSmallVideo(currentId);

Loading…
Cancel
Save