summaryrefslogtreecommitdiff
path: root/muse/include/muse_recorder_msg.h
blob: 1a02e13406dfd5ad4adbb6d91b3fcefe39a68d16 (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
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/*
* 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 __RECORDER_MSG_PRIVATE_H__
#define __RECORDER_MSG_PRIVATE_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <muse_core.h>

/**
 * @file muse_recorder_msg.h
 * @brief This file contains the muse_camera message APIs, related structures, defines and macros.
 */

/**
 * @brief Definition for the handle parameter.
 */
#define PARAM_HANDLE        "handle"

/**
 * @brief Definition for the ret parameter.
 */
#define PARAM_RET           "ret"

/**
 * @brief Definition for the event parameter.
 */
#define PARAM_EVENT         "event"

/**
 * @brief Definition for the api class parameter.
 */
#define PARAM_API_CLASS     "api_class"

/**
 * @brief Definition for the event class parameter.
 */
#define PARAM_EVENT_CLASS   "event_class"

/**
 * @brief Definition for the error parameter.
 */
#define PARAM_ERROR         "error"

/**
 * @brief Definition for the tbm key parameter.
 */
#define PARAM_TBM_KEY       "t_key"

/**
 * @brief Definition for the display mode parameter.
 */
#define PARAM_DISPLAY_MODE  "display_mode"

/**
 * @brief Definition for the device type parameter.
 */
#define PARAM_DEVICE_TYPE   "device_type"

/**
 * @brief Definition for the recorder type parameter audio/video
 */
 #define PARAM_RECORDER_TYPE "recorder_type"

/**
 * @brief Definition for the camera handle ipc parameter
 */
#define PARAM_CAMERA_HANDLE "camera_handle"

/**
 * @brief Definition for the INTEGER type.
 */
typedef int32_t INT;

/**
 * @brief Definition for the 64 bit INTEGER type.
 */
typedef int64_t INT64;

/**
 * @brief Definition for the 64 bit integer pointer type.
 */
typedef intptr_t POINTER;

/**
 * @brief Definition for the 64 bit DOUBLE type.
 */
typedef double DOUBLE;

/**
 * @brief Definition for the 64 bit STRING type.
 */
typedef const char* STRING;

/**
 * @brief Query the specific value from the input message via ipc.
 * @param[in] param The key to query, the variable name should be matched to the message's one.
 * @param[out] buf The string of message buffer.
 */
#define muse_recorder_msg_get(param, buf) \
	muse_core_msg_deserialize(#param, buf, NULL, NULL, MUSE_TYPE_ANY, &param)

/**
 * @brief Query the specific value from the input message via ipc.
 * @param[in] param The key to query, the variable name should be matched to the message's one.
 * @param[out] buf The string of message buffer.
 */
#define muse_recorder_msg_get_double(param, buf) \
	muse_core_msg_deserialize(#param, buf, NULL, NULL, MUSE_TYPE_DOUBLE, &param)

/**
 * @brief Query the specific string type value from the input message via ipc.
 * @param[in] param The key to query, the variable name should be matched to the message's one.
 * @param[out] buf The string of message buffer.
 */
#define muse_recorder_msg_get_string(param, buf) \
	muse_core_msg_deserialize(#param, buf, NULL, NULL, MUSE_TYPE_STRING, param)

/**
 * @brief Query the specific array type value from the input message via ipc.
 * @param[in] param The key to query, the variable name should be matched to the message's one.
 * @param[out] buf The string of message buffer.
 */
#define muse_recorder_msg_get_array(param, buf) \
	muse_core_msg_deserialize(#param, buf, NULL, NULL, MUSE_TYPE_ARRAY, param)

/**
 * @brief Query the specific pointer type value from the input message via ipc.
 * @param[in] param The key to query, the variable name should be matched to the message's one.
 * @param[out] buf The string of message buffer.
 */
#define muse_recorder_msg_get_pointer(param, buf) \
	muse_core_msg_deserialize(#param, buf, NULL, NULL, MUSE_TYPE_POINTER, &param)


/**
 * @brief Query the specific value with error return from the input message via ipc.
 * @param[in] param The key to query, the variable name should be matched to the message's one.
 * @param[out] buf The string of message buffer.
 * @param[out] e The error return from the core api.
 */
#define muse_recorder_msg_get_error_e(param, buf, e) \
	muse_core_msg_deserialize(#param, buf, NULL, &e, MUSE_TYPE_ANY, &param)

/**
 * @brief Returning the ack message from the server to client side.
 * @param[in] api The enumeration of the corresponding api.
 * @param[in] class The enumeration of the api class.
 * @param[out] ret The delivered return value from the module to proxy side.
 * @param[in] module The module info for the ipc transportation.
 */
#define muse_recorder_msg_return(api, class, ret, module) \
	do {	\
		char *__sndMsg__; \
		int __len__; \
		__sndMsg__ = muse_core_msg_new(api, \
			MUSE_TYPE_INT, PARAM_API_CLASS, class, \
			MUSE_TYPE_INT, PARAM_RET, ret, \
			0); \
		__len__ = muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
		if (__len__ <= 0) { \
			LOGE("sending message failed"); \
			ret = RECORDER_ERROR_INVALID_OPERATION; \
		} \
		muse_core_msg_free(__sndMsg__); \
	} while (0)

/**
 * @brief Returning the ack message from the server to client side.
 * @param[in] api The enumeration of the corresponding api.
 * @param[in] class The enumeration of the api class.
 * @param[out] ret The delivered return value from the module to proxy side.
 * @param[in] module The module info for the ipc transportation.
 * @param[in] type The data type of the parameter.
 * @param[in] param A parameter to be included in the message.
 */
#define muse_recorder_msg_return1(api, class, ret, module, type, param) \
	do {	\
		char *__sndMsg__; \
		int __len__; \
		type __value__ = (type)param; \
		__sndMsg__ = muse_core_msg_new(api, \
			MUSE_TYPE_INT, PARAM_API_CLASS, class, \
			MUSE_TYPE_INT, PARAM_RET, ret, \
			MUSE_TYPE_##type, #param, __value__, \
			0); \
		__len__ = muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
		if (__len__ <= 0) { \
			LOGE("sending message failed"); \
			ret = RECORDER_ERROR_INVALID_OPERATION; \
		} \
		muse_core_msg_free(__sndMsg__); \
	} while (0)

/**
 * @brief Returning the ack message from the server to client side, adding 2 parameters.
 * @param[in] api The enumeration of the corresponding api.
 * @param[in] class The enumeration of the api class.
 * @param[out] ret The delivered return value from the module to proxy side.
 * @param[in] module The module info for the ipc transportation.
 * @param[in] type1 The data type of the parameter.
 * @param[in] param1 The 1st parameter to be included in the message.
 * @param[in] type2 The data type of the parameter.
 * @param[in] param2 The 2nd parameter to be included in the message.
 */
#define muse_recorder_msg_return2(api, class, ret, module, type1, param1, type2, param2) \
	do {	\
		char *__sndMsg__; \
		int __len__; \
		type1 __value1__ = (type1)param1; \
		type2 __value2__ = (type2)param2; \
		__sndMsg__ = muse_core_msg_new(api, \
			MUSE_TYPE_INT, PARAM_API_CLASS, class, \
			MUSE_TYPE_INT, PARAM_RET, ret, \
			MUSE_TYPE_##type1, #param1, __value1__, \
			MUSE_TYPE_##type2, #param2, __value2__, \
			0); \
		__len__ = muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
		if (__len__ <= 0) { \
			LOGE("sending message failed"); \
			ret = RECORDER_ERROR_INVALID_OPERATION; \
		} \
		muse_core_msg_free(__sndMsg__); \
	} while (0)

/**
 * @brief Returning the event ack message from the server to client side.
 * @param[in] api The enumeration of the corresponding api.
 * @param[in] event The enumeration of the event.
 * @param[in] class The enumeration of the event class.
 * @param[in] module The module info for the ipc transportation.
 */
#define muse_recorder_msg_event(api, event, class, module) \
	do {	\
		char *__sndMsg__; \
		__sndMsg__ = muse_core_msg_new(api, \
			MUSE_TYPE_INT, PARAM_EVENT, event, \
			MUSE_TYPE_INT, PARAM_EVENT_CLASS, class, \
			0); \
		muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
		muse_core_msg_free(__sndMsg__); \
	} while (0)

/**
 * @brief Returning the event ack message from the server to client side, adding a parameter.
 * @param[in] api The enumeration of the corresponding api.
 * @param[in] event The enumeration of the event.
 * @param[in] class The enumeration of the event class.
 * @param[in] module The module info for the ipc transportation.
 * @param[in] type The data type of the parameter.
 * @param[in] param A parameter to be included in the message.
 */
#define muse_recorder_msg_event1(api, event, class, module, type, param) \
	do {	\
		char *__sndMsg__; \
		type __value__ = (type)param; \
		__sndMsg__ = muse_core_msg_new(api, \
			MUSE_TYPE_INT, PARAM_EVENT, event, \
			MUSE_TYPE_INT, PARAM_EVENT_CLASS, class, \
			MUSE_TYPE_##type, #param, __value__, \
			0); \
		muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
		muse_core_msg_free(__sndMsg__); \
	} while (0)

/**
 * @brief Returning the event ack message from the server to client side, adding 2 parameters.
 * @param[in] api The enumeration of the corresponding api.
 * @param[in] event The enumeration of the event.
 * @param[in] class The enumeration of the event class.
 * @param[in] module The module info for the ipc transportation.
 * @param[in] param1 The 1st parameter to be included in the message.
 * @param[in] type2 The data type of the parameter.
 * @param[in] param2 The 2nd parameter to be included in the message.
 */
#define muse_recorder_msg_event2(api, event, class, module, type1, param1, type2, param2) \
	do {	\
		char *__sndMsg__; \
		type1 __value1__ = (type1)param1; \
		type2 __value2__ = (type2)param2; \
		__sndMsg__ = muse_core_msg_new(api, \
			MUSE_TYPE_INT, PARAM_EVENT, event, \
			MUSE_TYPE_INT, PARAM_EVENT_CLASS, class, \
			MUSE_TYPE_##type1, #param1, __value1__, \
			MUSE_TYPE_##type2, #param2, __value2__, \
			0); \
		muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
		muse_core_msg_free(__sndMsg__); \
	} while (0)

/**
 * @brief Returning the event ack message from the server to client side, adding 3 parameters.
 * @param[in] api The enumeration of the corresponding api.
 * @param[in] event The enumeration of the event.
 * @param[in] class The enumeration of the event class.
 * @param[in] module The module info for the ipc transportation.
 * @param[in] param1 The 1st parameter to be included in the message.
 * @param[in] type2 The data type of the parameter.
 * @param[in] param2 The 2nd parameter to be included in the message.
 * @param[in] type3 The data type of the parameter.
 * @param[in] param3 The 3rd parameter to be included in the message.
 */
#define muse_recorder_msg_event3(api, event, class, module, type1, param1, type2, param2, type3, param3) \
	do {	\
		char *__sndMsg__; \
		type1 __value1__ = (type1)param1; \
		type2 __value2__ = (type2)param2; \
		type3 __value3__ = (type3)param3; \
		__sndMsg__ = muse_core_msg_new(api, \
			MUSE_TYPE_INT, PARAM_EVENT, event, \
			MUSE_TYPE_INT, PARAM_EVENT_CLASS, class, \
			MUSE_TYPE_##type1, #param1, __value1__, \
			MUSE_TYPE_##type2, #param2, __value2__, \
			MUSE_TYPE_##type3, #param3, __value3__, \
			0); \
		muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
		muse_core_msg_free(__sndMsg__); \
	} while (0)

/**
 * @brief Returning the event ack message from the server to client side, adding 5 parameters.
 * @param[in] api The enumeration of the corresponding api.
 * @param[in] event The enumeration of the event.
 * @param[in] class The enumeration of the event class.
 * @param[in] module The module info for the ipc transportation.
 * @param[in] param1 The 1st parameter to be included in the message.
 * @param[in] type2 The data type of the parameter.
 * @param[in] param2 The 2nd parameter to be included in the message.
 * @param[in] type3 The data type of the parameter.
 * @param[in] param3 The 3rd parameter to be included in the message.
 * @param[in] type4 The data type of the parameter.
 * @param[in] param4 The 4th parameter to be included in the message.
 * @param[in] type5 The data type of the parameter.
 * @param[in] param5 The 5th parameter to be included in the message.
 */
#define muse_recorder_msg_event5(api, event, class, module, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5) \
	do {	\
		char *__sndMsg__; \
		type1 __value1__ = (type1)param1; \
		type2 __value2__ = (type2)param2; \
		type3 __value3__ = (type3)param3; \
		type4 __value4__ = (type4)param4; \
		type5 __value5__ = (type5)param5; \
		__sndMsg__ = muse_core_msg_new(api, \
			MUSE_TYPE_INT, PARAM_EVENT, event, \
			MUSE_TYPE_INT, PARAM_EVENT_CLASS, class, \
			MUSE_TYPE_##type1, #param1, __value1__, \
			MUSE_TYPE_##type2, #param2, __value2__, \
			MUSE_TYPE_##type3, #param3, __value3__, \
			MUSE_TYPE_##type4, #param4, __value4__, \
			MUSE_TYPE_##type5, #param5, __value5__, \
			0); \
		muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
		muse_core_msg_free(__sndMsg__); \
	} while (0)

#ifdef __cplusplus
}
#endif

#endif /*__RECORDER_MSG_PRIVATE_H__*/