[Player] Add PlayerDisplayMode.Roi and PlayerDisplay.SetRoi for ROI display mode.
authorcoderhyme <jhyo.kim@samsung.com>
Wed, 5 Apr 2017 10:40:39 +0000 (19:40 +0900)
committercoderhyme <jhyo.kim@samsung.com>
Wed, 5 Apr 2017 10:40:39 +0000 (19:40 +0900)
Change-Id: I4211fcab7c293f9b6057558b3d7a593c09e4fbf0
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
src/Tizen.Multimedia/Interop/Interop.Player.cs
src/Tizen.Multimedia/Player/PlayerDisplay.cs
src/Tizen.Multimedia/Player/PlayerEnums.cs

index 047e887..1f75907 100644 (file)
@@ -234,6 +234,9 @@ namespace Tizen.Multimedia
             [DllImport(Libraries.Player, EntryPoint = "player_get_display_rotation")]
             internal static extern int GetDisplayRotation(IntPtr player, out int rotation);
 
+            [DllImport(Libraries.Player, EntryPoint = "player_set_display_roi_area")]
+            internal static extern int SetDisplayRoi(IntPtr player, int x, int y, int width, int height);
+
             [DllImport(Libraries.Player, EntryPoint = "player_get_content_info")]
             internal static extern int GetContentInfo(IntPtr player, int key, out IntPtr value);
 
index 5ed28de..f6ebe0c 100644 (file)
@@ -24,41 +24,33 @@ namespace Tizen.Multimedia
     /// </summary>
     public class PlayerDisplay
     {
-        private readonly EvasObject _evasObject;
-
-        private PlayerDisplay(PlayerDisplayType type, EvasObject evasObject)
+        private PlayerDisplay(PlayerDisplayType type, EvasObject target)
         {
-            if (evasObject == null)
+            if (target == null)
             {
                 Log.Error(PlayerLog.Tag, "evas object is null");
-                throw new ArgumentNullException(nameof(evasObject));
+                throw new ArgumentNullException(nameof(target));
             }
 
-            if (evasObject == IntPtr.Zero)
+            if (target == IntPtr.Zero)
             {
                 Log.Error(PlayerLog.Tag, "The evas object is not realized.");
                 throw new ArgumentException("The evas object is not realized.");
             }
 
             Type = type;
-            _evasObject = evasObject;
+            EvasObject = target;
         }
 
         public PlayerDisplay(Window window) : this(PlayerDisplayType.Overlay, window)
         {
         }
 
-        public PlayerDisplay(ElmSharp.Image image) : this(PlayerDisplayType.Surface, image)
+        public PlayerDisplay(Image image) : this(PlayerDisplayType.Surface, image)
         {
         }
 
-        public EvasObject EvasObject
-        {
-            get
-            {
-                return _evasObject;
-            }
-        }
+        public EvasObject EvasObject { get; }
 
         internal PlayerDisplayType Type { get; }
 
@@ -87,7 +79,6 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Set/Get Display mode.
         /// </summary>
-        /// <value> LetterBox, OriginalSize, FullScreen, CroppedFull, OriginalOrFull, DstRoi </value>
         /// <exception cref="InvalidOperationException">
         /// The display is not assigned.
         /// <para>-or-</para>
@@ -201,5 +192,45 @@ namespace Tizen.Multimedia
                 _rotation = value;
             }
         }
+
+        /// <summary>
+        /// Sets the roi(region of interest).
+        /// </summary>
+        /// <remarks>
+        /// To set roi, <see cref="Mode"/> must be set to <see cref="PlayerDisplayMode.Roi"/> first.
+        /// </remarks>
+        /// <exception cref="InvalidOperationException">
+        /// The display is not assigned.
+        /// <para>-or-</para>
+        /// Operation failed; internal error.
+        /// <para>-or-</para>
+        /// <see cref="Mode"/> is not set to <see cref="PlayerDisplayMode.Roi"/>
+        /// </exception>
+        /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
+        /// <exception cref="ArgumentOutOfRangeException">width or height is less than or equal to zero.</exception>
+        public void SetRoi(Rectangle roi)
+        {
+            ValidatePlayer();
+
+            if (_displayMode != PlayerDisplayMode.Roi)
+            {
+                throw new InvalidOperationException("Mode is not set to Roi");
+            }
+
+            if (roi.Width <= 0)
+            {
+                throw new ArgumentOutOfRangeException(nameof(roi), roi.Width,
+                    $"The width of the roi can't be less than or equal to zero.");
+            }
+            if (roi.Height <= 0)
+            {
+                throw new ArgumentOutOfRangeException(nameof(roi), roi.Height,
+                    $"The height of the roi can't be less than or equal to zero.");
+            }
+
+            PlayerErrorConverter.ThrowIfError(
+                Interop.Player.SetDisplayRoi(Player.GetHandle(), roi.X, roi.Y, roi.Width, roi.Height),
+                "Failed to set the roi");
+        }
     }
 }
index 12fc51b..184c053 100644 (file)
@@ -193,6 +193,10 @@ namespace Tizen.Multimedia
         /// </summary>
         OriginalOrFull,
 
+        /// <summary>
+        /// Region of interest, See <see cref="PlayerDisplay.SetRoi(Rectangle)"/>.
+        /// </summary>
+        Roi
     }
 
     internal enum StreamType