From e5e88b594e256001f0db34609f0b07b39cfbfbbe Mon Sep 17 00:00:00 2001 From: coderhyme Date: Wed, 5 Apr 2017 19:40:39 +0900 Subject: [PATCH] [Player] Add PlayerDisplayMode.Roi and PlayerDisplay.SetRoi for ROI display mode. Change-Id: I4211fcab7c293f9b6057558b3d7a593c09e4fbf0 Signed-off-by: coderhyme --- src/Tizen.Multimedia/Interop/Interop.Player.cs | 3 ++ src/Tizen.Multimedia/Player/PlayerDisplay.cs | 63 +++++++++++++++++++------- src/Tizen.Multimedia/Player/PlayerEnums.cs | 4 ++ 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/Tizen.Multimedia/Interop/Interop.Player.cs b/src/Tizen.Multimedia/Interop/Interop.Player.cs index 047e887..1f75907 100644 --- a/src/Tizen.Multimedia/Interop/Interop.Player.cs +++ b/src/Tizen.Multimedia/Interop/Interop.Player.cs @@ -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); diff --git a/src/Tizen.Multimedia/Player/PlayerDisplay.cs b/src/Tizen.Multimedia/Player/PlayerDisplay.cs index 5ed28de..f6ebe0c 100644 --- a/src/Tizen.Multimedia/Player/PlayerDisplay.cs +++ b/src/Tizen.Multimedia/Player/PlayerDisplay.cs @@ -24,41 +24,33 @@ namespace Tizen.Multimedia /// 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 /// /// Set/Get Display mode. /// - /// LetterBox, OriginalSize, FullScreen, CroppedFull, OriginalOrFull, DstRoi /// /// The display is not assigned. /// -or- @@ -201,5 +192,45 @@ namespace Tizen.Multimedia _rotation = value; } } + + /// + /// Sets the roi(region of interest). + /// + /// + /// To set roi, must be set to first. + /// + /// + /// The display is not assigned. + /// -or- + /// Operation failed; internal error. + /// -or- + /// is not set to + /// + /// The player already has been disposed of. + /// width or height is less than or equal to zero. + 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"); + } } } diff --git a/src/Tizen.Multimedia/Player/PlayerEnums.cs b/src/Tizen.Multimedia/Player/PlayerEnums.cs index 12fc51b..184c053 100644 --- a/src/Tizen.Multimedia/Player/PlayerEnums.cs +++ b/src/Tizen.Multimedia/Player/PlayerEnums.cs @@ -193,6 +193,10 @@ namespace Tizen.Multimedia /// OriginalOrFull, + /// + /// Region of interest, See . + /// + Roi } internal enum StreamType -- 2.7.4