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.Runtime.InteropServices;
19 using Native = Interop.CameraSettings;
20 using static Interop.Camera;
22 namespace Tizen.Multimedia
25 /// The camera setting class provides methods/properties to get and
26 /// set basic camera attributes.
28 public class CameraSettings
30 internal readonly Camera _camera;
32 private readonly Range? _brightnessRange;
33 private readonly Range? _contrastRange;
34 private readonly Range? _panRange;
35 private readonly Range? _tiltRange;
36 private readonly Range? _exposureRange;
37 private readonly Range? _zoomRange;
39 internal CameraSettings(Camera camera)
43 _contrastRange = GetRange(Native.GetContrastRange);
44 _brightnessRange = GetRange(Native.GetBrightnessRange);
45 _exposureRange = GetRange(Native.GetExposureRange);
46 _zoomRange = GetRange(Native.GetZoomRange);
47 _panRange = GetRange(Native.GetPanRange);
48 _tiltRange = GetRange(Native.GetTiltRange);
51 private delegate CameraError GetRangeDelegate(IntPtr handle, out int min, out int max);
52 private Range? GetRange(GetRangeDelegate func)
54 CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out int min, out int max),
55 "Failed to initialize the camera settings");
62 return new Range(min, max);
67 /// Sets the auto focus area.
69 /// <since_tizen> 3 </since_tizen>
71 /// <see cref="CameraAutoFocusMode"/> should not be the <see cref="CameraAutoFocusMode.None"/>.
73 /// <param name="x">X position.</param>
74 /// <param name="y">Y position.</param>
75 /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
76 /// <exception cref="InvalidOperationException">In case of any invalid operations.</exception>
77 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
78 public void SetAutoFocusArea(int x, int y)
80 CameraErrorFactory.ThrowIfError(Native.SetAutoFocusArea(_camera.GetHandle(), x, y),
81 "Failed to set the autofocus area.");
85 /// Sets the auto focus area.
87 /// <since_tizen> 3 </since_tizen>
89 /// <see cref="CameraAutoFocusMode"/> should not be the <see cref="CameraAutoFocusMode.None"/>.
91 /// <param name="pos"><see cref="Point"/> structure including X, Y position.</param>
92 /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
93 /// <exception cref="InvalidOperationException">In case of any invalid operations.</exception>
94 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
95 public void SetAutoFocusArea(Point pos)
97 CameraErrorFactory.ThrowIfError(Native.SetAutoFocusArea(_camera.GetHandle(), pos.X, pos.Y),
98 "Failed to set the autofocus area.");
102 /// Clears the auto focus area.
104 /// <since_tizen> 3 </since_tizen>
105 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
106 public void ClearFocusArea()
108 CameraErrorFactory.ThrowIfError(Native.ClearAutoFocusArea(_camera.GetHandle()),
109 "Failed to clear the autofocus area.");
113 /// The auto focus mode.
115 /// <since_tizen> 3 </since_tizen>
116 /// <value>A <see cref="CameraAutoFocusMode"/> that specifies the auto focus mode.</value>
117 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
118 public CameraAutoFocusMode AutoFocusMode
122 CameraAutoFocusMode val = CameraAutoFocusMode.None;
124 CameraErrorFactory.ThrowIfError(Native.GetAutoFocusMode(_camera.GetHandle(), out val),
125 "Failed to get camera autofocus mode");
132 ValidationUtil.ValidateEnum(typeof(CameraAutoFocusMode), value);
133 CameraErrorFactory.ThrowIfError(Native.SetAutoFocusMode(_camera.GetHandle(), value),
134 "Failed to set camera autofocus mode.");
137 #endregion Auto Focus
141 /// The contrast level of the camera.
143 /// <since_tizen> 3 </since_tizen>
144 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
149 CameraErrorFactory.ThrowIfError(Native.GetContrast(_camera.GetHandle(), out int val),
150 "Failed to get camera contrast value");
157 CameraErrorFactory.ThrowIfError(Native.SetContrast(_camera.GetHandle(), value),
158 "Failed to set camera contrast value.");
163 /// The auto contrast.
164 /// If true auto contrast is enabled, otherwise false.
166 /// <since_tizen> 3 </since_tizen>
167 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
168 public bool AutoContrast
172 CameraErrorFactory.ThrowIfError(Native.IsEnabledAutoContrast(_camera.GetHandle(), out bool val),
173 "Failed to get camera auto contrast");
180 CameraErrorFactory.ThrowIfError(Native.EnableAutoContrast(_camera.GetHandle(), value),
181 "Failed to set camera enable auto contrast.");
185 /// Gets the available contrast level.
187 /// <since_tizen> 3 </since_tizen>
189 /// If the mininum value is greater than the maximum value, it means this feature is not supported.
191 /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
192 public Range ContrastRange
196 if (!_contrastRange.HasValue)
198 throw new NotSupportedException("Contrast is not supported.");
201 return _contrastRange.Value;
208 /// The brightness level of the camera.
210 /// <since_tizen> 3 </since_tizen>
211 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
212 public int Brightness
216 CameraErrorFactory.ThrowIfError(Native.GetBrightness(_camera.GetHandle(), out int val),
217 "Failed to get camera brightness value");
224 CameraErrorFactory.ThrowIfError(Native.SetBrightness(_camera.GetHandle(), value),
225 "Failed to set camera brightness value.");
230 /// Gets the available brightness level.
232 /// <since_tizen> 3 </since_tizen>
234 /// If the minimum value is greater than the maximum value, it means this feature is not supported.
236 /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
237 public Range BrightnessRange
241 if (!_brightnessRange.HasValue)
243 throw new NotSupportedException("Brightness is not supported.");
246 return _brightnessRange.Value;
249 #endregion Brightness
253 /// The exposure value.
255 /// <since_tizen> 3 </since_tizen>
256 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
261 CameraErrorFactory.ThrowIfError(Native.GetExposure(_camera.GetHandle(), out int val),
262 "Failed to get camera exposure value");
269 CameraErrorFactory.ThrowIfError(Native.SetExposure(_camera.GetHandle(), value),
270 "Failed to set camera exposure value.");
275 /// The exposure mode.
277 /// <since_tizen> 3 </since_tizen>
278 /// <value>A <see cref="CameraExposureMode"/> that specifies the exposure mode.</value>
279 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
280 public CameraExposureMode ExposureMode
284 CameraExposureMode val = CameraExposureMode.Off;
286 CameraErrorFactory.ThrowIfError(Native.GetExposureMode(_camera.GetHandle(), out val),
287 "Failed to get camera exposure mode");
294 ValidationUtil.ValidateEnum(typeof(CameraExposureMode), value);
295 CameraErrorFactory.ThrowIfError(Native.SetExposureMode(_camera.GetHandle(), value),
296 "Failed to set camera exposure mode.");
301 /// Gets the available exposure value.
303 /// <since_tizen> 3 </since_tizen>
305 /// If the minimum value is greater than the maximum value, it means this feature is not supported.
307 /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
308 public Range ExposureRange
312 if (!_exposureRange.HasValue)
314 throw new NotSupportedException("Exposure is not supported.");
317 return _exposureRange.Value;
325 /// The range for the zoom level is received from the ZoomRange property.
327 /// <since_tizen> 3 </since_tizen>
328 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
333 CameraErrorFactory.ThrowIfError(Native.GetZoom(_camera.GetHandle(), out int val),
334 "Failed to get zoom level");
341 CameraErrorFactory.ThrowIfError(Native.SetZoom(_camera.GetHandle(), value),
342 "Failed to set zoom level.");
347 /// Gets the available zoom level.
349 /// <since_tizen> 3 </since_tizen>
351 /// If the minimum value is greater than the maximum value, it means this feature is not supported.
353 /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
354 public Range ZoomRange
358 if (!_zoomRange.HasValue)
360 throw new NotSupportedException("Zoom is not supported.");
363 return _zoomRange.Value;
369 /// The white balance mode.
371 /// <since_tizen> 3 </since_tizen>
372 /// <value>A <see cref="CameraWhiteBalance"/> that specifies the white balance mode.</value>
373 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
374 public CameraWhiteBalance WhiteBalance
378 CameraWhiteBalance val = CameraWhiteBalance.None;
380 CameraErrorFactory.ThrowIfError(Native.GetWhiteBalance(_camera.GetHandle(), out val),
381 "Failed to get camera whitebalance");
388 ValidationUtil.ValidateEnum(typeof(CameraWhiteBalance), value);
389 CameraErrorFactory.ThrowIfError(Native.SetWhitebalance(_camera.GetHandle(), value),
390 "Failed to set camera whitebalance.");
397 /// <since_tizen> 3 </since_tizen>
398 /// <value>A <see cref="CameraIsoLevel"/> that specifies the ISO level.</value>
399 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
400 public CameraIsoLevel IsoLevel
404 CameraIsoLevel val = CameraIsoLevel.Auto;
406 CameraErrorFactory.ThrowIfError(Native.GetIso(_camera.GetHandle(), out val),
407 "Failed to get camera Iso level");
414 ValidationUtil.ValidateEnum(typeof(CameraIsoLevel), value);
415 CameraErrorFactory.ThrowIfError(Native.SetIso(_camera.GetHandle(), value),
416 "Failed to set camera Iso level.");
421 /// The quality of the image.
422 /// The range for the image quality is 1 to 100.
424 /// <since_tizen> 3 </since_tizen>
425 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
426 public int ImageQuality
430 CameraErrorFactory.ThrowIfError(Native.GetImageQuality(_camera.GetHandle(), out int val),
431 "Failed to get image quality");
438 if (value < 1 || value > 100)
440 throw new ArgumentException("Valid value is from 1(lowest quality) to 100(highest quality)");
443 CameraErrorFactory.ThrowIfError(Native.SetImageQuality(_camera.GetHandle(), value),
444 "Failed to set image quality.");
448 #region Resolution, Format, Fps of preview, capture
450 /// The preview frame rate.
452 /// <since_tizen> 3 </since_tizen>
453 /// <value>A <see cref="CameraFps"/> that specifies the preview frame rate.</value>
454 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
455 public CameraFps PreviewFps
459 CameraErrorFactory.ThrowIfError(Native.GetPreviewFps(_camera.GetHandle(), out var val),
460 "Failed to get camera preview fps");
467 ValidationUtil.ValidateEnum(typeof(CameraFps), value);
468 CameraErrorFactory.ThrowIfError(Native.SetPreviewFps(_camera.GetHandle(), value),
469 "Failed to set preview fps.");
474 /// Gets or sets the resolution of the preview.
476 /// <since_tizen> 3 </since_tizen>
477 /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
478 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
479 public Size PreviewResolution
483 CameraErrorFactory.ThrowIfError(GetPreviewResolution(_camera.GetHandle(), out int width, out int height),
484 "Failed to get camera preview resolution");
486 return new Size(width, height);
491 CameraErrorFactory.ThrowIfError(SetPreviewResolution(_camera.GetHandle(), value.Width, value.Height),
492 "Failed to set preview resolution.");
497 /// Gets the recommended preview resolution.
499 /// <since_tizen> 3 </since_tizen>
501 /// Depending on the capture resolution aspect ratio and the display resolution,
502 /// the recommended preview resolution is determined.
504 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
505 public Size RecommendedPreviewResolution
509 CameraErrorFactory.ThrowIfError(GetRecommendedPreviewResolution(_camera.GetHandle(), out int width, out int height),
510 "Failed to get recommended preview resolution");
512 return new Size(width, height);
517 /// The preview data format.
519 /// <since_tizen> 3 </since_tizen>
520 /// <value>A <see cref="CameraPixelFormat"/> that specifies the pixel format of the preview data.</value>
521 /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
522 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
523 public CameraPixelFormat PreviewPixelFormat
527 CameraErrorFactory.ThrowIfError(GetPreviewPixelFormat(_camera.GetHandle(), out var val),
528 "Failed to get preview format");
535 ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value);
536 CameraErrorFactory.ThrowIfError(SetPreviewPixelFormat(_camera.GetHandle(), value),
537 "Failed to set preview format.");
542 /// Resolution of the captured image.
544 /// <since_tizen> 3 </since_tizen>
545 /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
546 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
547 public Size CaptureResolution
551 CameraErrorFactory.ThrowIfError(GetCaptureResolution(_camera.GetHandle(), out int width, out int height),
552 "Failed to get camera capture resolution");
554 return new Size(width, height);
561 CameraErrorFactory.ThrowIfError(SetCaptureResolution(_camera.GetHandle(), res.Width, res.Height),
562 "Failed to set capture resolution.");
567 /// Format of an image to be captured.
569 /// <since_tizen> 3 </since_tizen>
570 /// <value>A <see cref="CameraPixelFormat"/> that specifies the pixel format of captured image.</value>
571 /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
572 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
573 public CameraPixelFormat CapturePixelFormat
577 CameraErrorFactory.ThrowIfError(GetCaptureFormat(_camera.GetHandle(), out var val),
578 "Failed to get camera capture formats");
585 ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value);
586 CameraErrorFactory.ThrowIfError(SetCaptureFormat(_camera.GetHandle(), value),
587 "Failed to set capture format.");
590 #endregion Resolution, Format, Fps of preview, capture
592 #region Encoded preview
594 /// The bit rate of the encoded preview.
596 /// <since_tizen> 3 </since_tizen>
597 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
598 public int EncodedPreviewBitrate
602 CameraErrorFactory.ThrowIfError(Native.GetBitrate(_camera.GetHandle(), out int val),
603 "Failed to get preview bitrate");
610 CameraErrorFactory.ThrowIfError(Native.SetBitrate(_camera.GetHandle(), value),
611 "Failed to set encoded preview bitrate.");
616 /// The GOP(Group Of Pictures) interval of the encoded preview.
618 /// <since_tizen> 3 </since_tizen>
619 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
620 public int EncodedPreviewGopInterval
624 CameraErrorFactory.ThrowIfError(Native.GetGopInterval(_camera.GetHandle(), out int val),
625 "Failed to get preview gop interval");
632 CameraErrorFactory.ThrowIfError(Native.SetGopInterval(_camera.GetHandle(), value),
633 "Failed to set encoded preview gop intervals.");
636 #endregion Encoded preview
639 /// The theater mode.
641 /// <since_tizen> 3 </since_tizen>
642 /// <value>A <see cref="CameraTheaterMode"/> that specifies the theater mode.</value>
644 /// If you want to display the preview image on the external display with the full screen mode,
645 /// use this property.
647 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
648 public CameraTheaterMode TheaterMode
652 CameraErrorFactory.ThrowIfError(Native.GetTheaterMode(_camera.GetHandle(), out var val),
653 "Failed to get camera theater mode");
660 ValidationUtil.ValidateEnum(typeof(CameraTheaterMode), value);
661 CameraErrorFactory.ThrowIfError(Native.SetTheaterMode(_camera.GetHandle(), value),
662 "Failed to set camera theater mode.");
667 /// The camera effect mode.
669 /// <since_tizen> 3 </since_tizen>
670 /// <value>A <see cref="CameraEffectMode"/> that specifies the effect mode.</value>
671 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
672 public CameraEffectMode Effect
676 CameraErrorFactory.ThrowIfError(Native.GetEffect(_camera.GetHandle(), out var val),
677 "Failed to get camera effect");
684 ValidationUtil.ValidateEnum(typeof(CameraEffectMode), value);
685 CameraErrorFactory.ThrowIfError(Native.SetEffect(_camera.GetHandle(), value),
686 "Failed to set camera effect.");
693 /// <since_tizen> 3 </since_tizen>
694 /// <value>A <see cref="CameraSceneMode"/> that specifies the scene mode.</value>
695 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
696 public CameraSceneMode SceneMode
700 CameraErrorFactory.ThrowIfError(Native.GetSceneMode(_camera.GetHandle(), out var val),
701 "Failed to get camera scene mode");
708 ValidationUtil.ValidateEnum(typeof(CameraSceneMode), value);
709 CameraErrorFactory.ThrowIfError(Native.SetSceneMode(_camera.GetHandle(), value),
710 "Failed to set camera scene mode.");
715 /// The camera's flash mode.
717 /// <since_tizen> 3 </since_tizen>
718 /// <value>A <see cref="CameraFlashMode"/> that specifies the flash mode.</value>
719 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
720 public CameraFlashMode FlashMode
724 CameraErrorFactory.ThrowIfError(Native.GetFlashMode(_camera.GetHandle(), out var val),
725 "Failed to get camera flash mode");
732 ValidationUtil.ValidateEnum(typeof(CameraFlashMode), value);
733 CameraErrorFactory.ThrowIfError(Native.SetFlashMode(_camera.GetHandle(), value),
734 "Failed to set camera flash mode.");
739 /// Gets the camera lens orientation angle.
741 /// <since_tizen> 3 </since_tizen>
742 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
743 public int LensOrientation
747 CameraErrorFactory.ThrowIfError(Native.GetLensOrientation(_camera.GetHandle(), out var val),
748 "Failed to get camera lens orientation");
755 /// The stream rotation.
757 /// <since_tizen> 3 </since_tizen>
758 /// <value>A <see cref="Rotation"/> that specifies the rotation of camera device.</value>
759 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
760 public Rotation StreamRotation
764 CameraErrorFactory.ThrowIfError(Native.GetStreamRotation(_camera.GetHandle(), out var val),
765 "Failed to get camera stream rotation");
772 ValidationUtil.ValidateEnum(typeof(Rotation), value);
774 CameraErrorFactory.ThrowIfError(Native.SetStreamRotation(_camera.GetHandle(), value),
775 "Failed to set camera stream rotation.");
782 /// <since_tizen> 3 </since_tizen>
783 /// <value>A <see cref="Flips"/> that specifies the camera flip type.</value>
784 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
785 public Flips StreamFlip
789 CameraErrorFactory.ThrowIfError(Native.GetFlip(_camera.GetHandle(), out var val),
790 "Failed to get camera stream flip");
797 ValidationUtil.ValidateFlagsEnum(value, Flips.Horizontal | Flips.Vertical, nameof(Flips));
799 CameraErrorFactory.ThrowIfError(Native.SetFlip(_camera.GetHandle(), value),
800 "Failed to set camera flip.");
805 /// The mode of the HDR(High dynamic range) capture.
807 /// <since_tizen> 3 </since_tizen>
808 /// <value>A <see cref="CameraHdrMode"/> that specifies the HDR mode.</value>
810 /// Taking multiple pictures at different exposure levels and intelligently stitching them together,
811 /// so that we eventually arrive at a picture that is representative in both dark and bright areas.
812 /// If this attribute is set, then event handler set for the HdrCaptureProgress event is invoked.
814 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
815 public CameraHdrMode HdrMode
819 CameraErrorFactory.ThrowIfError(Native.GetHdrMode(_camera.GetHandle(), out var val),
820 "Failed to get camera hdr mode");
827 ValidationUtil.ValidateEnum(typeof(CameraHdrMode), value);
828 CameraErrorFactory.ThrowIfError(Native.SetHdrMode(_camera.GetHandle(), value),
829 "Failed to set camera hdr mode.");
834 /// The anti shake feature.
835 /// If true, the antishake feature is enabled, otherwise false.
837 /// <since_tizen> 3 </since_tizen>
838 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
839 public bool AntiShake
843 CameraErrorFactory.ThrowIfError(Native.IsEnabledAntiShake(_camera.GetHandle(), out bool val),
844 "Failed to get camera anti shake value");
851 CameraErrorFactory.ThrowIfError(Native.EnableAntiShake(_camera.GetHandle(), value),
852 "Failed to set camera anti shake value.");
857 /// Enables or disables the video stabilization feature.
858 /// If true, video stabilization is enabled, otherwise false.
860 /// <since_tizen> 3 </since_tizen>
862 /// If video stabilization is enabled, zero shutter lag is disabled.
863 /// This feature is used to record a video.
865 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
866 public bool VideoStabilization
870 CameraErrorFactory.ThrowIfError(Native.IsEnabledVideoStabilization(_camera.GetHandle(), out bool val),
871 "Failed to get camera video stabilization");
878 CameraErrorFactory.ThrowIfError(Native.EnableVideoStabilization(_camera.GetHandle(), value),
879 "Failed to set camera video stabilization.");
884 /// Turn the shutter sound on or off, if it is permitted by policy.
886 /// <since_tizen> 3 </since_tizen>
887 /// <param name="shutterSound">Shutter sound On/Off flag</param>
889 /// If this value is true, shutter sound will be disabled, otherwise enabled.
890 /// In some countries, this operation is not permitted.
892 /// <exception cref="InvalidOperationException">Disabling shutter sound is not permitted.</exception>
893 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
894 public void DisableShutterSound(bool shutterSound)
896 CameraErrorFactory.ThrowIfError(Native.DisableShutterSound(_camera.GetHandle(), shutterSound),
897 "Failed to set disable shutter sound.");
900 #region PTZ(Pan Tilt Zoom), Pan, Tilt
902 /// Sets the type of the PTZ(Pan Tilt Zoom). Mechanical or electronic.
904 /// <since_tizen> 3 </since_tizen>
905 /// <value>A <see cref="CameraPtzType"/> that specifies the type of the PTZ.</value>
906 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
907 public CameraPtzType PtzType
911 ValidationUtil.ValidateEnum(typeof(CameraPtzType), value);
913 CameraErrorFactory.ThrowIfError(Native.SetPtzType(_camera.GetHandle(), value),
914 "Failed to set camera ptz type.");
919 /// Sets the position to move horizontally.
921 /// <since_tizen> 3 </since_tizen>
922 /// <param name="type">The PTZ move type. <seealso cref="CameraPtzMoveType"/>.</param>
923 /// <param name="panStep">The pan step.</param>
924 /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
925 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
926 public void SetPan(CameraPtzMoveType type, int panStep)
928 ValidationUtil.ValidateEnum(typeof(CameraPtzMoveType), type, nameof(type));
929 CameraErrorFactory.ThrowIfError(Native.SetPan(_camera.GetHandle(), type, panStep),
930 "Failed to set the camera pan type.");
934 /// Gets the current position of the camera.
936 /// <since_tizen> 3 </since_tizen>
937 /// <returns>Returns the camera's horizontal position.</returns>
938 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
941 CameraErrorFactory.ThrowIfError(Native.GetPan(_camera.GetHandle(), out int val),
942 "Failed to get the camera pan step.");
948 /// Sets the position to move vertically.
950 /// <since_tizen> 3 </since_tizen>
951 /// <param name="type">the PTZ move type.</param>
952 /// <param name="tiltStep">The tilt step.</param>
953 /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
954 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
955 public void SetTilt(CameraPtzMoveType type, int tiltStep)
957 ValidationUtil.ValidateEnum(typeof(CameraPtzMoveType), type, nameof(type));
958 CameraErrorFactory.ThrowIfError(Native.SetTilt(_camera.GetHandle(), type, tiltStep),
959 "Failed to set the camera tilt type\t.");
963 /// Gets the current position of the camera.
965 /// <since_tizen> 3 </since_tizen>
966 /// <returns>Returns the current vertical position.</returns>
967 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
970 CameraErrorFactory.ThrowIfError(Native.GetTilt(_camera.GetHandle(), out int val),
971 "Failed to set the camera current position.");
977 /// Gets the lower limit and the upper limit for the pan position.
979 /// <since_tizen> 3 </since_tizen>
981 /// If the minimum value is greater than the maximum value, it means this feature is not supported.
983 /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
984 public Range PanRange
988 if (!_panRange.HasValue)
990 throw new NotSupportedException("Pan is not supported.");
993 return _panRange.Value;
998 /// Gets the lower limit and the upper limit for the tilt position.
1000 /// <since_tizen> 3 </since_tizen>
1002 /// If the minimum value is greater than the maximum value, it means this feature is not supported.
1004 /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
1005 public Range TiltRange
1009 if (!_tiltRange.HasValue)
1011 throw new NotSupportedException("Tilt is not supported.");
1014 return _tiltRange.Value;
1017 #endregion PTZ(Pan Tilt Zoom), Pan, Tilt
1023 /// <value>true if EXIF tags are enabled in the JPEG file, otherwise false.</value>
1024 /// <since_tizen> 3 </since_tizen>
1025 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
1026 public bool EnableTag
1030 CameraErrorFactory.ThrowIfError(Native.IsEnabledTag(_camera.GetHandle(), out bool val),
1031 "Failed to get camera enable tag");
1038 CameraErrorFactory.ThrowIfError(Native.EnableTag(_camera.GetHandle(), value),
1039 "Failed to set camera enable tag.");
1044 /// The camera image description in the EXIF tag.
1046 /// <since_tizen> 3 </since_tizen>
1047 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
1048 public string ImageDescriptionTag
1052 IntPtr val = IntPtr.Zero;
1055 CameraErrorFactory.ThrowIfError(Native.GetImageDescription(_camera.GetHandle(), out val),
1056 "Failed to get image description");
1058 return Marshal.PtrToStringAnsi(val);
1062 LibcSupport.Free(val);
1068 CameraErrorFactory.ThrowIfError(Native.SetImageDescription(_camera.GetHandle(), value),
1069 "Failed to set image description.");
1074 /// The software information in the EXIF tag.
1076 /// <since_tizen> 3 </since_tizen>
1077 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
1078 public string SoftwareTag
1082 IntPtr val = IntPtr.Zero;
1086 CameraErrorFactory.ThrowIfError(Native.GetTagSoftware(_camera.GetHandle(), out val),
1087 "Failed to get tag software");
1089 return Marshal.PtrToStringAnsi(val);
1093 LibcSupport.Free(val);
1099 CameraErrorFactory.ThrowIfError(Native.SetTagSoftware(_camera.GetHandle(), value),
1100 "Failed to set tag software.");
1105 /// The geo tag(GPS data) in the EXIF tag.
1107 /// <since_tizen> 3 </since_tizen>
1108 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
1109 public Location GeoTag
1113 CameraErrorFactory.ThrowIfError(Native.GetGeotag(_camera.GetHandle(),
1114 out double latitude, out double longitude, out double altitude), "Failed to get tag");
1116 return new Location(latitude, longitude, altitude);
1121 CameraErrorFactory.ThrowIfError(Native.SetGeotag(_camera.GetHandle(),
1122 value.Latitude, value.Longitude, value.Altitude), "Failed to set geo tag.");
1127 /// Removes the geo tag(GPS data) in the EXIF(EXchangeable Image File format) tag.
1129 /// <since_tizen> 3 </since_tizen>
1130 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
1131 public void RemoveGeoTag()
1133 CameraErrorFactory.ThrowIfError(Native.RemoveGeotag(_camera.GetHandle()),
1134 "Failed to remove the geotag\t.");
1138 /// The camera orientation in the tag.
1140 /// <since_tizen> 3 </since_tizen>
1141 /// <exception cref="ObjectDisposedException">The camera already has been disposed of.</exception>
1142 public CameraTagOrientation OrientationTag
1146 CameraErrorFactory.ThrowIfError(Native.GetTagOrientation(_camera.GetHandle(), out var val),
1147 "Failed to get camera tag orientation");
1154 ValidationUtil.ValidateEnum(typeof(CameraTagOrientation), value);
1155 CameraErrorFactory.ThrowIfError(Native.SetTagOrientation(_camera.GetHandle(), value),
1156 "Failed to set camera tag orientation.");