2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
19 using Tizen.Multimedia;
21 internal static partial class Interop
23 internal static partial class Camera
25 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
26 internal delegate void FaceDetectedCallback(IntPtr faces, int count, IntPtr userData);
28 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
29 internal delegate void StateChangedCallback(CameraState previous, CameraState current, bool byPolicy, IntPtr userData);
31 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
32 internal delegate void InterruptedCallback(CameraPolicy policy, CameraState previous, CameraState current, IntPtr userData);
34 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
35 internal delegate void InterruptStartedCallback(CameraPolicy policy, CameraState state, IntPtr userData);
37 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
38 internal delegate void FocusStateChangedCallback(CameraFocusState state, IntPtr userData);
40 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
41 internal delegate void ErrorCallback(CameraErrorCode error, CameraState current, IntPtr userData);
43 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
44 internal delegate void CapturingCallback(IntPtr image, IntPtr postview, IntPtr thumbnail, IntPtr userData);
46 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
47 internal delegate void CaptureCompletedCallback(IntPtr userData);
49 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
50 internal delegate void PreviewCallback(IntPtr frame, IntPtr userData);
52 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
53 internal delegate void MediaPacketPreviewCallback(IntPtr mediaPacketHandle, IntPtr userData);
55 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
56 internal delegate void HdrCaptureProgressCallback(int percent, IntPtr userData);
58 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
59 internal delegate void DeviceStateChangedCallback(CameraDevice device, CameraDeviceState state, IntPtr userData);
61 [DllImport(Libraries.Camera, EntryPoint = "camera_create")]
62 internal static extern CameraError Create(CameraDevice device, out IntPtr handle);
64 [DllImport(Libraries.Camera, EntryPoint = "camera_change_device")]
65 internal static extern CameraError ChangeDevice(IntPtr handle, CameraDevice device);
67 [DllImport(Libraries.Camera, EntryPoint = "camera_destroy")]
68 internal static extern CameraError Destroy(IntPtr handle);
70 [DllImport(Libraries.Camera, EntryPoint = "camera_get_device_count")]
71 internal static extern CameraError GetDeviceCount(IntPtr handle, out int count);
73 [DllImport(Libraries.Camera, EntryPoint = "camera_start_preview")]
74 internal static extern CameraError StartPreview(IntPtr handle);
76 [DllImport(Libraries.Camera, EntryPoint = "camera_stop_preview")]
77 internal static extern CameraError StopPreview(IntPtr handle);
79 [DllImport(Libraries.Camera, EntryPoint = "camera_get_device_state")]
80 internal static extern CameraError GetDeviceState(CameraDevice device, out CameraDeviceState state);
82 [DllImport(Libraries.Camera, EntryPoint = "camera_start_capture")]
83 internal static extern CameraError StartCapture(IntPtr handle, CapturingCallback captureCallback,
84 CaptureCompletedCallback completedCallback, IntPtr userData);
86 [DllImport(Libraries.Camera, EntryPoint = "camera_start_continuous_capture")]
87 internal static extern CameraError StartContinuousCapture(IntPtr handle, int count, int interval,
88 CapturingCallback captureCallback, CaptureCompletedCallback completedCallback, IntPtr userData);
90 [DllImport(Libraries.Camera, EntryPoint = "camera_stop_continuous_capture")]
91 internal static extern CameraError StopContinuousCapture(IntPtr handle);
93 [DllImport(Libraries.Camera, EntryPoint = "camera_get_state")]
94 internal static extern CameraError GetState(IntPtr handle, out CameraState state);
96 [DllImport(Libraries.Camera, EntryPoint = "camera_start_focusing")]
97 internal static extern CameraError StartFocusing(IntPtr handle, bool continuous);
99 [DllImport(Libraries.Camera, EntryPoint = "camera_cancel_focusing")]
100 internal static extern CameraError CancelFocusing(IntPtr handle);
102 [DllImport(Libraries.Camera, EntryPoint = "camera_set_preview_resolution")]
103 internal static extern CameraError SetPreviewResolution(IntPtr handle, int width, int height);
105 [DllImport(Libraries.Camera, EntryPoint = "camera_get_preview_resolution")]
106 internal static extern CameraError GetPreviewResolution(IntPtr handle, out int width, out int height);
108 [DllImport(Libraries.Camera, EntryPoint = "camera_get_recommended_preview_resolution")]
109 internal static extern CameraError GetRecommendedPreviewResolution(IntPtr handle, out int width, out int height);
111 [DllImport(Libraries.Camera, EntryPoint = "camera_start_face_detection")]
112 internal static extern CameraError StartFaceDetection(IntPtr handle, FaceDetectedCallback callback, IntPtr userData);
114 [DllImport(Libraries.Camera, EntryPoint = "camera_stop_face_detection")]
115 internal static extern CameraError StopFaceDetection(IntPtr handle);
117 [DllImport(Libraries.Camera, EntryPoint = "camera_set_display_reuse_hint")]
118 internal static extern CameraError SetDisplayReuseHint(IntPtr handle, bool hint);
120 [DllImport(Libraries.Camera, EntryPoint = "camera_get_display_reuse_hint")]
121 internal static extern CameraError GetDisplayReuseHint(IntPtr handle, out bool hint);
123 [DllImport(Libraries.Camera, EntryPoint = "camera_set_capture_resolution")]
124 internal static extern CameraError SetCaptureResolution(IntPtr handle, int width, int height);
126 [DllImport(Libraries.Camera, EntryPoint = "camera_get_capture_resolution")]
127 internal static extern CameraError GetCaptureResolution(IntPtr handle, out int width, out int height);
129 [DllImport(Libraries.Camera, EntryPoint = "camera_set_capture_format")]
130 internal static extern CameraError SetCaptureFormat(IntPtr handle, CameraPixelFormat format);
132 [DllImport(Libraries.Camera, EntryPoint = "camera_get_capture_format")]
133 internal static extern CameraError GetCaptureFormat(IntPtr handle, out CameraPixelFormat format);
135 [DllImport(Libraries.Camera, EntryPoint = "camera_set_preview_format")]
136 internal static extern CameraError SetPreviewPixelFormat(IntPtr handle, CameraPixelFormat format);
138 [DllImport(Libraries.Camera, EntryPoint = "camera_get_preview_format")]
139 internal static extern CameraError GetPreviewPixelFormat(IntPtr handle, out CameraPixelFormat format);
141 [DllImport(Libraries.Camera, EntryPoint = "camera_get_facing_direction")]
142 internal static extern CameraError GetFacingDirection(IntPtr handle, out CameraFacingDirection direction);
144 [DllImport(Libraries.Camera, EntryPoint = "camera_get_flash_state")]
145 internal static extern CameraError GetFlashState(CameraDevice device, out CameraFlashState state);
147 [DllImport(Libraries.Camera, EntryPoint = "camera_set_preview_cb")]
148 internal static extern CameraError SetPreviewCallback(IntPtr handle, PreviewCallback callback, IntPtr userData);
150 [DllImport(Libraries.Camera, EntryPoint = "camera_unset_preview_cb")]
151 internal static extern CameraError UnsetPreviewCallback(IntPtr handle);
153 [DllImport(Libraries.Camera, EntryPoint = "camera_set_media_packet_preview_cb")]
154 internal static extern CameraError SetMediaPacketPreviewCallback(IntPtr handle, MediaPacketPreviewCallback callback, IntPtr userData);
156 [DllImport(Libraries.Camera, EntryPoint = "camera_unset_media_packet_preview_cb")]
157 internal static extern CameraError UnsetMediaPacketPreviewCallback(IntPtr handle);
159 [DllImport(Libraries.Camera, EntryPoint = "camera_set_state_changed_cb")]
160 internal static extern CameraError SetStateChangedCallback(IntPtr handle, StateChangedCallback callback, IntPtr userData);
162 [DllImport(Libraries.Camera, EntryPoint = "camera_add_device_state_changed_cb")]
163 internal static extern CameraError SetDeviceStateChangedCallback(DeviceStateChangedCallback callback, IntPtr userData, out int callbackId);
165 [DllImport(Libraries.Camera, EntryPoint = "camera_unset_state_changed_cb")]
166 internal static extern CameraError UnsetStateChangedCallback(IntPtr handle);
168 [DllImport(Libraries.Camera, EntryPoint = "camera_remove_device_state_changed_cb")]
169 internal static extern CameraError UnsetDeviceStateChangedCallback(int cbId);
171 [DllImport(Libraries.Camera, EntryPoint = "camera_set_interrupt_started_cb")]
172 internal static extern CameraError SetInterruptStartedCallback(IntPtr handle, InterruptStartedCallback callback, IntPtr userData);
174 [DllImport(Libraries.Camera, EntryPoint = "camera_unset_interrupt_started_cb")]
175 internal static extern CameraError UnsetInterruptStartedCallback(IntPtr handle);
177 [DllImport(Libraries.Camera, EntryPoint = "camera_set_interrupted_cb")]
178 internal static extern CameraError SetInterruptedCallback(IntPtr handle, InterruptedCallback callback, IntPtr userData);
180 [DllImport(Libraries.Camera, EntryPoint = "camera_unset_interrupted_cb")]
181 internal static extern CameraError UnsetInterruptedCallback(IntPtr handle);
183 [DllImport(Libraries.Camera, EntryPoint = "camera_set_focus_changed_cb")]
184 internal static extern CameraError SetFocusStateChangedCallback(IntPtr handle, FocusStateChangedCallback callback, IntPtr userData);
186 [DllImport(Libraries.Camera, EntryPoint = "camera_unset_focus_changed_cb")]
187 internal static extern CameraError UnsetFocusChangedCallback(IntPtr handle);
189 [DllImport(Libraries.Camera, EntryPoint = "camera_set_error_cb")]
190 internal static extern CameraError SetErrorCallback(IntPtr handle, ErrorCallback callback, IntPtr userData);
192 [DllImport(Libraries.Camera, EntryPoint = "camera_unset_error_cb")]
193 internal static extern CameraError UnsetErrorCallback(IntPtr handle);
195 [DllImport(Libraries.Camera, EntryPoint = "camera_attr_set_hdr_capture_progress_cb")]
196 internal static extern CameraError SetHdrCaptureProgressCallback(IntPtr handle, HdrCaptureProgressCallback callback, IntPtr userData);
198 [DllImport(Libraries.Camera, EntryPoint = "camera_attr_unset_hdr_capture_progress_cb")]
199 internal static extern CameraError UnsetHdrCaptureProgressCallback(IntPtr handle);
201 [StructLayout(LayoutKind.Sequential)]
202 internal struct StillImageDataStruct
204 internal IntPtr Data;
205 internal uint DataLength;
208 internal CameraPixelFormat Format;
209 internal IntPtr Exif;
210 internal uint ExifLength;
213 [StructLayout(LayoutKind.Sequential)]
214 internal struct DetectedFaceStruct
224 [StructLayout(LayoutKind.Sequential)]
225 internal struct SinglePlaneStruct
227 internal IntPtr Data;
228 internal uint DataLength;
231 [StructLayout(LayoutKind.Sequential)]
232 internal struct DoublePlaneStruct
236 internal uint YLength;
237 internal uint UVLength;
240 [StructLayout(LayoutKind.Sequential)]
241 internal struct TriplePlaneStruct
246 internal uint YLength;
247 internal uint ULength;
248 internal uint VLength;
251 [StructLayout(LayoutKind.Sequential)]
252 internal struct EncodedPlaneStruct
254 internal IntPtr Data;
255 internal uint DataLength;
258 [StructLayout(LayoutKind.Explicit)]
259 internal struct PreviewPlaneStruct
261 [FieldOffsetAttribute(0)]
262 internal SinglePlaneStruct SinglePlane;
263 [FieldOffsetAttribute(0)]
264 internal DoublePlaneStruct DoublePlane;
265 [FieldOffsetAttribute(0)]
266 internal TriplePlaneStruct TriplePlane;
267 [FieldOffsetAttribute(0)]
268 internal EncodedPlaneStruct EncodedPlane;
271 [StructLayout(LayoutKind.Sequential)]
272 internal struct CameraPreviewDataStruct
274 internal CameraPixelFormat Format;
277 internal int NumOfPlanes;
278 internal uint TimeStamp;
279 internal PreviewPlaneStruct Plane;