Received message is at risk for corruption with previous message.
[platform/core/api/recorder.git] / include / recorder_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 #ifndef __TIZEN_MULTIMEDIA_RECORDER_PRIVATE_H__
20 #define __TIZEN_MULTIMEDIA_RECORDER_PRIVATE_H__
21 #include <camera.h>
22 #include <recorder.h>
23 #include <muse_core.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #define RECORDER_PARSED_STRING_NUM_MAX 20
30 #define RECORDER_CB_TIMEOUT        5
31 #define RECORDER_FILENAME_MAX      256
32
33 #define RECORDER_MSG_PARAM_SET(param, msg_type, set_value) { \
34         param.type = MUSE_TYPE_##msg_type; \
35         param.name = #set_value; \
36         param.value.value_##msg_type = set_value; \
37 }
38
39 enum {
40         _RECORDER_GET_INT_STATE = 0,
41         _RECORDER_GET_INT_VIDEO_RESOLUTION,
42         _RECORDER_GET_INT_FILE_FORMAT,
43         _RECORDER_GET_INT_AUDIO_ENCODER,
44         _RECORDER_GET_INT_VIDEO_ENCODER,
45         _RECORDER_GET_INT_SIZE_LIMIT,
46         _RECORDER_GET_INT_TIME_LIMIT,
47         _RECORDER_GET_INT_AUDIO_DEVICE,
48         _RECORDER_GET_INT_AUDIO_SAMPLERATE,
49         _RECORDER_GET_INT_AUDIO_ENCODER_BITRATE,
50         _RECORDER_GET_INT_VIDEO_ENCODER_BITRATE,
51         _RECORDER_GET_INT_AUDIO_CHANNEL,
52         _RECORDER_GET_INT_ORIENTATION_TAG,
53         _RECORDER_GET_INT_MAX
54 };
55
56 enum {
57         _RECORDER_GET_DOUBLE_AUDIO_LEVEL = 0,
58         _RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE,
59         _RECORDER_GET_DOUBLE_MAX
60 };
61
62 enum {
63         _RECORDER_MESSAGE_HANDLER_TYPE_GENERAL,
64         _RECORDER_MESSAGE_HANDLER_TYPE_AUDIO_STREAM_CB
65 };
66
67 typedef struct _recorder_msg_handler_info_s {
68         int type;
69         void *cb_info;
70         int running;
71         GCond cond;
72         GMutex mutex;
73         GQueue *queue;
74         GThread *thread;
75 } recorder_msg_handler_info_s;
76
77 typedef struct _recorder_cb_info_s {
78         /* server connection */
79         gint fd;
80         gboolean is_server_connected;
81
82         /* message receive thread */
83         GThread *msg_recv_thread;
84         gint msg_recv_running;
85         gchar recv_msg[MUSE_RECORDER_MSG_MAX_LENGTH * RECORDER_PARSED_STRING_NUM_MAX];
86         GCond api_cond[MUSE_RECORDER_API_MAX];
87         GMutex api_mutex[MUSE_RECORDER_API_MAX];
88         gint api_activating[MUSE_RECORDER_API_MAX];
89         gint api_ret[MUSE_RECORDER_API_MAX];
90
91         /* general message handler info */
92         recorder_msg_handler_info_s msg_handler_info;
93
94         /* preview cb message handler info */
95         recorder_msg_handler_info_s audio_stream_cb_info;
96
97         /* idle event */
98         GList *idle_event_list;
99         GCond idle_event_cond;
100         GMutex idle_event_mutex;
101
102         /* user callback */
103         gpointer user_cb[MUSE_RECORDER_EVENT_TYPE_NUM];
104         gpointer user_data[MUSE_RECORDER_EVENT_TYPE_NUM];
105
106         /* tbm */
107         tbm_bufmgr bufmgr;
108
109         /* get values */
110         char *get_filename;
111         gint get_int_value[_RECORDER_GET_INT_MAX];
112         gdouble get_double_value[_RECORDER_GET_DOUBLE_MAX];
113 } recorder_cb_info_s;
114
115 typedef struct _recorder_message_s {
116         gchar recv_msg[MUSE_RECORDER_MSG_MAX_LENGTH];
117         muse_recorder_api_e api;
118         muse_recorder_event_e event;
119         muse_recorder_event_class_e event_class;
120 } recorder_message_s;
121
122 typedef struct _recorder_idle_event_s {
123         recorder_cb_info_s *cb_info;
124         gchar recv_msg[MUSE_RECORDER_MSG_MAX_LENGTH];
125         muse_recorder_event_e event;
126         GMutex event_mutex;
127 } recorder_idle_event_s;
128
129 typedef struct _recorder_cli_s {
130         intptr_t remote_handle;
131         recorder_cb_info_s *cb_info;
132         camera_h camera;
133 } recorder_cli_s;
134
135 typedef struct _recorder_msg_param {
136         int type;
137         const char *name;
138         union {
139                 int value_INT;
140                 double value_DOUBLE;
141                 const char *value_STRING;
142         } value;
143 } recorder_msg_param;
144
145 typedef struct _camera_cli_s {
146         intptr_t remote_handle;
147         void *cb_info;
148 } camera_cli_s;
149
150 typedef struct _recorder_cb_info {
151         int id;
152         void *callback;
153         void *user_data;
154 } recorder_cb_info;
155
156 int __convert_recorder_error_code(const char *func, int code);
157
158 #ifdef __cplusplus
159 }
160 #endif
161
162 #endif /* __TIZEN_MULTIMEDIA_RECORDER_PRIVATE_H__ */
163
164