From: Haesu Gwon Date: Fri, 24 Mar 2023 03:12:00 +0000 (+0900) Subject: [Multimedia] Fix rotation issue for portrait mode (#5105) X-Git-Tag: submit/tizen_7.0/20230324.150922~1^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c981316ac61d247a05e1485c09664d656b2a2226;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Multimedia] Fix rotation issue for portrait mode (#5105) --- diff --git a/src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs b/src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs index 3f62ac6..11963c6 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 c256f45..c0aadf3 100644 --- a/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs +++ b/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs @@ -377,12 +377,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 a53cd3f..754b546 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 df7f9d6..b56c0c6 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/MediaSource.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/MediaSource.cs @@ -669,7 +669,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 650ca26..39a3b37 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs @@ -111,7 +111,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 a5c81c8..1082110 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; + } + } }