openvidu-browser: improve video mirroring logic

pull/707/head
pabloFuente 2022-03-10 16:36:51 +01:00
parent 905b7fe281
commit 85b6496ba0
1 changed files with 13 additions and 9 deletions

View File

@ -414,17 +414,17 @@ export class StreamManager extends EventDispatcher {
}
}
if (this.remote) {
// Do not mirror remote video.
// Remove the mirror if this video was currently associated with a local mirrored video.
this.removeMirrorVideo(video);
}
else if (!this.stream.displayMyRemote()) {
if (this.remote && this.isMirroredVideo(video)) {
// Remote video associated to a previously mirrored video element
this.removeMirrorVideo(video);
} else if (!this.stream.displayMyRemote()) {
// Local video
video.muted = true;
if (video.style.transform === 'rotateY(180deg)' && !this.stream.outboundStreamOpts.publisherProperties.mirror) {
if (this.isMirroredVideo(video) && !this.stream.outboundStreamOpts.publisherProperties.mirror) {
// If the video was already rotated and now is set to not mirror
this.removeMirrorVideo(video);
} else if (this.stream.outboundStreamOpts.publisherProperties.mirror && !this.stream.isSendScreen()) {
// If the video is now set to mirror and is not screen share
this.mirrorVideo(video);
}
}
@ -536,18 +536,22 @@ export class StreamManager extends EventDispatcher {
}
}
private mirrorVideo(video): void {
private mirrorVideo(video: HTMLVideoElement): void {
if (!platform.isIonicIos()) {
video.style.transform = 'rotateY(180deg)';
video.style.webkitTransform = 'rotateY(180deg)';
}
}
private removeMirrorVideo(video): void {
private removeMirrorVideo(video: HTMLVideoElement): void {
video.style.transform = 'unset';
video.style.webkitTransform = 'unset';
}
private isMirroredVideo(video: HTMLVideoElement): boolean {
return video.style.transform === 'rotateY(180deg)' || video.style.webkitTransform === 'rotateY(180deg)';
}
private activateStreamPlayingEventExceptionTimeout() {
if (!this.remote) {
// ExceptionEvent NO_STREAM_PLAYING_EVENT is only for subscribers