Browse Source

ref(VideoLayout): reduce 'forceUpdate' usage

j8
paweldomas 8 years ago
parent
commit
de2eee2e61

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

523
         return this.getContainer(this.state);
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
      * Remove Large container of specified type.
535
      * Remove Large container of specified type.
528
      * @param {string} type container type.
536
      * @param {string} type container type.

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

113
         // when removing only the video element and we are on stage
113
         // when removing only the video element and we are on stage
114
         // update the stage
114
         // update the stage
115
         if (this.isCurrentlyOnLargeVideo()) {
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
         stream.off(TrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
118
         stream.off(TrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
121
     };
119
     };

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

432
     // when removing only the video element and we are on stage
432
     // when removing only the video element and we are on stage
433
     // update the stage
433
     // update the stage
434
     if (isVideo && this.isCurrentlyOnLargeVideo()) {
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
     } else {
436
     } else {
439
         // Missing video stream will affect display mode
437
         // Missing video stream will affect display mode
440
         this.updateView();
438
         this.updateView();

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

254
         this.$videoBackground.toggleClass("videoProblemFilter", enable);
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
      * Get size of video element.
266
      * Get size of video element.
259
      * @returns {{width, height}}
267
      * @returns {{width, height}}

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

195
 
195
 
196
         localVideoThumbnail.changeVideo(stream);
196
         localVideoThumbnail.changeVideo(stream);
197
 
197
 
198
-        /* force update if we're currently being displayed */
198
+        /* Update if we're currently being displayed */
199
         if (this.isCurrentlyOnLarge(localId)) {
199
         if (this.isCurrentlyOnLarge(localId)) {
200
-            this.updateLargeVideo(localId, true);
200
+            this.updateLargeVideo(localId);
201
         }
201
         }
202
     },
202
     },
203
 
203
 
761
         if (remoteVideo) {
761
         if (remoteVideo) {
762
             remoteVideo.updateView();
762
             remoteVideo.updateView();
763
             if (remoteVideo.isCurrentlyOnLargeVideo()) {
763
             if (remoteVideo.isCurrentlyOnLargeVideo()) {
764
-                this.updateLargeVideo(id, true);
764
+                this.updateLargeVideo(id);
765
             }
765
             }
766
         }
766
         }
767
     },
767
     },
1010
         if (!largeVideo) {
1010
         if (!largeVideo) {
1011
             return;
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
         if (!isOnLarge || forceUpdate) {
1034
         if (!isOnLarge || forceUpdate) {
1017
             let videoType = this.getRemoteVideoType(id);
1035
             let videoType = this.getRemoteVideoType(id);
1020
                 eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
1038
                 eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
1021
             }
1039
             }
1022
 
1040
 
1023
-            let smallVideo = this.getSmallVideo(id);
1024
             let oldSmallVideo;
1041
             let oldSmallVideo;
1025
             if (currentId) {
1042
             if (currentId) {
1026
                 oldSmallVideo = this.getSmallVideo(currentId);
1043
                 oldSmallVideo = this.getSmallVideo(currentId);

Loading…
Cancel
Save