ref(VideoLayout): reduce 'forceUpdate' usage

This commit is contained in:
paweldomas 2017-07-10 12:06:48 +02:00 committed by virtuacoplenny
parent badbedf0f5
commit de2eee2e61
5 changed files with 41 additions and 12 deletions

View File

@ -523,6 +523,14 @@ export default class LargeVideoManager {
return this.getContainer(this.state); return this.getContainer(this.state);
} }
/**
* Returns type of the current {@link LargeContainer}
* @return {string}
*/
getCurrentContainerType() {
return this.state;
}
/** /**
* Remove Large container of specified type. * Remove Large container of specified type.
* @param {string} type container type. * @param {string} type container type.

View File

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

View File

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

View File

@ -254,6 +254,14 @@ export class VideoContainer extends LargeContainer {
this.$videoBackground.toggleClass("videoProblemFilter", enable); this.$videoBackground.toggleClass("videoProblemFilter", enable);
} }
/**
* Obtains media stream ID of the underlying {@link JitsiTrack}.
* @return {string|null}
*/
getStreamID() {
return this.stream ? this.stream.getId() : null;
}
/** /**
* Get size of video element. * Get size of video element.
* @returns {{width, height}} * @returns {{width, height}}

View File

@ -195,9 +195,9 @@ var VideoLayout = {
localVideoThumbnail.changeVideo(stream); localVideoThumbnail.changeVideo(stream);
/* force update if we're currently being displayed */ /* Update if we're currently being displayed */
if (this.isCurrentlyOnLarge(localId)) { if (this.isCurrentlyOnLarge(localId)) {
this.updateLargeVideo(localId, true); this.updateLargeVideo(localId);
} }
}, },
@ -761,7 +761,7 @@ var VideoLayout = {
if (remoteVideo) { if (remoteVideo) {
remoteVideo.updateView(); remoteVideo.updateView();
if (remoteVideo.isCurrentlyOnLargeVideo()) { if (remoteVideo.isCurrentlyOnLargeVideo()) {
this.updateLargeVideo(id, true); this.updateLargeVideo(id);
} }
} }
}, },
@ -1010,8 +1010,26 @@ var VideoLayout = {
if (!largeVideo) { if (!largeVideo) {
return; return;
} }
let isOnLarge = this.isCurrentlyOnLarge(id); const currentContainer = largeVideo.getCurrentContainer();
let currentId = largeVideo.id; const currentContainerType = largeVideo.getCurrentContainerType();
const currentId = largeVideo.id;
const isOnLarge = this.isCurrentlyOnLarge(id);
const smallVideo = this.getSmallVideo(id);
if (isOnLarge && !forceUpdate
&& LargeVideoManager.isVideoContainer(currentContainerType)
&& smallVideo) {
const currentStreamId = currentContainer.getStreamID();
const newStreamId
= smallVideo.videoStream
? smallVideo.videoStream.getId() : null;
// FIXME it might be possible to get rid of 'forceUpdate' argument
if (currentStreamId !== newStreamId) {
logger.debug('Enforcing large video update for stream change');
forceUpdate = true;
}
}
if (!isOnLarge || forceUpdate) { if (!isOnLarge || forceUpdate) {
let videoType = this.getRemoteVideoType(id); let videoType = this.getRemoteVideoType(id);
@ -1020,7 +1038,6 @@ var VideoLayout = {
eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id); eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
} }
let smallVideo = this.getSmallVideo(id);
let oldSmallVideo; let oldSmallVideo;
if (currentId) { if (currentId) {
oldSmallVideo = this.getSmallVideo(currentId); oldSmallVideo = this.getSmallVideo(currentId);