summaryrefslogtreecommitdiff
path: root/include/recorder_private.h
blob: 388b5a74281d8832ecf6cb71d20a704c2092a4db (plain)
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
/*
* 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_RECORDER_PRIVATE_H__
#define __TIZEN_MULTIMEDIA_RECORDER_PRIVATE_H__
#include <camera.h>
#include <recorder.h>
#include <muse_core.h>
#include <glib.h>

#ifdef __cplusplus
extern "C" {
#endif

#define RECORDER_CB_TIMEOUT        5
#define RECORDER_CB_NO_TIMEOUT     0
#define RECORDER_FILENAME_MAX      256

#define RECORDER_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; \
}

enum {
	_RECORDER_GET_INT_STATE = 0,
	_RECORDER_GET_INT_VIDEO_RESOLUTION,
	_RECORDER_GET_INT_FILE_FORMAT,
	_RECORDER_GET_INT_AUDIO_ENCODER,
	_RECORDER_GET_INT_VIDEO_ENCODER,
	_RECORDER_GET_INT_SIZE_LIMIT,
	_RECORDER_GET_INT_TIME_LIMIT,
	_RECORDER_GET_INT_AUDIO_DEVICE,
	_RECORDER_GET_INT_AUDIO_SAMPLERATE,
	_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE,
	_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE,
	_RECORDER_GET_INT_AUDIO_CHANNEL,
	_RECORDER_GET_INT_ORIENTATION_TAG,
	_RECORDER_GET_INT_MAX
};

enum {
	_RECORDER_GET_DOUBLE_AUDIO_LEVEL = 0,
	_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE,
	_RECORDER_GET_DOUBLE_MAX
};

enum {
	_RECORDER_MESSAGE_HANDLER_TYPE_GENERAL,
	_RECORDER_MESSAGE_HANDLER_TYPE_AUDIO_STREAM_CB,
	_RECORDER_MESSAGE_HANDLER_TYPE_MUXED_STREAM_CB
};

typedef struct _recorder_msg_handler_info_s {
	int type;
	void *cb_info;
	int running;
	GCond cond;
	GMutex mutex;
	GQueue *queue;
	GThread *thread;
} recorder_msg_handler_info_s;

typedef struct _recorder_cb_info_s {
	/* server connection */
	gint fd;
	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_RECORDER_API_MAX];
	GMutex api_mutex[MUSE_RECORDER_API_MAX];
	gint api_activating[MUSE_RECORDER_API_MAX];
	gint api_waiting[MUSE_RECORDER_API_MAX];
	gint api_ret[MUSE_RECORDER_API_MAX];

	/* general message handler info */
	recorder_msg_handler_info_s msg_handler_info;

	/* audio stream cb message handler info */
	recorder_msg_handler_info_s audio_stream_cb_info;

	/* muxed stream cb message handler info */
	recorder_msg_handler_info_s muxed_stream_cb_info;

	/* idle event */
	GList *idle_event_list;

	/* user callback */
	gpointer user_cb[MUSE_RECORDER_EVENT_TYPE_NUM];
	gpointer user_data[MUSE_RECORDER_EVENT_TYPE_NUM];
	GMutex user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_NUM];

	/* tbm */
	tbm_bufmgr bufmgr;

	/* get values */
	char *get_filename;
	gint get_int_value[_RECORDER_GET_INT_MAX];
	gdouble get_double_value[_RECORDER_GET_DOUBLE_MAX];
	gboolean is_filename_converted;
} recorder_cb_info_s;

typedef struct _recorder_message_s {
	gchar recv_msg[MUSE_RECORDER_MSG_MAX_LENGTH + 1];
	muse_recorder_api_e api;
	muse_recorder_event_e event;
	muse_recorder_event_class_e event_class;
} recorder_message_s;

typedef struct _recorder_idle_event_s {
	recorder_cb_info_s *cb_info;
	gchar recv_msg[MUSE_RECORDER_MSG_MAX_LENGTH + 1];
	muse_recorder_event_e event;
	GMutex event_mutex;
} recorder_idle_event_s;

typedef struct _recorder_cli_s {
	intptr_t remote_handle;
	recorder_cb_info_s *cb_info;
	camera_h camera;
} recorder_cli_s;

typedef struct _recorder_msg_param {
	int type;
	const char *name;
	union {
		int value_INT;
		double value_DOUBLE;
		const char *value_STRING;
	} value;
} recorder_msg_param;

typedef struct _camera_cli_s {
	intptr_t remote_handle;
	void *cb_info;
} camera_cli_s;

typedef struct _recorder_cb_info {
	int id;
	void *callback;
	void *user_data;
} recorder_cb_info;

int __convert_recorder_error_code(const char *func, int code);

#ifdef __cplusplus
}
#endif

#endif /* __TIZEN_MULTIMEDIA_RECORDER_PRIVATE_H__ */