[ScreenMirroring] Add new display and device type APIs (#6864)
authorHaesu Gwon <haesu.gwon@samsung.com>
Thu, 29 May 2025 01:54:46 +0000 (10:54 +0900)
committerGitHub <noreply@github.com>
Thu, 29 May 2025 01:54:46 +0000 (10:54 +0900)
* [ScreenMirroring] Add new display and device type APIs

src/Tizen.Multimedia.Remoting/Interop/Interop.ScreenMirroring.cs
src/Tizen.Multimedia.Remoting/ScreenMirroring/ScreenMirroring.cs
src/Tizen.Multimedia.Remoting/ScreenMirroring/ScreenMirroringEnums.cs

index 20a9a4602328801adff774c457dee4494b1e5a95..9357aceaf9c263ae7a85b475a0d671a4b467e8ee 100755 (executable)
@@ -15,7 +15,9 @@
  */
 
 using System;
+using System.Drawing;
 using System.Runtime.InteropServices;
+using Tizen.Multimedia;
 using Tizen.Multimedia.Remoting;
 
 internal static partial class Interop
@@ -39,12 +41,24 @@ internal static partial class Interop
         [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_set_display")]
         internal static extern ScreenMirroringErrorCode SetDisplay(IntPtr handle, int type, IntPtr display);
 
+        [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_set_display_mode")]
+        internal static extern ScreenMirroringErrorCode SetDisplayMode(IntPtr handle, ScreenMirroringDisplayMode mode);
+
+        [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_set_display_roi")]
+        internal static extern ScreenMirroringErrorCode SetDisplayRoi(IntPtr handle, int x, int y, int width, int height);
+
+        [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_set_display_rotation")]
+        internal static extern ScreenMirroringErrorCode SetDisplayRotation(IntPtr handle, Rotation rotatjion);
+
         [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_set_ecore_wl_display")]
         internal static extern ScreenMirroringErrorCode SetEcoreDisplay(IntPtr handle, IntPtr display);
 
         [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_set_resolution")]
         internal static extern ScreenMirroringErrorCode SetResolution(IntPtr handle, ScreenMirroringResolutions resolution);
 
+        [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_set_src_device_type")]
+        internal static extern ScreenMirroringErrorCode SetSrcDeviceType(IntPtr handle, ScreenMirroringDeviceType type);
+
         [DllImport(Libraries.ScreenMirroring, EntryPoint = "scmirroring_sink_prepare")]
         internal static extern ScreenMirroringErrorCode Prepare(IntPtr handle);
 
index 754b546c96504ee24f0c301bf02ab5df6444bad4..7bfa7efd3c4807ba738adc4cdfb6d5b951532677 100644 (file)
@@ -463,6 +463,121 @@ namespace Tizen.Multimedia.Remoting
             }
         }
 
+        private ScreenMirroringDisplayMode _displayMode;
+        /// <summary>
+        /// Gets or sets the display mode.
+        /// </summary>
+        /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
+        /// <since_tizen> 13 </since_tizen>
+        public ScreenMirroringDisplayMode DisplayMode
+        {
+            get
+            {
+                ThrowIfDisposed();
+
+                return _displayMode;
+            }
+            set
+            {
+                Native.SetDisplayMode(Handle, value).ThrowIfError("Failed to set display mode");
+                _displayMode = value;
+            }
+        }
+
+        private Rectangle _displayRoi;
+        /// <summary>
+        /// Gets or sets the display position and size of the receiver screen view.
+        /// </summary>
+        /// <remarks>
+        /// DisplayRoi will be applied when <see cref="DisplayMode"/> is <see cref="ScreenMirroringDisplayMode.CustomRoi"/>.
+        /// </remarks>
+        /// <exception cref="ArgumentOutOfRangeException">
+        ///     DisplayRoi.X or DisplayRoi.Y is less than 0.<br/>
+        ///     -or-<br/>
+        ///     DisplayRoi.Width or DisplayRoi.Height is less than or equal to 0.<br/>
+        /// </exception>
+        /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
+        /// <seealso cref="DisplayMode"/>
+        /// <since_tizen> 13 </since_tizen>
+        public Rectangle DisplayRoi
+        {
+            get
+            {
+                ThrowIfDisposed();
+
+                return _displayRoi;
+            }
+            set
+            {
+                if (value.X < 0)
+                {
+                    throw new ArgumentOutOfRangeException("X", value.X,
+                        $"The X of the roi can't be less than zero.");
+                }
+                if (value.Y < 0)
+                {
+                    throw new ArgumentOutOfRangeException("Y", value.Y,
+                        $"The Y of the roi can't be less than zero.");
+                }
+                if (value.Width <= 0)
+                {
+                    throw new ArgumentOutOfRangeException("Width", value.Width,
+                        $"The Width of the roi can't be less than or equal to zero.");
+                }
+                if (value.Height <= 0)
+                {
+                    throw new ArgumentOutOfRangeException("Height", value.Height,
+                        $"The Height of the roi can't be less than or equal to zero.");
+                }
+
+                Native.SetDisplayRoi(Handle, value.X, value.Y, value.Width, value.Height)
+                    .ThrowIfError("Failed to set display ROI");
+                _displayRoi = value;
+            }
+        }
+
+        private Rotation _displayRotation;
+        /// <summary>
+        /// Gets or sets the display rotation.
+        /// </summary>
+        /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
+        /// <since_tizen> 13 </since_tizen>
+        public Rotation DisplayRotation
+        {
+            get
+            {
+                ThrowIfDisposed();
+
+                return _displayRotation;
+            }
+            set
+            {
+                Native.SetDisplayRotation(Handle, value).ThrowIfError("Failed to set display rotation");
+                _displayRotation = value;
+            }
+        }
+
+        private ScreenMirroringDeviceType _srcDeviceType;
+        /// <summary>
+        /// Gets or sets the source device type.
+        /// </summary>
+        /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
+        /// <since_tizen> 13 </since_tizen>
+        public ScreenMirroringDeviceType SourceDeviceType
+        {
+            get
+            {
+                ThrowIfDisposed();
+
+                return _srcDeviceType;
+            }
+            set
+            {
+                Native.SetSrcDeviceType(Handle, value).ThrowIfError("Failed to set source device type");
+                _srcDeviceType = value;
+            }
+        }
+
         /// <summary>
         /// Releases all resource used by the <see cref="ScreenMirroring"/> object.
         /// </summary>
index e4c5aa8fc21c840daea3241cb984b2ee1a4a6cbc..b8ea52bdd57de808938a23eabe38437392f3799b 100644 (file)
@@ -150,4 +150,63 @@ namespace Tizen.Multimedia.Remoting
         /// </summary>
         InvalidOperation = ScreenMirroringErrorCode.InvalidOperation
     }
+
+    /// <summary>
+    /// Specifies the display mode for <see cref="ScreenMirroring"/>.
+    /// </summary>
+    /// <since_tizen> 13 </since_tizen>
+    public enum ScreenMirroringDisplayMode
+    {
+        /// <summary>
+        /// Letter box.
+        /// </summary>
+        LetterBox,
+
+        /// <summary>
+        /// Original size.
+        /// </summary>
+        OriginSize,
+
+        /// <summary>
+        /// Full screen.
+        /// </summary>
+        Full,
+
+        /// <summary>
+        /// Cropped full screen.
+        /// </summary>
+        CroppedFull,
+
+        /// <summary>
+        /// Original size or letter box.
+        /// </summary>
+        OriginOrLetterBox,
+
+        /// <summary>
+        /// Custom ROI.
+        /// </summary>
+        CustomRoi
+    }
+
+    /// <summary>
+    /// Specifies the device type for <see cref="ScreenMirroring"/>.
+    /// </summary>
+    /// <since_tizen> 13 </since_tizen>
+    public enum ScreenMirroringDeviceType
+    {
+        /// <summary>
+        /// All other devices except TV and Mobile.
+        /// </summary>
+        Generic,
+
+        /// <summary>
+        /// TV device.
+        /// </summary>
+        Tv,
+
+        /// <summary>
+        /// Mobile device.
+        /// </summary>
+        Mobile
+    }
 }