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