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