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