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