[ACR-1487] Add new preview format and update camera_preview_data_s
[platform/core/api/camera.git] / include / camera_private.h
index 56e8ad5..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_display_interface.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -32,8 +34,22 @@ extern "C" {
 #undef BUFFER_MAX_PLANE_NUM
 #endif /* BUFFER_MAX_PLANE_NUM */
 
-#define BUFFER_MAX_PLANE_NUM    4
-#define CAMERA_PARSE_STRING_SIZE 20
+#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
@@ -42,6 +58,11 @@ extern "C" {
 #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 {
@@ -66,7 +87,8 @@ typedef struct _camera_stream_data_s {
                struct {
                        unsigned char *data;
                        unsigned int length_data;
-               } encoded;
+                       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)*/
@@ -81,79 +103,135 @@ typedef struct _camera_stream_data_s {
        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;
+       GMutex fd_lock;
+       gboolean is_server_connected;
+
+       /* message receive thread */
        GThread *msg_recv_thread;
-       GThread *msg_handler_thread;
        gint msg_recv_running;
-       gint msg_handler_running;
-       GCond msg_handler_cond;
-       GMutex msg_handler_mutex;
-       GQueue *msg_queue;
+       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;
-       GCond idle_event_cond;
-       GMutex idle_event_mutex;
+
+       /* user callback */
        gpointer user_cb[MUSE_CAMERA_EVENT_TYPE_NUM];
        gpointer user_data[MUSE_CAMERA_EVENT_TYPE_NUM];
-       gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH];
-       GCond api_cond[MUSE_CAMERA_API_MAX];
-       GMutex api_mutex[MUSE_CAMERA_API_MAX];
-       gint *api_activating;
-       gint *api_ret;
+       GMutex user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_NUM];
+
+       /* tbm */
        tbm_bufmgr bufmgr;
+       gboolean user_buffer_supported;
+       tbm_bo bos[MUSE_NUM_FD];
+       tbm_fd fds[MUSE_NUM_FD];
+
+       /* media packet */
        media_format_h pkt_fmt;
-       int preview_cb_flag;
        GMutex mp_data_mutex;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
-       void *evas_info;
-       GMutex evas_mutex;
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+
+       /* 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];
+       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 _camera_idle_event_s {
        camera_cb_info_s *cb_info;
-       gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH];
+       gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH + 1];
        muse_camera_event_e event;
-       GMutex event_mutex;
+       int tfd[MUSE_NUM_FD];
 } camera_idle_event_s;
 
-typedef struct _camera_wl_info_s {
-       int parent_id;
-       int window_x;
-       int window_y;
-       int window_width;
-       int window_height;
-       void *evas_obj;
-} camera_wl_info_s;
-
 typedef struct _camera_cli_s {
        intptr_t remote_handle;
-       intptr_t display_handle;
        camera_cb_info_s *cb_info;
-       camera_wl_info_s wl_info;
 } camera_cli_s;
 
 typedef struct _camera_media_packet_data {
-       int tbm_key;
+       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_key;
+       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 _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
 }