[Release version 0.2.64] Remove unnecessary feature, Rename "EVAS_RENDERER_SUPPORT...
[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
38 #define PREVIEW_CB_TYPE_USER 0x0000000F
39 #define PREVIEW_CB_TYPE_EVAS 0x000000F0
40
41 #define CHECK_PREVIEW_CB(cb_info, cb_type) ((cb_info)->preview_cb_flag & cb_type)
42 #define SET_PREVIEW_CB_TYPE(cb_info, cb_type) ((cb_info)->preview_cb_flag |= cb_type)
43 #define UNSET_PREVIEW_CB_TYPE(cb_info, cb_type) ((cb_info)->preview_cb_flag &= ~cb_type)
44
45
46 typedef struct _camera_stream_data_s {
47         union {
48                 struct {
49                         unsigned char *yuv;
50                         unsigned int length_yuv;
51                 } yuv420, yuv422;
52                 struct {
53                         unsigned char *y;
54                         unsigned int length_y;
55                         unsigned char *uv;
56                         unsigned int length_uv;
57                 } yuv420sp;
58                 struct {
59                         unsigned char *y;
60                         unsigned int length_y;
61                         unsigned char *u;
62                         unsigned int length_u;
63                         unsigned char *v;
64                         unsigned int length_v;
65                 } yuv420p, yuv422p;
66                 struct {
67                         unsigned char *data;
68                         unsigned int length_data;
69                 } encoded;
70         } data;                         /**< pointer of captured stream */
71         int data_type;                  /**< data type */
72         unsigned int length_total;      /**< total length of stream buffer (in byte)*/
73         unsigned int num_planes;        /**< number of planes */
74         MMPixelFormatType format;       /**< image format */
75         int width;                      /**< width of video buffer */
76         int height;                     /**< height of video buffer */
77         unsigned int timestamp;         /**< timestamp of stream buffer (msec)*/
78         void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */
79         void *internal_buffer;          /**< Internal buffer pointer */
80         int stride[BUFFER_MAX_PLANE_NUM];    /**< Stride of each plane */
81         int elevation[BUFFER_MAX_PLANE_NUM]; /**< Elevation of each plane */
82 } camera_stream_data_s;
83
84 typedef struct _camera_cb_info_s {
85         gint fd;
86         GThread *msg_recv_thread;
87         GThread *msg_handler_thread;
88         gint msg_recv_running;
89         gint msg_handler_running;
90         GCond msg_handler_cond;
91         GMutex msg_handler_mutex;
92         GQueue *msg_queue;
93         GList *idle_event_list;
94         GCond idle_event_cond;
95         GMutex idle_event_mutex;
96         gpointer user_cb[MUSE_CAMERA_EVENT_TYPE_NUM];
97         gpointer user_data[MUSE_CAMERA_EVENT_TYPE_NUM];
98         gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH];
99         GCond api_cond[MUSE_CAMERA_API_MAX];
100         GMutex api_mutex[MUSE_CAMERA_API_MAX];
101         gint *api_activating;
102         gint *api_ret;
103         tbm_bufmgr bufmgr;
104         media_format_h pkt_fmt;
105         int preview_cb_flag;
106         GMutex mp_data_mutex;
107 #ifdef TIZEN_FEATURE_EVAS_RENDERER
108         void *evas_info;
109         GMutex evas_mutex;
110 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
111         gboolean run_evas_render;
112 } camera_cb_info_s;
113
114 typedef struct _camera_message_s {
115         gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH];
116         muse_camera_api_e api;
117 } camera_message_s;
118
119 typedef struct _camera_idle_event_s {
120         camera_cb_info_s *cb_info;
121         gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH];
122         muse_camera_event_e event;
123         GMutex event_mutex;
124 } camera_idle_event_s;
125
126 typedef struct _camera_wl_info_s {
127         int parent_id;
128         int window_x;
129         int window_y;
130         int window_width;
131         int window_height;
132         void *evas_obj;
133 } camera_wl_info_s;
134
135 typedef struct _camera_cli_s {
136         intptr_t remote_handle;
137         intptr_t display_handle;
138         camera_cb_info_s *cb_info;
139         camera_wl_info_s wl_info;
140 } camera_cli_s;
141
142 typedef struct _camera_media_packet_data {
143         int tbm_key;
144         tbm_bo bo;
145         tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM];
146         int num_buffer_key;
147         tbm_bo data_bo;
148         int ref_cnt;
149 } camera_media_packet_data;
150
151
152 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format);
153 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype);
154 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data);
155 int _camera_start_evas_rendering(camera_h camera);
156 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen);
157
158 #ifdef __cplusplus
159 }
160 #endif
161
162 #endif /* __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__ */
163