diff --git a/src/Tizen.Multimedia.Camera/Camera/Camera.cs b/src/Tizen.Multimedia.Camera/Camera/Camera.cs index c2b8925f503..1e73a181a45 100644 --- a/src/Tizen.Multimedia.Camera/Camera/Camera.cs +++ b/src/Tizen.Multimedia.Camera/Camera/Camera.cs @@ -46,7 +46,6 @@ public partial class Camera : IDisposable, IDisplayable private bool _disposed = false; private CameraState _state = CameraState.None; PinnedPreviewBuffer _previewBuffer; - private CameraDeviceManager _cameraDeviceManager; /// /// Initializes a new instance of the class. @@ -69,12 +68,20 @@ public Camera(CameraDevice device) /// /// Initializes a new instance of the class. /// - /// CameraDevice and Type will be selected internally by CameraDeviceManager. - /// In case of any invalid operations. + /// + /// If is supported, will be selected automatically by internal policy.
+ /// (User can check whether CameraDeviceManager is supported or not by using .)
+ /// But, if not, this constructor will try to create Camera instance with by default. + ///
+ /// + /// There's no available camera device. + /// -or-
+ /// In case of any invalid operations. + ///
/// The camera feature is not supported. - /// 9 + /// 12 /// http://tizen.org/feature/camera - [EditorBrowsable(EditorBrowsableState.Never)] + /// public Camera() : this(CameraDevice.Default) { } @@ -95,31 +102,31 @@ private void CreateCameraDevice(CameraDevice device) CameraDeviceType cameraDeviceType = CameraDeviceType.BuiltIn; CameraDevice cameraDevice = device; - try - { - _cameraDeviceManager = new CameraDeviceManager(); - } - catch (NotSupportedException) - { - Log.Info(CameraLog.Tag, - $"CameraDeviceManager is not supported. Not error."); - } - - if (_cameraDeviceManager != null) + if (device == CameraDevice.Default) { - var deviceInfo = _cameraDeviceManager.SupportedDevices; - - // CameraDeviceManager is not used internally anymore. - _cameraDeviceManager.Dispose(); + var deviceInfo = Enumerable.Empty(); - if (!deviceInfo.Any()) + try { - throw new InvalidOperationException("CameraDeviceManager is supported but, there's no available camera device."); + using (var cameraDeviceManager = new CameraDeviceManager()) + { + deviceInfo = cameraDeviceManager.SupportedDevices; + } + + if (!deviceInfo.Any()) + { + throw new InvalidOperationException("CameraDeviceManager is supported but, there's no available camera device."); + } + + cameraDeviceType = deviceInfo.First().Type; + cameraDevice = deviceInfo.First().Device; + Log.Debug(CameraLog.Tag, $"Type:[{cameraDeviceType}], Auto selected camera device:[{cameraDevice}]"); + } + catch (NotSupportedException) + { + Log.Debug(CameraLog.Tag, "CameraDeviceManager is not supported. Try to create Camera instance by CameraDevice0."); + cameraDevice = CameraDevice.CameraDevice0; } - - cameraDeviceType = deviceInfo.First().Type; - cameraDevice = deviceInfo.First().Device; - Log.Debug(CameraLog.Tag, $"Type:[{cameraDeviceType}], Device:[{cameraDevice}]"); } CreateNativeCameraDevice(cameraDeviceType, cameraDevice); diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraDeviceManager.cs b/src/Tizen.Multimedia.Camera/Camera/CameraDeviceManager.cs index 535a7819ece..09181109428 100644 --- a/src/Tizen.Multimedia.Camera/Camera/CameraDeviceManager.cs +++ b/src/Tizen.Multimedia.Camera/Camera/CameraDeviceManager.cs @@ -65,6 +65,28 @@ public CameraDeviceManager() d.Type == CameraDeviceType.Network) .Any(); + /// + /// Gets the state of Camera Device Manager support. + /// + /// true if camera device manager is supported. + /// 11 + public static bool IsCameraDeviceManagerSupported + { + get + { + try + { + using (var cameraDeviceManager = new CameraDeviceManager()) {} + } + catch (NotSupportedException) + { + return false; + } + + return true; + } + } + /// /// Retrieves all the supported camera devices and returns its information. /// diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraEnums.cs b/src/Tizen.Multimedia.Camera/Camera/CameraEnums.cs index fecfb36fd59..29c231449fa 100644 --- a/src/Tizen.Multimedia.Camera/Camera/CameraEnums.cs +++ b/src/Tizen.Multimedia.Camera/Camera/CameraEnums.cs @@ -26,7 +26,7 @@ namespace Tizen.Multimedia public enum CameraDevice { /// - /// The CameraDevice will be decided internally by target policy. + /// The CameraDevice will be decided automatically by internal policy, if CameraDeviceManager is supported. /// /// 9 [EditorBrowsable(EditorBrowsableState.Never)]