[Camera] minor code change
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Camera / Camera / CameraFeatures.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.Collections.Generic;
19 using NativeFeatures = Interop.CameraFeatures;
20 using NativeSettings = Interop.CameraSettings;
21
22 namespace Tizen.Multimedia
23 {
24     /// <summary>
25     /// The CameraFeatures class provides properties
26     /// to get various capability information of the camera device.
27     /// </summary>
28     public class CameraFeatures
29     {
30         internal readonly Camera _camera;
31
32         private List<Size> _previewResolutions;
33         private List<Size> _cameraResolutions;
34         private List<CameraPixelFormat> _captureFormats;
35         private List<CameraPixelFormat> _previewFormats;
36         private List<CameraFps> _fps;
37         private List<CameraFps> _fpsByResolution;
38         private List<CameraAutoFocusMode> _autoFocusModes;
39         private List<CameraExposureMode> _exposureModes;
40         private List<CameraIsoLevel> _isoLevels;
41         private List<CameraTheaterMode> _theaterModes;
42         private List<CameraWhiteBalance> _whitebalances;
43         private List<CameraFlashMode> _flashModes;
44         private List<CameraSceneMode> _sceneModes;
45         private List<CameraEffectMode> _effectModes;
46         private List<CameraRotation> _streamRotations;
47         private List<CameraFlip> _streamFlips;
48         private List<CameraPtzType> _ptzTypes;
49
50         private delegate CameraError GetRangeDelegate(IntPtr handle, out int min, out int max);
51         private delegate bool IsSupportedDelegate(IntPtr handle);
52
53         internal CameraFeatures(Camera camera)
54         {
55             _camera = camera;
56
57             IsFaceDetectionSupported = IsFeatureSupported(NativeFeatures.IsFaceDetectionSupported);
58             IsMediaPacketPreviewCallbackSupported = IsFeatureSupported(NativeFeatures.IsMediaPacketPreviewCallbackSupported);
59             IsZeroShutterLagSupported = IsFeatureSupported(NativeFeatures.IsZeroShutterLagSupported);
60             IsContinuousCaptureSupported = IsFeatureSupported(NativeFeatures.IsContinuousCaptureSupported);
61             IsHdrCaptureSupported = IsFeatureSupported(NativeFeatures.IsHdrCaptureSupported);
62             IsAntiShakeSupported = IsFeatureSupported(NativeFeatures.IsAntiShakeSupported);
63             IsVideoStabilizationSupported = IsFeatureSupported(NativeFeatures.IsVideoStabilizationSupported);
64             IsAutoContrastSupported = IsFeatureSupported(NativeFeatures.IsAutoContrastSupported);
65             IsBrigtnessSupported = CheckRangeValid(NativeSettings.GetBrightnessRange);
66             IsExposureSupported = CheckRangeValid(NativeSettings.GetExposureRange);
67             IsZoomSupported = CheckRangeValid(NativeSettings.GetZoomRange);
68             IsPanSupported = CheckRangeValid(NativeSettings.GetPanRange);
69             IsTiltSupported = CheckRangeValid(NativeSettings.GetTiltRange);
70         }
71
72         private bool IsFeatureSupported(IsSupportedDelegate func)
73         {
74             return func(_camera.GetHandle());
75         }
76
77         private bool CheckRangeValid(GetRangeDelegate func)
78         {
79             CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out int min, out int max),
80                 "Failed to check feature is suported or not.");
81
82             return min < max;
83         }
84
85         /// <summary>
86         /// Gets the face detection feature's supported state.
87         /// true if supported, otherwise false.
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         public bool IsFaceDetectionSupported { get; }
91
92         /// <summary>
93         /// Gets the media packet preview callback feature's supported state.
94         /// true if supported, otherwise false.
95         /// </summary>
96         /// <since_tizen> 3 </since_tizen>
97         public bool IsMediaPacketPreviewCallbackSupported { get; }
98
99         /// <summary>
100         /// Gets the zero shutter lag feature's supported state.
101         /// true if supported, otherwise false.
102         /// </summary>
103         /// <since_tizen> 3 </since_tizen>
104         public bool IsZeroShutterLagSupported { get; }
105
106         /// <summary>
107         /// Gets continuous capture feature's supported state.
108         /// true if supported, otherwise false.
109         /// </summary>
110         /// <since_tizen> 3 </since_tizen>
111         public bool IsContinuousCaptureSupported { get; }
112
113         /// <summary>
114         /// Gets the support state of HDR capture.
115         /// true if supported, otherwise false.
116         /// </summary>
117         /// <since_tizen> 3 </since_tizen>
118         public bool IsHdrCaptureSupported { get; }
119
120         /// <summary>
121         /// Gets the support state of the anti-shake feature.
122         /// true if supported, otherwise false.
123         /// </summary>
124         /// <since_tizen> 3 </since_tizen>
125         public bool IsAntiShakeSupported { get; }
126
127         /// <summary>
128         /// Gets the support state of the video stabilization feature.
129         /// true if supported, otherwise false.
130         /// </summary>
131         /// <since_tizen> 3 </since_tizen>
132         public bool IsVideoStabilizationSupported { get; }
133
134         /// <summary>
135         /// Gets the support state of auto contrast feature.
136         /// true if supported, otherwise false.
137         /// </summary>
138         /// <since_tizen> 3 </since_tizen>
139         public bool IsAutoContrastSupported { get; }
140
141         /// <summary>
142         /// Gets the support state of brightness feature.
143         /// true if supported, otherwise false.
144         /// </summary>
145         /// <since_tizen> 3 </since_tizen>
146         public bool IsBrigtnessSupported { get; }
147
148         /// <summary>
149         /// Gets the support state of exposure feature.
150         /// true if supported, otherwise false.
151         /// </summary>
152         /// <since_tizen> 3 </since_tizen>
153         public bool IsExposureSupported { get; }
154
155         /// <summary>
156         /// Gets the support state of zoom feature.
157         /// true if supported, otherwise false.
158         /// </summary>
159         /// <since_tizen> 3 </since_tizen>
160         public bool IsZoomSupported { get; }
161
162         /// <summary>
163         /// Gets the support state of pan feature.
164         /// true if supported, otherwise false.
165         /// </summary>
166         /// <since_tizen> 3 </since_tizen>
167         public bool IsPanSupported { get; }
168
169         /// <summary>
170         /// Gets the support state of tilt feature.
171         /// true if supported, otherwise false.
172         /// </summary>
173         /// <since_tizen> 3 </since_tizen>
174         public bool IsTiltSupported { get; }
175
176         /// <summary>
177         /// Retrieves all the preview resolutions supported by the camera.
178         /// </summary>
179         /// <since_tizen> 3 </since_tizen>
180         /// <returns>
181         /// It returns a list containing all the supported preview resolutions.
182         /// by recorder.
183         /// </returns>
184         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
185         public IEnumerable<Size> SupportedPreviewResolutions
186         {
187             get
188             {
189                 if (_previewResolutions == null)
190                 {
191                     try
192                     {
193                         _previewResolutions = new List<Size>();
194
195                         NativeFeatures.PreviewResolutionCallback callback = (int width, int height, IntPtr userData) =>
196                         {
197                             _previewResolutions.Add(new Size(width, height));
198                             return true;
199                         };
200                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedPreviewResolutions(_camera.GetHandle(), callback, IntPtr.Zero),
201                             "Failed to get the supported preview resolutions");
202                     }
203                     catch
204                     {
205                         _previewResolutions = null;
206                         throw;
207                     }
208                 }
209
210                 return _previewResolutions;
211             }
212         }
213
214         /// <summary>
215         /// Retrieves all the capture resolutions supported by the camera.
216         /// </summary>
217         /// <since_tizen> 3 </since_tizen>
218         /// <returns>
219         /// It returns a list containing all the supported capture resolutions.
220         /// </returns>
221         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
222         public IEnumerable<Size> SupportedCaptureResolutions
223         {
224             get
225             {
226                 if (_cameraResolutions == null)
227                 {
228                     try
229                     {
230                         _cameraResolutions = new List<Size>();
231
232                         NativeFeatures.CaptureResolutionCallback callback = (int width, int height, IntPtr userData) =>
233                         {
234                             _cameraResolutions.Add(new Size(width, height));
235                             return true;
236                         };
237                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedCaptureResolutions(_camera.GetHandle(), callback, IntPtr.Zero),
238                             "Failed to get the supported capture resolutions");
239                     }
240                     catch
241                     {
242                         _cameraResolutions = null;
243                         throw;
244                     }
245                 }
246
247                 return _cameraResolutions;
248             }
249         }
250
251         /// <summary>
252         /// Retrieves all the capture formats supported by the camera.
253         /// </summary>
254         /// <since_tizen> 3 </since_tizen>
255         /// <returns>
256         /// It returns a list containing all the supported <see cref="CameraPixelFormat"/>.
257         /// </returns>
258         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
259         public IEnumerable<CameraPixelFormat> SupportedCapturePixelFormats
260         {
261             get
262             {
263                 if (_captureFormats == null)
264                 {
265                     try
266                     {
267                         _captureFormats = new List<CameraPixelFormat>();
268
269                         NativeFeatures.CaptureFormatCallback callback = (CameraPixelFormat format, IntPtr userData) =>
270                         {
271                             _captureFormats.Add(format);
272                             return true;
273                         };
274                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedCapturePixelFormats(_camera.GetHandle(), callback, IntPtr.Zero),
275                             "Failed to get the supported capture formats.");
276                     }
277                     catch
278                     {
279                         _captureFormats = null;
280                         throw;
281                     }
282                 }
283
284                 return _captureFormats;
285             }
286         }
287
288         /// <summary>
289         /// Retrieves all the preview formats supported by the camera.
290         /// </summary>
291         /// <since_tizen> 3 </since_tizen>
292         /// <returns>
293         /// It returns a list containing all the supported <see cref="CameraPixelFormat"/>.
294         /// </returns>
295         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
296         public IEnumerable<CameraPixelFormat> SupportedPreviewPixelFormats
297         {
298             get
299             {
300                 if (_previewFormats == null)
301                 {
302                     try
303                     {
304                         _previewFormats = new List<CameraPixelFormat>();
305
306                         NativeFeatures.PreviewFormatCallback callback = (CameraPixelFormat format, IntPtr userData) =>
307                         {
308                             _previewFormats.Add(format);
309                             return true;
310                         };
311                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedPreviewPixelFormats(_camera.GetHandle(), callback, IntPtr.Zero),
312                             "Failed to get the supported preview formats.");
313                     }
314                     catch
315                     {
316                         _previewFormats = null;
317                         throw;
318                     }
319                 }
320
321                 return _previewFormats;
322             }
323         }
324
325         /// <summary>
326         /// Retrieves all the fps supported by the camera.
327         /// </summary>
328         /// <since_tizen> 3 </since_tizen>
329         /// <returns>
330         /// It returns a list containing all the supported <see cref="CameraFps"/>.
331         /// </returns>
332         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
333         public IEnumerable<CameraFps> SupportedPreviewFps
334         {
335             get
336             {
337                 if (_fps == null)
338                 {
339                     try
340                     {
341                         _fps = new List<CameraFps>();
342
343                         NativeFeatures.FpsCallback callback = (CameraFps fps, IntPtr userData) =>
344                         {
345                             _fps.Add(fps);
346                             return true;
347                         };
348                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedPreviewFps(_camera.GetHandle(), callback, IntPtr.Zero),
349                             "Failed to get the supported camera fps");
350                     }
351                     catch
352                     {
353                         _fps = null;
354                         throw;
355                     }
356                 }
357
358                 return _fps;
359             }
360         }
361
362         /// <summary>
363         /// Retrieves all the fps by resolution supported by the camera.
364         /// </summary>
365         /// <since_tizen> 3 </since_tizen>
366         /// <returns>
367         /// It returns a list containing all the supported <see cref="CameraFps"/> by resolution.
368         /// </returns>
369         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
370         public IEnumerable<CameraFps> GetSupportedPreviewFpsByResolution(int width, int height)
371         {
372             if (_fpsByResolution == null)
373             {
374                 try
375                 {
376                     _fpsByResolution = new List<CameraFps>();
377
378                     NativeFeatures.FpsByResolutionCallback callback = (CameraFps fps, IntPtr userData) =>
379                     {
380                         _fpsByResolution.Add(fps);
381                         return true;
382                     };
383                     CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedPreviewFpsByResolution(_camera.GetHandle(),
384                         width, height, callback, IntPtr.Zero), "Failed to get the supported fps by resolutions.");
385                 }
386                 catch
387                 {
388                     _fpsByResolution = null;
389                     throw;
390                 }
391             }
392
393             return _fpsByResolution;
394         }
395
396         /// <summary>
397         /// Retrieves all the fps by resolution supported by the camera.
398         /// </summary>
399         /// <since_tizen> 3 </since_tizen>
400         /// <returns>
401         /// It returns a list containing all the supported <see cref="CameraFps"/> by resolution.
402         /// </returns>
403         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
404         public IEnumerable<CameraFps> GetSupportedPreviewFpsByResolution(Size size)
405         {
406             return GetSupportedPreviewFpsByResolution(size.Width, size.Height);
407         }
408
409         /// <summary>
410         /// Retrieves all the auto focus modes supported by the camera.
411         /// </summary>
412         /// <since_tizen> 3 </since_tizen>
413         /// <returns>
414         /// It returns a list containing all the supported <see cref="CameraAutoFocusMode"/>.
415         /// </returns>
416         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
417         public IEnumerable<CameraAutoFocusMode> SupportedAutoFocusModes
418         {
419             get
420             {
421                 if (_autoFocusModes == null)
422                 {
423                     try
424                     {
425                         _autoFocusModes = new List<CameraAutoFocusMode>();
426
427                         NativeFeatures.AfModeCallback callback = (CameraAutoFocusMode mode, IntPtr userData) =>
428                         {
429                             _autoFocusModes.Add(mode);
430                             return true;
431                         };
432                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedAfModes(_camera.GetHandle(), callback, IntPtr.Zero),
433                         "Failed to get the supported Auto focus modes.");
434                     }
435                     catch
436                     {
437                         _autoFocusModes = null;
438                         throw;
439                     }
440                 }
441
442                 return _autoFocusModes;
443             }
444         }
445
446         /// <summary>
447         /// Retrieves all the exposure modes supported by the camera.
448         /// </summary>
449         /// <since_tizen> 3 </since_tizen>
450         /// <returns>
451         /// It returns a list containing all the supported <see cref="CameraExposureMode"/>.
452         /// </returns>
453         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
454         public IEnumerable<CameraExposureMode> SupportedExposureModes
455         {
456             get
457             {
458                 if (_exposureModes == null)
459                 {
460                     try
461                     {
462                         _exposureModes = new List<CameraExposureMode>();
463
464                         NativeFeatures.ExposureModeCallback callback = (CameraExposureMode mode, IntPtr userData) =>
465                         {
466                             _exposureModes.Add(mode);
467                             return true;
468                         };
469                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedExposureModes(_camera.GetHandle(), callback, IntPtr.Zero),
470                         "Failed to get the supported Exposure modes.");
471                     }
472                     catch
473                     {
474                         _exposureModes = null;
475                         throw;
476                     }
477                 }
478
479                 return _exposureModes;
480             }
481         }
482
483         /// <summary>
484         /// Retrieves all the Iso level supported by the camera.
485         /// </summary>
486         /// <since_tizen> 3 </since_tizen>
487         /// <returns>
488         /// It returns a list containing all the supported <see cref="CameraIsoLevel"/>.
489         /// </returns>
490         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
491         public IEnumerable<CameraIsoLevel> SupportedIsoLevels
492         {
493             get
494             {
495                 if (_isoLevels == null)
496                 {
497                     try
498                     {
499                         _isoLevels = new List<CameraIsoLevel>();
500
501                         NativeFeatures.IsoCallback callback = (CameraIsoLevel iso, IntPtr userData) =>
502                         {
503                             _isoLevels.Add(iso);
504                             return true;
505                         };
506                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedIso(_camera.GetHandle(), callback, IntPtr.Zero),
507                         "Failed to get the supported Iso levels.");
508                     }
509                     catch
510                     {
511                         _isoLevels = null;
512                         throw;
513                     }
514                 }
515
516                 return _isoLevels;
517             }
518         }
519
520         /// <summary>
521         /// Retrieves all the theater modes supported by the camera.
522         /// </summary>
523         /// <since_tizen> 3 </since_tizen>
524         /// <returns>
525         /// It returns a list containing all the supported <see cref="CameraTheaterMode"/>.
526         /// </returns>
527         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
528         public IEnumerable<CameraTheaterMode> SupportedTheaterModes
529         {
530             get
531             {
532                 if (_theaterModes == null)
533                 {
534                     try
535                     {
536                         _theaterModes = new List<CameraTheaterMode>();
537
538                         NativeFeatures.TheaterModeCallback callback = (CameraTheaterMode theaterMode, IntPtr userData) =>
539                         {
540                             _theaterModes.Add(theaterMode);
541                             return true;
542                         };
543                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedTheaterModes(_camera.GetHandle(), callback, IntPtr.Zero),
544                         "Failed to get the supported theater modes.");
545                     }
546                     catch
547                     {
548                         _theaterModes = null;
549                         throw;
550                     }
551                 }
552
553                 return _theaterModes;
554             }
555         }
556
557         /// <summary>
558         /// Retrieves all the whitebalance modes supported by the camera.
559         /// </summary>
560         /// <since_tizen> 3 </since_tizen>
561         /// <returns>
562         /// It returns a list containing all the supported <see cref="CameraWhiteBalance"/>.
563         /// </returns>
564         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
565         public IEnumerable<CameraWhiteBalance> SupportedWhiteBalances
566         {
567             get
568             {
569                 if (_whitebalances == null)
570                 {
571                     try
572                     {
573                         _whitebalances = new List<CameraWhiteBalance>();
574
575                         NativeFeatures.WhitebalanceCallback callback = (CameraWhiteBalance whiteBalance, IntPtr userData) =>
576                         {
577                             _whitebalances.Add(whiteBalance);
578                             return true;
579                         };
580                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedWhitebalance(_camera.GetHandle(), callback, IntPtr.Zero),
581                         "Failed to get the supported white balance.");
582                     }
583                     catch
584                     {
585                         _whitebalances = null;
586                         throw;
587                     }
588                 }
589
590                 return _whitebalances;
591             }
592         }
593
594         /// <summary>
595         /// Retrieves all the flash modes supported by the camera.
596         /// </summary>
597         /// <since_tizen> 3 </since_tizen>
598         /// <returns>
599         /// It returns a list containing all the supported <see cref="CameraFlashMode"/>.
600         /// </returns>
601         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
602         public IEnumerable<CameraFlashMode> SupportedFlashModes
603         {
604             get
605             {
606                 if (_flashModes == null)
607                 {
608                     try
609                     {
610                         _flashModes = new List<CameraFlashMode>();
611
612                         NativeFeatures.FlashModeCallback callback = (CameraFlashMode flashMode, IntPtr userData) =>
613                         {
614                             _flashModes.Add(flashMode);
615                             return true;
616                         };
617                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedFlashModes(_camera.GetHandle(), callback, IntPtr.Zero),
618                         "Failed to get the supported flash modes.");
619                     }
620                     catch
621                     {
622                         _flashModes = null;
623                         throw;
624                     }
625                 }
626
627                 return _flashModes;
628             }
629         }
630
631         /// <summary>
632         /// Retrieves all the scene modes supported by the camera.
633         /// </summary>
634         /// <since_tizen> 3 </since_tizen>
635         /// <returns>
636         /// It returns a list containing all the supported <see cref="CameraSceneMode"/>.
637         /// </returns>
638         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
639         public IEnumerable<CameraSceneMode> SupportedSceneModes
640         {
641             get
642             {
643                 if (_sceneModes == null)
644                 {
645                     try
646                     {
647                         _sceneModes = new List<CameraSceneMode>();
648
649                         NativeFeatures.SceneModeCallback callback = (CameraSceneMode sceneMode, IntPtr userData) =>
650                         {
651                             _sceneModes.Add(sceneMode);
652                             return true;
653                         };
654                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedSceneModes(_camera.GetHandle(), callback, IntPtr.Zero),
655                         "Failed to get the supported scene modes.");
656                     }
657                     catch
658                     {
659                         _sceneModes = null;
660                         throw;
661                     }
662                 }
663
664                 return _sceneModes;
665             }
666         }
667
668         /// <summary>
669         /// Retrieves all the effect modes supported by the camera.
670         /// </summary>
671         /// <since_tizen> 3 </since_tizen>
672         /// <returns>
673         /// It returns a list containing all the supported <see cref="CameraEffectMode"/>.
674         /// </returns>
675         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
676         public IEnumerable<CameraEffectMode> SupportedEffects
677         {
678             get
679             {
680                 if (_effectModes == null)
681                 {
682                     try
683                     {
684                         _effectModes = new List<CameraEffectMode>();
685
686                         NativeFeatures.EffectCallback callback = (CameraEffectMode effect, IntPtr userData) =>
687                         {
688                             _effectModes.Add(effect);
689                             return true;
690                         };
691                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedEffects(_camera.GetHandle(), callback, IntPtr.Zero),
692                         "Failed to get the supported camera effects.");
693                     }
694                     catch
695                     {
696                         _effectModes = null;
697                         throw;
698                     }
699                 }
700
701                 return _effectModes;
702             }
703         }
704
705         /// <summary>
706         /// Retrieves all the stream rotation supported by the camera.
707         /// </summary>
708         /// <since_tizen> 3 </since_tizen>
709         /// <returns>
710         /// It returns a list containing all the supported <see cref="CameraRotation"/>.
711         /// </returns>
712         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
713         public IEnumerable<CameraRotation> SupportedStreamRotations
714         {
715             get
716             {
717                 if (_streamRotations == null)
718                 {
719                     try
720                     {
721                         _streamRotations = new List<CameraRotation>();
722
723                         NativeFeatures.StreamRotationCallback callback = (CameraRotation streamRotation, IntPtr userData) =>
724                         {
725                             _streamRotations.Add(streamRotation);
726                             return true;
727                         };
728                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedStreamRotations(_camera.GetHandle(), callback, IntPtr.Zero),
729                         "Failed to get the supported camera rotations.");
730                     }
731                     catch
732                     {
733                         _streamRotations = null;
734                         throw;
735                     }
736                 }
737
738                 return _streamRotations;
739             }
740         }
741
742         /// <summary>
743         /// Retrieves all the flips supported by the camera.
744         /// </summary>
745         /// <since_tizen> 3 </since_tizen>
746         /// <returns>
747         /// It returns a list containing all the supported <see cref="CameraFlip"/>.
748         /// </returns>
749         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
750         public IEnumerable<CameraFlip> SupportedStreamFlips
751         {
752             get
753             {
754                 if (_streamFlips == null)
755                 {
756                     try
757                     {
758                         _streamFlips = new List<CameraFlip>();
759
760                         NativeFeatures.StreamFlipCallback callback = (CameraFlip streamFlip, IntPtr userData) =>
761                         {
762                             _streamFlips.Add(streamFlip);
763                             return true;
764                         };
765                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedStreamFlips(_camera.GetHandle(), callback, IntPtr.Zero),
766                         "Failed to get the supported camera flips.");
767                     }
768                     catch
769                     {
770                         _streamFlips = null;
771                         throw;
772                     }
773                 }
774
775                 return _streamFlips;
776             }
777         }
778
779         /// <summary>
780         /// Retrieves all the ptz types by the camera.
781         /// </summary>
782         /// <since_tizen> 3 </since_tizen>
783         /// <returns>
784         /// It returns a list containing all the supported <see cref="CameraPtzType"/>.
785         /// </returns>
786         /// <exception cref="ObjectDisposedException">The camera already has been disposed.</exception>
787         public IEnumerable<CameraPtzType> SupportedPtzTypes
788         {
789             get
790             {
791                 if (_ptzTypes.Count == 0)
792                 {
793                     try
794                     {
795                         _ptzTypes = new List<CameraPtzType>();
796
797                         NativeFeatures.PtzTypeCallback callback = (CameraPtzType ptzType, IntPtr userData) =>
798                         {
799                             _ptzTypes.Add(ptzType);
800                             return true;
801                         };
802                         CameraErrorFactory.ThrowIfError(NativeFeatures.SupportedPtzTypes(_camera.GetHandle(), callback, IntPtr.Zero),
803                         "Failed to get the supported Ptz types.");
804                     }
805                     catch
806                     {
807                         _ptzTypes = null;
808                         throw;
809                     }
810                 }
811
812                 return _ptzTypes;
813             }
814         }
815     }
816 }