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