[Camera] Add new APIs for manual focus level, product id and vendor id (#5443)
authorHaesu Gwon <haesu.gwon@samsung.com>
Wed, 9 Aug 2023 02:03:01 +0000 (11:03 +0900)
committerGitHub <noreply@github.com>
Wed, 9 Aug 2023 02:03:01 +0000 (11:03 +0900)
* [Camera] Add new APIs for manual focus level, product id and vendor id

src/Tizen.Multimedia.Camera/Camera/CameraCapabilities.cs
src/Tizen.Multimedia.Camera/Camera/CameraDeviceManager.cs
src/Tizen.Multimedia.Camera/Camera/CameraSettings.cs
src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs
src/Tizen.Multimedia.Camera/Interop/Interop.CameraSettings.cs

index feda7f9..3cf2e92 100644 (file)
@@ -70,6 +70,7 @@ namespace Tizen.Multimedia
             IsHueSupported = CheckRangeValid(NativeSettings.GetHueRange);
             IsSaturationSupported = CheckRangeValid(NativeSettings.GetSaturationRange);
             IsSharpnessSupported = CheckRangeValid(NativeSettings.GetSharpnessRange);
+            IsFocusLevelSupported = CheckRangeValid(NativeSettings.GetFocusLevelRange);
             IsGainSupported = CheckRangeValid(NativeSettings.GetGainRange);
             IsWhiteBalanceTemperatureSupported = CheckRangeValid(NativeSettings.GetWhiteBalanceTemperatureRange);
         }
@@ -207,6 +208,13 @@ namespace Tizen.Multimedia
         public bool IsSharpnessSupported { get; }
 
         /// <summary>
+        /// Gets the manual focus level feature support state.
+        /// </summary>
+        /// <value>true if supported, otherwise false.</value>
+        /// <since_tizen> 11 </since_tizen>
+        public bool IsFocusLevelSupported { get; }
+
+        /// <summary>
         /// Gets the gain feature support state.
         /// </summary>
         /// <value>true if supported, otherwise false.</value>
index 1e3f201..535a781 100644 (file)
@@ -114,6 +114,36 @@ namespace Tizen.Multimedia
         }
 
         /// <summary>
+        /// Gets the product ID for given <param name="device"/>.
+        /// </summary>
+        /// <exception cref="ArgumentException">Invalid enumeration.</exception>
+        /// <exception cref="ObjectDisposedException">The CameraDeviceManager already has been disposed.</exception>
+        /// <since_tizen> 11 </since_tizen>
+        public ushort GetProductId(CameraDevice device)
+        {
+            ValidationUtil.ValidateEnum(typeof(CameraDevice), device, nameof(device));
+
+            Native.GetProductId(Handle, out ushort productId).ThrowIfFailed("failed to get product ID");
+
+            return productId;
+        }
+
+        /// <summary>
+        /// Gets the vendor ID for given <param name="device"/>.
+        /// </summary>
+        /// <exception cref="ArgumentException">Invalid enumeration.</exception>
+        /// <exception cref="ObjectDisposedException">The CameraDeviceManager already has been disposed.</exception>
+        /// <since_tizen> 11 </since_tizen>
+        public ushort GetVendorId(CameraDevice device)
+        {
+            ValidationUtil.ValidateEnum(typeof(CameraDevice), device, nameof(device));
+
+            Native.GetVendorId(Handle, out ushort vendorId).ThrowIfFailed("failed to get vendor ID");
+
+            return vendorId;
+        }
+
+        /// <summary>
         /// Gets the current camera device information.
         /// Retrieves all the supported camera devices and returns its information.
         /// </summary>
index efabdea..46b0798 100644 (file)
@@ -40,6 +40,7 @@ namespace Tizen.Multimedia
         private readonly Range? _zoomRange;
         private readonly Range? _saturationRange;
         private readonly Range? _sharpnessRange;
+        private readonly Range? _focusLevelRange;
         private readonly Range? _gainRange;
         private readonly Range? _whitebalanceTemperatureRange;
 
@@ -56,6 +57,7 @@ namespace Tizen.Multimedia
             _zoomRange = GetRange(Native.GetZoomRange);
             _saturationRange = GetRange(Native.GetSaturationRange);
             _sharpnessRange = GetRange(Native.GetSharpnessRange);
+            _focusLevelRange = GetRange(Native.GetFocusLevelRange);
             _gainRange = GetRange(Native.GetGainRange);
             _whitebalanceTemperatureRange = GetRange(Native.GetWhiteBalanceTemperatureRange);
         }
@@ -471,6 +473,51 @@ namespace Tizen.Multimedia
         }
         #endregion sharpness
 
+        #region focus level
+        /// <summary>
+        /// Gets or sets the camera manual focus level.
+        /// </summary>
+        /// <remark>If user set this value for manual focus, auto focusing will be stopped.</remark>
+        /// <since_tizen> 11 </since_tizen>
+        /// <exception cref="ObjectDisposedException">The camera has already been disposed. </exception>
+        public int FocusLevel
+        {
+            get
+            {
+                Native.GetFocusLevel(_camera.GetHandle(), out int val).
+                    ThrowIfFailed("Failed to get camera manual focus level.");
+
+                return val;
+            }
+            set
+            {
+                Native.SetFocusLevel(_camera.GetHandle(), value).
+                    ThrowIfFailed("Failed to set camera manual focus level.");
+            }
+        }
+
+        /// <summary>
+        /// Gets the available manual focus level range.
+        /// </summary>
+        /// <since_tizen> 11 </since_tizen>
+        /// <remarks>
+        /// If the minimum value is greater than the maximum value, it means this feature is not supported.
+        /// </remarks>
+        /// <exception cref="NotSupportedException">Focus level is not supported.</exception>
+        public Range FocusLevelRange
+        {
+            get
+            {
+                if (!_focusLevelRange.HasValue)
+                {
+                    throw new NotSupportedException("Focus level is not supported.");
+                }
+
+                return _focusLevelRange.Value;
+            }
+        }
+        #endregion focus level
+
         #region gain
         /// <summary>
         /// Gets or sets the camera gain value.
index f90715b..75998ed 100644 (file)
@@ -350,6 +350,12 @@ internal static partial class Interop
         [DllImport(Libraries.Camera, EntryPoint = "camera_device_manager_remove_device_connection_changed_cb")]
         internal static extern CameraError UnsetDeviceConnectionChangedCallback(IntPtr handle, int id);
 
+        [DllImport(Libraries.Camera, EntryPoint = "camera_device_manager_get_product_id")]
+        internal static extern CameraError GetProductId(IntPtr handle, out ushort id);
+
+        [DllImport(Libraries.Camera, EntryPoint = "camera_device_manager_get_vendor_id")]
+        internal static extern CameraError GetVendorId(IntPtr handle, out ushort id);
+
         [NativeStruct("camera_device_s", Include="camera.h", PkgConfig="capi-media-camera")]
         [StructLayout(LayoutKind.Sequential)]
         internal struct CameraDeviceStruct
index b13e60f..60d403c 100644 (file)
@@ -157,6 +157,15 @@ internal static partial class Interop
         [DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_sharpness_range")]
         internal static extern CameraError GetSharpnessRange(IntPtr handle, out int min, out int max);
 
+        [DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_focus_level")]
+        internal static extern CameraError SetFocusLevel(IntPtr handle, int level);
+
+        [DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_focus_level")]
+        internal static extern CameraError GetFocusLevel(IntPtr handle, out int level);
+
+        [DllImport(Libraries.Camera, EntryPoint = "camera_attr_get_focus_level_range")]
+        internal static extern CameraError GetFocusLevelRange(IntPtr handle, out int min, out int max);
+
         [DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_gain")]
         internal static extern CameraError SetGain(IntPtr handle, int level);