2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Diagnostics;
19 using Native = Interop.Display;
21 namespace Tizen.Multimedia
24 /// Provides a means to configure display settings for video <see cref="Player"/>.
26 public class PlayerDisplaySettings
28 protected PlayerDisplaySettings(Player player)
32 throw new ArgumentNullException(nameof(player));
38 internal static PlayerDisplaySettings Create(Player player) => new PlayerDisplaySettings(player);
40 protected Player Player { get; }
43 /// Gets or sets the <see cref="PlayerDisplayMode"/>.
45 /// <exception cref="InvalidOperationException">
46 /// The display is not assigned.\n
48 /// Operation failed; internal error.
50 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
51 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
52 public PlayerDisplayMode Mode
56 Native.GetMode(Player.Handle, out var value).
57 ThrowIfFailed("Failed to get display mode");
63 ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
65 Native.SetMode(Player.Handle, value).
66 ThrowIfFailed("Failed to set display mode");
71 /// Gets or sets the value indicating whether the display is visible.
73 /// <value>true if the display is visible; otherwise false.</value>
74 /// <exception cref="InvalidOperationException">
75 /// The display is not assigned.\n
77 /// Operation failed; internal error.
79 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
84 Native.IsVisible(Player.Handle, out var value).
85 ThrowIfFailed("Failed to get the visible state of the display");
91 Native.SetVisible(Player.Handle, value).ThrowIfFailed("Failed to set the visible state of the display");
96 /// Gets or sets the rotation of the display.
98 /// <value><see cref="Rotation.Rotate0"/>, <see cref="Rotation.Rotate90"/>, <see cref="Rotation.Rotate180"/>,
99 /// <see cref="Rotation.Rotate270"/></value>
100 /// <exception cref="InvalidOperationException">
101 /// The display is not assigned.\n
103 /// Operation failed; internal error.
105 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
106 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
107 public Rotation Rotation
111 Native.GetRotation(Player.Handle, out var value).
112 ThrowIfFailed("Failed to get the rotation state of the display");
118 ValidationUtil.ValidateEnum(typeof(Rotation), value);
120 Native.SetRotation(Player.Handle, value).
121 ThrowIfFailed("Failed to set the rotation state of the display");
126 /// Sets the roi(region of interest).
128 /// <param name="roi">The region.</param>
130 /// To set roi, <see cref="Mode"/> must be set to <see cref="PlayerDisplayMode.Roi"/> first.
132 /// <exception cref="InvalidOperationException">
133 /// The display is not assigned.\n
135 /// Operation failed; internal error.\n
137 /// <see cref="Mode"/> is not set to <see cref="PlayerDisplayMode.Roi"/>.
139 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
140 /// <exception cref="ArgumentOutOfRangeException">width or height is less than or equal to zero.</exception>
141 public void SetRoi(Rectangle roi)
145 throw new ArgumentOutOfRangeException(nameof(roi), roi.Width,
146 $"The width of the roi can't be less than or equal to zero.");
150 throw new ArgumentOutOfRangeException(nameof(roi), roi.Height,
151 $"The height of the roi can't be less than or equal to zero.");
154 if (Mode != PlayerDisplayMode.Roi)
156 throw new InvalidOperationException("Mode is not set to Roi");
159 Native.SetRoi(Player.Handle, roi.X, roi.Y, roi.Width, roi.Height).
160 ThrowIfFailed("Failed to set the roi");