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 /// Operation failed; internal error.
48 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
49 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
50 public PlayerDisplayMode Mode
54 Native.GetMode(Player.Handle, out var value).
55 ThrowIfFailed("Failed to get display mode");
61 ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
63 Native.SetMode(Player.Handle, value).
64 ThrowIfFailed("Failed to set display mode");
69 /// Gets or sets the value indicating whether the display is visible.
71 /// <value>true if the display is visible; otherwise false.</value>
72 /// <exception cref="InvalidOperationException">
73 /// Operation failed; internal error.
75 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
80 Native.IsVisible(Player.Handle, out var value).
81 ThrowIfFailed("Failed to get the visible state of the display");
87 Native.SetVisible(Player.Handle, value).ThrowIfFailed("Failed to set the visible state of the display");
92 /// Gets or sets the rotation of the display.
94 /// <value><see cref="Rotation.Rotate0"/>, <see cref="Rotation.Rotate90"/>, <see cref="Rotation.Rotate180"/>,
95 /// <see cref="Rotation.Rotate270"/></value>
96 /// <exception cref="InvalidOperationException">
97 /// Operation failed; internal error.
99 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
100 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
101 public Rotation Rotation
105 Native.GetRotation(Player.Handle, out var value).
106 ThrowIfFailed("Failed to get the rotation state of the display");
112 ValidationUtil.ValidateEnum(typeof(Rotation), value);
114 Native.SetRotation(Player.Handle, value).
115 ThrowIfFailed("Failed to set the rotation state of the display");
120 /// Sets the roi(region of interest).
122 /// <param name="roi">The region.</param>
124 /// To set roi, <see cref="Mode"/> must be set to <see cref="PlayerDisplayMode.Roi"/> first.
126 /// <exception cref="InvalidOperationException">
127 /// Operation failed; internal error.\n
129 /// <see cref="Mode"/> is not set to <see cref="PlayerDisplayMode.Roi"/>.
131 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
132 /// <exception cref="ArgumentOutOfRangeException">width or height is less than or equal to zero.</exception>
133 public void SetRoi(Rectangle roi)
137 throw new ArgumentOutOfRangeException(nameof(roi), roi.Width,
138 $"The width of the roi can't be less than or equal to zero.");
142 throw new ArgumentOutOfRangeException(nameof(roi), roi.Height,
143 $"The height of the roi can't be less than or equal to zero.");
146 if (Mode != PlayerDisplayMode.Roi)
148 throw new InvalidOperationException("Mode is not set to Roi");
151 Native.SetRoi(Player.Handle, roi.X, roi.Y, roi.Width, roi.Height).
152 ThrowIfFailed("Failed to set the roi");