[Multimedia] Fix rotation issue for portrait mode (#5766)
authorHaesu Gwon <haesu.gwon@samsung.com>
Tue, 21 Nov 2023 08:35:32 +0000 (17:35 +0900)
committerGitHub <noreply@github.com>
Tue, 21 Nov 2023 08:35:32 +0000 (17:35 +0900)
src/Tizen.Multimedia.Camera/Camera/Camera.Properties.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
src/Tizen.Multimedia.Remoting/ScreenMirroring/ScreenMirroring.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaSource.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs
src/Tizen.Multimedia/Common/Display.cs

index 3f62ac6..11963c6 100644 (file)
@@ -116,7 +116,7 @@ namespace Tizen.Multimedia
             return CameraDisplay.SetDisplay(GetHandle(), type, evasObject);
         }
 
-        CameraError IDisplayable<CameraError>.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect)
+        CameraError IDisplayable<CameraError>.ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation)
         {
             Debug.Assert(_disposed == false);
 
index c2bac2f..1b5d2f3 100644 (file)
@@ -373,12 +373,14 @@ namespace Tizen.Multimedia
                 type == DisplayType.Overlay ? PlayerDisplayType.Overlay : PlayerDisplayType.Evas, evasObject);
         }
 
-        PlayerErrorCode IDisplayable<PlayerErrorCode>.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect)
+        PlayerErrorCode IDisplayable<PlayerErrorCode>.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
 
index a53cd3f..754b546 100644 (file)
@@ -134,7 +134,7 @@ namespace Tizen.Multimedia.Remoting
             return Native.SetDisplay(Handle, (int)type, evasObject);
         }
 
-        ScreenMirroringErrorCode IDisplayable<ScreenMirroringErrorCode>.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect)
+        ScreenMirroringErrorCode IDisplayable<ScreenMirroringErrorCode>.ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation)
         {
             return Native.SetEcoreDisplay(Handle, windowHandle);
         }
index 69bb95d..8798eb2 100755 (executable)
@@ -675,7 +675,7 @@ namespace Tizen.Multimedia.Remoting
             return trackId;
         }
 
-        uint IDisplayable<uint>.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect)
+        uint IDisplayable<uint>.ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation)
         {
             NativeWebRTC.SetEcoreVideoLoopback(WebRtc.Handle, SourceId.Value, windowHandle, out uint trackId).
                 ThrowIfFailed("Failed to set ecore video loopback");
index 2e5e3aa..be62beb 100755 (executable)
@@ -126,7 +126,7 @@ namespace Tizen.Multimedia.Remoting
                 type == DisplayType.Overlay ? WebRTCDisplayType.Overlay : WebRTCDisplayType.Evas, evasObject);
         }
 
-        WebRTCErrorCode IDisplayable<WebRTCErrorCode>.ApplyEcoreWindow(IntPtr windowHandle, NUI.Rectangle rect)
+        WebRTCErrorCode IDisplayable<WebRTCErrorCode>.ApplyEcoreWindow(IntPtr windowHandle, Rectangle rect, Rotation rotation)
         {
             return NativeWebRTC.SetEcoreDisplay(_webRtc.Handle, _trackId, windowHandle);
         }
index a5c81c8..1082110 100644 (file)
@@ -39,7 +39,7 @@ namespace Tizen.Multimedia
     internal interface IDisplayable<TError>
     {
         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<TError>(IDisplayable<TError> 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;
+        }
+    }
 }