Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Camera / Camera / CameraSettings.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19 using Native = Interop.CameraSettings;
20 using static Interop.Camera;
21
22 namespace Tizen.Multimedia
23 {
24     /// <summary>
25     /// The camera setting class provides methods/properties to get and
26     /// set basic camera attributes.
27     /// </summary>
28     public class CameraSettings
29     {
30         internal readonly Camera _camera;
31
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;
38
39         internal CameraSettings(Camera camera)
40         {
41             _camera = camera;
42
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);
49         }
50
51         private delegate CameraError GetRangeDelegate(IntPtr handle, out int min, out int max);
52         private Range? GetRange(GetRangeDelegate func)
53         {
54             CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out int min, out int max),
55                 "Failed to initialize the camera settings");
56
57             if (min > max)
58             {
59                 return null;
60             }
61
62             return new Range(min, max);
63         }
64
65         #region Auto Focus
66         /// <summary>
67         /// Sets auto focus area.
68         /// </summary>
69         /// <since_tizen> 3 </since_tizen>
70         /// <remarks>
71         /// <see cref="CameraAutoFocusMode"/> should not be the <see cref="CameraAutoFocusMode.None"/>.
72         /// </remarks>
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.</exception>
78         public void SetAutoFocusArea(int x, int y)
79         {
80             CameraErrorFactory.ThrowIfError(Native.SetAutoFocusArea(_camera.GetHandle(), x, y),
81                 "Failed to set the autofocus area.");
82         }
83
84         /// <summary>
85         /// Sets auto focus area.
86         /// </summary>
87         /// <since_tizen> 3 </since_tizen>
88         /// <remarks>
89         /// <see cref="CameraAutoFocusMode"/> should not be the <see cref="CameraAutoFocusMode.None"/>.
90         /// </remarks>
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.</exception>
95         public void SetAutoFocusArea(Point pos)
96         {
97             CameraErrorFactory.ThrowIfError(Native.SetAutoFocusArea(_camera.GetHandle(), pos.X, pos.Y),
98                 "Failed to set the autofocus area.");
99         }
100
101         /// <summary>
102         /// Clears the auto focus area.
103         /// </summary>
104         /// <since_tizen> 3 </since_tizen>
105         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
106         public void ClearFocusArea()
107         {
108             CameraErrorFactory.ThrowIfError(Native.ClearAutoFocusArea(_camera.GetHandle()),
109                 "Failed to clear the autofocus area.");
110         }
111
112         /// <summary>
113         /// The auto focus mode.
114         /// </summary>
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.</exception>
118         public CameraAutoFocusMode AutoFocusMode
119         {
120             get
121             {
122                 CameraAutoFocusMode val = CameraAutoFocusMode.None;
123
124                 CameraErrorFactory.ThrowIfError(Native.GetAutoFocusMode(_camera.GetHandle(), out val),
125                     "Failed to get camera autofocus mode");
126
127                 return val;
128             }
129
130             set
131             {
132                 ValidationUtil.ValidateEnum(typeof(CameraAutoFocusMode), value);
133                 CameraErrorFactory.ThrowIfError(Native.SetAutoFocusMode(_camera.GetHandle(), value),
134                     "Failed to set camera autofocus mode.");
135             }
136         }
137         #endregion Auto Focus
138
139         #region Contrast
140         /// <summary>
141         /// The contrast level of the camera.
142         /// </summary>
143         /// <since_tizen> 3 </since_tizen>
144         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
145         public int Contrast
146         {
147             get
148             {
149                 CameraErrorFactory.ThrowIfError(Native.GetContrast(_camera.GetHandle(), out int val),
150                     "Failed to get camera contrast value");
151
152                 return val;
153             }
154
155             set
156             {
157                 CameraErrorFactory.ThrowIfError(Native.SetContrast(_camera.GetHandle(), value),
158                     "Failed to set camera contrast value.");
159             }
160         }
161
162         /// <summary>
163         /// The auto contrast.
164         /// If true auto contrast is enabled, otherwise false.
165         /// </summary>
166         /// <since_tizen> 3 </since_tizen>
167         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
168         public bool AutoContrast
169         {
170             get
171             {
172                 CameraErrorFactory.ThrowIfError(Native.IsEnabledAutoContrast(_camera.GetHandle(), out bool val),
173                     "Failed to get camera auto contrast");
174
175                 return val;
176             }
177
178             set
179             {
180                 CameraErrorFactory.ThrowIfError(Native.EnableAutoContrast(_camera.GetHandle(), value),
181                     "Failed to set camera enable auto contrast.");
182             }
183         }
184         /// <summary>
185         /// Gets the available contrast level.
186         /// </summary>
187         /// <since_tizen> 3 </since_tizen>
188         /// <remarks>
189         /// If min value is greater than the max value, it means this feature is not supported.
190         /// </remarks>
191         /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
192         public Range ContrastRange
193         {
194             get
195             {
196                 if (!_contrastRange.HasValue)
197                 {
198                     throw new NotSupportedException("Contrast is not supported.");
199                 }
200
201                 return _contrastRange.Value;
202             }
203         }
204         #endregion Contrast
205
206         #region Brightness
207         /// <summary>
208         /// The brightness level of the camera.
209         /// </summary>
210         /// <since_tizen> 3 </since_tizen>
211         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
212         public int Brightness
213         {
214             get
215             {
216                 CameraErrorFactory.ThrowIfError(Native.GetBrightness(_camera.GetHandle(), out int val),
217                     "Failed to get camera brightness value");
218
219                 return val;
220             }
221
222             set
223             {
224                 CameraErrorFactory.ThrowIfError(Native.SetBrightness(_camera.GetHandle(), value),
225                     "Failed to set camera brightness value.");
226             }
227         }
228
229         /// <summary>
230         /// Gets the available brightness level.
231         /// </summary>
232         /// <since_tizen> 3 </since_tizen>
233         /// <remarks>
234         /// If min value is greater than the max value, it means this feature is not supported.
235         /// </remarks>
236         /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
237         public Range BrightnessRange
238         {
239             get
240             {
241                 if (!_brightnessRange.HasValue)
242                 {
243                     throw new NotSupportedException("Brightness is not supported.");
244                 }
245
246                 return _brightnessRange.Value;
247             }
248         }
249         #endregion Brightness
250
251         #region Exposure
252         /// <summary>
253         /// The exposure value.
254         /// </summary>
255         /// <since_tizen> 3 </since_tizen>
256         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
257         public int Exposure
258         {
259             get
260             {
261                 CameraErrorFactory.ThrowIfError(Native.GetExposure(_camera.GetHandle(), out int val),
262                     "Failed to get camera exposure value");
263
264                 return val;
265             }
266
267             set
268             {
269                 CameraErrorFactory.ThrowIfError(Native.SetExposure(_camera.GetHandle(), value),
270                     "Failed to set camera exposure value.");
271             }
272         }
273
274         /// <summary>
275         /// The exposure mode.
276         /// </summary>
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.</exception>
280         public CameraExposureMode ExposureMode
281         {
282             get
283             {
284                 CameraExposureMode val = CameraExposureMode.Off;
285
286                 CameraErrorFactory.ThrowIfError(Native.GetExposureMode(_camera.GetHandle(), out val),
287                     "Failed to get camera exposure mode");
288
289                 return val;
290             }
291
292             set
293             {
294                 ValidationUtil.ValidateEnum(typeof(CameraExposureMode), value);
295                 CameraErrorFactory.ThrowIfError(Native.SetExposureMode(_camera.GetHandle(), value),
296                     "Failed to set camera exposure mode.");
297             }
298         }
299
300         /// <summary>
301         /// Gets the available exposure value.
302         /// </summary>
303         /// <since_tizen> 3 </since_tizen>
304         /// <remarks>
305         /// If min value is greater than the max value, it means this feature is not supported.
306         /// </remarks>
307         /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
308         public Range ExposureRange
309         {
310             get
311             {
312                 if (!_exposureRange.HasValue)
313                 {
314                     throw new NotSupportedException("Exposure is not supported.");
315                 }
316
317                 return _exposureRange.Value;
318             }
319         }
320         #endregion Exposure
321
322         #region Zoom
323         /// <summary>
324         /// The zoom level.
325         /// The range for zoom level is received from ZoomRange property.
326         /// </summary>
327         /// <since_tizen> 3 </since_tizen>
328         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
329         public int ZoomLevel
330         {
331             get
332             {
333                 CameraErrorFactory.ThrowIfError(Native.GetZoom(_camera.GetHandle(), out int val),
334                     "Failed to get zoom level");
335
336                 return val;
337             }
338
339             set
340             {
341                 CameraErrorFactory.ThrowIfError(Native.SetZoom(_camera.GetHandle(), value),
342                     "Failed to set zoom level.");
343             }
344         }
345
346         /// <summary>
347         /// Gets the available zoom level.
348         /// </summary>
349         /// <since_tizen> 3 </since_tizen>
350         /// <remarks>
351         /// If min value is greater than the max value, it means this feature is not supported.
352         /// </remarks>
353         /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
354         public Range ZoomRange
355         {
356             get
357             {
358                 if (!_zoomRange.HasValue)
359                 {
360                     throw new NotSupportedException("Zoom is not supported.");
361                 }
362
363                 return _zoomRange.Value;
364             }
365         }
366         #endregion Zoom
367
368         /// <summary>
369         /// The whitebalance mode.
370         /// </summary>
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.</exception>
374         public CameraWhiteBalance WhiteBalance
375         {
376             get
377             {
378                 CameraWhiteBalance val = CameraWhiteBalance.None;
379
380                 CameraErrorFactory.ThrowIfError(Native.GetWhiteBalance(_camera.GetHandle(), out val),
381                     "Failed to get camera whitebalance");
382
383                 return val;
384             }
385
386             set
387             {
388                 ValidationUtil.ValidateEnum(typeof(CameraWhiteBalance), value);
389                 CameraErrorFactory.ThrowIfError(Native.SetWhitebalance(_camera.GetHandle(), value),
390                     "Failed to set camera whitebalance.");
391             }
392         }
393
394         /// <summary>
395         /// The ISO level.
396         /// </summary>
397         /// <since_tizen> 3 </since_tizen>
398         /// <value>A <see cref="CameraIsoLevel"/> that specifies ISO level.</value>
399         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
400         public CameraIsoLevel IsoLevel
401         {
402             get
403             {
404                 CameraIsoLevel val = CameraIsoLevel.Auto;
405
406                 CameraErrorFactory.ThrowIfError(Native.GetIso(_camera.GetHandle(), out val),
407                     "Failed to get camera Iso level");
408
409                 return val;
410             }
411
412             set
413             {
414                 ValidationUtil.ValidateEnum(typeof(CameraIsoLevel), value);
415                 CameraErrorFactory.ThrowIfError(Native.SetIso(_camera.GetHandle(), value),
416                     "Failed to set camera Iso level.");
417             }
418         }
419
420         /// <summary>
421         /// The quality of the image.
422         /// The range for image quality is 1 to 100.
423         /// </summary>
424         /// <since_tizen> 3 </since_tizen>
425         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
426         public int ImageQuality
427         {
428             get
429             {
430                 CameraErrorFactory.ThrowIfError(Native.GetImageQuality(_camera.GetHandle(), out int val),
431                     "Failed to get image quality");
432
433                 return val;
434             }
435
436             set
437             {
438                 if (value < 1 || value > 100)
439                 {
440                     throw new ArgumentException("Valid value is from 1(lowest quality) to 100(highest quality)");
441                 }
442
443                 CameraErrorFactory.ThrowIfError(Native.SetImageQuality(_camera.GetHandle(), value),
444                     "Failed to set image quality.");
445             }
446         }
447
448         #region Resolution, Format, Fps of preview, capture
449         /// <summary>
450         /// The preview frame rate.
451         /// </summary>
452         /// <since_tizen> 3 </since_tizen>
453         /// <value>A <see cref="CameraFps"/> that specifies preview frame rate.</value>
454         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
455         public CameraFps PreviewFps
456         {
457             get
458             {
459                 CameraErrorFactory.ThrowIfError(Native.GetPreviewFps(_camera.GetHandle(), out var val),
460                     "Failed to get camera preview fps");
461
462                 return val;
463             }
464
465             set
466             {
467                 ValidationUtil.ValidateEnum(typeof(CameraFps), value);
468                 CameraErrorFactory.ThrowIfError(Native.SetPreviewFps(_camera.GetHandle(), value),
469                     "Failed to set preview fps.");
470             }
471         }
472
473         /// <summary>
474         /// Gets or sets the resolution of preview
475         /// </summary>
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.</exception>
479         public Size PreviewResolution
480         {
481             get
482             {
483                 CameraErrorFactory.ThrowIfError(GetPreviewResolution(_camera.GetHandle(), out int width, out int height),
484                     "Failed to get camera preview resolution");
485
486                 return new Size(width, height);
487             }
488
489             set
490             {
491                 CameraErrorFactory.ThrowIfError(SetPreviewResolution(_camera.GetHandle(), value.Width, value.Height),
492                     "Failed to set preview resolution.");
493             }
494         }
495
496         /// <summary>
497         /// Gets the recommended preview resolution.
498         /// </summary>
499         /// <since_tizen> 3 </since_tizen>
500         /// <remarks>
501         /// Depending on the capture resolution aspect ratio and display resolution,
502         /// the recommended preview resolution is determined.
503         /// </remarks>
504         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
505         public Size RecommendedPreviewResolution
506         {
507             get
508             {
509                 CameraErrorFactory.ThrowIfError(GetRecommendedPreviewResolution(_camera.GetHandle(), out int width, out int height),
510                     "Failed to get recommended preview resolution");
511
512                 return new Size(width, height);
513             }
514         }
515
516         /// <summary>
517         /// The preview data format.
518         /// </summary>
519         /// <since_tizen> 3 </since_tizen>
520         /// <value>A <see cref="CameraPixelFormat"/> that specifies the pixel format of preview data.</value>
521         /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
522         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
523         public CameraPixelFormat PreviewPixelFormat
524         {
525             get
526             {
527                 CameraErrorFactory.ThrowIfError(GetPreviewPixelFormat(_camera.GetHandle(), out var val),
528                     "Failed to get preview format");
529
530                 return val;
531             }
532
533             set
534             {
535                 ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value);
536                 CameraErrorFactory.ThrowIfError(SetPreviewPixelFormat(_camera.GetHandle(), value),
537                     "Failed to set preview format.");
538             }
539         }
540
541         /// <summary>
542         /// Resolution of the captured image.
543         /// </summary>
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.</exception>
547         public Size CaptureResolution
548         {
549             get
550             {
551                 CameraErrorFactory.ThrowIfError(GetCaptureResolution(_camera.GetHandle(), out int width, out int height),
552                     "Failed to get camera capture resolution");
553
554                 return new Size(width, height);
555             }
556
557             set
558             {
559                 Size res = value;
560
561                 CameraErrorFactory.ThrowIfError(SetCaptureResolution(_camera.GetHandle(), res.Width, res.Height),
562                     "Failed to set capture resolution.");
563             }
564         }
565
566         /// <summary>
567         /// Format of an image to be captured.
568         /// </summary>
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.</exception>
573         public CameraPixelFormat CapturePixelFormat
574         {
575             get
576             {
577                 CameraErrorFactory.ThrowIfError(GetCaptureFormat(_camera.GetHandle(), out var val),
578                     "Failed to get camera capture formats");
579
580                 return val;
581             }
582
583             set
584             {
585                 ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value);
586                 CameraErrorFactory.ThrowIfError(SetCaptureFormat(_camera.GetHandle(), value),
587                     "Failed to set capture format.");
588             }
589         }
590         #endregion Resolution, Format, Fps of preview, capture
591
592         #region Encoded preview
593         /// <summary>
594         /// The bit rate of encoded preview.
595         /// </summary>
596         /// <since_tizen> 3 </since_tizen>
597         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
598         public int EncodedPreviewBitrate
599         {
600             get
601             {
602                 CameraErrorFactory.ThrowIfError(Native.GetBitrate(_camera.GetHandle(), out int val),
603                     "Failed to get preview bitrate");
604
605                 return val;
606             }
607
608             set
609             {
610                 CameraErrorFactory.ThrowIfError(Native.SetBitrate(_camera.GetHandle(), value),
611                     "Failed to set encoded preview bitrate.");
612             }
613         }
614
615         /// <summary>
616         /// GOP(Group Of Pictures) interval of encoded preview.
617         /// </summary>
618         /// <since_tizen> 3 </since_tizen>
619         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
620         public int EncodedPreviewGopInterval
621         {
622             get
623             {
624                 CameraErrorFactory.ThrowIfError(Native.GetGopInterval(_camera.GetHandle(), out int val),
625                     "Failed to get preview gop interval");
626
627                 return val;
628             }
629
630             set
631             {
632                 CameraErrorFactory.ThrowIfError(Native.SetGopInterval(_camera.GetHandle(), value),
633                     "Failed to set encoded preview gop intervals.");
634             }
635         }
636         #endregion Encoded preview
637
638         /// <summary>
639         /// The theater mode.
640         /// </summary>
641         /// <since_tizen> 3 </since_tizen>
642         /// <value>A <see cref="CameraTheaterMode"/> that specifies theater mode.</value>
643         /// <remarks>
644         /// If you want to display the preview image on the external display with the full screen mode,
645         /// use this property.
646         /// </remarks>
647         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
648         public CameraTheaterMode TheaterMode
649         {
650             get
651             {
652                 CameraErrorFactory.ThrowIfError(Native.GetTheaterMode(_camera.GetHandle(), out var val),
653                     "Failed to get camera theater mode");
654
655                 return val;
656             }
657
658             set
659             {
660                 ValidationUtil.ValidateEnum(typeof(CameraTheaterMode), value);
661                 CameraErrorFactory.ThrowIfError(Native.SetTheaterMode(_camera.GetHandle(), value),
662                     "Failed to set camera theater mode.");
663             }
664         }
665
666         /// <summary>
667         /// The camera effect mode.
668         /// </summary>
669         /// <since_tizen> 3 </since_tizen>
670         /// <value>A <see cref="CameraEffectMode"/> that specifies effect mode.</value>
671         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
672         public CameraEffectMode Effect
673         {
674             get
675             {
676                 CameraErrorFactory.ThrowIfError(Native.GetEffect(_camera.GetHandle(), out var val),
677                     "Failed to get camera effect");
678
679                 return val;
680             }
681
682             set
683             {
684                 ValidationUtil.ValidateEnum(typeof(CameraEffectMode), value);
685                 CameraErrorFactory.ThrowIfError(Native.SetEffect(_camera.GetHandle(), value),
686                     "Failed to set camera effect.");
687             }
688         }
689
690         /// <summary>
691         /// The scene mode.
692         /// </summary>
693         /// <since_tizen> 3 </since_tizen>
694         /// <value>A <see cref="CameraSceneMode"/> that specifies scene mode.</value>
695         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
696         public CameraSceneMode SceneMode
697         {
698             get
699             {
700                 CameraErrorFactory.ThrowIfError(Native.GetSceneMode(_camera.GetHandle(), out var val),
701                     "Failed to get camera scene mode");
702
703                 return val;
704             }
705
706             set
707             {
708                 ValidationUtil.ValidateEnum(typeof(CameraSceneMode), value);
709                 CameraErrorFactory.ThrowIfError(Native.SetSceneMode(_camera.GetHandle(), value),
710                     "Failed to set camera scene mode.");
711             }
712         }
713
714         /// <summary>
715         /// The camera's flash mode.
716         /// </summary>
717         /// <since_tizen> 3 </since_tizen>
718         /// <value>A <see cref="CameraFlashMode"/> that specifies flash mode.</value>
719         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
720         public CameraFlashMode FlashMode
721         {
722             get
723             {
724                 CameraErrorFactory.ThrowIfError(Native.GetFlashMode(_camera.GetHandle(), out var val),
725                     "Failed to get camera flash mode");
726
727                 return val;
728             }
729
730             set
731             {
732                 ValidationUtil.ValidateEnum(typeof(CameraFlashMode), value);
733                 CameraErrorFactory.ThrowIfError(Native.SetFlashMode(_camera.GetHandle(), value),
734                     "Failed to set camera flash mode.");
735             }
736         }
737
738         /// <summary>
739         /// Gets the camera lens orientation angle.
740         /// </summary>
741         /// <since_tizen> 3 </since_tizen>
742         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
743         public int LensOrientation
744         {
745             get
746             {
747                 CameraErrorFactory.ThrowIfError(Native.GetLensOrientation(_camera.GetHandle(), out var val),
748                     "Failed to get camera lens orientation");
749
750                 return val;
751             }
752         }
753
754         /// <summary>
755         /// The stream rotation.
756         /// </summary>
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.</exception>
760         public Rotation StreamRotation
761         {
762             get
763             {
764                 CameraErrorFactory.ThrowIfError(Native.GetStreamRotation(_camera.GetHandle(), out var val),
765                     "Failed to get camera stream rotation");
766
767                 return val;
768             }
769
770             set
771             {
772                 ValidationUtil.ValidateEnum(typeof(Rotation), value);
773
774                 CameraErrorFactory.ThrowIfError(Native.SetStreamRotation(_camera.GetHandle(), value),
775                     "Failed to set camera stream rotation.");
776             }
777         }
778
779         /// <summary>
780         /// The stream flip.
781         /// </summary>
782         /// <since_tizen> 3 </since_tizen>
783         /// <value>A <see cref="CameraFlip"/> that specifies camera flip type.</value>
784         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
785         public Flips StreamFlip
786         {
787             get
788             {
789                 CameraErrorFactory.ThrowIfError(Native.GetFlip(_camera.GetHandle(), out var val),
790                     "Failed to get camera stream flip");
791
792                 return val;
793             }
794
795             set
796             {
797                 ValidationUtil.ValidateFlagsEnum(value, Flips.Horizontal | Flips.Vertical, nameof(Flips));
798
799                 CameraErrorFactory.ThrowIfError(Native.SetFlip(_camera.GetHandle(), value),
800                     "Failed to set camera flip.");
801             }
802         }
803
804         /// <summary>
805         /// The mode of HDR(High dynamic range) capture.
806         /// </summary>
807         /// <since_tizen> 3 </since_tizen>
808         /// <value>A <see cref="CameraHdrMode"/> that specifies the HDR mode.</value>
809         /// <remarks>
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 eventhandler set for HdrCaptureProgress event is invoked.
813         /// </remarks>
814         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
815         public CameraHdrMode HdrMode
816         {
817             get
818             {
819                 CameraErrorFactory.ThrowIfError(Native.GetHdrMode(_camera.GetHandle(), out var val),
820                     "Failed to get camera hdr mode");
821
822                 return val;
823             }
824
825             set
826             {
827                 ValidationUtil.ValidateEnum(typeof(CameraHdrMode), value);
828                 CameraErrorFactory.ThrowIfError(Native.SetHdrMode(_camera.GetHandle(), value),
829                     "Failed to set camera hdr mode.");
830             }
831         }
832
833         /// <summary>
834         /// The anti shake feature.
835         /// If true the antishake feature is enabled, otherwise false.
836         /// </summary>
837         /// <since_tizen> 3 </since_tizen>
838         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
839         public bool AntiShake
840         {
841             get
842             {
843                 CameraErrorFactory.ThrowIfError(Native.IsEnabledAntiShake(_camera.GetHandle(), out bool val),
844                     "Failed to get camera anti shake value");
845
846                 return val;
847             }
848
849             set
850             {
851                 CameraErrorFactory.ThrowIfError(Native.EnableAntiShake(_camera.GetHandle(), value),
852                     "Failed to set camera anti shake value.");
853             }
854         }
855
856         /// <summary>
857         /// Enables/Disables the video stabilization feature.
858         /// If true video stabilization is enabled, otherwise false.
859         /// </summary>
860         /// <since_tizen> 3 </since_tizen>
861         /// <remarks>
862         /// If video stabilization is enabled, zero shutter lag is disabled.
863         /// This feature is used to record a video.
864         /// </remarks>
865         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
866         public bool VideoStabilization
867         {
868             get
869             {
870                 CameraErrorFactory.ThrowIfError(Native.IsEnabledVideoStabilization(_camera.GetHandle(), out bool val),
871                     "Failed to get camera video stabilization");
872
873                 return val;
874             }
875
876             set
877             {
878                 CameraErrorFactory.ThrowIfError(Native.EnableVideoStabilization(_camera.GetHandle(), value),
879                     "Failed to set camera video stabilization.");
880             }
881         }
882
883         /// <summary>
884         /// Turn the shutter sound on or off, if it is permitted by policy.
885         /// </summary>
886         /// <since_tizen> 3 </since_tizen>
887         /// <param name="shutterSound">Shutter sound On/Off flag</param>
888         /// <remarks>
889         /// If this value is true, shutter sound will be disabled, otherwise enabled.
890         /// In some countries, this operation is not permitted.
891         /// </remarks>
892         /// <exception cref="InvalidOperationException">Disabling shutter sound is not permitted.</exception>
893         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
894         public void DisableShutterSound(bool shutterSound)
895         {
896             CameraErrorFactory.ThrowIfError(Native.DisableShutterSound(_camera.GetHandle(), shutterSound),
897                     "Failed to set disable shutter sound.");
898         }
899
900         #region PTZ(Pan Tilt Zoom), Pan, Tilt
901         /// <summary>
902         /// Sets the type of PTZ(Pan Tilt Zoom). Mechanical or Electronic.
903         /// </summary>
904         /// <since_tizen> 3 </since_tizen>
905         /// <value>A <see cref="CameraPtzType"/> that specifies the type of PTZ.</value>
906         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
907         public CameraPtzType PtzType
908         {
909             set
910             {
911                 ValidationUtil.ValidateEnum(typeof(CameraPtzType), value);
912
913                 CameraErrorFactory.ThrowIfError(Native.SetPtzType(_camera.GetHandle(), value),
914                     "Failed to set camera ptz type.");
915             }
916         }
917
918         /// <summary>
919         /// Sets the position to move horizontally.
920         /// </summary>
921         /// <since_tizen> 3 </since_tizen>
922         /// <param name="type">ptz move type. <seealso cref="CameraPtzMoveType"/></param>
923         /// <param name="panStep">pan step</param>
924         /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
925         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
926         public void SetPan(CameraPtzMoveType type, int panStep)
927         {
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.");
931         }
932
933         /// <summary>
934         /// Gets the current position of the camera.
935         /// </summary>
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.</exception>
939         public int GetPan()
940         {
941             CameraErrorFactory.ThrowIfError(Native.GetPan(_camera.GetHandle(), out int val),
942                 "Failed to get the camera pan step.");
943
944             return val;
945         }
946
947         /// <summary>
948         /// Sets the position to move vertically.
949         /// </summary>
950         /// <since_tizen> 3 </since_tizen>
951         /// <param name="type">ptz move type</param>
952         /// <param name="tiltStep">tilt step</param>
953         /// <exception cref="ArgumentException">In case of invalid parameters.</exception>
954         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
955         public void SetTilt(CameraPtzMoveType type, int tiltStep)
956         {
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.");
960         }
961
962         /// <summary>
963         /// Gets the current position of the camera.
964         /// </summary>
965         /// <since_tizen> 3 </since_tizen>
966         /// <returns>Returns the current vertical position</returns>
967         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
968         public int GetTilt()
969         {
970             CameraErrorFactory.ThrowIfError(Native.GetTilt(_camera.GetHandle(), out int val),
971                 "Failed to set the camera current position.");
972
973             return val;
974         }
975
976         /// <summary>
977         /// Gets lower limit and upper limit for pan position.
978         /// </summary>
979         /// <since_tizen> 3 </since_tizen>
980         /// <remarks>
981         /// If min value is greater than the max value, it means this feature is not supported.
982         /// </remarks>
983         /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
984         public Range PanRange
985         {
986             get
987             {
988                 if (!_panRange.HasValue)
989                 {
990                     throw new NotSupportedException("Pan is not supported.");
991                 }
992                 return _panRange.Value;
993             }
994         }
995
996         /// <summary>
997         /// Gets lower limit and upper limit for tilt position.
998         /// </summary>
999         /// <since_tizen> 3 </since_tizen>
1000         /// <remarks>
1001         /// If min value is greater than the max value, it means this feature is not supported.
1002         /// </remarks>
1003         /// <exception cref="NotSupportedException">In case of this feature is not supported.</exception>
1004         public Range TiltRange
1005         {
1006             get
1007             {
1008                 if (!_tiltRange.HasValue)
1009                 {
1010                     throw new NotSupportedException("Tilt is not supported.");
1011                 }
1012                 return _tiltRange.Value;
1013             }
1014         }
1015         #endregion PTZ(Pan Tilt Zoom), Pan, Tilt
1016
1017         #region EXIF tag
1018         /// <summary>
1019         /// The scene mode.
1020         /// true if EXIF tags are enabled in JPEG file, otherwise false.
1021         /// </summary>
1022         /// <since_tizen> 3 </since_tizen>
1023         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
1024         public bool EnableTag
1025         {
1026             get
1027             {
1028                 CameraErrorFactory.ThrowIfError(Native.IsEnabledTag(_camera.GetHandle(), out bool val),
1029                     "Failed to get camera enable tag");
1030
1031                 return val;
1032             }
1033
1034             set
1035             {
1036                 CameraErrorFactory.ThrowIfError(Native.EnableTag(_camera.GetHandle(), value),
1037                     "Failed to set camera enable tag.");
1038             }
1039         }
1040
1041         /// <summary>
1042         /// The camera image description in the EXIF tag.
1043         /// </summary>
1044         /// <since_tizen> 3 </since_tizen>
1045         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
1046         public string ImageDescriptionTag
1047         {
1048             get
1049             {
1050                 IntPtr val = IntPtr.Zero;
1051                 try
1052                 {
1053                     CameraErrorFactory.ThrowIfError(Native.GetImageDescription(_camera.GetHandle(), out val),
1054                     "Failed to get image description");
1055
1056                     return Marshal.PtrToStringAnsi(val);
1057                 }
1058                 finally
1059                 {
1060                     LibcSupport.Free(val);
1061                 }
1062             }
1063
1064             set
1065             {
1066                 CameraErrorFactory.ThrowIfError(Native.SetImageDescription(_camera.GetHandle(), value),
1067                     "Failed to set image description.");
1068             }
1069         }
1070
1071         /// <summary>
1072         /// The software information in the EXIF tag.
1073         /// </summary>
1074         /// <since_tizen> 3 </since_tizen>
1075         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
1076         public string SoftwareTag
1077         {
1078             get
1079             {
1080                 IntPtr val = IntPtr.Zero;
1081
1082                 try
1083                 {
1084                     CameraErrorFactory.ThrowIfError(Native.GetTagSoftware(_camera.GetHandle(), out val),
1085                     "Failed to get tag software");
1086
1087                     return Marshal.PtrToStringAnsi(val);
1088                 }
1089                 finally
1090                 {
1091                     LibcSupport.Free(val);
1092                 }
1093             }
1094
1095             set
1096             {
1097                 CameraErrorFactory.ThrowIfError(Native.SetTagSoftware(_camera.GetHandle(), value),
1098                     "Failed to set tag software.");
1099             }
1100         }
1101
1102         /// <summary>
1103         /// The geotag(GPS data) in the EXIF tag.
1104         /// </summary>
1105         /// <since_tizen> 3 </since_tizen>
1106         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
1107         public Location GeoTag
1108         {
1109             get
1110             {
1111                 CameraErrorFactory.ThrowIfError(Native.GetGeotag(_camera.GetHandle(),
1112                     out double latitude, out double longitude, out double altitude), "Failed to get tag");
1113
1114                 return new Location(latitude, longitude, altitude);
1115             }
1116
1117             set
1118             {
1119                 CameraErrorFactory.ThrowIfError(Native.SetGeotag(_camera.GetHandle(),
1120                     value.Latitude, value.Longitude, value.Altitude), "Failed to set geo tag.");
1121             }
1122         }
1123
1124         /// <summary>
1125         /// Removes the geotag(GPS data) in the EXIF(Exchangeable image file format) tag.
1126         /// </summary>
1127         /// <since_tizen> 3 </since_tizen>
1128         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
1129         public void RemoveGeoTag()
1130         {
1131             CameraErrorFactory.ThrowIfError(Native.RemoveGeotag(_camera.GetHandle()),
1132                 "Failed to remove the geotag\t.");
1133         }
1134
1135         /// <summary>
1136         /// The camera orientation in the tag.
1137         /// </summary>
1138         /// <since_tizen> 3 </since_tizen>
1139         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
1140         public CameraTagOrientation OrientationTag
1141         {
1142             get
1143             {
1144                 CameraErrorFactory.ThrowIfError(Native.GetTagOrientation(_camera.GetHandle(), out var val),
1145                     "Failed to get camera tag orientation");
1146
1147                 return val;
1148             }
1149
1150             set
1151             {
1152                 ValidationUtil.ValidateEnum(typeof(CameraTagOrientation), value);
1153                 CameraErrorFactory.ThrowIfError(Native.SetTagOrientation(_camera.GetHandle(), value),
1154                     "Failed to set camera tag orientation.");
1155             }
1156         }
1157         #endregion EXIF tag
1158     }
1159 }
1160