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.
19 namespace Tizen.Multimedia
22 /// The CameraDisplay class allows you to manage display for the camera.
23 /// It allows to set and get various display properties such as
24 /// rotation, display visibility and display mode.
26 public class CameraDisplay
28 internal readonly Camera _camera;
30 internal CameraDisplay(Camera camera)
38 /// <value>A <see cref="CameraDisplayMode"/> that specifies the display mode.</value>
39 /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
40 public CameraDisplayMode Mode
44 CameraDisplayMode val = CameraDisplayMode.LetterBox;
46 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetMode(_camera.GetHandle(), out val),
47 "Failed to get camera display mode");
54 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetMode(_camera.GetHandle(), value),
55 "Failed to set camera display mode.");
60 /// The display visibility.
61 /// True if camera display visible, otherwise false.
63 /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
70 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetVisible(_camera.GetHandle(), out val),
71 "Failed to get visible value");
78 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetVisible(_camera.GetHandle(), value),
79 "Failed to set display visible.");
84 /// The display rotation.
86 /// <value>A <see cref="CameraRotation"/> that specifies the rotation of camera device.</value>
88 /// http://tizen.org/privilege/camera.
90 /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
91 public CameraRotation Rotation
95 CameraRotation val = CameraRotation.None;
97 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetRotation(_camera.GetHandle(), out val),
98 "Failed to get display rotation");
105 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetRotation(_camera.GetHandle(), value),
106 "Failed to set display rotation.");
111 /// The display flip.
113 /// <value>A <see cref="CameraFlip"/> that specifies camera flip type.</value>
115 /// http://tizen.org/privilege/camera.
117 /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
118 public CameraFlip Flip
122 CameraFlip val = CameraFlip.None;
124 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetFlip(_camera.GetHandle(), out val),
125 "Failed to get display flip");
132 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetFlip(_camera.GetHandle(), value),
133 "Failed to set display flip.");
138 /// the ROI(Region Of Interest) area of display.
140 /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
141 public Rectangle RoiArea
150 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.GetRoiArea(_camera.GetHandle(), out x, out y, out width, out height),
151 "Failed to get display roi area");
153 return new Rectangle(x, y, width, height);
158 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetRoiArea(_camera.GetHandle(),
159 value.X, value.Y, value.Width, value.Height), "Failed to set display roi area.");
164 /// Sets the display type and handle to show preview images.
165 /// The camera must be in the <see cref="CameraState.Created"/> state.
167 /// <param name="displayType">Display type.</param>
168 /// <param name="preview">MediaView object to display preview.</param>
170 /// This method must be called before StartPreview() method.
171 /// In Custom ROI display mode, DisplayRoiArea property must be set before calling this method.
173 /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
174 /// <exception cref="InvalidOperationException">In case of any invalid operations.</exception>
175 /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
176 /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
177 /// <exception cref="UnauthorizedAccessException">In case of access to the resources cannot be granted.</exception>
178 public void SetInfo(CameraDisplayType displayType, MediaView displayHandle)
180 _camera.ValidateState(CameraState.Created);
182 ValidationUtil.ValidateEnum(typeof(CameraDisplayType), displayType);
184 CameraErrorFactory.ThrowIfError(Interop.CameraDisplay.SetInfo(_camera.GetHandle(), displayType, displayHandle),
185 "Failed to set the camera display.");