From: Haesu Gwon Date: Tue, 6 Jul 2021 07:55:12 +0000 (+0900) Subject: [Camera] Add extra stream format for production (#3257) X-Git-Tag: accepted/tizen/unified/20231205.024657~1709 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e083d135515f31ad8a438756c31654fb660fb66;hp=c53be22c2bb726f32aed28b00d6fd3c577015452;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Camera] Add extra stream format for production (#3257) * [Camera] Add extra stream format for production --- diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraDeviceManager.cs b/src/Tizen.Multimedia.Camera/Camera/CameraDeviceManager.cs index 0291272..496a554 100644 --- a/src/Tizen.Multimedia.Camera/Camera/CameraDeviceManager.cs +++ b/src/Tizen.Multimedia.Camera/Camera/CameraDeviceManager.cs @@ -101,18 +101,7 @@ namespace Tizen.Multimedia } internal static CameraDeviceInformation GetDeviceInformation(Native.CameraDeviceStruct device) => - new CameraDeviceInformation(device.Type, device.device, GetString(device.name), GetString(device.id)); - - private static string GetString(char[] word) - { - int length = 0; - while(word[length] != '\0') - { - length++; - } - - return new String(word, 0, length); - } + new CameraDeviceInformation(device.Type, device.device, device.name, device.id, device.extraStreamNum); private event EventHandler _deviceConnectionChanged; /// @@ -231,7 +220,7 @@ namespace Tizen.Multimedia /// /// 9 [EditorBrowsable(EditorBrowsableState.Never)] - public class CameraDeviceInformation + public struct CameraDeviceInformation { /// /// Initializes a new instance of the class. @@ -240,11 +229,12 @@ namespace Tizen.Multimedia /// /// The name of camera device /// The ID of camera device + /// The number of extra stream /// Invalid enumeration. /// name or id is null. /// 9 [EditorBrowsable(EditorBrowsableState.Never)] - internal CameraDeviceInformation(CameraDeviceType type, CameraDevice device, string name, string id) + internal CameraDeviceInformation(CameraDeviceType type, CameraDevice device, string name, string id, int numberOfExtraStream) { ValidationUtil.ValidateEnum(typeof(CameraDeviceType), type, nameof(type)); ValidationUtil.ValidateEnum(typeof(CameraDevice), device, nameof(device)); @@ -253,6 +243,7 @@ namespace Tizen.Multimedia Device = device; Name = name ?? throw new ArgumentNullException(nameof(name), "name is null"); Id = id ?? throw new ArgumentNullException(nameof(id), "id is null"); + NumberOfExtraStream = numberOfExtraStream; } /// @@ -288,12 +279,20 @@ namespace Tizen.Multimedia public string Id { get; } /// + /// Gets the number of extra stream. + /// + /// The number of extra stream. + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public int NumberOfExtraStream { get; } + + /// /// Returns a string that represents the current object. /// /// A string that represents the current object. /// 9 [EditorBrowsable(EditorBrowsableState.Never)] public override string ToString() => - $"Type:{Type.ToString()}, Device:{Device.ToString()}, Name:{Name}, Id:{Id}"; + $"Type:{Type.ToString()}, Device:{Device.ToString()}, Name:{Name}, Id:{Id}, NumberOfExtraStream:{NumberOfExtraStream}"; } } diff --git a/src/Tizen.Multimedia.Camera/Camera/CameraSettings.cs b/src/Tizen.Multimedia.Camera/Camera/CameraSettings.cs index a46ef05..e8eb89e 100644 --- a/src/Tizen.Multimedia.Camera/Camera/CameraSettings.cs +++ b/src/Tizen.Multimedia.Camera/Camera/CameraSettings.cs @@ -15,6 +15,7 @@ */ using System; +using System.ComponentModel; using System.Runtime.InteropServices; using Native = Interop.CameraSettings; using static Interop.Camera; @@ -1231,5 +1232,99 @@ namespace Tizen.Multimedia } } #endregion EXIF tag + + /// + /// Gets the information of extra preview stream. + /// + /// The stream id. + /// 9 + /// The camera already has been disposed of. + [EditorBrowsable(EditorBrowsableState.Never)] + public ExtraPreviewStreamInfo GetExtraPreviewStreamInfo(int streamId) + { + GetExtraPreviewStreamFormat(_camera.GetHandle(), streamId, out CameraPixelFormat format, + out int width, out int height, out int fps).ThrowIfFailed("Failed to get extra preview stream foramt"); + + return new ExtraPreviewStreamInfo(streamId, format, new Size(width, height), fps); + } + + /// + /// Sets the information of extra preview stream. + /// + /// The extra preview stream information. + /// 9 + /// The camera already has been disposed of. + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetExtraPreviewStreamInfo(ExtraPreviewStreamInfo info) + { + SetExtraPreviewStreamFormat(_camera.GetHandle(), info.StreamId, info.Format, + info.Size.Width, info.Size.Height, info.Fps).ThrowIfFailed("Failed to set extra preview stream foramt"); + } + } + + /// + /// Provides the ability to get the information of extra preview stream. + /// + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public struct ExtraPreviewStreamInfo + { + /// + /// Initializes a new instance of the class. + /// + /// The stream id. + /// The preview format. + /// The preview resolution. + /// The fps. + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public ExtraPreviewStreamInfo(int streamId, CameraPixelFormat format, Size size, int fps) + { + StreamId = streamId; + Format = format; + Size = size; + Fps = fps; + } + + /// + /// Gets the stream Id. + /// + /// The stream Id. + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public int StreamId { get; set;} + + /// + /// Gets the extra preview format. + /// + /// + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public CameraPixelFormat Format { get; } + + /// + /// Gets the extra preview resolution. + /// + /// + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public Size Size { get; } + + /// + /// Gets the fps. + /// + /// + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public int Fps { get; } + + /// + /// Returns a string that represents the current object. + /// + /// A string that represents the current object. + /// 9 + [EditorBrowsable(EditorBrowsableState.Never)] + public override string ToString() => + $"StreamId:{StreamId}, Format:{Format.ToString()}, Resolution:{Size.Width}x{Size.Height}, Fps:{Fps}"; } } diff --git a/src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs b/src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs index ba79a8e..dc82ab3 100644 --- a/src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs +++ b/src/Tizen.Multimedia.Camera/Interop/Interop.Camera.cs @@ -151,6 +151,15 @@ internal static partial class Interop [DllImport(Libraries.Camera, EntryPoint = "camera_get_flash_state")] internal static extern CameraError GetFlashState(CameraDevice device, out CameraFlashState state); + [DllImport(Libraries.Camera, EntryPoint = "camera_set_extra_preview_stream_format")] + internal static extern CameraError SetExtraPreviewStreamFormat(IntPtr handle, int streamId, CameraPixelFormat format, + int width, int height, int fps); + + [DllImport(Libraries.Camera, EntryPoint = "camera_get_extra_preview_stream_format")] + internal static extern CameraError GetExtraPreviewStreamFormat(IntPtr handle, int streamId, out CameraPixelFormat format, + out int width, out int height, out int fps); + + [DllImport(Libraries.Camera, EntryPoint = "camera_set_preview_cb")] internal static extern CameraError SetPreviewCallback(IntPtr handle, PreviewCallback callback, IntPtr userData = default); @@ -211,6 +220,7 @@ internal static partial class Interop [DllImport(Libraries.Camera, EntryPoint = "camera_attr_unset_hdr_capture_progress_cb")] internal static extern CameraError UnsetHdrCaptureProgressCallback(IntPtr handle); + [NativeStruct("camera_image_data_s", Include="camera.h", PkgConfig="capi-media-camera")] [StructLayout(LayoutKind.Sequential)] internal struct StillImageDataStruct @@ -345,11 +355,13 @@ internal static partial class Interop internal CameraDevice device; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - internal char[] name; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] + internal string name; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] + internal string id; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] - internal char[] id; + internal int extraStreamNum; } [NativeStruct("camera_device_list_s", Include="camera_internal.h", PkgConfig="capi-media-camera")]