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