[Release version 0.2.70] Add new enum for server connection error - CAMERA_ERROR_SERV...
[platform/core/api/camera.git] / include / camera_private.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18
19
20
21 #ifndef __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__
22 #define __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__
23 #include <camera.h>
24 #include <muse_core.h>
25 #include <muse_camera.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #ifdef BUFFER_MAX_PLANE_NUM
32 #undef BUFFER_MAX_PLANE_NUM
33 #endif /* BUFFER_MAX_PLANE_NUM */
34
35 #define BUFFER_MAX_PLANE_NUM     4
36 #define CAMERA_PARSE_STRING_SIZE 20
37 #define CAMERA_CB_TIMEOUT        5
38 #define CAMERA_CB_TIMEOUT_LONG   8
39
40 #define CAMERA_MSG_PARAM_SET(param, msg_type, set_value) { \
41         param.type = MUSE_TYPE_##msg_type; \
42         param.name = #set_value; \
43         param.value.value_##msg_type = set_value; \
44 }
45
46 #define PREVIEW_CB_TYPE_USER 0x0000000F
47 #define PREVIEW_CB_TYPE_EVAS 0x000000F0
48
49 #define CHECK_PREVIEW_CB(cb_info, cb_type) ((cb_info)->preview_cb_flag & cb_type)
50 #define SET_PREVIEW_CB_TYPE(cb_info, cb_type) ((cb_info)->preview_cb_flag |= cb_type)
51 #define UNSET_PREVIEW_CB_TYPE(cb_info, cb_type) ((cb_info)->preview_cb_flag &= ~cb_type)
52
53 enum {
54         CAMERA_MESSAGE_HANDLER_TYPE_GENERAL,
55         CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB,
56         CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB
57 };
58
59 typedef struct _camera_stream_data_s {
60         union {
61                 struct {
62                         unsigned char *yuv;
63                         unsigned int length_yuv;
64                 } yuv420, yuv422;
65                 struct {
66                         unsigned char *y;
67                         unsigned int length_y;
68                         unsigned char *uv;
69                         unsigned int length_uv;
70                 } yuv420sp;
71                 struct {
72                         unsigned char *y;
73                         unsigned int length_y;
74                         unsigned char *u;
75                         unsigned int length_u;
76                         unsigned char *v;
77                         unsigned int length_v;
78                 } yuv420p, yuv422p;
79                 struct {
80                         unsigned char *data;
81                         unsigned int length_data;
82                 } encoded;
83         } data;                         /**< pointer of captured stream */
84         int data_type;                  /**< data type */
85         unsigned int length_total;      /**< total length of stream buffer (in byte)*/
86         unsigned int num_planes;        /**< number of planes */
87         MMPixelFormatType format;       /**< image format */
88         int width;                      /**< width of video buffer */
89         int height;                     /**< height of video buffer */
90         unsigned int timestamp;         /**< timestamp of stream buffer (msec)*/
91         void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */
92         void *internal_buffer;          /**< Internal buffer pointer */
93         int stride[BUFFER_MAX_PLANE_NUM];    /**< Stride of each plane */
94         int elevation[BUFFER_MAX_PLANE_NUM]; /**< Elevation of each plane */
95 } camera_stream_data_s;
96
97 typedef struct _camera_msg_handler_info_s {
98         int type;
99         void *cb_info;
100         int running;
101         GCond cond;
102         GMutex mutex;
103         GQueue *queue;
104         GThread *thread;
105 } camera_msg_handler_info_s;
106
107 typedef struct _camera_cb_info_s {
108         gint fd;
109         gboolean is_server_connected;
110
111         /* message receive thread */
112         GThread *msg_recv_thread;
113         gint msg_recv_running;
114
115         /* general message handler info */
116         camera_msg_handler_info_s msg_handler_info;
117
118         /* preview cb message handler info */
119         camera_msg_handler_info_s preview_cb_info;
120
121         /* capture cb message handler info */
122         camera_msg_handler_info_s capture_cb_info;
123
124         GList *idle_event_list;
125         GCond idle_event_cond;
126         GMutex idle_event_mutex;
127         gpointer user_cb[MUSE_CAMERA_EVENT_TYPE_NUM];
128         gpointer user_data[MUSE_CAMERA_EVENT_TYPE_NUM];
129         gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH];
130         GCond api_cond[MUSE_CAMERA_API_MAX];
131         GMutex api_mutex[MUSE_CAMERA_API_MAX];
132         gint api_activating[MUSE_CAMERA_API_MAX];
133         gint api_ret[MUSE_CAMERA_API_MAX];
134         tbm_bufmgr bufmgr;
135         media_format_h pkt_fmt;
136         int preview_cb_flag;
137         GMutex mp_data_mutex;
138 #ifdef TIZEN_FEATURE_EVAS_RENDERER
139         void *evas_info;
140         GMutex evas_mutex;
141 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
142         gboolean run_evas_render;
143 } camera_cb_info_s;
144
145 typedef struct _camera_message_s {
146         gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH];
147         muse_camera_api_e api;
148         muse_camera_event_e event;
149         muse_camera_event_class_e event_class;
150 } camera_message_s;
151
152 typedef struct _camera_idle_event_s {
153         camera_cb_info_s *cb_info;
154         gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH];
155         muse_camera_event_e event;
156         GMutex event_mutex;
157 } camera_idle_event_s;
158
159 typedef struct _camera_wl_info_s {
160         int parent_id;
161         int window_x;
162         int window_y;
163         int window_width;
164         int window_height;
165         void *evas_obj;
166 } camera_wl_info_s;
167
168 typedef struct _camera_cli_s {
169         intptr_t remote_handle;
170         intptr_t display_handle;
171         camera_cb_info_s *cb_info;
172         camera_wl_info_s wl_info;
173 } camera_cli_s;
174
175 typedef struct _camera_media_packet_data {
176         int tbm_key;
177         tbm_bo bo;
178         tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM];
179         int num_buffer_key;
180         tbm_bo data_bo;
181         int ref_cnt;
182 } camera_media_packet_data;
183
184 typedef struct _camera_msg_param {
185         int type;
186         const char *name;
187         union {
188                 int value_INT;
189                 const char *value_STRING;
190         } value;
191 } camera_msg_param;
192
193
194 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format);
195 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype);
196 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data);
197 int _camera_start_evas_rendering(camera_h camera);
198 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen);
199
200 typedef bool (*camera_supported_cb_param1)(int param, void *user_data);
201 typedef bool (*camera_supported_cb_param2)(int param1, int param2, void *user_data);
202
203 #ifdef __cplusplus
204 }
205 #endif
206
207 #endif /* __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__ */
208