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
29 /// This constructor supports the product infrastructure and is not intended to be used directly from application code.
31 protected PlayerDisplaySettings(Player player)
35 throw new ArgumentNullException(nameof(player));
41 internal static PlayerDisplaySettings Create(Player player) => new PlayerDisplaySettings(player);
44 /// Gets the player of this instance.
46 /// <value>The <see cref="Player"/> of this <see cref="PlayerDisplaySettings"/> instance.</value>
47 protected Player Player { get; }
50 /// Gets or sets the <see cref="PlayerDisplayMode"/>.
52 /// <exception cref="InvalidOperationException">
53 /// Operation failed; internal error.
55 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
56 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
57 public PlayerDisplayMode Mode
61 Native.GetMode(Player.Handle, out var value).
62 ThrowIfFailed("Failed to get display mode");
68 ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
70 Native.SetMode(Player.Handle, value).
71 ThrowIfFailed("Failed to set display mode");
76 /// Gets or sets the value indicating whether the display is visible.
78 /// <value>true if the display is visible; otherwise false.</value>
79 /// <exception cref="InvalidOperationException">
80 /// Operation failed; internal error.
82 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
87 Native.IsVisible(Player.Handle, out var value).
88 ThrowIfFailed("Failed to get the visible state of the display");
94 Native.SetVisible(Player.Handle, value).ThrowIfFailed("Failed to set the visible state of the display");
99 /// Gets or sets the rotation of the display.
101 /// <value><see cref="Rotation.Rotate0"/>, <see cref="Rotation.Rotate90"/>, <see cref="Rotation.Rotate180"/>,
102 /// <see cref="Rotation.Rotate270"/></value>
103 /// <exception cref="InvalidOperationException">
104 /// Operation failed; internal error.
106 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
107 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
108 public Rotation Rotation
112 Native.GetRotation(Player.Handle, out var value).
113 ThrowIfFailed("Failed to get the rotation state of the display");
119 ValidationUtil.ValidateEnum(typeof(Rotation), value);
121 Native.SetRotation(Player.Handle, value).
122 ThrowIfFailed("Failed to set the rotation state of the display");
127 /// Sets the roi(region of interest).
129 /// <param name="roi">The region.</param>
131 /// To set roi, <see cref="Mode"/> must be set to <see cref="PlayerDisplayMode.Roi"/> first.
133 /// <exception cref="InvalidOperationException">
134 /// Operation failed; internal error.\n
136 /// <see cref="Mode"/> is not set to <see cref="PlayerDisplayMode.Roi"/>.
138 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
139 /// <exception cref="ArgumentOutOfRangeException">The width or the height is less than or equal to zero.</exception>
140 public void SetRoi(Rectangle roi)
144 throw new ArgumentOutOfRangeException(nameof(roi), roi.Width,
145 $"The width of the roi can't be less than or equal to zero.");
149 throw new ArgumentOutOfRangeException(nameof(roi), roi.Height,
150 $"The height of the roi can't be less than or equal to zero.");
153 if (Mode != PlayerDisplayMode.Roi)
155 throw new InvalidOperationException("Mode is not set to Roi");
158 Native.SetRoi(Player.Handle, roi.X, roi.Y, roi.Width, roi.Height).
159 ThrowIfFailed("Failed to set the roi");