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