2 * Copyright (c) 2011 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.
17 #ifndef __TIZEN_MULTIMEDIA_CAMERA_INTERNAL_H__
18 #define __TIZEN_MULTIMEDIA_CAMERA_INTERNAL_H__
22 #include <tbm_surface_internal.h>
29 * @file camera_internal.h
30 * @brief This file contains the internal Camera API, related structures and enumerations.
35 * @addtogroup CAPI_MEDIA_CAMERA_INTERNAL_MODULE
39 #ifdef BUFFER_MAX_PLANE_NUM
40 #undef BUFFER_MAX_PLANE_NUM
41 #endif /* BUFFER_MAX_PLANE_NUM */
43 #define BUFFER_MAX_PLANE_NUM 4
44 #define CAMERA_DEVICE_MAX ((CAMERA_DEVICE_CAMERA9 + 1) * 2)
45 #define DEVICE_NAME_MAX_LENGTH 64
46 #define DEVICE_ID_MAX_LENGTH 64
48 typedef struct _camera_stream_data_s {
52 unsigned int length_yuv;
56 unsigned int length_y;
58 unsigned int length_uv;
62 unsigned int length_y;
64 unsigned int length_u;
66 unsigned int length_v;
70 unsigned int length_data;
72 } encoded, depth, rgb;
73 } data; /**< pointer of captured stream */
74 int data_type; /**< data type */
75 unsigned int length_total; /**< total length of stream buffer (in byte)*/
76 unsigned int num_planes; /**< number of planes */
77 MMPixelFormatType format; /**< image format */
78 int width; /**< width of video buffer */
79 int height; /**< height of video buffer */
80 unsigned int timestamp; /**< timestamp of stream buffer (msec)*/
81 void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */
82 void *internal_buffer; /**< Internal buffer pointer */
83 int stride[BUFFER_MAX_PLANE_NUM]; /**< Stride of each plane */
84 int elevation[BUFFER_MAX_PLANE_NUM]; /**< Elevation of each plane */
85 int extra_stream_id; /**< ID of extra preview stream */
86 } camera_stream_data_s;
90 CAMERA_DEVICE_TYPE_BUILTIN = 0, /**< Built-in camera */
91 CAMERA_DEVICE_TYPE_USB, /**< USB connected camera */
92 CAMERA_DEVICE_TYPE_NETWORK /**< Network camera */
93 } camera_device_type_e;
95 typedef struct _camera_device_s {
96 camera_device_type_e type;
97 camera_device_e index;
98 char name[DEVICE_NAME_MAX_LENGTH];
99 char id[DEVICE_ID_MAX_LENGTH];
100 int extra_stream_num;
103 typedef struct _camera_device_list_s {
105 camera_device_s device[CAMERA_DEVICE_MAX];
106 } camera_device_list_s;
108 typedef struct camera_device_manager *camera_device_manager_h;
112 * @brief Called when the camera device list is changed.
114 * @param[in] list The device list of the camera
115 * @param[in] user_data The user data passed from the callback registration function
116 * @see camera_device_manager_add_device_list_changed_cb()
118 typedef void (*camera_device_list_changed_cb)(camera_device_list_s *list, void *user_data);
122 * @brief Called to register for notifications about delivering a copy of the new extra preview frames.
124 * @param[in] frame The reference pointer to extra preview stream data
125 * @param[in] stream_id The id of stream
126 * @param[in] user_data The user data passed from the callback registration function
127 * @pre camera_start_preview() will invoke this callback function if you register this callback using camera_set_extra_preview_cb().
128 * @see camera_start_preview()
129 * @see camera_set_extra_preview_cb()
130 * @see camera_unset_extra_preview_cb()
132 typedef void (*camera_extra_preview_cb)(camera_preview_data_s *frame, int stream_id, void *user_data);
136 * @brief Start the evas rendering.
138 * @param[in] camera The handle to the camera
139 * @return @c 0 on success, otherwise a negative error value
140 * @retval #CAMERA_ERROR_NONE Successful
141 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
142 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
143 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
144 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
146 int camera_start_evas_rendering(camera_h camera);
150 * @brief Stop the evas rendering.
152 * @param[in] camera The handle to the camera
153 * @param[in] keep_screen If @c true keep last frame on display, otherwise @c false
154 * @return @c 0 on success, otherwise a negative error value
155 * @retval #CAMERA_ERROR_NONE Successful
156 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
157 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
158 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
159 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
161 int camera_stop_evas_rendering(camera_h camera, bool keep_screen);
165 * @brief Sets the ecore wayland video display.
167 * @remarks This function must be called in main thread of the application.
168 * Otherwise, it will return #CAMERA_ERROR_INVALID_OPERATION by internal restriction.
169 * To avoid #CAMERA_ERROR_INVALID_OPERATION in sub thread, ecore_thread_main_loop_begin() and
170 * ecore_thread_main_loop_end() can be used, but deadlock can occur if the main thread is busy.
171 * So, it's not recommended to use them.
172 * @param[in] camera The handle to the camera
173 * @param[in] ecore_wl_window The ecore wayland window handle
174 * @return @c 0 on success,
175 * otherwise a negative error value
176 * @retval #CAMERA_ERROR_NONE Successful
177 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
178 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
179 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
180 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
181 * @pre The camera state must be set to #CAMERA_STATE_CREATED.
182 * @see camera_start_preview()
183 * @see ecore_thread_main_loop_begin()
184 * @see ecore_thread_main_loop_end()
186 int camera_set_ecore_wl_display(camera_h camera, void *ecore_wl_window);
190 * @brief Creates preview frame from stream data.
192 * @param[in] stream The stream from internal pipeline
193 * @param[in] num_buffer_fd The number of buffer fd
194 * @param[in] buffer_bo_handle The bo handle of buffer
195 * @param[in] data_bo_handle The bo handle of data
196 * @param[out] frame The frame which will be filled
198 void camera_create_preview_frame(camera_stream_data_s *stream, int num_buffer_fd,
199 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
203 * @brief Creates a new camera handle for controlling a network camera.
205 * @remarks A @a camera must be released using camera_destroy().
206 * @param[in] device The network camera to access
207 * @param[out] camera A newly returned handle to the camera
208 * @return @c 0 on success, otherwise a negative error value
209 * @retval #CAMERA_ERROR_NONE Successful
210 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
211 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
212 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
213 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
214 * @post If it succeeds, the camera state will be #CAMERA_STATE_CREATED.
216 * @see camera_destroy()
218 int camera_create_network(camera_device_e device, camera_h *camera);
222 * @brief Initialize a camera device manager.
224 * @param[out] manager A newly returned handle to the camera device manager
225 * @return @c 0 on success, otherwise a negative error value
226 * @retval #CAMERA_ERROR_NONE Successful
227 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
228 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
229 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
230 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
231 * @see camera_device_manager_deinitialize()
233 int camera_device_manager_initialize(camera_device_manager_h *manager);
237 * @brief Deinitialize the camera device manager handle.
239 * @param[in] manager The handle to the camera device manager
240 * @return @c 0 on success, otherwise a negative error value
241 * @retval #CAMERA_ERROR_NONE Successful
242 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
243 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
244 * @see camera_device_manager_initialize()
246 int camera_device_manager_deinitialize(camera_device_manager_h manager);
250 * @brief Gets a list of available camera devices.
252 * @param[in] manager The handle to the camera device manager
253 * @param[out] list A list of available camera devices
254 * @return @c 0 on success, otherwise a negative error value
255 * @retval #CAMERA_ERROR_NONE Successful
256 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
257 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
258 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
259 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
261 int camera_device_manager_get_device_list(camera_device_manager_h manager, camera_device_list_s *list);
265 * @brief Registers a callback function to be called when the camera device list changes.
267 * @param[in] manager The handle to the camera device manager
268 * @param[in] callback The callback function to register
269 * @param[in] user_data The user data to be passed to the callback function
270 * @param[out] cb_id The id of registered callback
271 * @return @c 0 on success, otherwise a negative error value
272 * @retval #CAMERA_ERROR_NONE Successful
273 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
274 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
275 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
276 * @post This function will invoke camera_device_list_changed_cb() when the camera device list changes.
277 * @see camera_device_manager_remove_device_list_changed_cb()
278 * @see camera_device_list_changed_cb()
280 int camera_device_manager_add_device_list_changed_cb(camera_device_manager_h manager, camera_device_list_changed_cb callback, void *user_data, int *cb_id);
284 * @brief Unregisters the callback function.
286 * @param[in] manager The handle to the camera device manager
287 * @param[in] cb_id The id of registered callback
288 * @return @c 0 on success, otherwise a negative error value
289 * @retval #CAMERA_ERROR_NONE Successful
290 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
291 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
292 * @see camera_device_manager_add_device_list_changed_cb()
294 int camera_device_manager_remove_device_list_changed_cb(camera_device_manager_h manager, int cb_id);
298 * @brief Sets the brightness level of flash.
300 * @remarks If the min value is greater than the max value from camera_attr_get_flash_brightness_range(), \n
301 * it means that this feature is not supported.
302 * @param[in] camera The handle to the camera
303 * @param[in] level The brightness level of flash
304 * @return @c 0 on success, otherwise a negative error value
305 * @retval #CAMERA_ERROR_NONE Successful
306 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
307 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
308 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
309 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
310 * @pre The camera state must be set to #CAMERA_STATE_CREATED or #CAMERA_STATE_PREVIEW.
311 * @see camera_attr_get_flash_brightness()
312 * @see camera_attr_get_flash_brightness_range()
314 int camera_attr_set_flash_brightness(camera_h camera, int level);
318 * @brief Gets the brightness level of flash.
320 * @param[in] camera The handle to the camera
321 * @param[out] level The brightness level of flash
322 * @return @c 0 on success, otherwise a negative error value
323 * @retval #CAMERA_ERROR_NONE Successful
324 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
325 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
326 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
327 * @see camera_attr_set_flash_brightness()
328 * @see camera_attr_get_flash_brightness_range()
330 int camera_attr_get_flash_brightness(camera_h camera, int *level);
334 * @brief Gets the available brightness level of flash.
336 * @remarks If the min value is greater than the max value, it means that this feature is not supported.
337 * @param[in] camera The handle to the camera
338 * @param[out] min The minimum brightness level of flash
339 * @param[out] max The maximum brightness level of flash
340 * @return @c 0 on success, otherwise a negative error value
341 * @retval #CAMERA_ERROR_NONE Successful
342 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
343 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
344 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
345 * @see camera_attr_set_flash_brightness()
346 * @see camera_attr_get_flash_brightness()
348 int camera_attr_get_flash_brightness_range(camera_h camera, int *min, int *max);
352 * @brief Registers a callback function to be called for extra preview frames.
354 * @param[in] camera The handle to the camera
355 * @param[in] callback The callback function to be registered
356 * @param[in] user_data The user data to be passed to the callback function
357 * @return @c 0 on success, otherwise a negative error value
358 * @retval #CAMERA_ERROR_NONE Successful
359 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
360 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
361 * @pre The camera state must be set to #CAMERA_STATE_CREATED or #CAMERA_STATE_PREVIEW.
362 * @see camera_start_preview()
363 * @see camera_unset_extra_preview_cb()
364 * @see camera_extra_preview_cb()
366 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data);
370 * @brief Unregisters the callback function.
372 * @param[in] camera The handle to the camera
373 * @return @c 0 on success, otherwise a negative error value
374 * @retval #CAMERA_ERROR_NONE Successful
375 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
376 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
377 * @see camera_set_extra_preview_cb()
379 int camera_unset_extra_preview_cb(camera_h camera);
383 * @brief Sets the extra preview stream format.
385 * @param[in] camera The handle to the camera
386 * @param[in] stream_id The id of extra preview stream
387 * @param[in] pixel_format The pixel format of extra preview stream
388 * @param[in] width The width of extra preview stream
389 * @param[in] height The height of extra preview stream
390 * @param[in] fps The fps of extra preview stream
391 * @return @c 0 on success, otherwise a negative error value
392 * @retval #CAMERA_ERROR_NONE Successful
393 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
394 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
395 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
396 * @pre The camera state must be set to #CAMERA_STATE_CREATED or #CAMERA_STATE_PREVIEW.
397 * @see camera_start_preview()
398 * @see camera_set_extra_preview_cb()
399 * @see camera_unset_extra_preview_cb()
400 * @see camera_get_extra_preview_stream_format()
402 int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e pixel_format, int width, int height, int fps);
406 * @brief Gets the extra preview stream format.
408 * @param[in] camera The handle to the camera
409 * @param[in] stream_id The id of extra preview stream
410 * @param[out] pixel_format The pixel format of extra preview stream
411 * @param[out] width The width of extra preview stream
412 * @param[out] height The height of extra preview stream
413 * @param[out] fps The fps of extra preview stream
414 * @return @c 0 on success, otherwise a negative error value
415 * @retval #CAMERA_ERROR_NONE Successful
416 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
417 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
418 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
419 * @pre The camera state must be set to #CAMERA_STATE_PREVIEW.
420 * @see camera_start_preview()
421 * @see camera_set_extra_preview_cb()
422 * @see camera_unset_extra_preview_cb()
423 * @see camera_set_extra_preview_stream_format()
425 int camera_get_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e *pixel_format, int *width, int *height, int *fps);
429 * @brief Sets the manual focus level.
431 * @remarks The auto focusing will be stopped when camera_attr_set_focus_level() is called.
432 * @param[in] camera The handle to the camera
433 * @param[in] level The manual focus level
434 * @return @c 0 on success, otherwise a negative error value
435 * @retval #CAMERA_ERROR_NONE Successful
436 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
437 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
438 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
439 * @see camera_attr_get_focus_level()
440 * @see camera_attr_get_focus_level_range()
442 int camera_attr_set_focus_level(camera_h camera, int level);
446 * @brief Gets the manual focus level.
448 * @param[in] camera The handle to the camera
449 * @param[out] level The manual focus level
450 * @return @c 0 on success, otherwise a negative error value
451 * @retval #CAMERA_ERROR_NONE Successful
452 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
453 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
454 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
455 * @see camera_attr_set_focus_level()
456 * @see camera_attr_get_focus_level_range()
458 int camera_attr_get_focus_level(camera_h camera, int *level);
462 * @brief Gets lower limit and upper limit for manual focus level.
464 * @remarks If the min value is greater than the max value, it means that this feature is not supported.
465 * @param[in] camera The handle to the camera
466 * @param[out] min The lower limit for manual focus level
467 * @param[out] max The upper limit for manual focus level
468 * @return @c 0 on success, otherwise a negative error value
469 * @retval #CAMERA_ERROR_NONE Successful
470 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
471 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
472 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
473 * @see camera_attr_set_focus_level()
474 * @see camera_attr_get_focus_level()
476 int camera_attr_get_focus_level_range(camera_h camera, int *min, int *max);
485 #endif /* __TIZEN_MULTIMEDIA_CAMERA_INTERNAL_H__ */