2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __RECORDER_MSG_PRIVATE_H__
18 #define __RECORDER_MSG_PRIVATE_H__
24 #include "muse_core_msg_json.h"
27 * @file muse_recorder_msg.h
28 * @brief This file contains the muse_camera message APIs, related structures, defines and macros.
32 * @brief Definition for the handle parameter.
34 #define PARAM_HANDLE "handle"
37 * @brief Definition for the ret parameter.
39 #define PARAM_RET "ret"
42 * @brief Definition for the event parameter.
44 #define PARAM_EVENT "event"
47 * @brief Definition for the error parameter.
49 #define PARAM_ERROR "error"
52 * @brief Definition for the tbm key parameter.
54 #define PARAM_TBM_KEY "t_key"
57 * @brief Definition for the display mode parameter.
59 #define PARAM_DISPLAY_MODE "display_mode"
62 * @brief Definition for the device type parameter.
64 #define PARAM_DEVICE_TYPE "device_type"
67 * @brief Definition for the recorder type parameter audio/video
69 #define PARAM_RECORDER_TYPE "recorder_type"
72 * @brief Definition for the camera handle ipc parameter
74 #define PARAM_CAMERA_HANDLE "camera_handle"
77 * @brief Definition for the INTEGER type.
82 * @brief Definition for the 64 bit INTEGER type.
84 typedef int64_t INT64;
87 * @brief Definition for the 64 bit integer pointer type.
89 typedef intptr_t POINTER;
92 * @brief Definition for the 64 bit DOUBLE type.
94 typedef double DOUBLE;
97 * @brief Definition for the 64 bit STRING type.
99 typedef const char* STRING;
102 * @brief Query the specific value from the input message via ipc.
103 * @param[in] param The key to query, the variable name should be matched to the message's one.
104 * @param[out] buf The string of message buffer.
106 #define muse_recorder_msg_get(param, buf) \
107 muse_core_msg_json_deserialize(#param, buf, NULL, ¶m, NULL, MUSE_TYPE_ANY)
110 * @brief Query the specific string type value from the input message via ipc.
111 * @param[in] param The key to query, the variable name should be matched to the message's one.
112 * @param[out] buf The string of message buffer.
114 #define muse_recorder_msg_get_string(param, buf) \
115 muse_core_msg_json_deserialize(#param, buf, NULL, param, NULL, MUSE_TYPE_STRING)
118 * @brief Query the specific array type value from the input message via ipc.
119 * @param[in] param The key to query, the variable name should be matched to the message's one.
120 * @param[out] buf The string of message buffer.
122 #define muse_recorder_msg_get_array(param, buf) \
123 muse_core_msg_json_deserialize(#param, buf, NULL, param, NULL, MUSE_TYPE_ARRAY)
126 * @brief Query the specific pointer type value from the input message via ipc.
127 * @param[in] param The key to query, the variable name should be matched to the message's one.
128 * @param[out] buf The string of message buffer.
130 #define muse_recorder_msg_get_pointer(param, buf) \
131 muse_core_msg_json_deserialize(#param, buf, NULL, ¶m, NULL, MUSE_TYPE_POINTER)
135 * @brief Query the specific value with error return from the input message via ipc.
136 * @param[in] param The key to query, the variable name should be matched to the message's one.
137 * @param[out] buf The string of message buffer.
138 * @param[out] e The error return from the core api.
140 #define muse_recorder_msg_get_error_e(param, buf, e) \
141 muse_core_msg_json_deserialize(#param, buf, NULL, ¶m, &e, MUSE_TYPE_ANY)
144 * @brief Send the message from proxy to module via ipc.
145 * @param[in] api The enumeration of the corresponding api.
146 * @param[in] fd The socket fd that connected to the module via ipc.
147 * @param[in] cb_info The callback information, waiting for the ack from the module.
148 * @param[out] ret The delivered return value from the module to proxy side.
150 #define muse_recorder_msg_send(api, fd, cb_info, ret) \
153 callback_cb_info_s *cb_info_s; \
155 cb_info_s = (callback_cb_info_s *)cb_info; \
156 cb_info_s->activating[api] = 0; \
157 __sndMsg__ = muse_core_msg_json_factory_new(api, 0); \
158 __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
159 if (__len__ <= 0) { \
160 LOGE("sending message failed"); \
161 ret = RECORDER_ERROR_INVALID_OPERATION; \
163 ret = client_wait_for_cb_return(api, cb_info, CALLBACK_TIME_OUT); \
164 muse_core_msg_json_factory_free(__sndMsg__); \
169 * @brief Send the message from proxy to module via ipc, adding 1 more parameter.
170 * @param[in] api The enumeration of the corresponding api.
171 * @param[in] fd The socket fd that connected to the module via ipc.
172 * @param[in] cb_info The callback information, waiting for the ack from the module.
173 * @param[out] ret The delivered return value from the module to proxy side.
174 * @param[in] type The data type of the parameter.
175 * @param[in] param A single parameter to be included in the message.
177 #define muse_recorder_msg_send1(api, fd, cb_info, ret, type, param) \
181 type __value__ = (type)param; \
182 __sndMsg__ = muse_core_msg_json_factory_new(api, \
183 MUSE_TYPE_##type, #param, __value__, \
185 __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
186 if (__len__ <= 0) { \
187 LOGE("sending message failed"); \
188 ret = RECORDER_ERROR_INVALID_OPERATION; \
190 ret = client_wait_for_cb_return(api, cb_info, CALLBACK_TIME_OUT); \
191 muse_core_msg_json_factory_free(__sndMsg__); \
195 * @brief Send the message from proxy to module via ipc, adding 2 more parameters.
196 * @param[in] api The enumeration of the corresponding api.
197 * @param[in] fd The socket fd that connected to the module via ipc.
198 * @param[in] cb_info The callback information, waiting for the ack from the module.
199 * @param[out] ret The delivered return value from the module to proxy side.
200 * @param[in] type1 The data type of the parameter.
201 * @param[in] param1 The first parameter to be included in the message.
202 * @param[in] type2 The data type of the parameter.
203 * @param[in] param2 The 2nd parameter to be included in the message.
205 #define muse_recorder_msg_send2(api, fd, cb_info, ret, type1, param1, type2, param2) \
209 type1 __value1__ = (type1)param1; \
210 type2 __value2__ = (type2)param2; \
211 __sndMsg__ = muse_core_msg_json_factory_new(api, \
212 MUSE_TYPE_##type1, #param1, __value1__, \
213 MUSE_TYPE_##type2, #param2, __value2__, \
215 __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
216 if (__len__ <= 0) { \
217 LOGE("sending message failed"); \
218 ret = RECORDER_ERROR_INVALID_OPERATION; \
220 ret = client_wait_for_cb_return(api, cb_info, CALLBACK_TIME_OUT); \
221 muse_core_msg_json_factory_free(__sndMsg__); \
226 * @brief Send the message from proxy to module via ipc, adding an array data.
227 * @param[in] api The enumeration of the corresponding api.
228 * @param[in] fd The socket fd that connected to the module via ipc.
229 * @param[in] cb_info The callback information, waiting for the ack from the module.
230 * @param[out] ret The delivered return value from the module to proxy side.
231 * @param[in] param The array data parameter to be included in the message.
232 * @param[in] length The length of the array.
233 * @param[in] datum_size The size of the array.
235 #define muse_recorder_msg_send_array(api, fd, cb_info, ret, param, length, datum_size) \
239 int *__value__ = (int *)param; \
240 __sndMsg__ = muse_core_msg_json_factory_new(api, \
241 MUSE_TYPE_INT, #length, length, \
242 MUSE_TYPE_ARRAY, #param, \
243 datum_size == sizeof(int)? length : \
244 length / sizeof(int) + (length % sizeof(int)?1:0), \
247 __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
248 if (__len__ <= 0) { \
249 LOGE("sending message failed"); \
250 ret = RECORDER_ERROR_INVALID_OPERATION; \
252 ret = client_wait_for_cb_return(api, cb_info, CALLBACK_TIME_OUT); \
253 muse_core_msg_json_factory_free(__sndMsg__); \
257 * @brief Returning the ack message from the server to client side.
258 * @param[in] api The enumeration of the corresponding api.
259 * @param[out] ret The delivered return value from the module to proxy side.
260 * @param[in] module The module info for the ipc transportation.
262 #define muse_recorder_msg_return(api, ret, module) \
266 __sndMsg__ = muse_core_msg_json_factory_new(api, \
267 MUSE_TYPE_INT, PARAM_RET, ret, \
269 __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
270 if (__len__ <= 0) { \
271 LOGE("sending message failed"); \
272 ret = RECORDER_ERROR_INVALID_OPERATION; \
274 muse_core_msg_json_factory_free(__sndMsg__); \
278 * @brief Returning the ack message from the server to client side.
279 * @param[in] api The enumeration of the corresponding api.
280 * @param[out] ret The delivered return value from the module to proxy side.
281 * @param[in] module The module info for the ipc transportation.
282 * @param[in] type The data type of the parameter.
283 * @param[in] param A parameter to be included in the message.
285 #define muse_recorder_msg_return1(api, ret, module, type, param) \
289 type __value__ = (type)param; \
290 __sndMsg__ = muse_core_msg_json_factory_new(api, \
291 MUSE_TYPE_INT, PARAM_RET, ret, \
292 MUSE_TYPE_##type, #param, __value__, \
294 __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
295 if (__len__ <= 0) { \
296 LOGE("sending message failed"); \
297 ret = RECORDER_ERROR_INVALID_OPERATION; \
299 muse_core_msg_json_factory_free(__sndMsg__); \
303 * @brief Returning the ack message from the server to client side, adding 2 parameters.
304 * @param[in] api The enumeration of the corresponding api.
305 * @param[out] ret The delivered return value from the module to proxy side.
306 * @param[in] module The module info for the ipc transportation.
307 * @param[in] type1 The data type of the parameter.
308 * @param[in] param1 The 1st parameter to be included in the message.
309 * @param[in] type2 The data type of the parameter.
310 * @param[in] param2 The 2nd parameter to be included in the message.
312 #define muse_recorder_msg_return2(api, ret, module, type1, param1, type2, param2) \
316 type1 __value1__ = (type1)param1; \
317 type2 __value2__ = (type2)param2; \
318 __sndMsg__ = muse_core_msg_json_factory_new(api, \
319 MUSE_TYPE_INT, PARAM_RET, ret, \
320 MUSE_TYPE_##type1, #param1, __value1__, \
321 MUSE_TYPE_##type2, #param2, __value2__, \
323 __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
324 if (__len__ <= 0) { \
325 LOGE("sending message failed"); \
326 ret = RECORDER_ERROR_INVALID_OPERATION; \
328 muse_core_msg_json_factory_free(__sndMsg__); \
332 * @brief Returning the ack message from the server to client side, adding 3 parameters.
333 * @param[in] api The enumeration of the corresponding api.
334 * @param[out] ret The delivered return value from the module to proxy side.
335 * @param[in] module The module info for the ipc transportation.
336 * @param[in] type1 The data type of the parameter.
337 * @param[in] param1 The 1st parameter to be included in the message.
338 * @param[in] type2 The data type of the parameter.
339 * @param[in] param2 The 2nd parameter to be included in the message.
340 * @param[in] type3 The data type of the parameter.
341 * @param[in] param3 The 3rd parameter to be included in the message.
343 #define muse_recorder_msg_return3(api, ret, module, type1, param1, type2, param2, type3, param3) \
347 type1 __value1__ = (type1)param1; \
348 type2 __value2__ = (type2)param2; \
349 type3 __value3__ = (type3)param3; \
350 __sndMsg__ = muse_core_msg_json_factory_new(api, \
351 MUSE_TYPE_INT, PARAM_RET, ret, \
352 MUSE_TYPE_##type1, #param1, __value1__, \
353 MUSE_TYPE_##type2, #param2, __value2__, \
354 MUSE_TYPE_##type3, #param3, __value3__, \
356 __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
357 if (__len__ <= 0) { \
358 LOGE("sending message failed"); \
359 ret = RECORDER_ERROR_INVALID_OPERATION; \
361 muse_core_msg_json_factory_free(__sndMsg__); \
365 * @brief Returning the ack message from the server to client side, adding array parameter.
366 * @param[in] api The enumeration of the corresponding api.
367 * @param[out] ret The delivered return value from the module to proxy side.
368 * @param[in] module The module info for the ipc transportation.
369 * @param[in] param The array data parameter to be included in the message.
370 * @param[in] length The length of the array.
371 * @param[in] datum_size The size of the array.
373 #define muse_recorder_msg_return_array(api, ret, module, param, length, datum_size) \
377 int *__value__ = (int *)param; \
378 __sndMsg__ = muse_core_msg_json_factory_new(api, \
379 MUSE_TYPE_INT, PARAM_RET, ret, \
380 MUSE_TYPE_INT, #length, length, \
381 MUSE_TYPE_ARRAY, #param, \
382 datum_size == sizeof(int)? length : \
383 length / sizeof(int) + (length % sizeof(int)?1:0), \
386 __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
387 if (__len__ <= 0) { \
388 LOGE("sending message failed"); \
389 ret = RECORDER_ERROR_INVALID_OPERATION; \
391 muse_core_msg_json_factory_free(__sndMsg__); \
395 * @brief Returning the event ack message from the server to client side.
396 * @param[in] api The enumeration of the corresponding api.
397 * @param[out] ret The delivered return value from the module to proxy side.
398 * @param[in] module The module info for the ipc transportation.
400 #define muse_recorder_msg_event(api, event, fd) \
403 __sndMsg__ = muse_core_msg_json_factory_new(api, \
404 MUSE_TYPE_INT, PARAM_EVENT, event, \
406 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
407 muse_core_msg_json_factory_free(__sndMsg__); \
411 * @brief Returning the event ack message from the server to client side, adding a parameter.
412 * @param[in] api The enumeration of the corresponding api.
413 * @param[out] ret The delivered return value from the module to proxy side.
414 * @param[in] module The module info for the ipc transportation.
415 * @param[in] type The data type of the parameter.
416 * @param[in] param A parameter to be included in the message.
418 #define muse_recorder_msg_event1(api, event, module, type, param) \
421 type __value__ = (type)param; \
422 __sndMsg__ = muse_core_msg_json_factory_new(api, \
423 MUSE_TYPE_INT, PARAM_EVENT, event, \
424 MUSE_TYPE_##type, #param, __value__, \
426 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
427 muse_core_msg_json_factory_free(__sndMsg__); \
431 * @brief Returning the event ack message from the server to client side, adding 2 parameters.
432 * @param[in] api The enumeration of the corresponding api.
433 * @param[out] ret The delivered return value from the module to proxy side.
434 * @param[in] module The module info for the ipc transportation.
435 * @param[in] param1 The 1st parameter to be included in the message.
436 * @param[in] type2 The data type of the parameter.
437 * @param[in] param2 The 2nd parameter to be included in the message.
439 #define muse_recorder_msg_event2(api, event, module, type1, param1, type2, param2) \
442 type1 __value1__ = (type1)param1; \
443 type2 __value2__ = (type2)param2; \
444 __sndMsg__ = muse_core_msg_json_factory_new(api, \
445 MUSE_TYPE_INT, PARAM_EVENT, event, \
446 MUSE_TYPE_##type1, #param1, __value1__, \
447 MUSE_TYPE_##type2, #param2, __value2__, \
449 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
450 muse_core_msg_json_factory_free(__sndMsg__); \
454 * @brief Returning the event ack message from the server to client side, adding 3 parameters.
455 * @param[in] api The enumeration of the corresponding api.
456 * @param[out] ret The delivered return value from the module to proxy side.
457 * @param[in] module The module info for the ipc transportation.
458 * @param[in] param1 The 1st parameter to be included in the message.
459 * @param[in] type2 The data type of the parameter.
460 * @param[in] param2 The 2nd parameter to be included in the message.
461 * @param[in] type3 The data type of the parameter.
462 * @param[in] param3 The 3rd parameter to be included in the message.
464 #define muse_recorder_msg_event3(api, event, module, type1, param1, type2, param2, type3, param3) \
467 type1 __value1__ = (type1)param1; \
468 type2 __value2__ = (type2)param2; \
469 type3 __value3__ = (type3)param3; \
470 __sndMsg__ = muse_core_msg_json_factory_new(api, \
471 MUSE_TYPE_INT, PARAM_EVENT, event, \
472 MUSE_TYPE_##type1, #param1, __value1__, \
473 MUSE_TYPE_##type2, #param2, __value2__, \
474 MUSE_TYPE_##type3, #param3, __value3__, \
476 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
477 muse_core_msg_json_factory_free(__sndMsg__); \
481 * @brief Returning the event ack message from the server to client side, adding 5 parameters.
482 * @param[in] api The enumeration of the corresponding api.
483 * @param[out] ret The delivered return value from the module to proxy side.
484 * @param[in] module The module info for the ipc transportation.
485 * @param[in] param1 The 1st parameter to be included in the message.
486 * @param[in] type2 The data type of the parameter.
487 * @param[in] param2 The 2nd parameter to be included in the message.
488 * @param[in] type3 The data type of the parameter.
489 * @param[in] param3 The 3rd parameter to be included in the message.
490 * @param[in] type4 The data type of the parameter.
491 * @param[in] param4 The 4th parameter to be included in the message.
492 * @param[in] type5 The data type of the parameter.
493 * @param[in] param5 The 5th parameter to be included in the message.
495 #define muse_recorder_msg_event5(api, event, module, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5) \
498 type1 __value1__ = (type1)param1; \
499 type2 __value2__ = (type2)param2; \
500 type3 __value3__ = (type3)param3; \
501 type4 __value4__ = (type4)param4; \
502 type5 __value5__ = (type5)param5; \
503 __sndMsg__ = muse_core_msg_json_factory_new(api, \
504 MUSE_TYPE_INT, PARAM_EVENT, event, \
505 MUSE_TYPE_##type1, #param1, __value1__, \
506 MUSE_TYPE_##type2, #param2, __value2__, \
507 MUSE_TYPE_##type3, #param3, __value3__, \
508 MUSE_TYPE_##type4, #param4, __value4__, \
509 MUSE_TYPE_##type5, #param5, __value5__, \
511 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
512 muse_core_msg_json_factory_free(__sndMsg__); \
519 #endif /*__RECORDER_MSG_PRIVATE_H__*/