Clean up the Makefiles, Add some descriptions
[platform/core/multimedia/mmsvc-recorder.git] / muse / include / muse_recorder_msg.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 #ifndef __RECORDER_MSG_PRIVATE_H__
18 #define __RECORDER_MSG_PRIVATE_H__
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include "muse_core_msg_json.h"
25
26 /**
27  * @file muse_recorder_msg.h
28  * @brief This file contains the muse_camera message APIs, related structures, defines and macros.
29  */
30
31 /**
32  * @brief Definition for the handle parameter.
33  */
34 #define PARAM_HANDLE                    "handle"
35
36 /**
37  * @brief Definition for the ret parameter.
38  */
39 #define PARAM_RET                               "ret"
40
41 /**
42  * @brief Definition for the event parameter.
43  */
44 #define PARAM_EVENT                     "event"
45
46 /**
47  * @brief Definition for the error parameter.
48  */
49 #define PARAM_ERROR                     "error"
50
51 /**
52  * @brief Definition for the tbm key parameter.
53  */
54 #define PARAM_TBM_KEY                   "t_key"
55
56 /**
57  * @brief Definition for the display mode parameter.
58  */
59 #define PARAM_DISPLAY_MODE      "display_mode"
60
61 /**
62  * @brief Definition for the device type parameter.
63  */
64 #define PARAM_DEVICE_TYPE               "device_type"
65
66 /**
67  * @brief Definition for the recorder type parameter audio/video
68  */
69  #define PARAM_RECORDER_TYPE    "recorder_type"
70
71 /**
72  * @brief Definition for the camera handle ipc parameter
73  */
74 #define PARAM_CAMERA_HANDLE     "camera_handle"
75
76 /**
77  * @brief Definition for the INTEGER type.
78  */
79 typedef int32_t INT;
80
81 /**
82  * @brief Definition for the 64 bit INTEGER type.
83  */
84 typedef int64_t INT64;
85
86 /**
87  * @brief Definition for the 64 bit integer pointer type.
88  */
89 typedef intptr_t POINTER;
90
91 /**
92  * @brief Definition for the 64 bit DOUBLE type.
93  */
94 typedef double DOUBLE;
95
96 /**
97  * @brief Definition for the 64 bit STRING type.
98  */
99 typedef const char* STRING;
100
101 /**
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.
105  */
106 #define muse_recorder_msg_get(param, buf) \
107         muse_core_msg_json_deserialize(#param, buf, NULL, &param, NULL, MUSE_TYPE_ANY)
108
109 /**
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.
113  */
114 #define muse_recorder_msg_get_string(param, buf) \
115         muse_core_msg_json_deserialize(#param, buf, NULL, param, NULL, MUSE_TYPE_STRING)
116
117 /**
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.
121  */
122 #define muse_recorder_msg_get_array(param, buf) \
123         muse_core_msg_json_deserialize(#param, buf, NULL, param, NULL, MUSE_TYPE_ARRAY)
124
125 /**
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.
129  */
130 #define muse_recorder_msg_get_pointer(param, buf) \
131         muse_core_msg_json_deserialize(#param, buf, NULL, &param, NULL, MUSE_TYPE_POINTER)
132
133
134 /**
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.
139  */
140 #define muse_recorder_msg_get_error_e(param, buf, e) \
141         muse_core_msg_json_deserialize(#param, buf, NULL, &param, &e, MUSE_TYPE_ANY)
142
143 /**
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.
149  */
150 #define muse_recorder_msg_send(api, fd, cb_info, ret) \
151         do{     \
152                 char *__sndMsg__; \
153                 callback_cb_info_s *cb_info_s; \
154                 int __len__; \
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; \
162                 } else \
163                         ret = client_wait_for_cb_return(api, cb_info, CALLBACK_TIME_OUT); \
164                 muse_core_msg_json_factory_free(__sndMsg__); \
165         }while(0)
166
167
168 /**
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.
176  */
177 #define muse_recorder_msg_send1(api, fd, cb_info, ret, type, param) \
178         do{     \
179                 char *__sndMsg__; \
180                 int __len__; \
181                 type __value__ = (type)param; \
182                 __sndMsg__ = muse_core_msg_json_factory_new(api, \
183                                 MUSE_TYPE_##type, #param, __value__, \
184                                 0); \
185                 __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
186                 if (__len__ <= 0) { \
187                         LOGE("sending message failed"); \
188                         ret = RECORDER_ERROR_INVALID_OPERATION; \
189                 } else \
190                         ret = client_wait_for_cb_return(api, cb_info, CALLBACK_TIME_OUT); \
191                 muse_core_msg_json_factory_free(__sndMsg__); \
192         }while(0)
193
194 /**
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.
204  */
205 #define muse_recorder_msg_send2(api, fd, cb_info, ret, type1, param1, type2, param2) \
206         do{     \
207                 char *__sndMsg__; \
208                 int __len__; \
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__, \
214                                 0); \
215                 __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
216                 if (__len__ <= 0) { \
217                         LOGE("sending message failed"); \
218                         ret = RECORDER_ERROR_INVALID_OPERATION; \
219                 } else \
220                         ret = client_wait_for_cb_return(api, cb_info, CALLBACK_TIME_OUT); \
221                 muse_core_msg_json_factory_free(__sndMsg__); \
222         }while(0)
223
224
225 /**
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.
234  */
235 #define muse_recorder_msg_send_array(api, fd, cb_info, ret, param, length, datum_size) \
236         do{     \
237                 char *__sndMsg__; \
238                 int __len__; \
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), \
245                                         __value__, \
246                                 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; \
251                 } else \
252                         ret = client_wait_for_cb_return(api, cb_info, CALLBACK_TIME_OUT); \
253                 muse_core_msg_json_factory_free(__sndMsg__); \
254         }while(0)
255
256 /**
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.
261  */
262 #define muse_recorder_msg_return(api, ret, module) \
263         do{     \
264                 char *__sndMsg__; \
265                 int __len__; \
266                 __sndMsg__ = muse_core_msg_json_factory_new(api, \
267                                 MUSE_TYPE_INT, PARAM_RET, ret, \
268                                 0); \
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; \
273                 } \
274                 muse_core_msg_json_factory_free(__sndMsg__); \
275         }while(0)
276
277 /**
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.
284  */
285 #define muse_recorder_msg_return1(api, ret, module, type, param) \
286         do{     \
287                 char *__sndMsg__; \
288                 int __len__; \
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__, \
293                                 0); \
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; \
298                 } \
299                 muse_core_msg_json_factory_free(__sndMsg__); \
300         }while(0)
301
302 /**
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.
311  */
312 #define muse_recorder_msg_return2(api, ret, module, type1, param1, type2, param2) \
313         do{     \
314                 char *__sndMsg__; \
315                 int __len__; \
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__, \
322                                 0); \
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; \
327                 } \
328                 muse_core_msg_json_factory_free(__sndMsg__); \
329         }while(0)
330
331 /**
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.
342  */
343 #define muse_recorder_msg_return3(api, ret, module, type1, param1, type2, param2, type3, param3) \
344         do{     \
345                 char *__sndMsg__; \
346                 int __len__; \
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__, \
355                                 0); \
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; \
360                 } \
361                 muse_core_msg_json_factory_free(__sndMsg__); \
362         }while(0)
363
364 /**
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.
372  */
373 #define muse_recorder_msg_return_array(api, ret, module, param, length, datum_size) \
374         do{     \
375                 char *__sndMsg__; \
376                 int __len__; \
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), \
384                                         __value__, \
385                                 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; \
390                 } \
391                 muse_core_msg_json_factory_free(__sndMsg__); \
392         }while(0)
393
394 /**
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.
399  */
400 #define muse_recorder_msg_event(api, event, fd) \
401         do{     \
402                 char *__sndMsg__; \
403                 __sndMsg__ = muse_core_msg_json_factory_new(api, \
404                                 MUSE_TYPE_INT, PARAM_EVENT, event, \
405                                 0); \
406                 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
407                 muse_core_msg_json_factory_free(__sndMsg__); \
408         }while(0)
409
410 /**
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.
417  */
418 #define muse_recorder_msg_event1(api, event, module, type, param) \
419         do{     \
420                 char *__sndMsg__; \
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__, \
425                                 0); \
426                 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
427                 muse_core_msg_json_factory_free(__sndMsg__); \
428         }while(0)
429
430 /**
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.
438  */
439 #define muse_recorder_msg_event2(api, event, module, type1, param1, type2, param2) \
440         do{     \
441                 char *__sndMsg__; \
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__, \
448                                 0); \
449                 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
450                 muse_core_msg_json_factory_free(__sndMsg__); \
451         }while(0)
452
453 /**
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.
463  */
464 #define muse_recorder_msg_event3(api, event, module, type1, param1, type2, param2, type3, param3) \
465         do{     \
466                 char *__sndMsg__; \
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__, \
475                                 0); \
476                 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
477                 muse_core_msg_json_factory_free(__sndMsg__); \
478         }while(0)
479
480 /**
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.
494  */
495 #define muse_recorder_msg_event5(api, event, module, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5) \
496         do{     \
497                 char *__sndMsg__; \
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__, \
510                                 0); \
511                 muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
512                 muse_core_msg_json_factory_free(__sndMsg__); \
513         }while(0)
514
515 #ifdef __cplusplus
516 }
517 #endif
518
519 #endif /*__RECORDER_MSG_PRIVATE_H__*/