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