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