[ACR-1487] Add new preview format and update camera_preview_data_s
[platform/core/api/camera.git] / include / camera_private.h
index d279dab..0ce8ed9 100644 (file)
 
 
 #ifndef __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__
-#define        __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__
+#define __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__
+#include <glib.h>
 #include <camera.h>
 #include <muse_core.h>
 #include <muse_camera.h>
-#include <mm_camcorder.h>
+#include <mm_display_interface.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define MAX_DETECTED_FACE 20
-
-#define CAMERA_PARSE_STRING_SIZE 200
-
-typedef enum {
-       _CAMERA_EVENT_TYPE_STATE_CHANGE,
-       _CAMERA_EVENT_TYPE_FOCUS_CHANGE,
-       _CAMERA_EVENT_TYPE_CAPTURE_COMPLETE,
-       _CAMERA_EVENT_TYPE_PREVIEW,
-       _CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW,
-       _CAMERA_EVENT_TYPE_CAPTURE,
-       _CAMERA_EVENT_TYPE_ERROR,
-       _CAMERA_EVENT_TYPE_HDR_PROGRESS,
-       _CAMERA_EVENT_TYPE_INTERRUPTED,
-       _CAMERA_EVENT_TYPE_FACE_DETECTION,
-       _CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR,
-       _CAMERA_EVENT_TYPE_NUM
-}_camera_event_e;
-
-typedef struct _camera_cb_data {
-       int event_type;
-       void *handle;
-} camera_cb_data;
-
-typedef struct _callback_cb_info {
-       GThread *msg_rcv_thread;
-       GThread *event_thread;
-       gint rcv_thread_running;
-       gint event_thread_running;
+#ifdef BUFFER_MAX_PLANE_NUM
+#undef BUFFER_MAX_PLANE_NUM
+#endif /* BUFFER_MAX_PLANE_NUM */
+
+#define BUFFER_MAX_PLANE_NUM     4
+#define CAMERA_CB_TIMEOUT        4
+#define CAMERA_CB_NO_TIMEOUT     0
+
+#define CAMERA_MSG_PARAM_SET(param, msg_type, set_value) { \
+       param.type = MUSE_TYPE_##msg_type; \
+       param.name = #set_value; \
+       param.value.value_##msg_type = set_value; \
+}
+
+#define CAMERA_MSG_PARAM_SET_ARRAY(param, msg_type, set_value, size) { \
+       param.type = MUSE_TYPE_##msg_type; \
+       param.name = #set_value; \
+       param.value.value_##msg_type = set_value; \
+       param.value_size = size; \
+}
+
+#define PREVIEW_CB_TYPE_USER 0x0000000F
+#define PREVIEW_CB_TYPE_EVAS 0x000000F0
+
+#define CHECK_PREVIEW_CB(cb_info, cb_type) ((cb_info)->preview_cb_flag & cb_type)
+#define SET_PREVIEW_CB_TYPE(cb_info, cb_type) ((cb_info)->preview_cb_flag |= cb_type)
+#define UNSET_PREVIEW_CB_TYPE(cb_info, cb_type) ((cb_info)->preview_cb_flag &= ~cb_type)
+
+enum {
+       CAMERA_MESSAGE_HANDLER_TYPE_GENERAL,
+       CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB,
+       CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB
+};
+
+typedef struct _camera_stream_data_s {
+       union {
+               struct {
+                       unsigned char *yuv;
+                       unsigned int length_yuv;
+               } yuv420, yuv422;
+               struct {
+                       unsigned char *y;
+                       unsigned int length_y;
+                       unsigned char *uv;
+                       unsigned int length_uv;
+               } yuv420sp;
+               struct {
+                       unsigned char *y;
+                       unsigned int length_y;
+                       unsigned char *u;
+                       unsigned int length_u;
+                       unsigned char *v;
+                       unsigned int length_v;
+               } yuv420p, yuv422p;
+               struct {
+                       unsigned char *data;
+                       unsigned int length_data;
+                       int is_delta_frame;
+               } encoded, depth, rgb;
+       } data;                         /**< pointer of captured stream */
+       int data_type;                  /**< data type */
+       unsigned int length_total;      /**< total length of stream buffer (in byte)*/
+       unsigned int num_planes;        /**< number of planes */
+       MMPixelFormatType format;       /**< image format */
+       int width;                      /**< width of video buffer */
+       int height;                     /**< height of video buffer */
+       unsigned int timestamp;         /**< timestamp of stream buffer (msec)*/
+       void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */
+       void *internal_buffer;          /**< Internal buffer pointer */
+       int stride[BUFFER_MAX_PLANE_NUM];    /**< Stride of each plane */
+       int elevation[BUFFER_MAX_PLANE_NUM]; /**< Elevation of each plane */
+} camera_stream_data_s;
+
+typedef struct _camera_msg_handler_info_s {
+       int type;
+       void *cb_info;
+       int running;
+       GCond cond;
+       GMutex mutex;
+       GQueue *queue;
+       GThread *thread;
+} camera_msg_handler_info_s;
+
+typedef struct _camera_cb_info_s {
+       /* server connection */
        gint fd;
-       gint id;
+       GMutex fd_lock;
+       gboolean is_server_connected;
+
+       /* message receive thread */
+       GThread *msg_recv_thread;
+       gint msg_recv_running;
+       gchar recv_msg[MUSE_MSG_MAX_LENGTH + 1];
+       GCond api_cond[MUSE_CAMERA_API_MAX];
+       GMutex api_mutex[MUSE_CAMERA_API_MAX];
+       gint api_activating[MUSE_CAMERA_API_MAX];
+       gint api_waiting[MUSE_CAMERA_API_MAX];
+       gint api_ret[MUSE_CAMERA_API_MAX];
+
+       /* general message handler info */
+       camera_msg_handler_info_s msg_handler_info;
+
+       /* preview cb message handler info */
+       camera_msg_handler_info_s preview_cb_info;
+
+       /* capture cb message handler info */
+       camera_msg_handler_info_s capture_cb_info;
+
+       /* idle event */
+       GList *idle_event_list;
+
+       /* user callback */
        gpointer user_cb[MUSE_CAMERA_EVENT_TYPE_NUM];
-       gpointer user_cb_completed[MUSE_CAMERA_EVENT_TYPE_NUM];
        gpointer user_data[MUSE_CAMERA_EVENT_TYPE_NUM];
-       gchar recvMsg[MUSE_CAMERA_MSG_MAX_LENGTH];
-       gchar recvApiMsg[MUSE_CAMERA_MSG_MAX_LENGTH];
-       gchar recvEventMsg[MUSE_CAMERA_MSG_MAX_LENGTH];
-       GCond *pCond;
-       GMutex *pMutex;
-       GCond event_cond;
-       GMutex event_mutex;
-       gint *activating;
+       GMutex user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_NUM];
+
+       /* tbm */
        tbm_bufmgr bufmgr;
-       GQueue *event_queue;
-} callback_cb_info_s;
+       gboolean user_buffer_supported;
+       tbm_bo bos[MUSE_NUM_FD];
+       tbm_fd fds[MUSE_NUM_FD];
+
+       /* media packet */
+       media_format_h pkt_fmt;
+       GMutex mp_data_mutex;
+
+       /* preview callback flag */
+       int preview_cb_flag;
+       camera_pixel_format_e preview_format;
+
+       /* display */
+       muse_camera_display_info_s dp_info;
+       mm_display_interface_h dp_interface;
+       gboolean run_evas_render;
+
+       /* get values */
+       gint get_int[MUSE_CAMERA_GET_INT_NUM];
+       gint get_int_pair[MUSE_CAMERA_GET_INT_PAIR_NUM][2];
+       gchar get_string[MUSE_CAMERA_GET_STRING_NUM][MUSE_CAMERA_MSG_MAX_LENGTH];
+       gdouble get_geotag[3];
+       gint get_display_roi_area[4];
+} camera_cb_info_s;
+
+typedef struct _camera_message_s {
+       gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH + 1];
+       muse_camera_api_e api;
+       muse_camera_event_e event;
+       muse_camera_event_class_e event_class;
+       int tfd[MUSE_NUM_FD];
+} camera_message_s;
 
-typedef struct _event_info_s {
-       gchar recvMsg[MUSE_CAMERA_MSG_MAX_LENGTH];
+typedef struct _camera_idle_event_s {
+       camera_cb_info_s *cb_info;
+       gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH + 1];
        muse_camera_event_e event;
-} event_info_s;
+       int tfd[MUSE_NUM_FD];
+} camera_idle_event_s;
 
 typedef struct _camera_cli_s {
        intptr_t remote_handle;
-       MMHandleType client_handle;
-       intptr_t cli_display_handle;
-       callback_cb_info_s *cb_info;
-#ifdef HAVE_WAYLAND
-       MMCamWaylandInfo *wl_info;
-#endif /* #ifdef HAVE_WAYLAND */
+       camera_cb_info_s *cb_info;
 } camera_cli_s;
 
-typedef enum {
-       MUSE_CAMERA_CLIENT_SYNC_CB_HANDLER,
-       MUSE_CAMERA_CLIENT_USER_CALLBACK,
-       MUSE_CAMERA_CLIENT_MAX
-} muse_cli_camera_api_e;
-
-int _camera_get_mm_handle(camera_h camera , MMHandleType *handle);
-int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data);
-int __camera_start_continuous_focusing(camera_h camera);
-int _camera_set_use(camera_h camera, bool used);
-bool _camera_is_used(camera_h camera);
+typedef struct _camera_media_packet_data {
+       int ret_fd;
+       tbm_fd fd;
+       tbm_fd data_fd;
+       tbm_fd buffer_fd[MUSE_NUM_FD];
+       tbm_bo bo;
+       tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM];
+       int num_buffer_fd;
+       tbm_bo data_bo;
+       int ref_cnt;
+} camera_media_packet_data;
+
+typedef struct _camera_msg_param {
+       int type;
+       const char *name;
+       union {
+               int value_INT;
+               const char *value_STRING;
+               void *value_ARRAY;
+       } value;
+       int value_size;
+} camera_msg_param;
+
+typedef struct _camera_cb_info {
+       int id;
+       void *callback;
+       void *user_data;
+} camera_cb_info;
+
+
 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format);
 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype);
 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data);
-int __convert_camera_error_code(const char* func, int code);
+int _camera_start_evas_rendering(camera_h camera);
+int _camera_stop_evas_rendering(camera_h camera, bool keep_screen);
+int _camera_independent_request(int api, int device_type, const char *key, int *value);
+
+typedef bool (*camera_supported_cb_param1)(int param, void *user_data);
+typedef bool (*camera_supported_cb_param2)(int param1, int param2, void *user_data);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif //__TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__
+#endif /* __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__ */