1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
/*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __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" {
#endif
#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;
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];
gboolean 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_data[MUSE_CAMERA_EVENT_TYPE_NUM];
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;
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 _camera_idle_event_s {
camera_cb_info_s *cb_info;
gchar recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH + 1];
muse_camera_event_e event;
int tfd[MUSE_NUM_FD];
} camera_idle_event_s;
typedef struct _camera_cli_s {
intptr_t remote_handle;
camera_cb_info_s *cb_info;
} camera_cli_s;
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 _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__ */
|