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 internal PlayerDisplaySettings(Player player)
30 Debug.Assert(player != null);
40 private PlayerDisplayMode _displayMode = PlayerDisplayMode.LetterBox;
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
60 if (_displayMode == value)
65 ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
67 Native.SetMode(Player.Handle, value).
68 ThrowIfFailed("Failed to set display mode");
74 private bool _isVisible = true;
77 /// Gets or sets the value indicating whether the display is visible.
79 /// <value>true if the display is visible; otherwise false.</value>
80 /// <exception cref="InvalidOperationException">
81 /// The display is not assigned.\n
83 /// Operation failed; internal error.
85 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
94 if (_isVisible == value)
99 Native.SetVisible(Player.Handle, value).
100 ThrowIfFailed("Failed to set the visible state of the display");
106 private Rotation _rotation = Rotation.Rotate0;
109 /// Gets or sets the rotation of the display.
111 /// <value><see cref="PlayerDisplayRotation.RotationNone"/>,
112 /// <see cref="PlayerDisplayRotation.Rotation90"/>,
113 /// <see cref="PlayerDisplayRotation.Rotation180"/>,
114 /// <see cref="PlayerDisplayRotation.Rotation270"/></value>
115 /// <exception cref="InvalidOperationException">
116 /// The display is not assigned.\n
118 /// Operation failed; internal error.
120 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
121 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
122 public Rotation Rotation
130 if (_rotation == value)
135 ValidationUtil.ValidateEnum(typeof(Rotation), value);
137 Native.SetRotation(Player.Handle, value).
138 ThrowIfFailed("Failed to set the rotation state of the display");
145 /// Sets the roi(region of interest).
147 /// <param name="roi">The region.</param>
149 /// To set roi, <see cref="Mode"/> must be set to <see cref="PlayerDisplayMode.Roi"/> first.
151 /// <exception cref="InvalidOperationException">
152 /// The display is not assigned.\n
154 /// Operation failed; internal error.\n
156 /// <see cref="Mode"/> is not set to <see cref="PlayerDisplayMode.Roi"/>
158 /// <exception cref="ObjectDisposedException">The player already has been disposed of.</exception>
159 /// <exception cref="ArgumentOutOfRangeException">width or height is less than or equal to zero.</exception>
160 public void SetRoi(Rectangle roi)
162 if (_displayMode != PlayerDisplayMode.Roi)
164 throw new InvalidOperationException("Mode is not set to Roi");
169 throw new ArgumentOutOfRangeException(nameof(roi), roi.Width,
170 $"The width of the roi can't be less than or equal to zero.");
174 throw new ArgumentOutOfRangeException(nameof(roi), roi.Height,
175 $"The height of the roi can't be less than or equal to zero.");
178 Native.SetRoi(Player.Handle, roi.X, roi.Y, roi.Width, roi.Height).
179 ThrowIfFailed("Failed to set the roi");