From: Haesu Gwon Date: Tue, 21 Nov 2023 08:35:32 +0000 (+0900) Subject: [Multimedia] Fix rotation issue for portrait mode (#5766) X-Git-Tag: submit/tizen_8.0/20231121.150905~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf1f33f17487585262a154090354dbb34610ae3b;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Multimedia] Fix rotation issue for portrait mode (#5766) --- diff --git a/src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs b/src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs index 3f62ac6ab..11963c644 100644 --- a/src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs +++ b/src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs @@ -116,7 +116,7 @@ namespace Tizen.Multimedia return CameraDisplay.SetDisplay(GetHandle(), type, evasObject); } - CameraError IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect) + CameraError IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation) { Debug.Assert(_disposed == false); diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs b/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs index c2bac2fc9..1b5d2f393 100644 --- a/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs +++ b/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs @@ -373,12 +373,14 @@ namespace Tizen.Multimedia type == DisplayType.Overlay ? PlayerDisplayType.Overlay : PlayerDisplayType.Evas, evasObject); } - PlayerErrorCode IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect) + PlayerErrorCode IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation) { Debug.Assert(IsDisposed == false); return NativeDisplay.SetEcoreDisplay(Handle, - _uiSync ? PlayerDisplayType.OverlayUISync : PlayerDisplayType.Overlay, windowHandle, rect.X, rect.Y, rect.Width, rect.Height); + _uiSync ? PlayerDisplayType.OverlayUISync : PlayerDisplayType.Overlay, windowHandle, rect.X, rect.Y, + rotation == Rotation.Rotate0 || rotation == Rotation.Rotate180 ? rect.Height : rect.Width, + rotation == Rotation.Rotate0 || rotation == Rotation.Rotate180 ? rect.Width : rect.Height); } #endregion diff --git a/src/Tizen.Multimedia.Remoting/ScreenMirroring/ScreenMirroring.cs b/src/Tizen.Multimedia.Remoting/ScreenMirroring/ScreenMirroring.cs index a53cd3f58..754b546c9 100644 --- a/src/Tizen.Multimedia.Remoting/ScreenMirroring/ScreenMirroring.cs +++ b/src/Tizen.Multimedia.Remoting/ScreenMirroring/ScreenMirroring.cs @@ -134,7 +134,7 @@ namespace Tizen.Multimedia.Remoting return Native.SetDisplay(Handle, (int)type, evasObject); } - ScreenMirroringErrorCode IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect) + ScreenMirroringErrorCode IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation) { return Native.SetEcoreDisplay(Handle, windowHandle); } diff --git a/src/Tizen.Multimedia.Remoting/WebRTC/MediaSource.cs b/src/Tizen.Multimedia.Remoting/WebRTC/MediaSource.cs index 69bb95d9d..8798eb2b0 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/MediaSource.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/MediaSource.cs @@ -675,7 +675,7 @@ namespace Tizen.Multimedia.Remoting return trackId; } - uint IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect) + uint IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation) { NativeWebRTC.SetEcoreVideoLoopback(WebRtc.Handle, SourceId.Value, windowHandle, out uint trackId). ThrowIfFailed("Failed to set ecore video loopback"); diff --git a/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs b/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs index 2e5e3aa06..be62bebf2 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs @@ -126,7 +126,7 @@ namespace Tizen.Multimedia.Remoting type == DisplayType.Overlay ? WebRTCDisplayType.Overlay : WebRTCDisplayType.Evas, evasObject); } - WebRTCErrorCode IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect) + WebRTCErrorCode IDisplayable.ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation) { return NativeWebRTC.SetEcoreDisplay(_webRtc.Handle, _trackId, windowHandle); } diff --git a/src/Tizen.Multimedia/Common/Display.cs b/src/Tizen.Multimedia/Common/Display.cs index a5c81c866..10821105d 100644 --- a/src/Tizen.Multimedia/Common/Display.cs +++ b/src/Tizen.Multimedia/Common/Display.cs @@ -39,7 +39,7 @@ namespace Tizen.Multimedia internal interface IDisplayable { TError ApplyEvasDisplay(DisplayType type, EvasObject evasObject); - TError ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect); + TError ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation); } internal interface IDisplaySetter @@ -72,17 +72,19 @@ namespace Tizen.Multimedia internal class EcoreDisplaySetter : IDisplaySetter { private readonly IntPtr _windowHandle; - private readonly NUI.Rectangle _rect; + private readonly Rectangle _rect; + private readonly Rotation _rotation; - internal EcoreDisplaySetter(IntPtr windowHandle, NUI.Rectangle rect) + internal EcoreDisplaySetter(IntPtr windowHandle, Rectangle rect, Rotation rotation) { _windowHandle = windowHandle; _rect = rect; + _rotation = rotation; } public TError SetDisplay(IDisplayable target) { - return target.ApplyEcoreWindow(_windowHandle, _rect); + return target.ApplyEcoreWindow(_windowHandle, _rect, _rotation); } } @@ -163,7 +165,11 @@ namespace Tizen.Multimedia { throw new ArgumentNullException(nameof(window)); } - _setter = new EcoreDisplaySetter(window.GetNativeWindowHandler(), window.WindowPositionSize); + + var windowSize = new Rectangle(window.WindowPositionSize.X, window.WindowPositionSize.Y, + window.WindowPositionSize.Width, window.WindowPositionSize.Height); + + _setter = new EcoreDisplaySetter(window.GetNativeWindowHandler(), windowSize, window.GetCurrentOrientation().ToMmRotation()); UiSync = uiSync; } @@ -195,4 +201,26 @@ namespace Tizen.Multimedia return _setter.SetDisplay(target); } } + + internal static class WindowOrientationExtension + { + internal static Tizen.Multimedia.Rotation ToMmRotation(this NUI.Window.WindowOrientation rotation) + { + switch (rotation) + { + case NUI.Window.WindowOrientation.Portrait: + return Tizen.Multimedia.Rotation.Rotate0; + case NUI.Window.WindowOrientation.Landscape: + return Tizen.Multimedia.Rotation.Rotate90; + case NUI.Window.WindowOrientation.PortraitInverse: + return Tizen.Multimedia.Rotation.Rotate180; + case NUI.Window.WindowOrientation.LandscapeInverse: + return Tizen.Multimedia.Rotation.Rotate270; + default: + break; + } + + return Tizen.Multimedia.Rotation.Rotate90; + } + } }