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 __TIZEN_MEDIA_PLAYER_MSG_PRIVATE_H__
18 #define __TIZEN_MEDIA_PLAYER_MSG_PRIVATE_H__
24 #include <muse_player_msg.h>
27 * @brief Create and send address of server side module infomation structure.
28 * @remarks Does NOT guarantee thread safe.
29 * @param[in] module The server side module infomation.
30 * @param[in] fd socket fd
32 #define muse_core_send_module_addr(module, fd) \
36 __sndMsg__ = muse_core_msg_json_factory_new(0, \
37 MUSE_TYPE_POINTER, #module, module, \
39 __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
40 muse_core_msg_json_factory_free(__sndMsg__); \
42 LOGE("sending message failed"); \
43 return PLAYER_ERROR_INVALID_OPERATION; \
48 * @brief Create and send message. Wait for server result.
49 * @remarks Does NOT guarantee thread safe.
50 * @param[in] api The enum of module API.
51 * @param[in] player The handle of capi media player.
52 * @param[out] retbuf The buffer of return message. Must be char pointer.
53 * @param[out] ret The return value from server.
55 #define player_msg_send(api, player, retbuf, ret) \
60 int __timeout__ = client_get_api_timeout(player, api); \
61 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
62 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
63 __sndMsg__ = muse_core_msg_json_factory_new(api, \
65 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
67 LOGE("sending message failed"); \
68 ret = PLAYER_ERROR_INVALID_OPERATION; \
70 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
71 muse_core_msg_json_factory_free(__sndMsg__); \
75 * @brief Create and send message. Wait for server result.
76 * @remarks Does NOT guarantee thread safe.
77 * @param[in] api The enum of module API.
78 * @param[in] player The handle of capi media player.
79 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
80 * @param[out] ret The return value from server.
81 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
82 * @param[in] param the name of param is key, must be local variable. never be pointer.
84 #define player_msg_send1(api, player, retbuf, ret, type, param) \
89 int __timeout__ = client_get_api_timeout(player, api); \
90 type __value__ = (type)param; \
91 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
92 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
93 __sndMsg__ = muse_core_msg_json_factory_new(api, \
94 MUSE_TYPE_##type, #param, __value__, \
96 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
98 LOGE("sending message failed"); \
99 ret = PLAYER_ERROR_INVALID_OPERATION; \
101 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
102 muse_core_msg_json_factory_free(__sndMsg__); \
106 * @brief Create and send message. Wait for server result.
107 * @remarks Does NOT guarantee thread safe.
108 * @param[in] api The enum of module API.
109 * @param[in] player The handle of capi media player.
110 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
111 * @param[out] ret The return value from server.
112 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
113 * @param[in] param# the name of param is key, must be local variable. never be pointer.
115 #define player_msg_send2(api, player, retbuf, ret, type1, param1, type2, param2) \
120 int __timeout__ = client_get_api_timeout(player, api); \
121 type1 __value1__ = (type1)param1; \
122 type2 __value2__ = (type2)param2; \
123 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
124 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
125 __sndMsg__ = muse_core_msg_json_factory_new(api, \
126 MUSE_TYPE_##type1, #param1, __value1__, \
127 MUSE_TYPE_##type2, #param2, __value2__, \
129 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
130 if (__len__ <= 0) { \
131 LOGE("sending message failed"); \
132 ret = PLAYER_ERROR_INVALID_OPERATION; \
134 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
135 muse_core_msg_json_factory_free(__sndMsg__); \
139 * @brief Create and send message. Wait for server result.
140 * @remarks Does NOT guarantee thread safe.
141 * @param[in] api The enum of module API.
142 * @param[in] player The handle of capi media player.
143 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
144 * @param[out] ret The return value from server.
145 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
146 * @param[in] param# the name of param is key, must be local variable. never be pointer.
148 #define player_msg_send3(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3) \
153 int __timeout__ = client_get_api_timeout(player, api); \
154 type1 __value1__ = (type1)param1; \
155 type2 __value2__ = (type2)param2; \
156 type3 __value3__ = (type3)param3; \
157 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
158 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
159 __sndMsg__ = muse_core_msg_json_factory_new(api, \
160 MUSE_TYPE_##type1, #param1, __value1__, \
161 MUSE_TYPE_##type2, #param2, __value2__, \
162 MUSE_TYPE_##type3, #param3, __value3__, \
164 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
165 if (__len__ <= 0) { \
166 LOGE("sending message failed"); \
167 ret = PLAYER_ERROR_INVALID_OPERATION; \
169 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
170 muse_core_msg_json_factory_free(__sndMsg__); \
174 * @brief Create and send message. Wait for server result.
175 * @remarks Does NOT guarantee thread safe.
176 * @param[in] api The enum of module API.
177 * @param[in] player The handle of capi media player.
178 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
179 * @param[out] ret The return value from server.
180 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
181 * @param[in] param# the name of param is key, must be local variable. never be pointer.
183 #define player_msg_send4(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, type4, param4) \
188 int __timeout__ = client_get_api_timeout(player, api); \
189 type1 __value1__ = (type1)param1; \
190 type2 __value2__ = (type2)param2; \
191 type3 __value3__ = (type3)param3; \
192 type4 __value4__ = (type4)param4; \
193 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
194 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
195 __sndMsg__ = muse_core_msg_json_factory_new(api, \
196 MUSE_TYPE_##type1, #param1, __value1__, \
197 MUSE_TYPE_##type2, #param2, __value2__, \
198 MUSE_TYPE_##type3, #param3, __value3__, \
199 MUSE_TYPE_##type4, #param4, __value4__, \
201 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
202 if (__len__ <= 0) { \
203 LOGE("sending message failed"); \
204 ret = PLAYER_ERROR_INVALID_OPERATION; \
206 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
207 muse_core_msg_json_factory_free(__sndMsg__); \
211 * @brief Create and send message. Wait for server result.
212 * @remarks Does NOT guarantee thread safe.
213 * @param[in] api The enum of module API.
214 * @param[in] player The handle of capi media player.
215 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
216 * @param[out] ret The return value from server.
217 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
218 * @param[in] param# the name of param is key, must be local variable. never be pointer.
220 #define player_msg_send5(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5) \
225 int __timeout__ = client_get_api_timeout(player, api); \
226 type1 __value1__ = (type1)param1; \
227 type2 __value2__ = (type2)param2; \
228 type3 __value3__ = (type3)param3; \
229 type4 __value4__ = (type4)param4; \
230 type5 __value5__ = (type5)param5; \
231 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
232 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
233 __sndMsg__ = muse_core_msg_json_factory_new(api, \
234 MUSE_TYPE_##type1, #param1, __value1__, \
235 MUSE_TYPE_##type2, #param2, __value2__, \
236 MUSE_TYPE_##type3, #param3, __value3__, \
237 MUSE_TYPE_##type4, #param4, __value4__, \
238 MUSE_TYPE_##type5, #param5, __value5__, \
240 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
241 if (__len__ <= 0) { \
242 LOGE("sending message failed"); \
243 ret = PLAYER_ERROR_INVALID_OPERATION; \
245 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
246 muse_core_msg_json_factory_free(__sndMsg__); \
250 * @brief Create and send message. Wait for server result.
251 * @remarks Does NOT guarantee thread safe.
252 * @param[in] api The enum of module API.
253 * @param[in] player The handle of capi media player.
254 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
255 * @param[out] ret The return value from server.
256 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
257 * @param[in] param# the name of param is key, must be local variable. never be pointer.
259 #define player_msg_send6(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6) \
264 int __timeout__ = client_get_api_timeout(player, api); \
265 type1 __value1__ = (type1)param1; \
266 type2 __value2__ = (type2)param2; \
267 type3 __value3__ = (type3)param3; \
268 type4 __value4__ = (type4)param4; \
269 type5 __value5__ = (type5)param5; \
270 type6 __value6__ = (type6)param6; \
271 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
272 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
273 __sndMsg__ = muse_core_msg_json_factory_new(api, \
274 MUSE_TYPE_##type1, #param1, __value1__, \
275 MUSE_TYPE_##type2, #param2, __value2__, \
276 MUSE_TYPE_##type3, #param3, __value3__, \
277 MUSE_TYPE_##type4, #param4, __value4__, \
278 MUSE_TYPE_##type5, #param5, __value5__, \
279 MUSE_TYPE_##type6, #param6, __value6__, \
281 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
282 if (__len__ <= 0) { \
283 LOGE("sending message failed"); \
284 ret = PLAYER_ERROR_INVALID_OPERATION; \
286 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
287 muse_core_msg_json_factory_free(__sndMsg__); \
291 * @brief Create and send message. Wait for server result.
292 * @remarks Does NOT guarantee thread safe.
293 * @param[in] api The enum of module API.
294 * @param[in] player The handle of capi media player.
295 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
296 * @param[out] ret The return value from server.
297 * @param[in] param the name of param is key, must be local array/pointer variable.
298 * @param[in] length The size of array.
299 * @param[in] datum_size The size of a array's datum.
301 #define player_msg_send_array(api, player, retbuf, ret, param, length, datum_size) \
306 int __timeout__ = client_get_api_timeout(player, api); \
307 int *__value__ = (int *)param; \
308 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
309 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
310 __sndMsg__ = muse_core_msg_json_factory_new(api, \
311 MUSE_TYPE_INT, #length, length, \
312 MUSE_TYPE_ARRAY, #param, \
313 datum_size == sizeof(int) ? length : \
314 length / sizeof(int) + (length % sizeof(int) ? 1 : 0), \
317 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
318 if (__len__ <= 0) { \
319 LOGE("sending message failed"); \
320 ret = PLAYER_ERROR_INVALID_OPERATION; \
322 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
323 muse_core_msg_json_factory_free(__sndMsg__); \
327 * @brief Create and send message. Wait for server result.
328 * @remarks Does NOT guarantee thread safe.
329 * @param[in] api The enum of module API.
330 * @param[in] player The handle of capi media player.
331 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
332 * @param[out] ret The return value from server.
333 * @param[in] param# the name of param is key, must be local array/pointer variable.
334 * @param[in] length# The size of array.
335 * @param[in] datum_size# The size of a array's datum.
337 #define player_msg_send_array2(api, player, retbuf, ret, param1, length1, datum_size1, param2, length2, datum_size2) \
342 int __timeout__ = client_get_api_timeout(player, api); \
343 int *__value1__ = (int *)param1; \
344 int *__value2__ = (int *)param2; \
345 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
346 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
347 __sndMsg__ = muse_core_msg_json_factory_new(api, \
348 MUSE_TYPE_INT, #length1, length1, \
349 MUSE_TYPE_ARRAY, #param1, \
350 datum_size1 == sizeof(int) ? length1 : \
351 length1 / sizeof(int) + (length1 % sizeof(int) ? 1 : 0), \
353 MUSE_TYPE_INT, #length2, length2, \
354 MUSE_TYPE_ARRAY, #param2, \
355 datum_size2 == sizeof(int) ? length2 : \
356 length2 / sizeof(int) + (length2 % sizeof(int) ? 1 : 0), \
359 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
360 if (__len__ <= 0) { \
361 LOGE("sending message failed"); \
362 ret = PLAYER_ERROR_INVALID_OPERATION; \
364 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
365 muse_core_msg_json_factory_free(__sndMsg__); \
369 * @brief Create and send message. Wait for server result.
370 * @remarks Does NOT guarantee thread safe.
371 * @param[in] api The enum of module API.
372 * @param[in] player The handle of capi media player.
373 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
374 * @param[out] ret The return value from server.
375 * @param[in] param# the name of param is key, must be local array/pointer variable.
376 * @param[in] length# The size of array.
377 * @param[in] datum_size# The size of a array's datum.
379 #define player_msg_send1_array2(api, player, retbuf, ret, type1, param1, param2, length2, datum_size2, param3, length3, datum_size3) \
384 int __timeout__ = client_get_api_timeout(player, api); \
385 type1 __value1__ = (type1)param1; \
386 int *__value2__ = (int *)param2; \
387 int *__value3__ = (int *)param3; \
388 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
389 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
390 __sndMsg__ = muse_core_msg_json_factory_new(api, \
391 MUSE_TYPE_##type1, #param1, __value1__, \
392 MUSE_TYPE_INT, #length2, length2, \
393 MUSE_TYPE_ARRAY, #param2, \
394 datum_size2 == sizeof(int) ? length2 : \
395 length2 / sizeof(int) + (length2 % sizeof(int) ? 1 : 0), \
397 MUSE_TYPE_INT, #length3, length3, \
398 MUSE_TYPE_ARRAY, #param3, \
399 datum_size3 == sizeof(int) ? length3 : \
400 length3 / sizeof(int) + (length3 % sizeof(int) ? 1 : 0), \
403 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
404 if (__len__ <= 0) { \
405 LOGE("sending message failed"); \
406 ret = PLAYER_ERROR_INVALID_OPERATION; \
408 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
409 muse_core_msg_json_factory_free(__sndMsg__); \
413 * @brief Create and send message. Wait for server result.
414 * @remarks Does NOT guarantee thread safe.
415 * @param[in] api The enum of module API.
416 * @param[in] player The handle of capi media player.
417 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
418 * @param[out] ret The return value from server.
419 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
420 * @param[in] param# the name of param is key, must be local variable. never be pointer.
421 * @param[in] length# The size of array.
422 * @param[in] datum_size# The size of a array's datum.
424 #define player_msg_send2_array(api, player, retbuf, ret, type1, param1, type2, param2, param_arr, length, datum_size) \
429 int __timeout__ = client_get_api_timeout(player, api); \
430 type1 __value1__ = (type1)param1; \
431 type2 __value2__ = (type2)param2; \
432 int *__value_arr__ = (int *)param_arr; \
433 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
434 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
435 __sndMsg__ = muse_core_msg_json_factory_new(api, \
436 MUSE_TYPE_##type1, #param1, __value1__, \
437 MUSE_TYPE_##type2, #param2, __value2__, \
438 MUSE_TYPE_INT, #length, length, \
439 MUSE_TYPE_ARRAY, #param_arr, \
440 datum_size == sizeof(int) ? length : \
441 length / sizeof(int) + (length % sizeof(int) ? 1 : 0), \
444 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
445 if (__len__ <= 0) { \
446 LOGE("sending message failed"); \
447 ret = PLAYER_ERROR_INVALID_OPERATION; \
449 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
450 muse_core_msg_json_factory_free(__sndMsg__); \
454 * @brief Create and send message. Wait for server result.
455 * @remarks Does NOT guarantee thread safe.
456 * @param[in] api The enum of module API.
457 * @param[in] player The handle of capi media player.
458 * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
459 * @param[out] ret The return value from server.
460 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
461 * @param[in] param# the name of param is key, must be local variable. never be pointer.
462 * @param[in] length# The size of array.
463 * @param[in] datum_size# The size of a array's datum.
465 #define player_msg_send3_array2(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, param4, length4, datum_size4, param5, length5, datum_size5) \
470 int __timeout__ = client_get_api_timeout(player, api); \
471 type1 __value1__ = (type1)param1; \
472 type2 __value2__ = (type2)param2; \
473 type3 __value3__ = (type3)param3; \
474 int *__value4__ = (int *)param4; \
475 int *__value5__ = (int *)param5; \
476 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
477 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
478 __sndMsg__ = muse_core_msg_json_factory_new(api, \
479 MUSE_TYPE_##type1, #param1, __value1__, \
480 MUSE_TYPE_##type2, #param2, __value2__, \
481 MUSE_TYPE_##type3, #param3, __value3__, \
482 MUSE_TYPE_INT, #length4, length4, \
483 MUSE_TYPE_ARRAY, #param4, \
484 datum_size4 == sizeof(int) ? length4 : \
485 length4 / sizeof(int) + (length4 % sizeof(int) ? 1 : 0), \
487 MUSE_TYPE_INT, #length5, length5, \
488 MUSE_TYPE_ARRAY, #param5, \
489 datum_size5 == sizeof(int) ? length5 : \
490 length5 / sizeof(int) + (length5 % sizeof(int) ? 1 : 0), \
493 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
494 if (__len__ <= 0) { \
495 LOGE("sending message failed"); \
496 ret = PLAYER_ERROR_INVALID_OPERATION; \
498 ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
499 muse_core_msg_json_factory_free(__sndMsg__); \
503 * @brief Create and send message. Does not wait server result.
504 * @remarks Does NOT guarantee thread safe.
505 * @param[in] api The enum of module API.
506 * @param[in] player The handle of capi media player.
507 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
508 * @param[in] param the name of param is key, must be local variable. never be pointer.
510 #define player_msg_send1_async(api, player, type, param) \
515 type __value__ = (type)param; \
516 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
517 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
518 __sndMsg__ = muse_core_msg_json_factory_new(api, \
519 MUSE_TYPE_##type, #param, __value__, \
521 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
522 muse_core_msg_json_factory_free(__sndMsg__); \
523 if (__len__ <= 0) { \
524 LOGE("sending message failed"); \
525 return PLAYER_ERROR_INVALID_OPERATION; \
530 * @brief Create and send message. Does not wait server result.
531 * @remarks Does NOT guarantee thread safe.
532 * @param[in] api The enum of module API.
533 * @param[in] player The handle of capi media player.
534 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
535 * @param[in] param the name of param is key, must be local variable. never be pointer.
537 #define player_msg_send1_no_return(api, fd, type, param) \
541 type __value__ = (type)param; \
542 __sndMsg__ = muse_core_msg_json_factory_new(api, \
543 MUSE_TYPE_##type, #param, __value__, \
545 __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
546 muse_core_msg_json_factory_free(__sndMsg__); \
547 if (__len__ <= 0) { \
548 LOGE("sending message failed"); \
553 * @brief Create and send message. Does not wait server result.
554 * @remarks Does NOT guarantee thread safe.
555 * @param[in] api The enum of module API.
556 * @param[in] player The server side handle of media player.
557 * @param[in] fd socket fd
558 * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
559 * @param[in] param the name of param is key, must be local variable. never be pointer.
561 #define player_msg_create_handle(api, fd, type1, param1, type2, param2) \
565 type1 __value1__ = (type1)param1; \
566 type2 __value2__ = (type2)param2; \
567 __sndMsg__ = muse_core_msg_json_factory_new(api, \
568 MUSE_TYPE_##type1, #param1, __value1__, \
569 MUSE_TYPE_##type2, #param2, __value2__, \
571 __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
572 muse_core_msg_json_factory_free(__sndMsg__); \
573 if (__len__ <= 0) { \
574 LOGE("sending message failed"); \
575 return PLAYER_ERROR_INVALID_OPERATION; \
581 * @brief Create and send message for callback. Does not wait server result.
582 * @remarks Does NOT guarantee thread safe.
583 * @param[in] api The enum of module API.
584 * @param[in] player The handle of capi media player.
585 * @param[out] ret set ERROR when fail to send msg.
586 * @param[in] event_type type of event (muse_player_event_e).
587 * @param[in] set 1 is set the user callback, 0 is unset the user callback.
589 #define player_msg_set_callback(api, player, ret, event_type, set) \
594 int __value1__ = (int)event_type; \
595 int __value2__ = (int)set; \
596 if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
597 else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
598 __sndMsg__ = muse_core_msg_json_factory_new(api, \
599 MUSE_TYPE_INT, #event_type, __value1__, \
600 MUSE_TYPE_INT, #set, __value2__, \
602 __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
603 muse_core_msg_json_factory_free(__sndMsg__); \
604 if (__len__ <= 0) { \
605 LOGE("sending message failed"); \
606 ret = PLAYER_ERROR_INVALID_OPERATION; \
611 * @brief Get value from Message.
612 * @remarks Does NOT guarantee thread safe.
613 * @param[in] buf string of message buffer. has key and value
614 * @param[out] param# the name of param is key, must be local variable. never be pointer.
615 * @param[in] type#The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE)
616 * @param[out] arr_param the name of param is key, must be local variable. never be pointer.
617 * @param[out] ret result of get value
620 #define player_msg_get2_array(buf, param1, type1, param2, type2, arr_param, ret) \
622 void *__jobj__ = muse_core_msg_json_object_new(buf, NULL, NULL); \
623 if (!muse_core_msg_json_object_get_value(#param1, __jobj__, ¶m1, MUSE_TYPE_##type1)) { \
624 LOGE("failed to get value(%s)", #param1); \
627 if (ret && !muse_core_msg_json_object_get_value(#param2, __jobj__, ¶m2, MUSE_TYPE_##type2)) { \
628 LOGE("failed to get %s value", #param2); \
631 if (ret && !muse_core_msg_json_object_get_value(#arr_param, __jobj__, arr_param, MUSE_TYPE_ANY)) { \
632 LOGE("failed to get %s value", #arr_param); \
635 muse_core_msg_json_object_free(__jobj__); \
639 * @brief Get value from Message.
640 * @remarks Does NOT guarantee thread safe.
641 * @param[in] buf string of message buffer. has key and value
642 * @param[out] str_param# the name of param is key, must be local pointer variable.
643 * @param[out] ret result of get value
645 #define player_msg_get_string2(buf, str_param1, str_param2, ret) \
647 muse_core_msg_parse_err_e __err__ = MUSE_MSG_PARSE_ERROR_NONE; \
648 void *__jobj__ = muse_core_msg_json_object_new(buf, NULL, &__err__); \
650 LOGE("failed to get msg object. err:%d", __err__); \
653 if (!muse_core_msg_json_object_get_value(#str_param1, __jobj__, str_param1, MUSE_TYPE_STRING)) { \
654 LOGE("failed to get %s value", #str_param1); \
657 if (ret && !muse_core_msg_json_object_get_value(#str_param2, __jobj__, str_param2, MUSE_TYPE_STRING)) { \
658 LOGE("failed to get %s value", #str_param2); \
661 muse_core_msg_json_object_free(__jobj__); \
665 #endif /* __TIZEN_MEDIA_PLAYER_MSG_PRIVATE_H__ */