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.
20 #include <sys/types.h>
22 #include <tbm_bufmgr.h>
23 #include <tbm_surface.h>
24 #include <tbm_surface_internal.h>
26 #include <Elementary.h>
28 #include <Ecore_Wayland.h>
31 #include <muse_core.h>
32 #include <muse_core_msg_json.h>
33 #include <muse_core_module.h>
34 #include <muse_core_ipc.h>
35 #include <muse_player.h>
36 #include <muse_player_msg.h>
37 #include <sound_manager.h>
38 #include <sound_manager_internal.h>
39 #include "player_internal.h"
40 #include "player_private.h"
41 #include "player_display.h"
42 #include "player_msg.h"
43 #ifdef EVAS_RENDERER_SUPPORT
44 #include <mm_evas_renderer.h>
46 #define INVALID_SOCKET -1
51 callback_cb_info_s *cb_info;
56 callback_cb_info_s *cb_info; /* to monitor the packet_list */
58 } _media_pkt_fin_data;
65 * Internal Implementation
67 static int _player_deinit_memory_buffer(player_cli_s * pc);
69 int _player_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
71 int ret = MEDIA_PACKET_FINALIZE;
72 muse_player_api_e api = MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB;
73 _media_pkt_fin_data *fin_data = (_media_pkt_fin_data *) user_data;
79 LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
83 if (!fin_data || fin_data->fd <= INVALID_SOCKET) {
84 LOGE("invalid parameter, fd: %d", (fin_data) ? (fin_data->fd) : (-1));
88 /* Do not destroy tbm surface here to reuse during playback *
89 * they will be destroyed at player_unprepare() or player_destroy(). *
90 * ref: __player_remove_tsurf_list() */
92 packet = fin_data->remote_pkt;
93 snd_msg = muse_core_msg_json_factory_new(api, MUSE_TYPE_POINTER, "packet", packet, 0);
94 snd_len = muse_core_ipc_send_msg(fin_data->fd, snd_msg);
95 muse_core_msg_json_factory_free(snd_msg);
98 /* player handle is available. remove packet from the list */
99 if (fin_data->cb_info->packet_list) {
100 g_mutex_lock(&fin_data->cb_info->data_mutex);
101 if (g_list_find(fin_data->cb_info->packet_list, pkt)) {
102 fin_data->cb_info->packet_list = g_list_remove(fin_data->cb_info->packet_list, pkt);
104 LOGW("there is no packet(%p) in exported list.", pkt);
106 g_mutex_unlock(&fin_data->cb_info->data_mutex);
108 LOGW("there is no packet list.", pkt);
111 LOGE("fail to send msg.");
123 static int __player_convert_error_code(int code, char *func_name)
125 int ret = PLAYER_ERROR_INVALID_OPERATION;
126 char *msg = "PLAYER_ERROR_INVALID_OPERATION";
129 case MM_ERROR_PLAYER_AUDIO_CODEC_NOT_FOUND:
130 case MM_ERROR_PLAYER_VIDEO_CODEC_NOT_FOUND:
131 ret = PLAYER_ERROR_NONE;
132 msg = "PLAYER_ERROR_NONE";
134 case MM_ERROR_INVALID_ARGUMENT:
135 ret = PLAYER_ERROR_INVALID_PARAMETER;
136 msg = "PLAYER_ERROR_INVALID_PARAMETER";
138 case MM_ERROR_PLAYER_CODEC_NOT_FOUND:
139 case MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_AUDIO:
140 case MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_VIDEO:
141 case MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_MEDIA_TYPE:
142 case MM_ERROR_PLAYER_NOT_SUPPORTED_FORMAT:
143 ret = PLAYER_ERROR_NOT_SUPPORTED_FILE;
144 msg = "PLAYER_ERROR_NOT_SUPPORTED_FILE";
146 case MM_ERROR_PLAYER_INVALID_STATE:
147 case MM_ERROR_PLAYER_NOT_INITIALIZED:
148 ret = PLAYER_ERROR_INVALID_STATE;
149 msg = "PLAYER_ERROR_INVALID_STATE";
151 case MM_ERROR_PLAYER_INTERNAL:
152 case MM_ERROR_PLAYER_INVALID_STREAM:
153 case MM_ERROR_PLAYER_STREAMING_FAIL:
154 case MM_ERROR_PLAYER_NO_OP:
155 ret = PLAYER_ERROR_INVALID_OPERATION;
156 msg = "PLAYER_ERROR_INVALID_OPERATION";
158 case MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS:
159 case MM_ERROR_NOT_SUPPORT_API:
160 case MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER:
161 ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
162 msg = "PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE";
164 case MM_ERROR_PLAYER_NO_FREE_SPACE:
165 ret = PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE;
166 msg = "PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE";
168 case MM_ERROR_PLAYER_FILE_NOT_FOUND:
169 ret = PLAYER_ERROR_NO_SUCH_FILE;
170 msg = "PLAYER_ERROR_NO_SUCH_FILE";
172 case MM_ERROR_PLAYER_SEEK:
173 ret = PLAYER_ERROR_SEEK_FAILED;
174 msg = "PLAYER_ERROR_SEEK_FAILED";
176 case MM_ERROR_PLAYER_INVALID_URI:
177 case MM_ERROR_PLAYER_STREAMING_INVALID_URL:
178 ret = PLAYER_ERROR_INVALID_URI;
179 msg = "PLAYER_ERROR_INVALID_URI";
181 case MM_ERROR_PLAYER_STREAMING_CONNECTION_FAIL:
182 case MM_ERROR_PLAYER_STREAMING_DNS_FAIL:
183 case MM_ERROR_PLAYER_STREAMING_SERVER_DISCONNECTED:
184 case MM_ERROR_PLAYER_STREAMING_INVALID_PROTOCOL:
185 case MM_ERROR_PLAYER_STREAMING_UNEXPECTED_MSG:
186 case MM_ERROR_PLAYER_STREAMING_OUT_OF_MEMORIES:
187 case MM_ERROR_PLAYER_STREAMING_RTSP_TIMEOUT:
188 case MM_ERROR_PLAYER_STREAMING_BAD_REQUEST:
189 case MM_ERROR_PLAYER_STREAMING_NOT_AUTHORIZED:
190 case MM_ERROR_PLAYER_STREAMING_PAYMENT_REQUIRED:
191 case MM_ERROR_PLAYER_STREAMING_FORBIDDEN:
192 case MM_ERROR_PLAYER_STREAMING_CONTENT_NOT_FOUND:
193 case MM_ERROR_PLAYER_STREAMING_METHOD_NOT_ALLOWED:
194 case MM_ERROR_PLAYER_STREAMING_NOT_ACCEPTABLE:
195 case MM_ERROR_PLAYER_STREAMING_PROXY_AUTHENTICATION_REQUIRED:
196 case MM_ERROR_PLAYER_STREAMING_SERVER_TIMEOUT:
197 case MM_ERROR_PLAYER_STREAMING_GONE:
198 case MM_ERROR_PLAYER_STREAMING_LENGTH_REQUIRED:
199 case MM_ERROR_PLAYER_STREAMING_PRECONDITION_FAILED:
200 case MM_ERROR_PLAYER_STREAMING_REQUEST_ENTITY_TOO_LARGE:
201 case MM_ERROR_PLAYER_STREAMING_REQUEST_URI_TOO_LARGE:
202 case MM_ERROR_PLAYER_STREAMING_PARAMETER_NOT_UNDERSTOOD:
203 case MM_ERROR_PLAYER_STREAMING_CONFERENCE_NOT_FOUND:
204 case MM_ERROR_PLAYER_STREAMING_NOT_ENOUGH_BANDWIDTH:
205 case MM_ERROR_PLAYER_STREAMING_NO_SESSION_ID:
206 case MM_ERROR_PLAYER_STREAMING_METHOD_NOT_VALID_IN_THIS_STATE:
207 case MM_ERROR_PLAYER_STREAMING_HEADER_FIELD_NOT_VALID_FOR_SOURCE:
208 case MM_ERROR_PLAYER_STREAMING_INVALID_RANGE:
209 case MM_ERROR_PLAYER_STREAMING_PARAMETER_IS_READONLY:
210 case MM_ERROR_PLAYER_STREAMING_AGGREGATE_OP_NOT_ALLOWED:
211 case MM_ERROR_PLAYER_STREAMING_ONLY_AGGREGATE_OP_ALLOWED:
212 case MM_ERROR_PLAYER_STREAMING_BAD_TRANSPORT:
213 case MM_ERROR_PLAYER_STREAMING_DESTINATION_UNREACHABLE:
214 case MM_ERROR_PLAYER_STREAMING_INTERNAL_SERVER_ERROR:
215 case MM_ERROR_PLAYER_STREAMING_NOT_IMPLEMENTED:
216 case MM_ERROR_PLAYER_STREAMING_BAD_GATEWAY:
217 case MM_ERROR_PLAYER_STREAMING_SERVICE_UNAVAILABLE:
218 case MM_ERROR_PLAYER_STREAMING_GATEWAY_TIME_OUT:
219 case MM_ERROR_PLAYER_STREAMING_OPTION_NOT_SUPPORTED:
220 ret = PLAYER_ERROR_CONNECTION_FAILED;
221 msg = "PLAYER_ERROR_CONNECTION_FAILED";
223 case MM_ERROR_POLICY_BLOCKED:
224 case MM_ERROR_POLICY_INTERRUPTED:
225 case MM_ERROR_POLICY_INTERNAL:
226 case MM_ERROR_POLICY_DUPLICATED:
227 ret = PLAYER_ERROR_SOUND_POLICY;
228 msg = "PLAYER_ERROR_SOUND_POLICY";
230 case MM_ERROR_PLAYER_DRM_EXPIRED:
231 ret = PLAYER_ERROR_DRM_EXPIRED;
232 msg = "PLAYER_ERROR_DRM_EXPIRED";
234 case MM_ERROR_PLAYER_DRM_NOT_AUTHORIZED:
235 case MM_ERROR_PLAYER_DRM_NO_LICENSE:
236 ret = PLAYER_ERROR_DRM_NO_LICENSE;
237 msg = "PLAYER_ERROR_DRM_NO_LICENSE";
239 case MM_ERROR_PLAYER_DRM_FUTURE_USE:
240 ret = PLAYER_ERROR_DRM_FUTURE_USE;
241 msg = "PLAYER_ERROR_DRM_FUTURE_USE";
243 case MM_ERROR_PLAYER_DRM_OUTPUT_PROTECTION:
244 ret = PLAYER_ERROR_DRM_NOT_PERMITTED;
245 msg = "PLAYER_ERROR_DRM_NOT_PERMITTED";
247 case MM_ERROR_PLAYER_RESOURCE_LIMIT:
248 ret = PLAYER_ERROR_RESOURCE_LIMIT;
249 msg = "PLAYER_ERROR_RESOURCE_LIMIT";
251 case MM_ERROR_PLAYER_PERMISSION_DENIED:
252 ret = PLAYER_ERROR_PERMISSION_DENIED;
253 msg = "PLAYER_ERROR_PERMISSION_DENIED";
255 LOGE("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
259 static void *_get_mem(player_cli_s * player, int size)
261 player_data_s *mem = g_new(player_data_s, sizeof(player_data_s));
263 mem->data = g_new(void, size);
264 mem->next = player->head;
271 static void _del_mem(player_cli_s * player)
274 while (player->head) {
275 mem = player->head->next;
276 g_free(player->head->data);
277 g_free(player->head);
282 static int player_recv_msg(callback_cb_info_s * cb_info)
285 msg_buff_s *buff = &cb_info->buff;
287 memset(buff->recvMsg, 0x00, sizeof(char)*buff->bufLen);
288 recvLen = muse_core_ipc_recv_msg(cb_info->fd, buff->recvMsg);
290 /* check the first msg */
291 if (buff->part_of_msg && buff->recvMsg[0] != '{')
293 gchar *tmp = strndup(buff->recvMsg, recvLen);
295 LOGE("failed to copy msg.");
299 LOGD("get remained part of msg %d + %d, %d", recvLen, strlen(buff->part_of_msg), buff->bufLen);
302 if (recvLen+strlen(buff->part_of_msg) >= buff->bufLen) {
303 LOGD("realloc Buffer %d -> %d", buff->bufLen, recvLen+strlen(buff->part_of_msg)+1);
304 buff->bufLen = recvLen+strlen(buff->part_of_msg)+1;
305 buff->recvMsg = g_renew(char, buff->recvMsg, buff->bufLen);
306 if (!buff->recvMsg) {
307 LOGE("failed renew buffer.");
312 memset(buff->recvMsg, 0x00, sizeof(char)*buff->bufLen);
314 snprintf(buff->recvMsg, buff->bufLen, "%s%s", buff->part_of_msg, tmp);
315 recvLen += strlen(buff->part_of_msg);
317 free(buff->part_of_msg);
318 buff->part_of_msg = NULL;
323 /* check the last msg */
324 if (buff->recvMsg[recvLen-1] != '}') {
325 char *part_pos = strrchr(buff->recvMsg, '}');
326 int part_len = ((part_pos) ? (strlen(part_pos+1)) : (0));
329 buff->part_of_msg = strndup(part_pos+1, part_len);
330 if (!buff->part_of_msg) {
331 LOGE("failed to alloc buffer for part of msg.");
334 LOGD("get part of msg: %d, %s", strlen(buff->part_of_msg), buff->part_of_msg);
342 static void set_null_user_cb(callback_cb_info_s * cb_info, muse_player_event_e event)
344 if (cb_info && event < MUSE_PLAYER_EVENT_TYPE_NUM) {
345 cb_info->user_cb[event] = NULL;
346 cb_info->user_data[event] = NULL;
350 static void set_null_user_cb_lock(callback_cb_info_s * cb_info, muse_player_event_e event)
352 bool lock = g_thread_self() != cb_info->event_queue.thread;
355 g_mutex_lock(&cb_info->event_queue.mutex);
357 set_null_user_cb(cb_info, event);
360 g_mutex_unlock(&cb_info->event_queue.mutex);
363 static int __set_callback(muse_player_event_e type, player_h player, void *callback, void *user_data)
365 PLAYER_INSTANCE_CHECK(player);
366 PLAYER_NULL_ARG_CHECK(callback);
367 int ret = PLAYER_ERROR_NONE;
368 player_cli_s *pc = (player_cli_s *) player;
369 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
372 LOGI("Event type : %d ", type);
373 player_msg_set_callback(api, pc, ret, type, set);
375 if (ret == PLAYER_ERROR_NONE) {
376 pc->cb_info->user_cb[type] = callback;
377 pc->cb_info->user_data[type] = user_data;
382 static int __unset_callback(muse_player_event_e type, player_h player)
384 PLAYER_INSTANCE_CHECK(player);
385 int ret = PLAYER_ERROR_NONE;
386 player_cli_s *pc = (player_cli_s *) player;
387 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
390 LOGI("Event type : %d ", type);
392 PLAYER_NULL_ARG_CHECK(CALLBACK_INFO(pc));
393 set_null_user_cb_lock(CALLBACK_INFO(pc), type);
395 player_msg_set_callback(api, pc, ret, type, set);
396 ret = PLAYER_ERROR_NONE;
401 static void __prepare_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
403 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_PREPARE;
405 ((player_prepared_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
407 set_null_user_cb(cb_info, ev);
410 static void __complete_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
412 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_COMPLETE;
413 ((player_completed_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
416 static void __interrupt_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
419 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_INTERRUPT;
421 if (player_msg_get(code, recvMsg))
422 ((player_interrupted_cb) cb_info->user_cb[ev]) (code, cb_info->user_data[ev]);
425 static void __error_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
428 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR;
430 if (player_msg_get(code, recvMsg))
431 ((player_error_cb) cb_info->user_cb[ev]) (code, cb_info->user_data[ev]);
434 static void __buffering_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
437 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_BUFFERING;
439 if (player_msg_get(percent, recvMsg))
440 ((player_buffering_cb) cb_info->user_cb[ev]) (percent, cb_info->user_data[ev]);
443 static void __subtitle_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
446 char text[MUSE_URI_MAX_LENGTH] = { 0, };
447 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SUBTITLE;
450 player_msg_get1_string(recvMsg, duration, INT, text, ret);
452 ((player_subtitle_updated_cb) cb_info->user_cb[ev]) (duration, text, cb_info->user_data[ev]);
456 static void __capture_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
458 unsigned char *data = NULL;
461 unsigned int size = 0;
463 tbm_bo_handle thandle;
467 player_msg_get3(recvMsg, width, INT, height, INT, size, INT, ret_val);
469 if (!player_msg_get(key, recvMsg)) {
470 LOGE("There is no tbm_key value. %d", key);
474 bo = tbm_bo_import(cb_info->bufmgr, key);
476 LOGE("TBM get error : bo is NULL");
479 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE | TBM_OPTION_READ);
480 if (thandle.ptr == NULL) {
481 LOGE("TBM get error : handle pointer is NULL");
484 data = g_new(unsigned char, size);
486 memcpy(data, thandle.ptr, size);
487 ((player_video_captured_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) (data, width, height, size, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
490 LOGE("g_new failure");
501 LOGD("send msg to release buffer. key:%d", key);
502 player_msg_send1_no_return(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, INT, key);
505 set_null_user_cb(cb_info, MUSE_PLAYER_EVENT_TYPE_CAPTURE);
508 static void __seek_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
510 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SEEK;
512 g_mutex_lock(&cb_info->seek_cb_mutex);
513 if (cb_info->user_cb[ev] && cb_info->block_seek_cb == FALSE) {
514 LOGD("call seek cb");
515 ((player_seek_completed_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
516 set_null_user_cb(cb_info, ev);
518 LOGW("ignored. seek cb %p, block %d", cb_info->user_cb[ev], cb_info->block_seek_cb);
520 g_mutex_unlock(&cb_info->seek_cb_mutex);
523 static void __player_remove_tsurf_list(player_cli_s * pc)
527 g_mutex_lock(&pc->cb_info->data_mutex);
528 if (pc->cb_info->tsurf_list) {
529 LOGD("total num of tsurf list = %d", g_list_length(pc->cb_info->tsurf_list));
531 for (l = g_list_first(pc->cb_info->tsurf_list); l; l = g_list_next(l)) {
532 player_tsurf_info_t* tmp = (player_tsurf_info_t *)l->data;
534 LOGD("%p will be removed", tmp);
537 tbm_surface_destroy(tmp->tsurf);
543 g_list_free(pc->cb_info->tsurf_list);
544 pc->cb_info->tsurf_list = NULL;
546 g_mutex_unlock(&pc->cb_info->data_mutex);
550 static player_tsurf_info_t* __player_get_tsurf_from_list(callback_cb_info_s * cb_info, tbm_key key)
554 g_mutex_lock(&cb_info->data_mutex);
555 for (l = g_list_first(cb_info->tsurf_list); l; l = g_list_next(l)) {
556 player_tsurf_info_t *tmp = (player_tsurf_info_t *)l->data;
557 if (tmp && (tmp->key == key)) {
558 LOGD("found tsurf_data of tbm_key %d", key);
559 g_mutex_unlock(&cb_info->data_mutex);
563 g_mutex_unlock(&cb_info->data_mutex);
564 LOGD("there is no tsurf_data for tbm_key:%d", key);
568 static void __media_packet_video_frame_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
570 tbm_bo bo[4] = { NULL, };
571 tbm_key key[4] = { 0, };
572 tbm_surface_info_s sinfo;
573 char *surface_info = (char *)&sinfo;
574 media_packet_h pkt = NULL;
575 tbm_surface_h tsurf = NULL;
576 player_tsurf_info_t *tsurf_data = NULL;
578 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
579 bool make_pkt_fmt = false;
580 int ret = MEDIA_FORMAT_ERROR_NONE;
581 _media_pkt_fin_data *fin_data = NULL;
585 muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
587 void *jobj = muse_core_msg_json_object_new(recvMsg, NULL, &err);
589 !muse_core_msg_json_object_get_value("key[0]", jobj, &key[0], MUSE_TYPE_ANY) ||
590 !muse_core_msg_json_object_get_value("key[1]", jobj, &key[1], MUSE_TYPE_ANY) ||
591 !muse_core_msg_json_object_get_value("key[2]", jobj, &key[2], MUSE_TYPE_ANY) ||
592 !muse_core_msg_json_object_get_value("key[3]", jobj, &key[3], MUSE_TYPE_ANY) ||
593 !muse_core_msg_json_object_get_value("packet", jobj, &packet, MUSE_TYPE_POINTER) ||
594 !muse_core_msg_json_object_get_value("mimetype", jobj, &mimetype, MUSE_TYPE_ANY) ||
595 !muse_core_msg_json_object_get_value("pts", jobj, &pts, MUSE_TYPE_INT64) ||
596 !muse_core_msg_json_object_get_value("surface_info", jobj, surface_info, MUSE_TYPE_ARRAY)) {
598 LOGE("failed to get value from msg. jobj:%p, err:%d", jobj, err);
600 muse_core_msg_json_object_free(jobj);
603 muse_core_msg_json_object_free(jobj);
605 LOGD("width %d, height %d", sinfo.width, sinfo.height);
608 LOGE("cb_info is null");
612 if (!cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
613 /* send msg to release packet. */
614 LOGE("_video_decoded_cb is not set");
615 player_msg_send1_no_return(MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB, cb_info->fd, POINTER, packet);
619 for (i = 0; i < 4; i++) {
622 bo[i] = tbm_bo_import(cb_info->bufmgr, key[i]);
626 tsurf_data = __player_get_tsurf_from_list(cb_info, key[0]);
628 tsurf_data = g_new(player_tsurf_info_t, 1);
630 LOGE("failed to alloc tsurf info");
634 tsurf = tbm_surface_internal_create_with_bos(&sinfo, bo, bo_num);
636 LOGE("failed to create tbm surface");
640 tsurf_data->key = key[0];
641 tsurf_data->tsurf = tsurf;
642 g_mutex_lock(&cb_info->data_mutex);
643 cb_info->tsurf_list = g_list_append(cb_info->tsurf_list, tsurf_data);
644 LOGD("key %d is added to the pool", key[0]);
645 if (cb_info->video_frame_pool_size < g_list_length(cb_info->tsurf_list)) {
646 LOGE("need to check the pool size: %d < %d", cb_info->video_frame_pool_size, g_list_length(cb_info->tsurf_list));
648 g_mutex_unlock(&cb_info->data_mutex);
650 if (tsurf_data->tsurf) {
651 tsurf = tsurf_data->tsurf;
653 LOGE("tsurf_data->tsurf is null (never enter here)");
658 /* check media packet format */
659 if (cb_info->pkt_fmt) {
660 int pkt_fmt_width = 0;
661 int pkt_fmt_height = 0;
662 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
664 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
665 if (pkt_fmt_mimetype != mimetype || pkt_fmt_width != sinfo.width || pkt_fmt_height != sinfo.height) {
666 LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d", pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, sinfo.width, sinfo.height);
667 media_format_unref(cb_info->pkt_fmt);
668 cb_info->pkt_fmt = NULL;
674 /* create packet format */
676 LOGI("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, sinfo.width, sinfo.height);
677 ret = media_format_create(&cb_info->pkt_fmt);
678 if (ret == MEDIA_FORMAT_ERROR_NONE) {
679 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
680 ret |= media_format_set_video_width(cb_info->pkt_fmt, sinfo.width);
681 ret |= media_format_set_video_height(cb_info->pkt_fmt, sinfo.height);
682 LOGI("media_format_set_video_mime,width,height ret : 0x%x", ret);
684 LOGE("media_format_create failed");
688 fin_data = g_new(_media_pkt_fin_data, 1);
690 LOGE("failed to alloc fin_data");
693 fin_data->remote_pkt = packet;
694 fin_data->cb_info = cb_info;
695 fin_data->fd = cb_info->fd;
696 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt, tsurf, (media_packet_finalize_cb) _player_media_packet_finalize, (void *)fin_data, &pkt);
697 if (ret != MEDIA_PACKET_ERROR_NONE || !pkt) {
698 LOGE("media_packet_create_from_tbm_surface failed %d %p", ret, pkt);
702 /* keep the media packet to avoid mem leak. */
703 g_mutex_lock(&cb_info->data_mutex);
704 cb_info->packet_list = g_list_append(cb_info->packet_list, pkt);
705 g_mutex_unlock(&cb_info->data_mutex);
708 ret = media_packet_set_pts(pkt, (uint64_t) pts);
709 if (ret != MEDIA_PACKET_ERROR_NONE)
710 LOGE("media_packet_set_pts failed");
712 if (cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
713 /* call media packet callback */
714 ((player_media_packet_video_decoded_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) (pkt, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]);
716 LOGE("_video_decoded_cb is not set");
717 media_packet_destroy(pkt);
720 for (i = 0; i < bo_num; i++) {
728 media_packet_destroy(pkt);
733 for (i = 0; i < bo_num; i++) {
738 player_msg_send1_no_return(MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB, cb_info->fd, POINTER, packet);
742 static void __audio_frame_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
745 tbm_bo_handle thandle;
747 player_audio_raw_data_s audio;
749 if (!player_msg_get(key, recvMsg)) {
750 LOGE("failed to get value from msg.");
754 bo = tbm_bo_import(cb_info->bufmgr, key);
756 LOGE("TBM get error : bo is NULL, key:%d", key);
760 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE | TBM_OPTION_READ);
761 if (thandle.ptr == NULL) {
762 LOGE("TBM get error : handle pointer is NULL");
766 memcpy(&audio, thandle.ptr, sizeof(player_audio_raw_data_s));
767 audio.data = thandle.ptr + sizeof(player_audio_raw_data_s);
769 LOGD("user callback data %p, size %d", audio.data, audio.size);
770 ((player_audio_pcm_extraction_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME]) (&audio, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME]);
779 LOGD("send msg to release buffer. key:%d", key);
780 player_msg_send1_no_return(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, INT, key);
784 static void __video_frame_render_error_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
788 static void __pd_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
791 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_PD;
793 if (player_msg_get(type, recvMsg))
794 ((player_pd_message_cb) cb_info->user_cb[ev]) (type, cb_info->user_data[ev]);
797 static void __supported_audio_effect_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
801 static void __supported_audio_effect_freset_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
805 static void __missed_plugin_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
809 static void __media_stream_video_buffer_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
811 /* player_media_stream_buffer_status_e status; */
814 if (player_msg_get(status, recvMsg)) {
815 ((player_media_stream_buffer_status_cb)
816 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS]) ((player_media_stream_buffer_status_e) status, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS]);
820 static void __media_stream_audio_buffer_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
822 /* player_media_stream_buffer_status_e status; */
825 if (player_msg_get(status, recvMsg)) {
826 ((player_media_stream_buffer_status_cb)
827 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS])
828 ((player_media_stream_buffer_status_e) status, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS]);
833 static void __media_stream_video_buffer_cb_handler_ex(callback_cb_info_s * cb_info, char *recvMsg)
835 /* player_media_stream_buffer_status_e status; */
837 unsigned long long bytes;
840 player_msg_get2(recvMsg, status, INT, bytes, INT64, ret);
842 ((player_media_stream_buffer_status_cb_ex)
843 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO])
844 ((player_media_stream_buffer_status_e) status, bytes, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO]);
848 static void __media_stream_audio_buffer_cb_handler_ex(callback_cb_info_s * cb_info, char *recvMsg)
850 /* player_media_stream_buffer_status_e status; */
852 unsigned long long bytes;
855 player_msg_get2(recvMsg, status, INT, bytes, INT64, ret);
857 ((player_media_stream_buffer_status_cb_ex)
858 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO])
859 ((player_media_stream_buffer_status_e) status, bytes, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO]);
864 static void __media_stream_video_seek_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
866 unsigned long long offset;
868 if (player_msg_get_type(offset, recvMsg, INT64)) {
869 ((player_media_stream_seek_cb)
870 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK])
871 (offset, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK]);
875 static void __media_stream_audio_seek_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
877 unsigned long long offset;
879 if (player_msg_get_type(offset, recvMsg, INT64)) {
880 ((player_media_stream_seek_cb)
881 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK])
882 (offset, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK]);
886 static void __video_stream_changed_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
894 player_msg_get4(recvMsg, width, INT, height, INT, fps, INT, bit_rate, INT, ret_val);
896 ((player_video_stream_changed_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED])
897 (width, height, fps, bit_rate, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED]);
901 static void (*_user_callbacks[MUSE_PLAYER_EVENT_TYPE_NUM]) (callback_cb_info_s * cb_info, char *recvMsg) = {
902 __prepare_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
903 __complete_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_COMPLETE */
904 __interrupt_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_INTERRUPT */
905 __error_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_ERROR */
906 __buffering_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_BUFFERING */
907 __subtitle_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SUBTITLE */
908 __capture_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_CAPTURE */
909 __seek_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SEEK */
910 __media_packet_video_frame_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME */
911 __audio_frame_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME */
912 __video_frame_render_error_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
913 __pd_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_PD */
914 __supported_audio_effect_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT */
915 __supported_audio_effect_freset_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET */
916 __missed_plugin_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN */
917 #ifdef _PLAYER_FOR_PRODUCT
918 NULL, /* MUSE_PLAYER_EVENT_TYPE_IMAGE_BUFFER */
919 NULL, /* MUSE_PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE */
921 __media_stream_video_buffer_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS */
922 __media_stream_audio_buffer_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS */
923 __media_stream_video_buffer_cb_handler_ex, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO */
924 __media_stream_audio_buffer_cb_handler_ex, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO */
925 __media_stream_video_seek_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK */
926 __media_stream_audio_seek_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK */
927 NULL, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED */
928 __video_stream_changed_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED */
931 static void _player_event_job_function(_player_cb_data * data)
933 muse_player_event_e ev = data->int_data;
934 if (data->cb_info->user_cb[ev])
935 _user_callbacks[ev] (data->cb_info, data->buf);
937 LOGW("user callback is unset. type : %d", ev);
943 static void *_player_event_queue_loop(void *param)
946 LOGE("NULL parameter");
949 callback_cb_info_s *cb_info = param;
950 player_event_queue *ev = &cb_info->event_queue;
951 _player_cb_data *event_data;
953 g_mutex_lock(&ev->mutex);
954 while (ev->running) {
955 g_mutex_lock(&ev->qlock);
956 if (g_queue_is_empty(ev->queue)) {
957 g_mutex_unlock(&ev->qlock);
958 g_cond_wait(&ev->cond, &ev->mutex);
962 g_mutex_unlock(&ev->qlock);
965 g_mutex_lock(&ev->qlock);
966 event_data = (_player_cb_data *) g_queue_pop_head(ev->queue);
967 g_mutex_unlock(&ev->qlock);
969 _player_event_job_function(event_data);
974 g_mutex_unlock(&ev->mutex);
975 LOGI("Exit event loop");
979 static gboolean _player_event_queue_new(callback_cb_info_s * cb_info)
981 g_return_val_if_fail(cb_info, FALSE);
982 player_event_queue *ev = &cb_info->event_queue;
984 ev->queue = g_queue_new();
985 g_return_val_if_fail(ev->queue, FALSE);
986 g_mutex_init(&ev->qlock);
988 g_mutex_init(&ev->mutex);
989 g_cond_init(&ev->cond);
991 ev->thread = g_thread_new("cb_event_thread", _player_event_queue_loop, (gpointer) cb_info);
992 g_return_val_if_fail(ev->thread, FALSE);
993 LOGI("event queue thread %p", ev->thread);
999 static void _player_event_queue_destroy(callback_cb_info_s * cb_info)
1001 g_return_if_fail(cb_info);
1002 player_event_queue *ev = &cb_info->event_queue;
1003 _player_cb_data *event_data;
1005 LOGI("event queue thread %p", ev->thread);
1007 g_mutex_lock(&ev->mutex);
1008 ev->running = FALSE;
1009 g_cond_broadcast(&ev->cond);
1010 g_mutex_unlock(&ev->mutex);
1012 g_thread_join(ev->thread);
1013 g_thread_unref(ev->thread);
1015 while (!g_queue_is_empty(ev->queue)) {
1016 event_data = (_player_cb_data *) g_queue_pop_head(ev->queue);
1018 g_free(event_data->buf);
1022 g_queue_free(ev->queue);
1023 g_mutex_clear(&ev->qlock);
1024 g_mutex_clear(&ev->mutex);
1025 g_cond_clear(&ev->cond);
1029 static void _player_event_queue_remove(player_event_queue * ev_queue, int ev)
1033 g_mutex_lock(&ev_queue->qlock);
1035 item = g_queue_peek_head_link(ev_queue->queue);
1037 GList *next = item->next;
1038 _player_cb_data *cb_data = (_player_cb_data *)item->data;
1040 if (cb_data && cb_data->int_data == ev) {
1041 LOGD("removing '%p (ev:%d)' from event queue", cb_data, cb_data->int_data);
1042 g_free(cb_data->buf);
1045 g_queue_delete_link(ev_queue->queue, item);
1049 g_mutex_unlock(&ev_queue->qlock);
1052 static void _player_event_queue_add(player_event_queue * ev, _player_cb_data * data)
1055 g_mutex_lock(&ev->qlock);
1056 g_queue_push_tail(ev->queue, (gpointer) data);
1057 g_mutex_unlock(&ev->qlock);
1058 g_cond_signal(&ev->cond);
1062 static void _user_callback_handler(callback_cb_info_s * cb_info, muse_player_event_e event, char *buffer)
1064 LOGD("get event %d", event);
1066 if (event < MUSE_PLAYER_EVENT_TYPE_NUM) {
1067 if (cb_info->user_cb[event] && _user_callbacks[event]) {
1068 _player_cb_data *data = NULL;
1069 data = g_new(_player_cb_data, 1);
1071 LOGE("fail to alloc mem");
1074 data->int_data = (int)event;
1075 data->cb_info = cb_info;
1077 _player_event_queue_add(&cb_info->event_queue, data);
1082 static void _add_ret_msg(muse_player_api_e api, callback_cb_info_s * cb_info, int offset, int parse_len)
1084 ret_msg_s *msg = NULL;
1085 ret_msg_s *last = cb_info->buff.retMsgHead;
1087 msg = g_new(ret_msg_s, 1);
1090 msg->msg = strndup(cb_info->buff.recvMsg + offset, parse_len);
1093 cb_info->buff.retMsgHead = msg;
1100 LOGE("g_new failure");
1103 static ret_msg_s *_get_ret_msg(muse_player_api_e api, callback_cb_info_s * cb_info)
1105 ret_msg_s *msg = cb_info->buff.retMsgHead;
1106 ret_msg_s *prev = NULL;
1108 if (msg->api == api) {
1110 cb_info->buff.retMsgHead = msg->next;
1112 prev->next = msg->next;
1121 static void _notify_disconnected(callback_cb_info_s * cb_info)
1123 int code = PLAYER_ERROR_SERVICE_DISCONNECTED;
1124 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR;
1125 if (!cb_info || !cb_info->user_cb[ev])
1127 ((player_error_cb) cb_info->user_cb[ev]) (code, cb_info->user_data[ev]);
1130 static void *client_cb_handler(gpointer data)
1136 callback_cb_info_s *cb_info = data;
1137 char *recvMsg = NULL;
1138 muse_core_msg_parse_err_e err;
1140 while (g_atomic_int_get(&cb_info->running)) {
1142 err = MUSE_MSG_PARSE_ERROR_NONE;
1144 len = player_recv_msg(cb_info);
1148 recvMsg = cb_info->buff.recvMsg;
1149 recvMsg[len] = '\0';
1153 while (offset < len) {
1154 api = MUSE_PLAYER_API_MAX;
1155 // LOGD(">>>>>> [%d/%d] %p, %s", offset, len, recvMsg + offset, recvMsg + offset);
1158 void *jobj = muse_core_msg_json_object_new(recvMsg + offset, &parse_len, &err);
1160 if (muse_core_msg_json_object_get_value("api", jobj, &api, MUSE_TYPE_INT)) {
1161 if (api < MUSE_PLAYER_API_MAX) {
1162 g_mutex_lock(&cb_info->player_mutex);
1163 cb_info->buff.recved++;
1164 _add_ret_msg(api, cb_info, offset, parse_len);
1165 g_cond_signal(&cb_info->player_cond[api]);
1166 g_mutex_unlock(&cb_info->player_mutex);
1167 if (api == MUSE_PLAYER_API_DESTROY)
1168 g_atomic_int_set(&cb_info->running, 0);
1169 } else if (api == MUSE_PLAYER_CB_EVENT) {
1172 g_mutex_lock(&cb_info->player_mutex);
1173 buffer = strndup(recvMsg + offset, parse_len);
1174 g_mutex_unlock(&cb_info->player_mutex);
1175 if (muse_core_msg_json_object_get_value("event", jobj, &event, MUSE_TYPE_INT))
1176 _user_callback_handler(cb_info, event, buffer);
1179 LOGE("Failed to get value. offset:%d/%d, [msg][ %s ]", offset, len, (recvMsg+offset));
1181 muse_core_msg_json_object_free(jobj);
1183 LOGE("Failed to get msg obj. err:%d", err);
1186 if (parse_len == 0 || err != MUSE_MSG_PARSE_ERROR_NONE)
1189 offset += parse_len;
1190 parse_len = len - offset;
1193 if (g_atomic_int_get(&cb_info->running))
1194 _notify_disconnected(cb_info);
1195 LOGD("client cb exit");
1200 static callback_cb_info_s *callback_new(gint sockfd)
1202 callback_cb_info_s *cb_info;
1206 g_return_val_if_fail(sockfd > 0, NULL);
1208 cb_info = g_new(callback_cb_info_s, 1);
1209 memset(cb_info, 0, sizeof(callback_cb_info_s));
1211 g_mutex_init(&cb_info->player_mutex);
1212 for (i = 0; i < MUSE_PLAYER_API_MAX; i++)
1213 g_cond_init(&cb_info->player_cond[i]);
1215 g_mutex_init(&cb_info->data_mutex);
1216 g_mutex_init(&cb_info->seek_cb_mutex);
1218 buff = &cb_info->buff;
1219 buff->recvMsg = g_new(char, MUSE_MSG_MAX_LENGTH + 1);
1220 buff->bufLen = MUSE_MSG_MAX_LENGTH + 1;
1222 buff->retMsgHead = NULL;
1223 buff->part_of_msg = NULL;
1225 g_atomic_int_set(&cb_info->running, 1);
1226 cb_info->fd = sockfd;
1227 cb_info->thread = g_thread_new("callback_thread", client_cb_handler, (gpointer) cb_info);
1232 static void callback_destroy(callback_cb_info_s * cb_info)
1235 g_return_if_fail(cb_info);
1237 if (cb_info->fd > INVALID_SOCKET)
1238 muse_core_connection_close(cb_info->fd);
1239 if (cb_info->data_fd > INVALID_SOCKET)
1240 muse_core_connection_close(cb_info->data_fd);
1241 cb_info->fd = cb_info->data_fd = INVALID_SOCKET;
1243 g_thread_join(cb_info->thread);
1244 g_thread_unref(cb_info->thread);
1245 cb_info->thread = NULL;
1247 LOGI("%p Callback destroyed", cb_info->thread);
1249 g_mutex_clear(&cb_info->player_mutex);
1250 for (i = 0; i < MUSE_PLAYER_API_MAX; i++)
1251 g_cond_clear(&cb_info->player_cond[i]);
1253 g_mutex_clear(&cb_info->data_mutex);
1254 g_mutex_clear(&cb_info->seek_cb_mutex);
1256 g_free(cb_info->buff.recvMsg);
1257 if (cb_info->buff.part_of_msg)
1258 g_free(cb_info->buff.part_of_msg);
1262 int client_get_api_timeout(player_cli_s * pc, muse_player_api_e api)
1267 case MUSE_PLAYER_API_PREPARE:
1268 case MUSE_PLAYER_API_PREPARE_ASYNC:
1269 case MUSE_PLAYER_API_UNPREPARE:
1270 case MUSE_PLAYER_API_START:
1271 case MUSE_PLAYER_API_STOP:
1272 case MUSE_PLAYER_API_PAUSE:
1273 timeout += SERVER_TIMEOUT(pc) * G_TIME_SPAN_MILLISECOND;
1276 /* check prepare async is done */
1277 if (pc && CALLBACK_INFO(pc) && CALLBACK_INFO(pc)->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])
1278 timeout += SERVER_TIMEOUT(pc) * G_TIME_SPAN_MILLISECOND;
1281 timeout += CALLBACK_TIME_OUT;
1282 return timeout; /* ms */
1285 int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s * cb_info, char **ret_buf, int time_out)
1287 int ret = PLAYER_ERROR_NONE;
1288 gint64 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_MILLISECOND;
1289 msg_buff_s *buff = &cb_info->buff;
1290 ret_msg_s *msg = NULL;
1292 g_mutex_lock(&cb_info->player_mutex);
1294 msg = _get_ret_msg(api, cb_info);
1295 if (!buff->recved || !msg) {
1296 if (!g_cond_wait_until(&cb_info->player_cond[api], &cb_info->player_mutex, end_time)) {
1297 LOGW("api %d return msg does not received %dms", api, time_out);
1298 g_mutex_unlock(&cb_info->player_mutex);
1299 return PLAYER_ERROR_INVALID_OPERATION;
1303 msg = _get_ret_msg(api, cb_info);
1305 *ret_buf = msg->msg;
1307 if (!player_msg_get(ret, *ret_buf))
1308 ret = PLAYER_ERROR_INVALID_OPERATION;
1310 LOGE("api %d return msg is not exist", api);
1311 ret = PLAYER_ERROR_INVALID_OPERATION;
1315 g_mutex_unlock(&cb_info->player_mutex);
1321 * Public Implementation
1324 int player_create(player_h * player)
1326 PLAYER_INSTANCE_CHECK(player);
1328 int ret = PLAYER_ERROR_NONE;
1329 int sock_fd = INVALID_SOCKET;
1332 muse_player_api_e api = MUSE_PLAYER_API_CREATE;
1333 muse_core_api_module_e module = MUSE_PLAYER;
1334 player_cli_s *pc = NULL;
1335 char *ret_buf = NULL;
1339 sock_fd = muse_core_client_new();
1340 if (sock_fd <= INVALID_SOCKET) {
1341 LOGE("connection failure %d", errno);
1342 ret = PLAYER_ERROR_INVALID_OPERATION;
1345 player_msg_create_handle(api, sock_fd, INT, module, INT, pid);
1347 pc = g_new0(player_cli_s, 1);
1349 ret = PLAYER_ERROR_OUT_OF_MEMORY;
1353 pc->cb_info = callback_new(sock_fd);
1355 LOGE("fail to create callback");
1356 ret = PLAYER_ERROR_INVALID_OPERATION;
1359 if (!_player_event_queue_new(pc->cb_info)) {
1360 LOGE("fail to create event queue");
1361 ret = PLAYER_ERROR_INVALID_OPERATION;
1365 ret = client_wait_for_cb_return(api, pc->cb_info, &ret_buf, CALLBACK_TIME_OUT);
1366 if (ret == PLAYER_ERROR_NONE) {
1367 intptr_t module_addr;
1368 *player = (player_h) pc;
1369 if (player_msg_get_type(module_addr, ret_buf, POINTER)) {
1370 pc->cb_info->data_fd = muse_core_client_new_data_ch();
1371 muse_core_send_module_addr(module_addr, pc->cb_info->data_fd);
1372 LOGD("Data channel fd %d, muse module addr %p", pc->cb_info->data_fd, module_addr);
1374 SERVER_TIMEOUT(pc) = MAX_SERVER_TIME_OUT; /* will be update after prepare phase. */
1378 pc->cb_info->bufmgr = tbm_bufmgr_init(-1);
1379 pc->push_media_stream = FALSE;
1385 if (pc && pc->cb_info) {
1386 if (pc->cb_info->event_queue.running)
1387 _player_event_queue_destroy(pc->cb_info);
1388 callback_destroy(pc->cb_info);
1393 LOGD("ret value : %d", ret);
1397 int player_destroy(player_h player)
1399 PLAYER_INSTANCE_CHECK(player);
1401 int ret = PLAYER_ERROR_NONE;
1402 muse_player_api_e api = MUSE_PLAYER_API_DESTROY;
1403 player_cli_s *pc = (player_cli_s *) player;
1404 char *ret_buf = NULL;
1408 player_msg_send(api, pc, ret_buf, ret);
1409 #ifdef EVAS_RENDERER_SUPPORT
1410 if (CALLBACK_INFO(pc) && EVAS_HANDLE(pc)) {
1411 player_unset_media_packet_video_frame_decoded_cb(player);
1412 if (mm_evas_renderer_destroy(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
1413 LOGW("fail to unset evas client");
1416 if (pc->cb_info && pc->cb_info->packet_list) {
1417 g_mutex_lock(&pc->cb_info->data_mutex);
1418 LOGW("num of remained packets : %d !!", g_list_length(pc->cb_info->packet_list));
1419 /* each media packet have to destroyed in application. */
1420 g_list_free(pc->cb_info->packet_list);
1421 pc->cb_info->packet_list = NULL;
1422 g_mutex_unlock(&pc->cb_info->data_mutex);
1425 if (_wl_window_evas_object_cb_del(player) != MM_ERROR_NONE)
1426 LOGW("fail to unset evas object callback");
1428 if (CALLBACK_INFO(pc)) {
1429 __player_remove_tsurf_list(pc);
1430 _player_event_queue_destroy(CALLBACK_INFO(pc));
1431 tbm_bufmgr_deinit(TBM_BUFMGR(pc));
1433 callback_destroy(CALLBACK_INFO(pc));
1443 int player_prepare_async(player_h player, player_prepared_cb callback, void *user_data)
1445 PLAYER_INSTANCE_CHECK(player);
1446 int ret = PLAYER_ERROR_NONE;
1447 muse_player_api_e api = MUSE_PLAYER_API_PREPARE_ASYNC;
1448 player_cli_s *pc = (player_cli_s *) player;
1449 char *ret_buf = NULL;
1453 if (pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
1454 LOGE("PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing...", PLAYER_ERROR_INVALID_OPERATION);
1455 return PLAYER_ERROR_INVALID_OPERATION;
1457 pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = callback;
1458 pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = user_data;
1460 player_msg_send(api, pc, ret_buf, ret);
1461 if (ret == PLAYER_ERROR_NONE) {
1463 player_msg_get_type(timeout, ret_buf, INT);
1465 LOGD("server timeout will be %d", timeout);
1466 SERVER_TIMEOUT(pc) = timeout;
1473 int player_prepare(player_h player)
1475 PLAYER_INSTANCE_CHECK(player);
1476 int ret = PLAYER_ERROR_NONE;
1477 muse_player_api_e api = MUSE_PLAYER_API_PREPARE;
1478 player_cli_s *pc = (player_cli_s *) player;
1479 char *ret_buf = NULL;
1483 player_msg_send(api, pc, ret_buf, ret);
1484 if (ret == PLAYER_ERROR_NONE) {
1486 player_msg_get_type(timeout, ret_buf, INT);
1488 LOGD("server timeout will be %d", timeout);
1489 SERVER_TIMEOUT(pc) = timeout;
1496 int player_unprepare(player_h player)
1498 PLAYER_INSTANCE_CHECK(player);
1499 int ret = PLAYER_ERROR_NONE;
1500 muse_player_api_e api = MUSE_PLAYER_API_UNPREPARE;
1501 player_cli_s *pc = (player_cli_s *) player;
1502 char *ret_buf = NULL;
1506 if (!CALLBACK_INFO(pc))
1507 return PLAYER_ERROR_INVALID_STATE;
1508 #ifdef EVAS_RENDERER_SUPPORT
1509 if (EVAS_HANDLE(pc)) {
1510 player_unset_media_packet_video_frame_decoded_cb(player);
1511 if (mm_evas_renderer_destroy(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
1512 LOGW("fail to unset evas client");
1515 player_msg_send(api, pc, ret_buf, ret);
1516 if (ret == PLAYER_ERROR_NONE) {
1517 set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
1518 set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE);
1520 _player_deinit_memory_buffer(pc);
1523 pc->cb_info->video_frame_pool_size = 0;
1524 __player_remove_tsurf_list(pc);
1530 int player_set_uri(player_h player, const char *uri)
1532 PLAYER_INSTANCE_CHECK(player);
1533 PLAYER_NULL_ARG_CHECK(uri);
1534 int ret = PLAYER_ERROR_NONE;
1535 muse_player_api_e api = MUSE_PLAYER_API_SET_URI;
1536 player_cli_s *pc = (player_cli_s *) player;
1537 char *ret_buf = NULL;
1541 player_msg_send1(api, pc, ret_buf, ret, STRING, uri);
1542 pc->push_media_stream = FALSE;
1548 int player_set_memory_buffer(player_h player, const void *data, int size)
1550 PLAYER_INSTANCE_CHECK(player);
1551 PLAYER_NULL_ARG_CHECK(data);
1552 int ret = PLAYER_ERROR_NONE;
1553 muse_player_api_e api = MUSE_PLAYER_API_SET_MEMORY_BUFFER;
1554 player_cli_s *pc = (player_cli_s *) player;
1555 char *ret_buf = NULL;
1557 tbm_bo_handle thandle;
1560 if (SERVER_TBM_BO(pc)) {
1561 LOGE("Already set the memory buffer. unprepare please");
1562 return PLAYER_ERROR_INVALID_OPERATION;
1565 bo = tbm_bo_alloc(pc->cb_info->bufmgr, size, TBM_BO_DEFAULT);
1567 LOGE("TBM get error : bo is NULL");
1568 return PLAYER_ERROR_INVALID_OPERATION;
1570 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
1571 if (thandle.ptr == NULL) {
1572 LOGE("TBM get error : handle pointer is NULL");
1573 ret = PLAYER_ERROR_INVALID_OPERATION;
1576 memcpy(thandle.ptr, data, size);
1579 key = tbm_bo_export(bo);
1581 LOGE("TBM get error : key is 0");
1582 ret = PLAYER_ERROR_INVALID_OPERATION;
1586 player_msg_send2(api, pc, ret_buf, ret, INT, key, INT, size);
1587 pc->push_media_stream = FALSE;
1592 if (ret == PLAYER_ERROR_NONE) {
1593 intptr_t bo_addr = 0;
1594 if (player_msg_get_type(bo_addr, ret_buf, POINTER))
1595 SERVER_TBM_BO(pc) = (intptr_t) bo_addr;
1602 static int _player_deinit_memory_buffer(player_cli_s * pc)
1604 PLAYER_INSTANCE_CHECK(pc);
1605 int ret = PLAYER_ERROR_NONE;
1606 muse_player_api_e api = MUSE_PLAYER_API_DEINIT_MEMORY_BUFFER;
1607 intptr_t bo_addr = SERVER_TBM_BO(pc);
1612 player_msg_send1_async(api, pc, POINTER, bo_addr);
1614 SERVER_TBM_BO(pc) = 0;
1619 int player_get_state(player_h player, player_state_e * pstate)
1621 PLAYER_INSTANCE_CHECK(player);
1622 PLAYER_NULL_ARG_CHECK(pstate);
1623 int ret = PLAYER_ERROR_NONE;
1624 muse_player_api_e api = MUSE_PLAYER_API_GET_STATE;
1625 player_cli_s *pc = (player_cli_s *) player;
1627 char *ret_buf = NULL;
1631 player_msg_send(api, pc, ret_buf, ret);
1633 if (ret == PLAYER_ERROR_NONE) {
1634 player_msg_get(state, ret_buf);
1642 int player_set_volume(player_h player, float left, float right)
1644 PLAYER_INSTANCE_CHECK(player);
1645 PLAYER_CHECK_CONDITION(left >= 0 && left <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1646 PLAYER_CHECK_CONDITION(right >= 0 && right <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1647 int ret = PLAYER_ERROR_NONE;
1648 muse_player_api_e api = MUSE_PLAYER_API_SET_VOLUME;
1649 player_cli_s *pc = (player_cli_s *) player;
1650 char *ret_buf = NULL;
1654 player_msg_send2(api, pc, ret_buf, ret, DOUBLE, right, DOUBLE, left);
1659 int player_get_volume(player_h player, float *pleft, float *pright)
1661 PLAYER_INSTANCE_CHECK(player);
1662 PLAYER_NULL_ARG_CHECK(pleft);
1663 PLAYER_NULL_ARG_CHECK(pright);
1664 int ret = PLAYER_ERROR_NONE;
1665 muse_player_api_e api = MUSE_PLAYER_API_GET_VOLUME;
1666 player_cli_s *pc = (player_cli_s *) player;
1669 char *ret_buf = NULL;
1673 player_msg_send(api, pc, ret_buf, ret);
1675 if (ret == PLAYER_ERROR_NONE) {
1676 bool ret_val = TRUE;
1677 player_msg_get2(ret_buf, left, DOUBLE, right, DOUBLE, ret_val);
1679 *pleft = (float)left;
1680 *pright = (float)right;
1682 LOGE("failed to get value from msg");
1683 ret = PLAYER_ERROR_INVALID_OPERATION;
1691 int player_set_sound_type(player_h player, sound_type_e type)
1693 PLAYER_INSTANCE_CHECK(player);
1694 int ret = PLAYER_ERROR_NONE;
1695 muse_player_api_e api = MUSE_PLAYER_API_SET_SOUND_TYPE;
1696 player_cli_s *pc = (player_cli_s *) player;
1697 char *ret_buf = NULL;
1701 player_msg_send1(api, pc, ret_buf, ret, INT, type);
1706 int player_set_audio_policy_info(player_h player, sound_stream_info_h stream_info)
1708 PLAYER_INSTANCE_CHECK(player);
1710 muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_POLICY_INFO;
1711 player_cli_s *pc = (player_cli_s *) player;
1712 char *ret_buf = NULL;
1716 bool is_available = false;
1718 /* check if stream_info is valid */
1719 int ret = __player_convert_error_code(
1720 sound_manager_is_available_stream_information(
1721 stream_info, NATIVE_API_PLAYER, &is_available), (char *)__FUNCTION__);
1723 if (ret == PLAYER_ERROR_NONE) {
1724 if (is_available == false)
1725 ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
1727 char *stream_type = NULL;
1728 int stream_index = 0;
1729 ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
1730 ret = sound_manager_get_index_from_stream_information(stream_info, &stream_index);
1731 if (ret == SOUND_MANAGER_ERROR_NONE)
1732 player_msg_send2(api, pc, ret_buf, ret, STRING, stream_type, INT, stream_index);
1734 ret = PLAYER_ERROR_INVALID_OPERATION;
1743 int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode)
1745 PLAYER_INSTANCE_CHECK(player);
1746 int ret = PLAYER_ERROR_NONE;
1747 muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE;
1748 player_cli_s *pc = (player_cli_s *) player;
1749 char *ret_buf = NULL;
1753 player_msg_send1(api, pc, ret_buf, ret, INT, latency_mode);
1758 int player_get_audio_latency_mode(player_h player, audio_latency_mode_e * platency_mode)
1760 PLAYER_INSTANCE_CHECK(player);
1761 PLAYER_NULL_ARG_CHECK(platency_mode);
1762 int ret = PLAYER_ERROR_NONE;
1763 muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE;
1764 player_cli_s *pc = (player_cli_s *) player;
1765 char *ret_buf = NULL;
1766 int latency_mode = -1;
1770 player_msg_send(api, pc, ret_buf, ret);
1772 if (ret == PLAYER_ERROR_NONE) {
1773 player_msg_get(latency_mode, ret_buf);
1774 *platency_mode = latency_mode;
1782 int player_start(player_h player)
1784 PLAYER_INSTANCE_CHECK(player);
1785 int ret = PLAYER_ERROR_NONE;
1786 muse_player_api_e api = MUSE_PLAYER_API_START;
1787 player_cli_s *pc = (player_cli_s *) player;
1788 char *ret_buf = NULL;
1791 #ifdef EVAS_RENDERER_SUPPORT
1792 if (EVAS_HANDLE(pc)) {
1793 ret = mm_evas_renderer_update_param(EVAS_HANDLE(pc));
1794 if (ret != PLAYER_ERROR_NONE)
1798 player_msg_send(api, pc, ret_buf, ret);
1804 int player_stop(player_h player)
1806 PLAYER_INSTANCE_CHECK(player);
1807 int ret = PLAYER_ERROR_NONE;
1808 muse_player_api_e api = MUSE_PLAYER_API_STOP;
1809 player_cli_s *pc = (player_cli_s *) player;
1810 char *ret_buf = NULL;
1814 player_msg_send(api, pc, ret_buf, ret);
1815 if (ret == PLAYER_ERROR_NONE)
1816 set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
1822 int player_pause(player_h player)
1824 PLAYER_INSTANCE_CHECK(player);
1825 int ret = PLAYER_ERROR_NONE;
1826 muse_player_api_e api = MUSE_PLAYER_API_PAUSE;
1827 player_cli_s *pc = (player_cli_s *) player;
1828 char *ret_buf = NULL;
1832 player_msg_send(api, pc, ret_buf, ret);
1837 int player_set_play_position(player_h player, int millisecond, bool accurate, player_seek_completed_cb callback, void *user_data)
1839 PLAYER_INSTANCE_CHECK(player);
1840 PLAYER_CHECK_CONDITION(millisecond >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1842 int ret = PLAYER_ERROR_NONE;
1843 muse_player_api_e api = MUSE_PLAYER_API_SET_PLAY_POSITION;
1844 player_cli_s *pc = (player_cli_s *) player;
1845 char *ret_buf = NULL;
1846 int pos = millisecond;
1850 LOGE("cb_info is null");
1851 return PLAYER_ERROR_INVALID_OPERATION;
1854 if ((pc->push_media_stream == FALSE) &&
1855 (pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK])) {
1856 LOGE("PLAYER_ERROR_SEEK_FAILED (0x%08x) : seeking...", PLAYER_ERROR_SEEK_FAILED);
1857 return PLAYER_ERROR_SEEK_FAILED;
1859 g_mutex_lock(&pc->cb_info->seek_cb_mutex);
1860 if (pc->push_media_stream == TRUE) {
1861 pc->cb_info->block_seek_cb = TRUE;
1863 LOGI("Event type : %d, pos : %d ", MUSE_PLAYER_EVENT_TYPE_SEEK, millisecond);
1864 pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback;
1865 pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data;
1866 g_mutex_unlock(&pc->cb_info->seek_cb_mutex);
1869 player_msg_send2(api, pc, ret_buf, ret, INT, pos, INT, accurate);
1871 if (ret != PLAYER_ERROR_NONE) {
1872 g_mutex_lock(&pc->cb_info->seek_cb_mutex);
1873 set_null_user_cb(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
1874 g_mutex_unlock(&pc->cb_info->seek_cb_mutex);
1877 if (pc->push_media_stream == TRUE) {
1878 _player_event_queue_remove(&pc->cb_info->event_queue, MUSE_PLAYER_EVENT_TYPE_SEEK);
1881 pc->cb_info->block_seek_cb = FALSE;
1886 int player_get_play_position(player_h player, int *millisecond)
1888 PLAYER_INSTANCE_CHECK(player);
1889 PLAYER_NULL_ARG_CHECK(millisecond);
1891 int ret = PLAYER_ERROR_NONE;
1892 muse_player_api_e api = MUSE_PLAYER_API_GET_PLAY_POSITION;
1893 player_cli_s *pc = (player_cli_s *) player;
1895 char *ret_buf = NULL;
1899 player_msg_send(api, pc, ret_buf, ret);
1901 if (ret == PLAYER_ERROR_NONE) {
1902 player_msg_get(pos, ret_buf);
1910 int player_set_mute(player_h player, bool muted)
1912 PLAYER_INSTANCE_CHECK(player);
1913 int ret = PLAYER_ERROR_NONE;
1914 muse_player_api_e api = MUSE_PLAYER_API_SET_MUTE;
1915 player_cli_s *pc = (player_cli_s *) player;
1916 char *ret_buf = NULL;
1917 int mute = (int)muted;
1921 player_msg_send1(api, pc, ret_buf, ret, INT, mute);
1926 int player_is_muted(player_h player, bool * muted)
1928 PLAYER_INSTANCE_CHECK(player);
1929 PLAYER_NULL_ARG_CHECK(muted);
1930 int ret = PLAYER_ERROR_NONE;
1931 muse_player_api_e api = MUSE_PLAYER_API_IS_MUTED;
1932 player_cli_s *pc = (player_cli_s *) player;
1933 char *ret_buf = NULL;
1938 player_msg_send(api, pc, ret_buf, ret);
1939 if (ret == PLAYER_ERROR_NONE) {
1940 player_msg_get(mute, ret_buf);
1941 *muted = (bool) mute;
1948 int player_set_looping(player_h player, bool looping)
1950 PLAYER_INSTANCE_CHECK(player);
1951 int ret = PLAYER_ERROR_NONE;
1952 muse_player_api_e api = MUSE_PLAYER_API_SET_LOOPING;
1953 player_cli_s *pc = (player_cli_s *) player;
1954 char *ret_buf = NULL;
1958 player_msg_send1(api, pc, ret_buf, ret, INT, looping);
1963 int player_is_looping(player_h player, bool * plooping)
1965 PLAYER_INSTANCE_CHECK(player);
1966 PLAYER_NULL_ARG_CHECK(plooping);
1967 int ret = PLAYER_ERROR_NONE;
1968 muse_player_api_e api = MUSE_PLAYER_API_IS_LOOPING;
1969 player_cli_s *pc = (player_cli_s *) player;
1970 char *ret_buf = NULL;
1975 player_msg_send(api, pc, ret_buf, ret);
1976 if (ret == PLAYER_ERROR_NONE) {
1977 player_msg_get(looping, ret_buf);
1978 *plooping = looping;
1984 int player_get_duration(player_h player, int *pduration)
1986 PLAYER_INSTANCE_CHECK(player);
1987 PLAYER_NULL_ARG_CHECK(pduration);
1988 int ret = PLAYER_ERROR_NONE;
1989 muse_player_api_e api = MUSE_PLAYER_API_GET_DURATION;
1990 player_cli_s *pc = (player_cli_s *) player;
1991 char *ret_buf = NULL;
1996 player_msg_send(api, pc, ret_buf, ret);
1997 if (ret == PLAYER_ERROR_NONE) {
1998 player_msg_get(duration, ret_buf);
1999 *pduration = duration;
2006 int player_set_display(player_h player, player_display_type_e type, player_display_h display)
2008 PLAYER_INSTANCE_CHECK(player);
2009 int ret = PLAYER_ERROR_NONE;
2010 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY;
2011 player_cli_s *pc = (player_cli_s *) player;
2012 char *ret_buf = NULL;
2013 Evas_Object *obj = NULL;
2014 const char *object_type = NULL;
2015 wl_win_msg_type wl_win;
2016 char *wl_win_msg = (char *)&wl_win;
2017 unsigned int wl_surface_id;
2018 struct wl_surface *wl_surface;
2019 struct wl_display *wl_display;
2020 Ecore_Wl_Window *wl_window = NULL;
2025 if (type != PLAYER_DISPLAY_TYPE_NONE) {
2026 obj = (Evas_Object *) display;
2028 return PLAYER_ERROR_INVALID_PARAMETER;
2030 object_type = evas_object_type_get(obj);
2032 if (type == PLAYER_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2033 /* wayland overlay surface */
2034 LOGI("Wayland overlay surface type");
2037 e = evas_object_evas_get(obj);
2038 return_val_if_fail(e != NULL, PLAYER_ERROR_INVALID_OPERATION);
2040 ret = _wl_window_geometry_get(obj, e, &wl_win.wl_window_x, &wl_win.wl_window_y,
2041 &wl_win.wl_window_width, &wl_win.wl_window_height);
2042 if (ret != MM_ERROR_NONE) {
2043 LOGE("Fail to get window geometry");
2046 if (_wl_window_evas_object_cb_add(player, obj) != MM_ERROR_NONE) {
2047 LOGW("fail to set evas object callback");
2050 wl_window = elm_win_wl_window_get(obj);
2051 return_val_if_fail(wl_window != NULL, PLAYER_ERROR_INVALID_OPERATION);
2053 wl_surface = (struct wl_surface *)ecore_wl_window_surface_get(wl_window);
2054 return_val_if_fail(wl_surface != NULL, PLAYER_ERROR_INVALID_OPERATION);
2056 /* get wl_display */
2057 wl_display = (struct wl_display *)ecore_wl_display_get();
2058 return_val_if_fail(wl_display != NULL, PLAYER_ERROR_INVALID_OPERATION);
2060 LOGD("surface = %p, wl_display = %p", wl_surface, wl_display);
2062 ret = _wl_client_create(&pc->wlclient);
2063 if (ret != MM_ERROR_NONE) {
2064 LOGE("Wayland client create failure");
2068 wl_surface_id = _wl_client_get_wl_window_wl_surface_id(pc->wlclient, wl_surface, wl_display);
2069 LOGD("wl_surface_id = %d", wl_surface_id);
2071 /* need to free always */
2073 g_free(pc->wlclient);
2074 pc->wlclient = NULL;
2076 return_val_if_fail(wl_surface_id > 0, PLAYER_ERROR_INVALID_OPERATION);
2077 wl_win.wl_surface_id = wl_surface_id;
2080 #ifdef EVAS_RENDERER_SUPPORT
2081 else if (type == PLAYER_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2082 /* evas object surface */
2083 LOGI("evas surface type");
2086 evas_object_geometry_get(obj, &wl_win.wl_window_x, &wl_win.wl_window_y,
2087 &wl_win.wl_window_width, &wl_win.wl_window_height);
2089 if (EVAS_HANDLE(pc)) {
2090 LOGW("evas client already exists");
2091 if (mm_evas_renderer_destroy(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
2092 LOGW("fail to unset evas client");
2094 if (mm_evas_renderer_create(&EVAS_HANDLE(pc), obj) != MM_ERROR_NONE) {
2095 LOGW("fail to set evas client");
2097 if (player_set_media_packet_video_frame_decoded_cb(player, mm_evas_renderer_write, (void *)EVAS_HANDLE(pc)) != PLAYER_ERROR_NONE) {
2098 LOGW("fail to set decoded callback");
2103 return PLAYER_ERROR_INVALID_PARAMETER;
2105 return PLAYER_ERROR_INVALID_PARAMETER;
2106 } else { /* PLAYER_DISPLAY_TYPE_NONE */
2107 LOGI("Wayland surface type is NONE");
2109 wl_win.wl_window_x = 0;
2110 wl_win.wl_window_y = 0;
2111 wl_win.wl_window_width = 0;
2112 wl_win.wl_window_height = 0;
2114 player_msg_send_array(api, pc, ret_buf, ret, wl_win_msg, sizeof(wl_win_msg_type), sizeof(char));
2119 int player_set_display_mode(player_h player, player_display_mode_e mode)
2121 PLAYER_INSTANCE_CHECK(player);
2122 PLAYER_CHECK_CONDITION(PLAYER_DISPLAY_MODE_LETTER_BOX <= mode && mode < PLAYER_DISPLAY_MODE_NUM, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2123 int ret = PLAYER_ERROR_NONE;
2124 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_MODE;
2125 player_cli_s *pc = (player_cli_s *) player;
2126 char *ret_buf = NULL;
2129 #ifdef EVAS_RENDERER_SUPPORT
2130 if (EVAS_HANDLE(pc)) {
2131 ret = mm_evas_renderer_set_geometry(EVAS_HANDLE(pc), mode);
2135 player_msg_send1(api, pc, ret_buf, ret, INT, mode);
2140 int player_get_display_mode(player_h player, player_display_mode_e * pmode)
2142 PLAYER_INSTANCE_CHECK(player);
2143 PLAYER_NULL_ARG_CHECK(pmode);
2144 int ret = PLAYER_ERROR_NONE;
2145 muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_MODE;
2146 player_cli_s *pc = (player_cli_s *) player;
2147 char *ret_buf = NULL;
2151 #ifdef EVAS_RENDERER_SUPPORT
2152 if (EVAS_HANDLE(pc)) {
2153 ret = mm_evas_renderer_get_geometry(EVAS_HANDLE(pc), &mode);
2154 *pmode = (player_display_mode_e) mode;
2158 player_msg_send(api, pc, ret_buf, ret);
2159 if (ret == PLAYER_ERROR_NONE) {
2160 player_msg_get_type(mode, ret_buf, INT);
2168 int player_set_playback_rate(player_h player, float rate)
2170 PLAYER_INSTANCE_CHECK(player);
2171 PLAYER_CHECK_CONDITION(rate >= -5.0 && rate <= 5.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2172 int ret = PLAYER_ERROR_NONE;
2173 muse_player_api_e api = MUSE_PLAYER_API_SET_PLAYBACK_RATE;
2174 player_cli_s *pc = (player_cli_s *) player;
2175 char *ret_buf = NULL;
2179 player_msg_send1(api, pc, ret_buf, ret, DOUBLE, rate);
2184 int player_set_display_rotation(player_h player, player_display_rotation_e rotation)
2186 PLAYER_INSTANCE_CHECK(player);
2187 int ret = PLAYER_ERROR_NONE;
2188 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROTATION;
2189 player_cli_s *pc = (player_cli_s *) player;
2190 char *ret_buf = NULL;
2193 #ifdef EVAS_RENDERER_SUPPORT
2194 if (EVAS_HANDLE(pc)) {
2195 ret = mm_evas_renderer_set_rotation(EVAS_HANDLE(pc), rotation);
2199 player_msg_send1(api, pc, ret_buf, ret, INT, rotation);
2204 int player_get_display_rotation(player_h player, player_display_rotation_e * protation)
2206 PLAYER_INSTANCE_CHECK(player);
2207 PLAYER_NULL_ARG_CHECK(protation);
2208 int ret = PLAYER_ERROR_NONE;
2209 player_cli_s *pc = (player_cli_s *) player;
2210 muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_ROTATION;
2211 char *ret_buf = NULL;
2215 #ifdef EVAS_RENDERER_SUPPORT
2216 if (EVAS_HANDLE(pc)) {
2217 ret = mm_evas_renderer_get_rotation(EVAS_HANDLE(pc), &rotation);
2218 *protation = (player_display_rotation_e) rotation;
2222 player_msg_send(api, pc, ret_buf, ret);
2223 if (ret == PLAYER_ERROR_NONE) {
2224 player_msg_get_type(rotation, ret_buf, INT);
2225 *protation = rotation;
2232 int player_set_display_visible(player_h player, bool visible)
2234 PLAYER_INSTANCE_CHECK(player);
2235 int ret = PLAYER_ERROR_NONE;
2236 player_cli_s *pc = (player_cli_s *) player;
2237 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_VISIBLE;
2238 char *ret_buf = NULL;
2241 #ifdef EVAS_RENDERER_SUPPORT
2242 if (EVAS_HANDLE(pc)) {
2243 ret = mm_evas_renderer_set_visible(EVAS_HANDLE(pc), visible);
2247 player_msg_send1(api, pc, ret_buf, ret, INT, visible);
2252 int player_is_display_visible(player_h player, bool * pvisible)
2254 PLAYER_INSTANCE_CHECK(player);
2255 PLAYER_NULL_ARG_CHECK(pvisible);
2256 int ret = PLAYER_ERROR_NONE;
2257 player_cli_s *pc = (player_cli_s *) player;
2258 muse_player_api_e api = MUSE_PLAYER_API_IS_DISPLAY_VISIBLE;
2259 char *ret_buf = NULL;
2261 #ifdef EVAS_RENDERER_SUPPORT
2265 #ifdef EVAS_RENDERER_SUPPORT
2266 if (EVAS_HANDLE(pc)) {
2267 ret = mm_evas_renderer_get_visible(EVAS_HANDLE(pc), &visible);
2275 player_msg_send(api, pc, ret_buf, ret);
2276 if (ret == PLAYER_ERROR_NONE) {
2277 player_msg_get_type(value, ret_buf, INT);
2289 int player_get_content_info(player_h player, player_content_info_e key, char **pvalue)
2291 PLAYER_INSTANCE_CHECK(player);
2292 PLAYER_NULL_ARG_CHECK(pvalue);
2293 int ret = PLAYER_ERROR_NONE;
2294 muse_player_api_e api = MUSE_PLAYER_API_GET_CONTENT_INFO;
2295 player_cli_s *pc = (player_cli_s *) player;
2296 char *ret_buf = NULL;
2297 char value[MUSE_MSG_MAX_LENGTH] = { 0, };
2301 player_msg_send1(api, pc, ret_buf, ret, INT, key);
2302 if (ret == PLAYER_ERROR_NONE) {
2303 player_msg_get_string(value, ret_buf);
2304 *pvalue = strndup(value, MUSE_MSG_MAX_LENGTH);
2310 int player_get_codec_info(player_h player, char **paudio_codec, char **pvideo_codec)
2312 PLAYER_INSTANCE_CHECK(player);
2313 PLAYER_NULL_ARG_CHECK(paudio_codec);
2314 PLAYER_NULL_ARG_CHECK(pvideo_codec);
2315 int ret = PLAYER_ERROR_NONE;
2316 muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_INFO;
2317 player_cli_s *pc = (player_cli_s *) player;
2318 char *ret_buf = NULL;
2319 char video_codec[MUSE_MSG_MAX_LENGTH] = { 0, };
2320 char audio_codec[MUSE_MSG_MAX_LENGTH] = { 0, };
2321 bool ret_val = TRUE;
2325 player_msg_send(api, pc, ret_buf, ret);
2326 if (ret == PLAYER_ERROR_NONE) {
2327 player_msg_get_string2(ret_buf, video_codec, audio_codec, ret_val);
2329 *pvideo_codec = strndup(video_codec, MUSE_MSG_MAX_LENGTH);
2330 *paudio_codec = strndup(audio_codec, MUSE_MSG_MAX_LENGTH);
2332 ret = PLAYER_ERROR_INVALID_OPERATION;
2339 int player_get_audio_stream_info(player_h player, int *psample_rate, int *pchannel, int *pbit_rate)
2341 PLAYER_INSTANCE_CHECK(player);
2342 PLAYER_NULL_ARG_CHECK(psample_rate);
2343 PLAYER_NULL_ARG_CHECK(pchannel);
2344 PLAYER_NULL_ARG_CHECK(pbit_rate);
2345 int ret = PLAYER_ERROR_NONE;
2346 muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO;
2347 player_cli_s *pc = (player_cli_s *) player;
2348 char *ret_buf = NULL;
2349 int sample_rate = 0;
2355 player_msg_send(api, pc, ret_buf, ret);
2356 if (ret == PLAYER_ERROR_NONE) {
2357 bool ret_val = TRUE;
2358 player_msg_get3(ret_buf, sample_rate, INT, channel, INT, bit_rate, INT, ret_val);
2360 *psample_rate = sample_rate;
2361 *pchannel = channel;
2362 *pbit_rate = bit_rate;
2364 ret = PLAYER_ERROR_INVALID_OPERATION;
2371 int player_get_video_stream_info(player_h player, int *pfps, int *pbit_rate)
2373 PLAYER_INSTANCE_CHECK(player);
2374 PLAYER_NULL_ARG_CHECK(pfps);
2375 PLAYER_NULL_ARG_CHECK(pbit_rate);
2376 int ret = PLAYER_ERROR_NONE;
2377 muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO;
2378 player_cli_s *pc = (player_cli_s *) player;
2379 char *ret_buf = NULL;
2385 player_msg_send(api, pc, ret_buf, ret);
2386 if (ret == PLAYER_ERROR_NONE) {
2387 bool ret_val = TRUE;
2388 player_msg_get2(ret_buf, fps, INT, bit_rate, INT, ret_val);
2391 *pbit_rate = bit_rate;
2393 ret = PLAYER_ERROR_INVALID_OPERATION;
2400 int player_get_video_size(player_h player, int *pwidth, int *pheight)
2402 PLAYER_INSTANCE_CHECK(player);
2403 PLAYER_NULL_ARG_CHECK(pwidth);
2404 PLAYER_NULL_ARG_CHECK(pheight);
2405 int ret = PLAYER_ERROR_NONE;
2406 muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_SIZE;
2407 player_cli_s *pc = (player_cli_s *) player;
2408 char *ret_buf = NULL;
2414 player_msg_send(api, pc, ret_buf, ret);
2415 if (ret == PLAYER_ERROR_NONE) {
2416 bool ret_val = TRUE;
2417 player_msg_get2(ret_buf, width, INT, height, INT, ret_val);
2422 ret = PLAYER_ERROR_INVALID_OPERATION;
2429 int player_get_album_art(player_h player, void **palbum_art, int *psize)
2431 PLAYER_INSTANCE_CHECK(player);
2432 PLAYER_NULL_ARG_CHECK(palbum_art);
2433 PLAYER_NULL_ARG_CHECK(psize);
2434 int ret = PLAYER_ERROR_NONE;
2435 muse_player_api_e api = MUSE_PLAYER_API_GET_ALBUM_ART;
2436 player_cli_s *pc = (player_cli_s *) player;
2437 char *ret_buf = NULL;
2441 tbm_bo_handle thandle;
2447 player_msg_send(api, pc, ret_buf, ret);
2448 if (ret == PLAYER_ERROR_NONE) {
2449 muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
2450 jobj = muse_core_msg_json_object_new(ret_buf, NULL, &err);
2452 LOGE("failed to get msg obj, err:%d", err);
2453 ret = PLAYER_ERROR_INVALID_OPERATION;
2457 if (muse_core_msg_json_object_get_value("size", jobj, &size, MUSE_TYPE_INT) && (size > 0)) {
2458 LOGD("size : %d", size);
2459 if (!muse_core_msg_json_object_get_value("key", jobj, &key, MUSE_TYPE_INT)) {
2460 ret = PLAYER_ERROR_INVALID_OPERATION;
2464 bo = tbm_bo_import(pc->cb_info->bufmgr, key);
2466 LOGE("TBM get error : bo is NULL");
2467 ret = PLAYER_ERROR_INVALID_OPERATION;
2470 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE | TBM_OPTION_READ);
2471 if (thandle.ptr == NULL) {
2472 LOGE("TBM get error : handle pointer is NULL");
2473 ret = PLAYER_ERROR_INVALID_OPERATION;
2476 album_art = _get_mem(pc, size);
2478 memcpy(album_art, thandle.ptr, size);
2479 *palbum_art = album_art;
2481 LOGE("g_new failure");
2482 ret = PLAYER_ERROR_INVALID_OPERATION;
2493 muse_core_msg_json_object_free(jobj);
2503 LOGD("send msg to release buffer. key:%d", key);
2504 player_msg_send1_async(MUSE_PLAYER_API_RETURN_BUFFER, pc, INT, key);
2510 int player_audio_effect_get_equalizer_bands_count(player_h player, int *pcount)
2512 PLAYER_INSTANCE_CHECK(player);
2513 PLAYER_NULL_ARG_CHECK(pcount);
2514 int ret = PLAYER_ERROR_NONE;
2515 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT;
2516 player_cli_s *pc = (player_cli_s *) player;
2517 char *ret_buf = NULL;
2522 player_msg_send(api, pc, ret_buf, ret);
2523 if (ret == PLAYER_ERROR_NONE) {
2524 player_msg_get(count, ret_buf);
2531 int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length)
2533 PLAYER_INSTANCE_CHECK(player);
2534 PLAYER_NULL_ARG_CHECK(band_levels);
2535 int ret = PLAYER_ERROR_NONE;
2536 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS;
2537 player_cli_s *pc = (player_cli_s *) player;
2538 char *ret_buf = NULL;
2542 player_msg_send_array(api, pc, ret_buf, ret, band_levels, length, sizeof(int));
2549 int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level)
2551 PLAYER_INSTANCE_CHECK(player);
2552 int ret = PLAYER_ERROR_NONE;
2553 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL;
2554 player_cli_s *pc = (player_cli_s *) player;
2555 char *ret_buf = NULL;
2559 player_msg_send2(api, pc, ret_buf, ret, INT, index, INT, level);
2565 int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *plevel)
2567 PLAYER_INSTANCE_CHECK(player);
2568 PLAYER_NULL_ARG_CHECK(plevel);
2569 int ret = PLAYER_ERROR_NONE;
2570 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL;
2571 player_cli_s *pc = (player_cli_s *) player;
2572 char *ret_buf = NULL;
2577 player_msg_send1(api, pc, ret_buf, ret, INT, index);
2578 if (ret == PLAYER_ERROR_NONE) {
2579 player_msg_get(level, ret_buf);
2586 int player_audio_effect_get_equalizer_level_range(player_h player, int *pmin, int *pmax)
2588 PLAYER_INSTANCE_CHECK(player);
2589 PLAYER_NULL_ARG_CHECK(pmin);
2590 PLAYER_NULL_ARG_CHECK(pmax);
2591 int ret = PLAYER_ERROR_NONE;
2592 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE;
2593 player_cli_s *pc = (player_cli_s *) player;
2594 char *ret_buf = NULL;
2595 int min = 0, max = 0;
2599 player_msg_send(api, pc, ret_buf, ret);
2600 if (ret == PLAYER_ERROR_NONE) {
2601 bool ret_val = TRUE;
2602 player_msg_get2(ret_buf, min, INT, max, INT, ret_val);
2607 ret = PLAYER_ERROR_INVALID_OPERATION;
2614 int player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *pfrequency)
2616 PLAYER_INSTANCE_CHECK(player);
2617 PLAYER_NULL_ARG_CHECK(pfrequency);
2618 int ret = PLAYER_ERROR_NONE;
2619 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY;
2620 player_cli_s *pc = (player_cli_s *) player;
2621 char *ret_buf = NULL;
2626 player_msg_send1(api, pc, ret_buf, ret, INT, index);
2627 if (ret == PLAYER_ERROR_NONE) {
2628 player_msg_get(frequency, ret_buf);
2629 *pfrequency = frequency;
2635 int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *prange)
2637 PLAYER_INSTANCE_CHECK(player);
2638 PLAYER_NULL_ARG_CHECK(prange);
2639 int ret = PLAYER_ERROR_NONE;
2640 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE;
2641 player_cli_s *pc = (player_cli_s *) player;
2642 char *ret_buf = NULL;
2647 player_msg_send1(api, pc, ret_buf, ret, INT, index);
2648 if (ret == PLAYER_ERROR_NONE) {
2649 player_msg_get(range, ret_buf);
2656 int player_audio_effect_equalizer_clear(player_h player)
2658 PLAYER_INSTANCE_CHECK(player);
2659 int ret = PLAYER_ERROR_NONE;
2660 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR;
2661 player_cli_s *pc = (player_cli_s *) player;
2662 char *ret_buf = NULL;
2666 player_msg_send(api, pc, ret_buf, ret);
2671 int player_audio_effect_equalizer_is_available(player_h player, bool * pavailable)
2673 PLAYER_INSTANCE_CHECK(player);
2674 PLAYER_NULL_ARG_CHECK(pavailable);
2675 int ret = PLAYER_ERROR_NONE;
2676 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE;
2677 player_cli_s *pc = (player_cli_s *) player;
2678 char *ret_buf = NULL;
2683 player_msg_send(api, pc, ret_buf, ret);
2684 if (ret == PLAYER_ERROR_NONE) {
2685 player_msg_get(available, ret_buf);
2686 *pavailable = available;
2692 int player_set_subtitle_path(player_h player, const char *path)
2694 PLAYER_INSTANCE_CHECK(player);
2695 int ret = PLAYER_ERROR_NONE;
2696 muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_PATH;
2697 player_cli_s *pc = (player_cli_s *) player;
2698 char *ret_buf = NULL;
2702 player_msg_send1(api, pc, ret_buf, ret, STRING, path);
2707 int player_set_subtitle_position_offset(player_h player, int millisecond)
2709 PLAYER_INSTANCE_CHECK(player);
2710 int ret = PLAYER_ERROR_NONE;
2711 muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET;
2712 player_cli_s *pc = (player_cli_s *) player;
2713 char *ret_buf = NULL;
2717 player_msg_send1(api, pc, ret_buf, ret, INT, millisecond);
2723 int player_set_progressive_download_path(player_h player, const char *path)
2725 PLAYER_INSTANCE_CHECK(player);
2726 PLAYER_NULL_ARG_CHECK(path);
2727 int ret = PLAYER_ERROR_NONE;
2728 muse_player_api_e api = MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH;
2729 player_cli_s *pc = (player_cli_s *) player;
2730 char *ret_buf = NULL;
2734 player_msg_send1(api, pc, ret_buf, ret, STRING, path);
2739 int player_get_progressive_download_status(player_h player, unsigned long *pcurrent, unsigned long *ptotal_size)
2741 PLAYER_INSTANCE_CHECK(player);
2742 PLAYER_NULL_ARG_CHECK(pcurrent);
2743 PLAYER_NULL_ARG_CHECK(ptotal_size);
2744 int ret = PLAYER_ERROR_NONE;
2745 muse_player_api_e api = MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS;
2746 player_cli_s *pc = (player_cli_s *) player;
2747 char *ret_buf = NULL;
2748 unsigned long current, total_size;
2752 player_msg_send(api, pc, ret_buf, ret);
2753 if (ret == PLAYER_ERROR_NONE) {
2754 bool ret_val = TRUE;
2755 player_msg_get2(ret_buf, current, POINTER, total_size, POINTER, ret_val);
2757 *pcurrent = current;
2758 *ptotal_size = total_size;
2760 ret = PLAYER_ERROR_INVALID_OPERATION;
2768 int player_capture_video(player_h player, player_video_captured_cb callback, void *user_data)
2770 PLAYER_INSTANCE_CHECK(player);
2771 PLAYER_NULL_ARG_CHECK(callback);
2772 int ret = PLAYER_ERROR_NONE;
2773 muse_player_api_e api = MUSE_PLAYER_API_CAPTURE_VIDEO;
2774 player_cli_s *pc = (player_cli_s *) player;
2775 char *ret_buf = NULL;
2778 if (pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
2779 LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : capturing...", PLAYER_ERROR_VIDEO_CAPTURE_FAILED);
2780 return PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
2782 LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_CAPTURE);
2783 pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = callback;
2784 pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = user_data;
2787 player_msg_send(api, pc, ret_buf, ret);
2789 if (ret != PLAYER_ERROR_NONE)
2790 set_null_user_cb(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_CAPTURE);
2796 int player_set_streaming_cookie(player_h player, const char *cookie, int size)
2798 PLAYER_INSTANCE_CHECK(player);
2799 PLAYER_NULL_ARG_CHECK(cookie);
2800 PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2801 int ret = PLAYER_ERROR_NONE;
2802 muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_COOKIE;
2803 player_cli_s *pc = (player_cli_s *) player;
2804 char *ret_buf = NULL;
2808 player_msg_send2(api, pc, ret_buf, ret, STRING, cookie, INT, size);
2813 int player_set_streaming_user_agent(player_h player, const char *user_agent, int size)
2815 PLAYER_INSTANCE_CHECK(player);
2816 PLAYER_NULL_ARG_CHECK(user_agent);
2817 PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2818 int ret = PLAYER_ERROR_NONE;
2819 muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_USER_AGENT;
2820 player_cli_s *pc = (player_cli_s *) player;
2821 char *ret_buf = NULL;
2825 player_msg_send2(api, pc, ret_buf, ret, STRING, user_agent, INT, size);
2830 int player_get_streaming_download_progress(player_h player, int *pstart, int *pcurrent)
2832 PLAYER_INSTANCE_CHECK(player);
2833 PLAYER_NULL_ARG_CHECK(pstart);
2834 PLAYER_NULL_ARG_CHECK(pcurrent);
2835 int ret = PLAYER_ERROR_NONE;
2836 muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS;
2837 player_cli_s *pc = (player_cli_s *) player;
2838 char *ret_buf = NULL;
2839 int start = 0, current = 0;
2843 player_msg_send(api, pc, ret_buf, ret);
2844 if (ret == PLAYER_ERROR_NONE) {
2845 bool ret_val = TRUE;
2846 player_msg_get2(ret_buf, start, INT, current, INT, ret_val);
2849 *pcurrent = current;
2851 ret = PLAYER_ERROR_INVALID_OPERATION;
2859 int player_set_completed_cb(player_h player, player_completed_cb callback, void *user_data)
2861 return __set_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player, callback, user_data);
2864 int player_unset_completed_cb(player_h player)
2866 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player);
2869 int player_set_interrupted_cb(player_h player, player_interrupted_cb callback, void *user_data)
2871 return __set_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player, callback, user_data);
2874 int player_unset_interrupted_cb(player_h player)
2876 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player);
2879 int player_set_error_cb(player_h player, player_error_cb callback, void *user_data)
2881 return __set_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player, callback, user_data);
2884 int player_unset_error_cb(player_h player)
2886 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player);
2889 int player_set_buffering_cb(player_h player, player_buffering_cb callback, void *user_data)
2891 return __set_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player, callback, user_data);
2894 int player_unset_buffering_cb(player_h player)
2896 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player);
2899 int player_set_subtitle_updated_cb(player_h player, player_subtitle_updated_cb callback, void *user_data)
2901 return __set_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player, callback, user_data);
2904 int player_unset_subtitle_updated_cb(player_h player)
2906 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player);
2909 int player_set_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data)
2911 PLAYER_INSTANCE_CHECK(player);
2912 PLAYER_NULL_ARG_CHECK(callback);
2913 int ret = PLAYER_ERROR_NONE;
2914 player_cli_s *pc = (player_cli_s *) player;
2915 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
2916 char *ret_buf = NULL;
2917 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PD;
2922 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
2924 if (ret == PLAYER_ERROR_NONE) {
2925 pc->cb_info->user_cb[type] = callback;
2926 pc->cb_info->user_data[type] = user_data;
2927 LOGI("Event type : %d ", type);
2934 int player_unset_progressive_download_message_cb(player_h player)
2936 PLAYER_INSTANCE_CHECK(player);
2937 int ret = PLAYER_ERROR_NONE;
2938 player_cli_s *pc = (player_cli_s *) player;
2939 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
2940 char *ret_buf = NULL;
2941 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PD;
2946 set_null_user_cb_lock(pc->cb_info, type);
2948 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
2955 int player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data)
2957 PLAYER_INSTANCE_CHECK(player);
2958 PLAYER_NULL_ARG_CHECK(callback);
2959 int ret = PLAYER_ERROR_NONE;
2960 player_cli_s *pc = (player_cli_s *) player;
2961 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
2962 char *ret_buf = NULL;
2963 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
2968 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
2970 if (ret == PLAYER_ERROR_NONE) {
2971 pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = callback;
2972 pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = user_data;
2973 LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
2980 int player_unset_media_packet_video_frame_decoded_cb(player_h player)
2982 PLAYER_INSTANCE_CHECK(player);
2983 int ret = PLAYER_ERROR_NONE;
2984 player_cli_s *pc = (player_cli_s *) player;
2985 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
2986 char *ret_buf = NULL;
2987 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
2992 set_null_user_cb_lock(pc->cb_info, type);
2994 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3000 int player_set_video_stream_changed_cb(player_h player, player_video_stream_changed_cb callback, void *user_data)
3002 PLAYER_INSTANCE_CHECK(player);
3003 PLAYER_NULL_ARG_CHECK(callback);
3004 int ret = PLAYER_ERROR_NONE;
3005 player_cli_s *pc = (player_cli_s *) player;
3006 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3007 char *ret_buf = NULL;
3008 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
3013 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3015 if (ret == PLAYER_ERROR_NONE) {
3016 pc->cb_info->user_cb[type] = callback;
3017 pc->cb_info->user_data[type] = user_data;
3018 LOGI("Event type : %d ", type);
3025 int player_unset_video_stream_changed_cb(player_h player)
3027 PLAYER_INSTANCE_CHECK(player);
3028 int ret = PLAYER_ERROR_NONE;
3029 player_cli_s *pc = (player_cli_s *) player;
3030 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3031 char *ret_buf = NULL;
3032 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
3037 set_null_user_cb_lock(pc->cb_info, type);
3039 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3045 int player_set_media_stream_buffer_status_cb(player_h player, player_stream_type_e stream_type, player_media_stream_buffer_status_cb callback, void *user_data)
3047 PLAYER_INSTANCE_CHECK(player);
3048 PLAYER_NULL_ARG_CHECK(callback);
3049 int ret = PLAYER_ERROR_NONE;
3050 player_cli_s *pc = (player_cli_s *) player;
3051 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3052 char *ret_buf = NULL;
3053 muse_player_event_e type;
3058 if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
3059 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
3060 else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
3061 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
3063 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
3064 return PLAYER_ERROR_INVALID_PARAMETER;
3067 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3069 if (ret == PLAYER_ERROR_NONE) {
3070 pc->cb_info->user_cb[type] = callback;
3071 pc->cb_info->user_data[type] = user_data;
3072 LOGI("Event type : %d ", type);
3079 int player_unset_media_stream_buffer_status_cb(player_h player, player_stream_type_e stream_type)
3081 PLAYER_INSTANCE_CHECK(player);
3082 int ret = PLAYER_ERROR_NONE;
3083 player_cli_s *pc = (player_cli_s *) player;
3084 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3085 char *ret_buf = NULL;
3086 muse_player_event_e type;
3091 if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
3092 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
3093 else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
3094 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
3096 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
3097 return PLAYER_ERROR_INVALID_PARAMETER;
3100 set_null_user_cb_lock(pc->cb_info, type);
3102 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3108 int player_set_media_stream_seek_cb(player_h player, player_stream_type_e stream_type, player_media_stream_seek_cb callback, void *user_data)
3110 PLAYER_INSTANCE_CHECK(player);
3111 PLAYER_NULL_ARG_CHECK(callback);
3112 int ret = PLAYER_ERROR_NONE;
3113 player_cli_s *pc = (player_cli_s *) player;
3114 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3115 char *ret_buf = NULL;
3116 muse_player_event_e type;
3121 if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
3122 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
3123 else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
3124 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
3126 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
3127 return PLAYER_ERROR_INVALID_PARAMETER;
3130 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3132 if (ret == PLAYER_ERROR_NONE) {
3133 pc->cb_info->user_cb[type] = callback;
3134 pc->cb_info->user_data[type] = user_data;
3135 LOGI("Event type : %d ", type);
3142 int player_unset_media_stream_seek_cb(player_h player, player_stream_type_e stream_type)
3144 PLAYER_INSTANCE_CHECK(player);
3145 int ret = PLAYER_ERROR_NONE;
3146 player_cli_s *pc = (player_cli_s *) player;
3147 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3148 char *ret_buf = NULL;
3149 muse_player_event_e type;
3154 if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
3155 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
3156 else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
3157 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
3159 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
3160 return PLAYER_ERROR_INVALID_PARAMETER;
3163 set_null_user_cb_lock(pc->cb_info, type);
3165 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3171 /* TODO Implement raw data socket channel */
3172 int player_push_media_stream(player_h player, media_packet_h packet)
3174 PLAYER_INSTANCE_CHECK(player);
3175 PLAYER_NULL_ARG_CHECK(packet);
3176 int ret = PLAYER_ERROR_NONE;
3177 player_cli_s *pc = (player_cli_s *) player;
3178 muse_player_api_e api = MUSE_PLAYER_API_PUSH_MEDIA_STREAM;
3179 char *ret_buf = NULL;
3180 player_push_media_msg_type push_media;
3181 char *push_media_msg = (char *)&push_media;
3182 int msg_size = sizeof(player_push_media_msg_type);
3186 tbm_bo_handle thandle;
3189 media_format_h format;
3195 media_packet_get_buffer_data_ptr(packet, (void **)&buf);
3196 media_packet_get_buffer_size(packet, &push_media.size);
3197 media_packet_get_pts(packet, &push_media.pts);
3198 media_packet_get_format(packet, &format);
3199 media_packet_get_flags(packet, &push_media.flags);
3201 push_media.buf_type = PUSH_MEDIA_BUF_TYPE_RAW;
3203 media_packet_is_video(packet, &is_video);
3204 media_packet_is_audio(packet, &is_audio);
3206 media_format_get_video_info(format, &push_media.mimetype, &push_media.width, &push_media.height, NULL, NULL);
3208 media_format_get_audio_info(format, &push_media.mimetype, NULL, NULL, NULL, NULL);
3210 media_format_unref(format);
3213 if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM) {
3214 bo = tbm_bo_alloc(pc->cb_info->bufmgr, push_media.size, TBM_BO_DEFAULT);
3216 LOGE("TBM get error : bo is NULL");
3217 return PLAYER_ERROR_INVALID_OPERATION;
3219 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
3220 if (thandle.ptr == NULL) {
3221 LOGE("TBM get error : handle pointer is NULL");
3222 ret = PLAYER_ERROR_INVALID_OPERATION;
3225 memcpy(thandle.ptr, buf, push_media.size);
3228 push_media.key = tbm_bo_export(bo);
3229 if (push_media.key == 0) {
3230 LOGE("TBM get error : key is 0");
3231 ret = PLAYER_ERROR_INVALID_OPERATION;
3235 player_msg_send_array(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char));
3236 } else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG) {
3237 buf_size = (int)push_media.size;
3238 player_msg_send_array2(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char), buf, buf_size, sizeof(char));
3241 if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW) {
3242 buf_size = (int)push_media.size;
3243 muse_core_ipc_push_data(pc->cb_info->data_fd, buf, buf_size, push_media.pts);
3244 player_msg_send_array(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char));
3247 LOGD("ret_buf %s", ret_buf);
3251 if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
3259 int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format)
3261 PLAYER_INSTANCE_CHECK(player);
3262 g_return_val_if_fail(format, PLAYER_ERROR_INVALID_OPERATION);
3263 int ret = PLAYER_ERROR_NONE;
3264 player_cli_s *pc = (player_cli_s *) player;
3265 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO;
3266 char *ret_buf = NULL;
3267 media_format_mimetype_e mimetype;
3278 media_format_ref(format);
3279 if (type == PLAYER_STREAM_TYPE_VIDEO) {
3280 media_format_get_video_info(format, &mimetype, &width, &height, &avg_bps, &max_bps);
3281 player_msg_send6(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, width, INT, height, INT, avg_bps, INT, max_bps);
3282 } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
3283 media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &avg_bps);
3284 player_msg_send6(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, channel, INT, samplerate, INT, avg_bps, INT, bit);
3286 media_format_unref(format);
3287 pc->push_media_stream = TRUE;
3293 int player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size)
3295 int ret = PLAYER_ERROR_NONE;
3296 PLAYER_INSTANCE_CHECK(player);
3297 player_cli_s *pc = (player_cli_s *) player;
3298 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE;
3299 char *ret_buf = NULL;
3303 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT64, max_size);
3309 int player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *pmax_size)
3311 int ret = PLAYER_ERROR_NONE;
3312 PLAYER_INSTANCE_CHECK(player);
3313 PLAYER_NULL_ARG_CHECK(pmax_size);
3314 player_cli_s *pc = (player_cli_s *) player;
3315 muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE;
3316 char *ret_buf = NULL;
3317 unsigned long long max_size;
3321 player_msg_send1(api, pc, ret_buf, ret, INT, type);
3322 if (ret == PLAYER_ERROR_NONE) {
3323 player_msg_get_type(max_size, ret_buf, INT64);
3324 *pmax_size = max_size;
3330 int player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent)
3332 int ret = PLAYER_ERROR_NONE;
3333 PLAYER_INSTANCE_CHECK(player);
3334 player_cli_s *pc = (player_cli_s *) player;
3335 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
3336 char *ret_buf = NULL;
3340 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, percent);
3346 int player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *ppercent)
3348 int ret = PLAYER_ERROR_NONE;
3349 PLAYER_INSTANCE_CHECK(player);
3350 PLAYER_NULL_ARG_CHECK(ppercent);
3351 player_cli_s *pc = (player_cli_s *) player;
3352 muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
3353 char *ret_buf = NULL;
3358 player_msg_send1(api, pc, ret_buf, ret, INT, type);
3359 if (ret == PLAYER_ERROR_NONE) {
3360 player_msg_get(percent, ret_buf);
3361 *ppercent = percent;
3368 int player_get_track_count(player_h player, player_stream_type_e type, int *pcount)
3370 PLAYER_INSTANCE_CHECK(player);
3371 PLAYER_NULL_ARG_CHECK(pcount);
3372 int ret = PLAYER_ERROR_NONE;
3373 player_cli_s *pc = (player_cli_s *) player;
3374 muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_COUNT;
3375 char *ret_buf = NULL;
3380 player_msg_send1(api, pc, ret_buf, ret, INT, type);
3381 if (ret == PLAYER_ERROR_NONE) {
3382 player_msg_get(count, ret_buf);
3390 int player_get_current_track(player_h player, player_stream_type_e type, int *pindex)
3392 PLAYER_INSTANCE_CHECK(player);
3393 PLAYER_NULL_ARG_CHECK(pindex);
3394 int ret = PLAYER_ERROR_NONE;
3395 player_cli_s *pc = (player_cli_s *) player;
3396 muse_player_api_e api = MUSE_PLAYER_API_GET_CURRENT_TRACK;
3397 char *ret_buf = NULL;
3402 player_msg_send1(api, pc, ret_buf, ret, INT, type);
3403 if (ret == PLAYER_ERROR_NONE) {
3404 player_msg_get(index, ret_buf);
3412 int player_select_track(player_h player, player_stream_type_e type, int index)
3414 PLAYER_INSTANCE_CHECK(player);
3415 int ret = PLAYER_ERROR_NONE;
3416 player_cli_s *pc = (player_cli_s *) player;
3417 muse_player_api_e api = MUSE_PLAYER_API_SELECT_TRACK;
3418 char *ret_buf = NULL;
3422 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, index);
3428 int player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **pcode)
3430 PLAYER_INSTANCE_CHECK(player);
3431 PLAYER_NULL_ARG_CHECK(pcode);
3432 int ret = PLAYER_ERROR_NONE;
3433 player_cli_s *pc = (player_cli_s *) player;
3434 muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE;
3435 char *ret_buf = NULL;
3436 char code[MUSE_MSG_MAX_LENGTH] = { 0, };
3437 const int code_len = 2;
3441 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, index);
3442 if (ret == PLAYER_ERROR_NONE) {
3443 if (player_msg_get_string(code, ret_buf))
3444 *pcode = strndup(code, code_len);