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 connection state of a camera device was changed.
114 * @param[in] device The camera device
115 * @param[in] is_connected The state of device connection: (@c true = connected, @c false = disconnected)
116 * @param[in] user_data The user data passed from the callback registration function
117 * @see camera_device_manager_add_device_connection_changed_cb()
118 * @see camera_device_manager_remove_device_connection_changed_cb()
120 typedef void (*camera_device_connection_changed_cb)(camera_device_s *device, bool is_connected, void *user_data);
124 * @brief Called to register for notifications about delivering a copy of the new extra preview frames.
126 * @param[in] frame The reference pointer to extra preview stream data
127 * @param[in] stream_id The id of stream
128 * @param[in] user_data The user data passed from the callback registration function
129 * @pre camera_start_preview() will invoke this callback function if you register this callback using camera_set_extra_preview_cb().
130 * @see camera_start_preview()
131 * @see camera_set_extra_preview_cb()
132 * @see camera_unset_extra_preview_cb()
134 typedef void (*camera_extra_preview_cb)(camera_preview_data_s *frame, int stream_id, void *user_data);
138 * @brief Start the evas rendering.
140 * @param[in] camera The handle to the camera
141 * @return @c 0 on success, otherwise a negative error value
142 * @retval #CAMERA_ERROR_NONE Successful
143 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
144 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
145 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
146 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
148 int camera_start_evas_rendering(camera_h camera);
152 * @brief Stop the evas rendering.
154 * @param[in] camera The handle to the camera
155 * @param[in] keep_screen If @c true keep last frame on display, otherwise @c false
156 * @return @c 0 on success, otherwise a negative error value
157 * @retval #CAMERA_ERROR_NONE Successful
158 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
159 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
160 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
161 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
163 int camera_stop_evas_rendering(camera_h camera, bool keep_screen);
167 * @brief Sets the ecore wayland video display.
169 * @remarks This function must be called in main thread of the application.
170 * Otherwise, it will return #CAMERA_ERROR_INVALID_OPERATION by internal restriction.
171 * To avoid #CAMERA_ERROR_INVALID_OPERATION in sub thread, ecore_thread_main_loop_begin() and
172 * ecore_thread_main_loop_end() can be used, but deadlock can occur if the main thread is busy.
173 * So, it's not recommended to use them.
174 * @param[in] camera The handle to the camera
175 * @param[in] ecore_wl_window The ecore wayland window handle
176 * @return @c 0 on success,
177 * otherwise a negative error value
178 * @retval #CAMERA_ERROR_NONE Successful
179 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
180 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
181 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
182 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
183 * @pre The camera state must be set to #CAMERA_STATE_CREATED.
184 * @see camera_start_preview()
185 * @see ecore_thread_main_loop_begin()
186 * @see ecore_thread_main_loop_end()
188 int camera_set_ecore_wl_display(camera_h camera, void *ecore_wl_window);
192 * @brief Creates preview frame from stream data.
194 * @param[in] stream The stream from internal pipeline
195 * @param[in] num_buffer_fd The number of buffer fd
196 * @param[in] buffer_bo_handle The bo handle of buffer
197 * @param[in] data_bo_handle The bo handle of data
198 * @param[out] frame The frame which will be filled
200 void camera_create_preview_frame(camera_stream_data_s *stream, int num_buffer_fd,
201 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
205 * @brief Creates a new camera handle for controlling a network camera.
207 * @remarks A @a camera must be released using camera_destroy().
208 * @param[in] device The network camera to access
209 * @param[out] camera A newly returned handle to the camera
210 * @return @c 0 on success, otherwise a negative error value
211 * @retval #CAMERA_ERROR_NONE Successful
212 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
213 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
214 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
215 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
216 * @post If it succeeds, the camera state will be #CAMERA_STATE_CREATED.
218 * @see camera_destroy()
220 int camera_create_network(camera_device_e device, camera_h *camera);
224 * @brief Initialize a camera device manager.
226 * @param[out] manager A newly returned handle to the camera device manager
227 * @return @c 0 on success, otherwise a negative error value
228 * @retval #CAMERA_ERROR_NONE Successful
229 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
230 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
231 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
232 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
233 * @see camera_device_manager_deinitialize()
235 int camera_device_manager_initialize(camera_device_manager_h *manager);
239 * @brief Deinitialize the camera device manager handle.
241 * @param[in] manager The handle to the camera device manager
242 * @return @c 0 on success, otherwise a negative error value
243 * @retval #CAMERA_ERROR_NONE Successful
244 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
245 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
246 * @see camera_device_manager_initialize()
248 int camera_device_manager_deinitialize(camera_device_manager_h manager);
252 * @brief Gets a list of available camera devices.
254 * @param[in] manager The handle to the camera device manager
255 * @param[out] list A list of available camera devices
256 * @return @c 0 on success, otherwise a negative error value
257 * @retval #CAMERA_ERROR_NONE Successful
258 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
259 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
260 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
261 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
263 int camera_device_manager_get_device_list(camera_device_manager_h manager, camera_device_list_s *list);
267 * @brief Registers a callback function to be called when the connection state of camera device is changed.
269 * @param[in] manager The handle to the camera device manager
270 * @param[in] callback The callback function to register
271 * @param[in] user_data The user data to be passed to the callback function
272 * @param[out] cb_id The id of registered callback
273 * @return @c 0 on success, otherwise a negative error value
274 * @retval #CAMERA_ERROR_NONE Successful
275 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
276 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
277 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
278 * @post camera_device_connection_changed_cb() will be invoked when the connection state of camera device is changed.
279 * @see camera_device_manager_remove_device_connection_changed_cb()
280 * @see camera_device_connection_changed_cb()
282 int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager, camera_device_connection_changed_cb callback, void *user_data, int *cb_id);
286 * @brief Unregisters the callback function.
288 * @param[in] manager The handle to the camera device manager
289 * @param[in] cb_id The id of registered callback
290 * @return @c 0 on success, otherwise a negative error value
291 * @retval #CAMERA_ERROR_NONE Successful
292 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
293 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
294 * @see camera_device_manager_add_device_changed_cb()
296 int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id);
300 * @brief Sets the brightness level of flash.
302 * @remarks If the min value is greater than the max value from camera_attr_get_flash_brightness_range(), \n
303 * it means that this feature is not supported.
304 * @param[in] camera The handle to the camera
305 * @param[in] level The brightness level of flash
306 * @return @c 0 on success, otherwise a negative error value
307 * @retval #CAMERA_ERROR_NONE Successful
308 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
309 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
310 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
311 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
312 * @pre The camera state must be set to #CAMERA_STATE_CREATED or #CAMERA_STATE_PREVIEW.
313 * @see camera_attr_get_flash_brightness()
314 * @see camera_attr_get_flash_brightness_range()
316 int camera_attr_set_flash_brightness(camera_h camera, int level);
320 * @brief Gets the brightness level of flash.
322 * @param[in] camera The handle to the camera
323 * @param[out] level The brightness level of flash
324 * @return @c 0 on success, otherwise a negative error value
325 * @retval #CAMERA_ERROR_NONE Successful
326 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
327 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
328 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
329 * @see camera_attr_set_flash_brightness()
330 * @see camera_attr_get_flash_brightness_range()
332 int camera_attr_get_flash_brightness(camera_h camera, int *level);
336 * @brief Gets the available brightness level of flash.
338 * @remarks If the min value is greater than the max value, it means that this feature is not supported.
339 * @param[in] camera The handle to the camera
340 * @param[out] min The minimum brightness level of flash
341 * @param[out] max The maximum brightness level of flash
342 * @return @c 0 on success, otherwise a negative error value
343 * @retval #CAMERA_ERROR_NONE Successful
344 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
345 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
346 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
347 * @see camera_attr_set_flash_brightness()
348 * @see camera_attr_get_flash_brightness()
350 int camera_attr_get_flash_brightness_range(camera_h camera, int *min, int *max);
354 * @brief Registers a callback function to be called for extra preview frames.
356 * @param[in] camera The handle to the camera
357 * @param[in] callback The callback function to be registered
358 * @param[in] user_data The user data to be passed to the callback function
359 * @return @c 0 on success, otherwise a negative error value
360 * @retval #CAMERA_ERROR_NONE Successful
361 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
362 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
363 * @pre The camera state must be set to #CAMERA_STATE_CREATED or #CAMERA_STATE_PREVIEW.
364 * @see camera_start_preview()
365 * @see camera_unset_extra_preview_cb()
366 * @see camera_extra_preview_cb()
368 int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data);
372 * @brief Unregisters the callback function.
374 * @param[in] camera The handle to the camera
375 * @return @c 0 on success, otherwise a negative error value
376 * @retval #CAMERA_ERROR_NONE Successful
377 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
378 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
379 * @see camera_set_extra_preview_cb()
381 int camera_unset_extra_preview_cb(camera_h camera);
385 * @brief Sets the extra preview stream format.
387 * @param[in] camera The handle to the camera
388 * @param[in] stream_id The id of extra preview stream
389 * @param[in] pixel_format The pixel format of extra preview stream
390 * @param[in] width The width of extra preview stream
391 * @param[in] height The height of extra preview stream
392 * @param[in] fps The fps of extra preview stream
393 * @return @c 0 on success, otherwise a negative error value
394 * @retval #CAMERA_ERROR_NONE Successful
395 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
396 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
397 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
398 * @pre The camera state must be set to #CAMERA_STATE_CREATED or #CAMERA_STATE_PREVIEW.
399 * @see camera_start_preview()
400 * @see camera_set_extra_preview_cb()
401 * @see camera_unset_extra_preview_cb()
402 * @see camera_get_extra_preview_stream_format()
404 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);
408 * @brief Gets the extra preview stream format.
410 * @param[in] camera The handle to the camera
411 * @param[in] stream_id The id of extra preview stream
412 * @param[out] pixel_format The pixel format of extra preview stream
413 * @param[out] width The width of extra preview stream
414 * @param[out] height The height of extra preview stream
415 * @param[out] fps The fps of extra preview stream
416 * @return @c 0 on success, otherwise a negative error value
417 * @retval #CAMERA_ERROR_NONE Successful
418 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
419 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
420 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
421 * @pre The camera state must be set to #CAMERA_STATE_PREVIEW.
422 * @see camera_start_preview()
423 * @see camera_set_extra_preview_cb()
424 * @see camera_unset_extra_preview_cb()
425 * @see camera_set_extra_preview_stream_format()
427 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);
431 * @brief Sets the manual focus level.
433 * @remarks The auto focusing will be stopped when camera_attr_set_focus_level() is called.
434 * @param[in] camera The handle to the camera
435 * @param[in] level The manual focus level
436 * @return @c 0 on success, otherwise a negative error value
437 * @retval #CAMERA_ERROR_NONE Successful
438 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
439 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
440 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
441 * @see camera_attr_get_focus_level()
442 * @see camera_attr_get_focus_level_range()
444 int camera_attr_set_focus_level(camera_h camera, int level);
448 * @brief Gets the manual focus level.
450 * @param[in] camera The handle to the camera
451 * @param[out] level The manual focus level
452 * @return @c 0 on success, otherwise a negative error value
453 * @retval #CAMERA_ERROR_NONE Successful
454 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
455 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
456 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
457 * @see camera_attr_set_focus_level()
458 * @see camera_attr_get_focus_level_range()
460 int camera_attr_get_focus_level(camera_h camera, int *level);
464 * @brief Gets lower limit and upper limit for manual focus level.
466 * @remarks If the min value is greater than the max value, it means that this feature is not supported.
467 * @param[in] camera The handle to the camera
468 * @param[out] min The lower limit for manual focus level
469 * @param[out] max The upper limit for manual focus level
470 * @return @c 0 on success, otherwise a negative error value
471 * @retval #CAMERA_ERROR_NONE Successful
472 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
473 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
474 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
475 * @see camera_attr_set_focus_level()
476 * @see camera_attr_get_focus_level()
478 int camera_attr_get_focus_level_range(camera_h camera, int *min, int *max);
482 * @brief Sets the bitrate of extra preview.
484 * @param[in] camera The handle to the camera
485 * @param[in] stream_id The id of extra preview stream
486 * @param[in] bitrate The bitrate(bps) of extra preview
487 * @return @c 0 on success, otherwise a negative error value
488 * @retval #CAMERA_ERROR_NONE Successful
489 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
490 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
491 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
492 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
493 * @see camera_attr_get_extra_preview_bitrate()
495 int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bitrate);
499 * @brief Gets the bitrate of extra preview.
501 * @param[in] camera The handle to the camera
502 * @param[in] stream_id The id of extra preview stream
503 * @param[out] bitrate The bitrate(bps) of extra preview stream
504 * @return @c 0 on success, otherwise a negative error value
505 * @retval #CAMERA_ERROR_NONE Successful
506 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
507 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
508 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
509 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
510 * @see camera_attr_set_extra_preview_bitrate()
512 int camera_attr_get_extra_preview_bitrate(camera_h camera, int stream_id, int *bitrate);
516 * @brief Sets the GOP (Group Of Pictures) interval of extra preview.
518 * @remarks The recommended range is from 1,000 (1 second) to 600,000 (10 minutes). \n
519 * But, due to codec limitations, it may not apply.
520 * @param[in] camera The handle to the camera
521 * @param[in] stream_id The id of extra preview stream
522 * @param[in] interval The GOP interval of extra preview (millisecond)
523 * @return @c 0 on success, otherwise a negative error value
524 * @retval #CAMERA_ERROR_NONE Successful
525 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
526 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
527 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
528 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
529 * @see camera_attr_get_extra_preview_gop_interval()
531 int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, int interval);
535 * @brief Gets the GOP (Group Of Pictures) interval of extra preview.
537 * @param[in] camera The handle to the camera
538 * @param[in] stream_id The id of extra preview stream
539 * @param[out] interval The GOP interval of extra preview (millisecond)
540 * @return @c 0 on success, otherwise a negative error value
541 * @retval #CAMERA_ERROR_NONE Successful
542 * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
543 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
544 * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
545 * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
546 * @see camera_attr_set_extra_preview_gop_interval()
548 int camera_attr_get_extra_preview_gop_interval(camera_h camera, int stream_id, int *interval);
557 #endif /* __TIZEN_MULTIMEDIA_CAMERA_INTERNAL_H__ */