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