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 TIZEN_FEATURE_EVAS_RENDERER
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]);
455 static void __capture_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
457 unsigned char *data = NULL;
460 unsigned int size = 0;
462 tbm_bo_handle thandle;
466 player_msg_get3(recvMsg, width, INT, height, INT, size, INT, ret_val);
468 if (!player_msg_get(key, recvMsg)) {
469 LOGE("There is no tbm_key value. %d", key);
473 bo = tbm_bo_import(cb_info->bufmgr, key);
475 LOGE("TBM get error : bo is NULL");
478 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE | TBM_OPTION_READ);
479 if (thandle.ptr == NULL) {
480 LOGE("TBM get error : handle pointer is NULL");
483 data = g_new(unsigned char, size);
485 memcpy(data, thandle.ptr, size);
486 ((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]);
489 LOGE("g_new failure");
500 LOGD("send msg to release buffer. key:%d", key);
501 player_msg_send1_no_return(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, INT, key);
504 set_null_user_cb(cb_info, MUSE_PLAYER_EVENT_TYPE_CAPTURE);
507 static void __seek_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
509 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SEEK;
511 g_mutex_lock(&cb_info->seek_cb_mutex);
512 if (cb_info->user_cb[ev] && cb_info->block_seek_cb == FALSE) {
513 LOGD("call seek cb");
514 ((player_seek_completed_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
515 set_null_user_cb(cb_info, ev);
517 LOGW("ignored. seek cb %p, block %d", cb_info->user_cb[ev], cb_info->block_seek_cb);
519 g_mutex_unlock(&cb_info->seek_cb_mutex);
522 static void __player_remove_tsurf_list(player_cli_s * pc)
526 g_mutex_lock(&pc->cb_info->data_mutex);
527 if (pc->cb_info->tsurf_list) {
528 LOGD("total num of tsurf list = %d", g_list_length(pc->cb_info->tsurf_list));
530 for (l = g_list_first(pc->cb_info->tsurf_list); l; l = g_list_next(l)) {
531 player_tsurf_info_t* tmp = (player_tsurf_info_t *)l->data;
533 LOGD("%p will be removed", tmp);
536 tbm_surface_destroy(tmp->tsurf);
542 g_list_free(pc->cb_info->tsurf_list);
543 pc->cb_info->tsurf_list = NULL;
545 g_mutex_unlock(&pc->cb_info->data_mutex);
549 static player_tsurf_info_t* __player_get_tsurf_from_list(callback_cb_info_s * cb_info, tbm_key key)
553 g_mutex_lock(&cb_info->data_mutex);
554 for (l = g_list_first(cb_info->tsurf_list); l; l = g_list_next(l)) {
555 player_tsurf_info_t *tmp = (player_tsurf_info_t *)l->data;
556 if (tmp && (tmp->key == key)) {
557 LOGD("found tsurf_data of tbm_key %d", key);
558 g_mutex_unlock(&cb_info->data_mutex);
562 g_mutex_unlock(&cb_info->data_mutex);
563 LOGD("there is no tsurf_data for tbm_key:%d", key);
567 static void __media_packet_video_frame_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
569 tbm_bo bo[4] = { NULL, };
570 tbm_key key[4] = { 0, };
571 tbm_surface_info_s sinfo;
572 char *surface_info = (char *)&sinfo;
573 media_packet_h pkt = NULL;
574 tbm_surface_h tsurf = NULL;
575 player_tsurf_info_t *tsurf_data = NULL;
577 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
578 bool make_pkt_fmt = false;
579 int ret = MEDIA_FORMAT_ERROR_NONE;
580 _media_pkt_fin_data *fin_data = NULL;
584 muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
586 void *jobj = muse_core_msg_json_object_new(recvMsg, NULL, &err);
588 !muse_core_msg_json_object_get_value("key[0]", jobj, &key[0], MUSE_TYPE_ANY) ||
589 !muse_core_msg_json_object_get_value("key[1]", jobj, &key[1], MUSE_TYPE_ANY) ||
590 !muse_core_msg_json_object_get_value("key[2]", jobj, &key[2], MUSE_TYPE_ANY) ||
591 !muse_core_msg_json_object_get_value("key[3]", jobj, &key[3], MUSE_TYPE_ANY) ||
592 !muse_core_msg_json_object_get_value("packet", jobj, &packet, MUSE_TYPE_POINTER) ||
593 !muse_core_msg_json_object_get_value("mimetype", jobj, &mimetype, MUSE_TYPE_ANY) ||
594 !muse_core_msg_json_object_get_value("pts", jobj, &pts, MUSE_TYPE_INT64) ||
595 !muse_core_msg_json_object_get_value("surface_info", jobj, surface_info, MUSE_TYPE_ARRAY)) {
597 LOGE("failed to get value from msg. jobj:%p, err:%d", jobj, err);
599 muse_core_msg_json_object_free(jobj);
602 muse_core_msg_json_object_free(jobj);
604 LOGD("width %d, height %d", sinfo.width, sinfo.height);
607 LOGE("cb_info is null");
611 if (!cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
612 /* send msg to release packet. */
613 LOGE("_video_decoded_cb is not set");
614 player_msg_send1_no_return(MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB, cb_info->fd, POINTER, packet);
618 for (i = 0; i < 4; i++) {
621 bo[i] = tbm_bo_import(cb_info->bufmgr, key[i]);
625 tsurf_data = __player_get_tsurf_from_list(cb_info, key[0]);
627 tsurf_data = g_new(player_tsurf_info_t, 1);
629 LOGE("failed to alloc tsurf info");
633 tsurf = tbm_surface_internal_create_with_bos(&sinfo, bo, bo_num);
635 LOGE("failed to create tbm surface");
639 tsurf_data->key = key[0];
640 tsurf_data->tsurf = tsurf;
641 g_mutex_lock(&cb_info->data_mutex);
642 cb_info->tsurf_list = g_list_append(cb_info->tsurf_list, tsurf_data);
643 LOGD("key %d is added to the pool", key[0]);
644 if (cb_info->video_frame_pool_size < g_list_length(cb_info->tsurf_list))
645 LOGE("need to check the pool size: %d < %d", cb_info->video_frame_pool_size, g_list_length(cb_info->tsurf_list));
646 g_mutex_unlock(&cb_info->data_mutex);
648 if (tsurf_data->tsurf) {
649 tsurf = tsurf_data->tsurf;
651 LOGE("tsurf_data->tsurf is null (never enter here)");
656 /* check media packet format */
657 if (cb_info->pkt_fmt) {
658 int pkt_fmt_width = 0;
659 int pkt_fmt_height = 0;
660 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
662 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
663 if (pkt_fmt_mimetype != mimetype || pkt_fmt_width != sinfo.width || pkt_fmt_height != sinfo.height) {
664 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);
665 media_format_unref(cb_info->pkt_fmt);
666 cb_info->pkt_fmt = NULL;
672 /* create packet format */
674 LOGI("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, sinfo.width, sinfo.height);
675 ret = media_format_create(&cb_info->pkt_fmt);
676 if (ret == MEDIA_FORMAT_ERROR_NONE) {
677 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
678 ret |= media_format_set_video_width(cb_info->pkt_fmt, sinfo.width);
679 ret |= media_format_set_video_height(cb_info->pkt_fmt, sinfo.height);
680 LOGI("media_format_set_video_mime,width,height ret : 0x%x", ret);
682 LOGE("media_format_create failed");
686 fin_data = g_new(_media_pkt_fin_data, 1);
688 LOGE("failed to alloc fin_data");
691 fin_data->remote_pkt = packet;
692 fin_data->cb_info = cb_info;
693 fin_data->fd = cb_info->fd;
694 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt, tsurf, (media_packet_finalize_cb) _player_media_packet_finalize, (void *)fin_data, &pkt);
695 if (ret != MEDIA_PACKET_ERROR_NONE || !pkt) {
696 LOGE("media_packet_create_from_tbm_surface failed %d %p", ret, pkt);
700 /* keep the media packet to avoid mem leak. */
701 g_mutex_lock(&cb_info->data_mutex);
702 cb_info->packet_list = g_list_append(cb_info->packet_list, pkt);
703 g_mutex_unlock(&cb_info->data_mutex);
706 ret = media_packet_set_pts(pkt, (uint64_t) pts);
707 if (ret != MEDIA_PACKET_ERROR_NONE)
708 LOGE("media_packet_set_pts failed");
710 if (cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
711 /* call media packet callback */
712 ((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]);
714 LOGE("_video_decoded_cb is not set");
715 media_packet_destroy(pkt);
718 for (i = 0; i < bo_num; i++) {
726 media_packet_destroy(pkt);
731 for (i = 0; i < bo_num; i++) {
736 player_msg_send1_no_return(MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB, cb_info->fd, POINTER, packet);
740 static void __audio_frame_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
743 tbm_bo_handle thandle;
745 player_audio_raw_data_s audio;
747 if (!player_msg_get(key, recvMsg)) {
748 LOGE("failed to get value from msg.");
752 bo = tbm_bo_import(cb_info->bufmgr, key);
754 LOGE("TBM get error : bo is NULL, key:%d", key);
758 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE | TBM_OPTION_READ);
759 if (thandle.ptr == NULL) {
760 LOGE("TBM get error : handle pointer is NULL");
764 memcpy(&audio, thandle.ptr, sizeof(player_audio_raw_data_s));
765 audio.data = thandle.ptr + sizeof(player_audio_raw_data_s);
767 LOGD("user callback data %p, size %d", audio.data, audio.size);
768 ((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]);
777 LOGD("send msg to release buffer. key:%d", key);
778 player_msg_send1_no_return(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, INT, key);
782 static void __video_frame_render_error_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
786 static void __pd_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
789 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_PD;
791 if (player_msg_get(type, recvMsg))
792 ((player_pd_message_cb) cb_info->user_cb[ev]) (type, cb_info->user_data[ev]);
795 static void __supported_audio_effect_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
799 static void __supported_audio_effect_freset_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
803 static void __missed_plugin_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
807 static void __media_stream_video_buffer_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
809 /* player_media_stream_buffer_status_e status; */
812 if (player_msg_get(status, recvMsg)) {
813 ((player_media_stream_buffer_status_cb)
814 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]);
818 static void __media_stream_audio_buffer_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
820 /* player_media_stream_buffer_status_e status; */
823 if (player_msg_get(status, recvMsg)) {
824 ((player_media_stream_buffer_status_cb)
825 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS])
826 ((player_media_stream_buffer_status_e) status, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS]);
831 static void __media_stream_video_buffer_cb_handler_ex(callback_cb_info_s * cb_info, char *recvMsg)
833 /* player_media_stream_buffer_status_e status; */
835 unsigned long long bytes;
838 player_msg_get2(recvMsg, status, INT, bytes, INT64, ret);
840 ((player_media_stream_buffer_status_cb_ex)
841 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO])
842 ((player_media_stream_buffer_status_e) status, bytes, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO]);
846 static void __media_stream_audio_buffer_cb_handler_ex(callback_cb_info_s * cb_info, char *recvMsg)
848 /* player_media_stream_buffer_status_e status; */
850 unsigned long long bytes;
853 player_msg_get2(recvMsg, status, INT, bytes, INT64, ret);
855 ((player_media_stream_buffer_status_cb_ex)
856 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO])
857 ((player_media_stream_buffer_status_e) status, bytes, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO]);
862 static void __media_stream_video_seek_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
864 unsigned long long offset;
866 if (player_msg_get_type(offset, recvMsg, INT64)) {
867 ((player_media_stream_seek_cb)
868 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK])
869 (offset, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK]);
873 static void __media_stream_audio_seek_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
875 unsigned long long offset;
877 if (player_msg_get_type(offset, recvMsg, INT64)) {
878 ((player_media_stream_seek_cb)
879 cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK])
880 (offset, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK]);
884 static void __video_stream_changed_cb_handler(callback_cb_info_s * cb_info, char *recvMsg)
892 player_msg_get4(recvMsg, width, INT, height, INT, fps, INT, bit_rate, INT, ret_val);
894 ((player_video_stream_changed_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED])
895 (width, height, fps, bit_rate, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED]);
899 static void (*_user_callbacks[MUSE_PLAYER_EVENT_TYPE_NUM]) (callback_cb_info_s * cb_info, char *recvMsg) = {
900 __prepare_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
901 __complete_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_COMPLETE */
902 __interrupt_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_INTERRUPT */
903 __error_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_ERROR */
904 __buffering_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_BUFFERING */
905 __subtitle_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SUBTITLE */
906 __capture_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_CAPTURE */
907 __seek_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SEEK */
908 __media_packet_video_frame_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME */
909 __audio_frame_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME */
910 __video_frame_render_error_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
911 __pd_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_PD */
912 __supported_audio_effect_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT */
913 __supported_audio_effect_freset_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET */
914 __missed_plugin_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN */
915 #ifdef _PLAYER_FOR_PRODUCT
916 NULL, /* MUSE_PLAYER_EVENT_TYPE_IMAGE_BUFFER */
917 NULL, /* MUSE_PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE */
919 __media_stream_video_buffer_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS */
920 __media_stream_audio_buffer_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS */
921 __media_stream_video_buffer_cb_handler_ex, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO */
922 __media_stream_audio_buffer_cb_handler_ex, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO */
923 __media_stream_video_seek_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK */
924 __media_stream_audio_seek_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK */
925 NULL, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED */
926 __video_stream_changed_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED */
929 static void _player_event_job_function(_player_cb_data * data)
931 muse_player_event_e ev = data->int_data;
932 if (data->cb_info->user_cb[ev])
933 _user_callbacks[ev] (data->cb_info, data->buf);
935 LOGW("user callback is unset. type : %d", ev);
941 static void *_player_event_queue_loop(void *param)
944 LOGE("NULL parameter");
947 callback_cb_info_s *cb_info = param;
948 player_event_queue *ev = &cb_info->event_queue;
949 _player_cb_data *event_data;
951 g_mutex_lock(&ev->mutex);
952 while (ev->running) {
953 g_mutex_lock(&ev->qlock);
954 if (g_queue_is_empty(ev->queue)) {
955 g_mutex_unlock(&ev->qlock);
956 g_cond_wait(&ev->cond, &ev->mutex);
960 g_mutex_unlock(&ev->qlock);
963 g_mutex_lock(&ev->qlock);
964 event_data = (_player_cb_data *) g_queue_pop_head(ev->queue);
965 g_mutex_unlock(&ev->qlock);
967 _player_event_job_function(event_data);
972 g_mutex_unlock(&ev->mutex);
973 LOGI("Exit event loop");
977 static gboolean _player_event_queue_new(callback_cb_info_s * cb_info)
979 g_return_val_if_fail(cb_info, FALSE);
980 player_event_queue *ev = &cb_info->event_queue;
982 ev->queue = g_queue_new();
983 g_return_val_if_fail(ev->queue, FALSE);
984 g_mutex_init(&ev->qlock);
986 g_mutex_init(&ev->mutex);
987 g_cond_init(&ev->cond);
989 ev->thread = g_thread_new("cb_event_thread", _player_event_queue_loop, (gpointer) cb_info);
990 g_return_val_if_fail(ev->thread, FALSE);
991 LOGI("event queue thread %p", ev->thread);
997 static void _player_event_queue_destroy(callback_cb_info_s * cb_info)
999 g_return_if_fail(cb_info);
1000 player_event_queue *ev = &cb_info->event_queue;
1001 _player_cb_data *event_data;
1003 LOGI("event queue thread %p", ev->thread);
1005 g_mutex_lock(&ev->mutex);
1006 ev->running = FALSE;
1007 g_cond_broadcast(&ev->cond);
1008 g_mutex_unlock(&ev->mutex);
1010 g_thread_join(ev->thread);
1011 g_thread_unref(ev->thread);
1013 while (!g_queue_is_empty(ev->queue)) {
1014 event_data = (_player_cb_data *) g_queue_pop_head(ev->queue);
1016 g_free(event_data->buf);
1020 g_queue_free(ev->queue);
1021 g_mutex_clear(&ev->qlock);
1022 g_mutex_clear(&ev->mutex);
1023 g_cond_clear(&ev->cond);
1027 static void _player_event_queue_remove(player_event_queue * ev_queue, int ev)
1031 g_mutex_lock(&ev_queue->qlock);
1033 item = g_queue_peek_head_link(ev_queue->queue);
1035 GList *next = item->next;
1036 _player_cb_data *cb_data = (_player_cb_data *)item->data;
1038 if (cb_data && cb_data->int_data == ev) {
1039 LOGD("removing '%p (ev:%d)' from event queue", cb_data, cb_data->int_data);
1040 g_free(cb_data->buf);
1043 g_queue_delete_link(ev_queue->queue, item);
1047 g_mutex_unlock(&ev_queue->qlock);
1050 static void _player_event_queue_add(player_event_queue * ev, _player_cb_data * data)
1053 g_mutex_lock(&ev->qlock);
1054 g_queue_push_tail(ev->queue, (gpointer) data);
1055 g_mutex_unlock(&ev->qlock);
1056 g_cond_signal(&ev->cond);
1060 static void _user_callback_handler(callback_cb_info_s * cb_info, muse_player_event_e event, char *buffer)
1062 LOGD("get event %d", event);
1064 if (event < MUSE_PLAYER_EVENT_TYPE_NUM) {
1065 if (cb_info->user_cb[event] && _user_callbacks[event]) {
1066 _player_cb_data *data = NULL;
1067 data = g_new(_player_cb_data, 1);
1069 LOGE("fail to alloc mem");
1072 data->int_data = (int)event;
1073 data->cb_info = cb_info;
1075 _player_event_queue_add(&cb_info->event_queue, data);
1080 static void _add_ret_msg(muse_player_api_e api, callback_cb_info_s * cb_info, int offset, int parse_len)
1082 ret_msg_s *msg = NULL;
1083 ret_msg_s *last = cb_info->buff.retMsgHead;
1085 msg = g_new(ret_msg_s, 1);
1088 msg->msg = strndup(cb_info->buff.recvMsg + offset, parse_len);
1091 cb_info->buff.retMsgHead = msg;
1098 LOGE("g_new failure");
1101 static ret_msg_s *_get_ret_msg(muse_player_api_e api, callback_cb_info_s * cb_info)
1103 ret_msg_s *msg = cb_info->buff.retMsgHead;
1104 ret_msg_s *prev = NULL;
1106 if (msg->api == api) {
1108 cb_info->buff.retMsgHead = msg->next;
1110 prev->next = msg->next;
1119 static void _notify_disconnected(callback_cb_info_s * cb_info)
1121 int code = PLAYER_ERROR_SERVICE_DISCONNECTED;
1122 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR;
1123 if (!cb_info || !cb_info->user_cb[ev])
1125 ((player_error_cb) cb_info->user_cb[ev]) (code, cb_info->user_data[ev]);
1128 static void *client_cb_handler(gpointer data)
1134 callback_cb_info_s *cb_info = data;
1135 char *recvMsg = NULL;
1136 muse_core_msg_parse_err_e err;
1138 while (g_atomic_int_get(&cb_info->running)) {
1140 err = MUSE_MSG_PARSE_ERROR_NONE;
1142 len = player_recv_msg(cb_info);
1146 recvMsg = cb_info->buff.recvMsg;
1147 recvMsg[len] = '\0';
1151 while (offset < len) {
1152 api = MUSE_PLAYER_API_MAX;
1153 // LOGD(">>>>>> [%d/%d] %p, %s", offset, len, recvMsg + offset, recvMsg + offset);
1156 void *jobj = muse_core_msg_json_object_new(recvMsg + offset, &parse_len, &err);
1158 if (muse_core_msg_json_object_get_value("api", jobj, &api, MUSE_TYPE_INT)) {
1159 if (api < MUSE_PLAYER_API_MAX) {
1160 g_mutex_lock(&cb_info->player_mutex);
1161 cb_info->buff.recved++;
1162 _add_ret_msg(api, cb_info, offset, parse_len);
1163 g_cond_signal(&cb_info->player_cond[api]);
1164 g_mutex_unlock(&cb_info->player_mutex);
1165 if (api == MUSE_PLAYER_API_DESTROY)
1166 g_atomic_int_set(&cb_info->running, 0);
1167 } else if (api == MUSE_PLAYER_CB_EVENT) {
1170 g_mutex_lock(&cb_info->player_mutex);
1171 buffer = strndup(recvMsg + offset, parse_len);
1172 g_mutex_unlock(&cb_info->player_mutex);
1173 if (muse_core_msg_json_object_get_value("event", jobj, &event, MUSE_TYPE_INT))
1174 _user_callback_handler(cb_info, event, buffer);
1177 LOGE("Failed to get value. offset:%d/%d, [msg][ %s ]", offset, len, (recvMsg+offset));
1179 muse_core_msg_json_object_free(jobj);
1181 LOGE("Failed to get msg obj. err:%d", err);
1184 if (parse_len == 0 || err != MUSE_MSG_PARSE_ERROR_NONE)
1187 offset += parse_len;
1188 parse_len = len - offset;
1191 if (g_atomic_int_get(&cb_info->running))
1192 _notify_disconnected(cb_info);
1193 LOGD("client cb exit");
1198 static callback_cb_info_s *callback_new(gint sockfd)
1200 callback_cb_info_s *cb_info;
1204 g_return_val_if_fail(sockfd > 0, NULL);
1206 cb_info = g_new(callback_cb_info_s, 1);
1207 memset(cb_info, 0, sizeof(callback_cb_info_s));
1209 g_mutex_init(&cb_info->player_mutex);
1210 for (i = 0; i < MUSE_PLAYER_API_MAX; i++)
1211 g_cond_init(&cb_info->player_cond[i]);
1213 g_mutex_init(&cb_info->data_mutex);
1214 g_mutex_init(&cb_info->seek_cb_mutex);
1216 buff = &cb_info->buff;
1217 buff->recvMsg = g_new(char, MUSE_MSG_MAX_LENGTH + 1);
1218 buff->bufLen = MUSE_MSG_MAX_LENGTH + 1;
1220 buff->retMsgHead = NULL;
1221 buff->part_of_msg = NULL;
1223 g_atomic_int_set(&cb_info->running, 1);
1224 cb_info->fd = sockfd;
1225 cb_info->thread = g_thread_new("callback_thread", client_cb_handler, (gpointer) cb_info);
1230 static void callback_destroy(callback_cb_info_s * cb_info)
1233 g_return_if_fail(cb_info);
1235 if (cb_info->fd > INVALID_SOCKET)
1236 muse_core_connection_close(cb_info->fd);
1237 if (cb_info->data_fd > INVALID_SOCKET)
1238 muse_core_connection_close(cb_info->data_fd);
1239 cb_info->fd = cb_info->data_fd = INVALID_SOCKET;
1241 g_thread_join(cb_info->thread);
1242 g_thread_unref(cb_info->thread);
1243 cb_info->thread = NULL;
1245 LOGI("%p Callback destroyed", cb_info->thread);
1247 g_mutex_clear(&cb_info->player_mutex);
1248 for (i = 0; i < MUSE_PLAYER_API_MAX; i++)
1249 g_cond_clear(&cb_info->player_cond[i]);
1251 g_mutex_clear(&cb_info->data_mutex);
1252 g_mutex_clear(&cb_info->seek_cb_mutex);
1254 g_free(cb_info->buff.recvMsg);
1255 if (cb_info->buff.part_of_msg)
1256 g_free(cb_info->buff.part_of_msg);
1260 int client_get_api_timeout(player_cli_s * pc, muse_player_api_e api)
1265 case MUSE_PLAYER_API_PREPARE:
1266 case MUSE_PLAYER_API_PREPARE_ASYNC:
1267 case MUSE_PLAYER_API_UNPREPARE:
1268 case MUSE_PLAYER_API_START:
1269 case MUSE_PLAYER_API_STOP:
1270 case MUSE_PLAYER_API_PAUSE:
1271 timeout += SERVER_TIMEOUT(pc) * G_TIME_SPAN_MILLISECOND;
1274 /* check prepare async is done */
1275 if (pc && CALLBACK_INFO(pc) && CALLBACK_INFO(pc)->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])
1276 timeout += SERVER_TIMEOUT(pc) * G_TIME_SPAN_MILLISECOND;
1279 timeout += CALLBACK_TIME_OUT;
1280 return timeout; /* ms */
1283 int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s * cb_info, char **ret_buf, int time_out)
1285 int ret = PLAYER_ERROR_NONE;
1286 gint64 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_MILLISECOND;
1287 msg_buff_s *buff = &cb_info->buff;
1288 ret_msg_s *msg = NULL;
1290 g_mutex_lock(&cb_info->player_mutex);
1292 msg = _get_ret_msg(api, cb_info);
1293 if (!buff->recved || !msg) {
1294 if (!g_cond_wait_until(&cb_info->player_cond[api], &cb_info->player_mutex, end_time)) {
1295 LOGW("api %d return msg does not received %dms", api, time_out);
1296 g_mutex_unlock(&cb_info->player_mutex);
1297 return PLAYER_ERROR_INVALID_OPERATION;
1301 msg = _get_ret_msg(api, cb_info);
1303 *ret_buf = msg->msg;
1305 if (!player_msg_get(ret, *ret_buf))
1306 ret = PLAYER_ERROR_INVALID_OPERATION;
1308 LOGE("api %d return msg is not exist", api);
1309 ret = PLAYER_ERROR_INVALID_OPERATION;
1313 g_mutex_unlock(&cb_info->player_mutex);
1319 * Public Implementation
1322 int player_create(player_h * player)
1324 PLAYER_INSTANCE_CHECK(player);
1326 int ret = PLAYER_ERROR_NONE;
1327 int sock_fd = INVALID_SOCKET;
1330 muse_player_api_e api = MUSE_PLAYER_API_CREATE;
1331 muse_core_api_module_e module = MUSE_PLAYER;
1332 player_cli_s *pc = NULL;
1333 char *ret_buf = NULL;
1337 sock_fd = muse_core_client_new();
1338 if (sock_fd <= INVALID_SOCKET) {
1339 LOGE("connection failure %d", errno);
1340 ret = PLAYER_ERROR_INVALID_OPERATION;
1343 player_msg_create_handle(api, sock_fd, INT, module, INT, pid);
1345 pc = g_new0(player_cli_s, 1);
1347 ret = PLAYER_ERROR_OUT_OF_MEMORY;
1351 pc->cb_info = callback_new(sock_fd);
1353 LOGE("fail to create callback");
1354 ret = PLAYER_ERROR_INVALID_OPERATION;
1357 if (!_player_event_queue_new(pc->cb_info)) {
1358 LOGE("fail to create event queue");
1359 ret = PLAYER_ERROR_INVALID_OPERATION;
1363 ret = client_wait_for_cb_return(api, pc->cb_info, &ret_buf, CALLBACK_TIME_OUT);
1364 if (ret == PLAYER_ERROR_NONE) {
1365 intptr_t module_addr;
1366 *player = (player_h) pc;
1367 if (player_msg_get_type(module_addr, ret_buf, POINTER)) {
1368 pc->cb_info->data_fd = muse_core_client_new_data_ch();
1369 muse_core_send_module_addr(module_addr, pc->cb_info->data_fd);
1370 LOGD("Data channel fd %d, muse module addr %p", pc->cb_info->data_fd, module_addr);
1372 SERVER_TIMEOUT(pc) = MAX_SERVER_TIME_OUT; /* will be update after prepare phase. */
1376 pc->cb_info->bufmgr = tbm_bufmgr_init(-1);
1377 pc->push_media_stream = FALSE;
1383 if (pc && pc->cb_info) {
1384 if (pc->cb_info->event_queue.running)
1385 _player_event_queue_destroy(pc->cb_info);
1386 callback_destroy(pc->cb_info);
1391 LOGD("ret value : %d", ret);
1395 int player_destroy(player_h player)
1397 PLAYER_INSTANCE_CHECK(player);
1399 int ret = PLAYER_ERROR_NONE;
1400 muse_player_api_e api = MUSE_PLAYER_API_DESTROY;
1401 player_cli_s *pc = (player_cli_s *) player;
1402 char *ret_buf = NULL;
1406 player_msg_send(api, pc, ret_buf, ret);
1407 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1408 if (CALLBACK_INFO(pc) && EVAS_HANDLE(pc)) {
1409 player_unset_media_packet_video_frame_decoded_cb(player);
1410 if (mm_evas_renderer_destroy(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
1411 LOGW("fail to unset evas client");
1414 if (pc->cb_info && pc->cb_info->packet_list) {
1415 g_mutex_lock(&pc->cb_info->data_mutex);
1416 LOGW("num of remained packets : %d !!", g_list_length(pc->cb_info->packet_list));
1417 /* each media packet have to destroyed in application. */
1418 g_list_free(pc->cb_info->packet_list);
1419 pc->cb_info->packet_list = NULL;
1420 g_mutex_unlock(&pc->cb_info->data_mutex);
1423 if (_wl_window_evas_object_cb_del(player) != MM_ERROR_NONE)
1424 LOGW("fail to unset evas object callback");
1426 if (CALLBACK_INFO(pc)) {
1427 __player_remove_tsurf_list(pc);
1428 _player_event_queue_destroy(CALLBACK_INFO(pc));
1429 tbm_bufmgr_deinit(TBM_BUFMGR(pc));
1431 callback_destroy(CALLBACK_INFO(pc));
1441 int player_prepare_async(player_h player, player_prepared_cb callback, void *user_data)
1443 PLAYER_INSTANCE_CHECK(player);
1444 int ret = PLAYER_ERROR_NONE;
1445 muse_player_api_e api = MUSE_PLAYER_API_PREPARE_ASYNC;
1446 player_cli_s *pc = (player_cli_s *) player;
1447 char *ret_buf = NULL;
1451 if (pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
1452 LOGE("PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing...", PLAYER_ERROR_INVALID_OPERATION);
1453 return PLAYER_ERROR_INVALID_OPERATION;
1455 pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = callback;
1456 pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = user_data;
1458 player_msg_send(api, pc, ret_buf, ret);
1459 if (ret == PLAYER_ERROR_NONE) {
1461 player_msg_get_type(timeout, ret_buf, INT);
1463 LOGD("server timeout will be %d", timeout);
1464 SERVER_TIMEOUT(pc) = timeout;
1471 int player_prepare(player_h player)
1473 PLAYER_INSTANCE_CHECK(player);
1474 int ret = PLAYER_ERROR_NONE;
1475 muse_player_api_e api = MUSE_PLAYER_API_PREPARE;
1476 player_cli_s *pc = (player_cli_s *) player;
1477 char *ret_buf = NULL;
1481 player_msg_send(api, pc, ret_buf, ret);
1482 if (ret == PLAYER_ERROR_NONE) {
1484 player_msg_get_type(timeout, ret_buf, INT);
1486 LOGD("server timeout will be %d", timeout);
1487 SERVER_TIMEOUT(pc) = timeout;
1494 int player_unprepare(player_h player)
1496 PLAYER_INSTANCE_CHECK(player);
1497 int ret = PLAYER_ERROR_NONE;
1498 muse_player_api_e api = MUSE_PLAYER_API_UNPREPARE;
1499 player_cli_s *pc = (player_cli_s *) player;
1500 char *ret_buf = NULL;
1504 if (!CALLBACK_INFO(pc))
1505 return PLAYER_ERROR_INVALID_STATE;
1506 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1507 if (EVAS_HANDLE(pc)) {
1508 player_unset_media_packet_video_frame_decoded_cb(player);
1509 if (mm_evas_renderer_destroy(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
1510 LOGW("fail to unset evas client");
1513 player_msg_send(api, pc, ret_buf, ret);
1514 if (ret == PLAYER_ERROR_NONE) {
1515 set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
1516 set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE);
1518 _player_deinit_memory_buffer(pc);
1521 pc->cb_info->video_frame_pool_size = 0;
1522 __player_remove_tsurf_list(pc);
1528 int player_set_uri(player_h player, const char *uri)
1530 PLAYER_INSTANCE_CHECK(player);
1531 PLAYER_NULL_ARG_CHECK(uri);
1532 int ret = PLAYER_ERROR_NONE;
1533 muse_player_api_e api = MUSE_PLAYER_API_SET_URI;
1534 player_cli_s *pc = (player_cli_s *) player;
1535 char *ret_buf = NULL;
1539 player_msg_send1(api, pc, ret_buf, ret, STRING, uri);
1540 pc->push_media_stream = FALSE;
1546 int player_set_memory_buffer(player_h player, const void *data, int size)
1548 PLAYER_INSTANCE_CHECK(player);
1549 PLAYER_NULL_ARG_CHECK(data);
1550 int ret = PLAYER_ERROR_NONE;
1551 muse_player_api_e api = MUSE_PLAYER_API_SET_MEMORY_BUFFER;
1552 player_cli_s *pc = (player_cli_s *) player;
1553 char *ret_buf = NULL;
1555 tbm_bo_handle thandle;
1558 if (SERVER_TBM_BO(pc)) {
1559 LOGE("Already set the memory buffer. unprepare please");
1560 return PLAYER_ERROR_INVALID_OPERATION;
1563 bo = tbm_bo_alloc(pc->cb_info->bufmgr, size, TBM_BO_DEFAULT);
1565 LOGE("TBM get error : bo is NULL");
1566 return PLAYER_ERROR_INVALID_OPERATION;
1568 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
1569 if (thandle.ptr == NULL) {
1570 LOGE("TBM get error : handle pointer is NULL");
1571 ret = PLAYER_ERROR_INVALID_OPERATION;
1574 memcpy(thandle.ptr, data, size);
1577 key = tbm_bo_export(bo);
1579 LOGE("TBM get error : key is 0");
1580 ret = PLAYER_ERROR_INVALID_OPERATION;
1584 player_msg_send2(api, pc, ret_buf, ret, INT, key, INT, size);
1585 pc->push_media_stream = FALSE;
1590 if (ret == PLAYER_ERROR_NONE) {
1591 intptr_t bo_addr = 0;
1592 if (player_msg_get_type(bo_addr, ret_buf, POINTER))
1593 SERVER_TBM_BO(pc) = (intptr_t) bo_addr;
1600 static int _player_deinit_memory_buffer(player_cli_s * pc)
1602 PLAYER_INSTANCE_CHECK(pc);
1603 int ret = PLAYER_ERROR_NONE;
1604 muse_player_api_e api = MUSE_PLAYER_API_DEINIT_MEMORY_BUFFER;
1605 intptr_t bo_addr = SERVER_TBM_BO(pc);
1610 player_msg_send1_async(api, pc, POINTER, bo_addr);
1612 SERVER_TBM_BO(pc) = 0;
1617 int player_get_state(player_h player, player_state_e * pstate)
1619 PLAYER_INSTANCE_CHECK(player);
1620 PLAYER_NULL_ARG_CHECK(pstate);
1621 int ret = PLAYER_ERROR_NONE;
1622 muse_player_api_e api = MUSE_PLAYER_API_GET_STATE;
1623 player_cli_s *pc = (player_cli_s *) player;
1625 char *ret_buf = NULL;
1629 player_msg_send(api, pc, ret_buf, ret);
1631 if (ret == PLAYER_ERROR_NONE) {
1632 player_msg_get(state, ret_buf);
1640 int player_set_volume(player_h player, float left, float right)
1642 PLAYER_INSTANCE_CHECK(player);
1643 PLAYER_CHECK_CONDITION(left >= 0 && left <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1644 PLAYER_CHECK_CONDITION(right >= 0 && right <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1645 int ret = PLAYER_ERROR_NONE;
1646 muse_player_api_e api = MUSE_PLAYER_API_SET_VOLUME;
1647 player_cli_s *pc = (player_cli_s *) player;
1648 char *ret_buf = NULL;
1652 player_msg_send2(api, pc, ret_buf, ret, DOUBLE, right, DOUBLE, left);
1657 int player_get_volume(player_h player, float *pleft, float *pright)
1659 PLAYER_INSTANCE_CHECK(player);
1660 PLAYER_NULL_ARG_CHECK(pleft);
1661 PLAYER_NULL_ARG_CHECK(pright);
1662 int ret = PLAYER_ERROR_NONE;
1663 muse_player_api_e api = MUSE_PLAYER_API_GET_VOLUME;
1664 player_cli_s *pc = (player_cli_s *) player;
1667 char *ret_buf = NULL;
1671 player_msg_send(api, pc, ret_buf, ret);
1673 if (ret == PLAYER_ERROR_NONE) {
1674 bool ret_val = TRUE;
1675 player_msg_get2(ret_buf, left, DOUBLE, right, DOUBLE, ret_val);
1677 *pleft = (float)left;
1678 *pright = (float)right;
1680 LOGE("failed to get value from msg");
1681 ret = PLAYER_ERROR_INVALID_OPERATION;
1689 int player_set_sound_type(player_h player, sound_type_e type)
1691 PLAYER_INSTANCE_CHECK(player);
1692 int ret = PLAYER_ERROR_NONE;
1693 muse_player_api_e api = MUSE_PLAYER_API_SET_SOUND_TYPE;
1694 player_cli_s *pc = (player_cli_s *) player;
1695 char *ret_buf = NULL;
1699 player_msg_send1(api, pc, ret_buf, ret, INT, type);
1704 int player_set_audio_policy_info(player_h player, sound_stream_info_h stream_info)
1706 PLAYER_INSTANCE_CHECK(player);
1708 muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_POLICY_INFO;
1709 player_cli_s *pc = (player_cli_s *) player;
1710 char *ret_buf = NULL;
1714 bool is_available = false;
1716 /* check if stream_info is valid */
1717 int ret = __player_convert_error_code(
1718 sound_manager_is_available_stream_information(
1719 stream_info, NATIVE_API_PLAYER, &is_available), (char *)__FUNCTION__);
1721 if (ret == PLAYER_ERROR_NONE) {
1722 if (is_available == false)
1723 ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
1725 char *stream_type = NULL;
1726 int stream_index = 0;
1727 ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
1728 ret = sound_manager_get_index_from_stream_information(stream_info, &stream_index);
1729 if (ret == SOUND_MANAGER_ERROR_NONE)
1730 player_msg_send2(api, pc, ret_buf, ret, STRING, stream_type, INT, stream_index);
1732 ret = PLAYER_ERROR_INVALID_OPERATION;
1741 int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode)
1743 PLAYER_INSTANCE_CHECK(player);
1744 int ret = PLAYER_ERROR_NONE;
1745 muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE;
1746 player_cli_s *pc = (player_cli_s *) player;
1747 char *ret_buf = NULL;
1751 player_msg_send1(api, pc, ret_buf, ret, INT, latency_mode);
1756 int player_get_audio_latency_mode(player_h player, audio_latency_mode_e * platency_mode)
1758 PLAYER_INSTANCE_CHECK(player);
1759 PLAYER_NULL_ARG_CHECK(platency_mode);
1760 int ret = PLAYER_ERROR_NONE;
1761 muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE;
1762 player_cli_s *pc = (player_cli_s *) player;
1763 char *ret_buf = NULL;
1764 int latency_mode = -1;
1768 player_msg_send(api, pc, ret_buf, ret);
1770 if (ret == PLAYER_ERROR_NONE) {
1771 player_msg_get(latency_mode, ret_buf);
1772 *platency_mode = latency_mode;
1780 int player_start(player_h player)
1782 PLAYER_INSTANCE_CHECK(player);
1783 int ret = PLAYER_ERROR_NONE;
1784 muse_player_api_e api = MUSE_PLAYER_API_START;
1785 player_cli_s *pc = (player_cli_s *) player;
1786 char *ret_buf = NULL;
1789 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1790 if (EVAS_HANDLE(pc)) {
1791 ret = mm_evas_renderer_update_param(EVAS_HANDLE(pc));
1792 if (ret != PLAYER_ERROR_NONE)
1796 player_msg_send(api, pc, ret_buf, ret);
1802 int player_stop(player_h player)
1804 PLAYER_INSTANCE_CHECK(player);
1805 int ret = PLAYER_ERROR_NONE;
1806 muse_player_api_e api = MUSE_PLAYER_API_STOP;
1807 player_cli_s *pc = (player_cli_s *) player;
1808 char *ret_buf = NULL;
1812 player_msg_send(api, pc, ret_buf, ret);
1813 if (ret == PLAYER_ERROR_NONE)
1814 set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
1820 int player_pause(player_h player)
1822 PLAYER_INSTANCE_CHECK(player);
1823 int ret = PLAYER_ERROR_NONE;
1824 muse_player_api_e api = MUSE_PLAYER_API_PAUSE;
1825 player_cli_s *pc = (player_cli_s *) player;
1826 char *ret_buf = NULL;
1830 player_msg_send(api, pc, ret_buf, ret);
1835 int player_set_play_position(player_h player, int millisecond, bool accurate, player_seek_completed_cb callback, void *user_data)
1837 PLAYER_INSTANCE_CHECK(player);
1838 PLAYER_CHECK_CONDITION(millisecond >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
1840 int ret = PLAYER_ERROR_NONE;
1841 muse_player_api_e api = MUSE_PLAYER_API_SET_PLAY_POSITION;
1842 player_cli_s *pc = (player_cli_s *) player;
1843 char *ret_buf = NULL;
1844 int pos = millisecond;
1848 LOGE("cb_info is null");
1849 return PLAYER_ERROR_INVALID_OPERATION;
1852 if ((pc->push_media_stream == FALSE) &&
1853 (pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK])) {
1854 LOGE("PLAYER_ERROR_SEEK_FAILED (0x%08x) : seeking...", PLAYER_ERROR_SEEK_FAILED);
1855 return PLAYER_ERROR_SEEK_FAILED;
1857 g_mutex_lock(&pc->cb_info->seek_cb_mutex);
1858 if (pc->push_media_stream == TRUE)
1859 pc->cb_info->block_seek_cb = TRUE;
1860 LOGI("Event type : %d, pos : %d ", MUSE_PLAYER_EVENT_TYPE_SEEK, millisecond);
1861 pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback;
1862 pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data;
1863 g_mutex_unlock(&pc->cb_info->seek_cb_mutex);
1866 player_msg_send2(api, pc, ret_buf, ret, INT, pos, INT, accurate);
1868 if (ret != PLAYER_ERROR_NONE) {
1869 g_mutex_lock(&pc->cb_info->seek_cb_mutex);
1870 set_null_user_cb(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
1871 g_mutex_unlock(&pc->cb_info->seek_cb_mutex);
1874 if (pc->push_media_stream == TRUE)
1875 _player_event_queue_remove(&pc->cb_info->event_queue, MUSE_PLAYER_EVENT_TYPE_SEEK);
1877 pc->cb_info->block_seek_cb = FALSE;
1882 int player_get_play_position(player_h player, int *millisecond)
1884 PLAYER_INSTANCE_CHECK(player);
1885 PLAYER_NULL_ARG_CHECK(millisecond);
1887 int ret = PLAYER_ERROR_NONE;
1888 muse_player_api_e api = MUSE_PLAYER_API_GET_PLAY_POSITION;
1889 player_cli_s *pc = (player_cli_s *) player;
1891 char *ret_buf = NULL;
1895 player_msg_send(api, pc, ret_buf, ret);
1897 if (ret == PLAYER_ERROR_NONE) {
1898 player_msg_get(pos, ret_buf);
1906 int player_set_mute(player_h player, bool muted)
1908 PLAYER_INSTANCE_CHECK(player);
1909 int ret = PLAYER_ERROR_NONE;
1910 muse_player_api_e api = MUSE_PLAYER_API_SET_MUTE;
1911 player_cli_s *pc = (player_cli_s *) player;
1912 char *ret_buf = NULL;
1913 int mute = (int)muted;
1917 player_msg_send1(api, pc, ret_buf, ret, INT, mute);
1922 int player_is_muted(player_h player, bool * muted)
1924 PLAYER_INSTANCE_CHECK(player);
1925 PLAYER_NULL_ARG_CHECK(muted);
1926 int ret = PLAYER_ERROR_NONE;
1927 muse_player_api_e api = MUSE_PLAYER_API_IS_MUTED;
1928 player_cli_s *pc = (player_cli_s *) player;
1929 char *ret_buf = NULL;
1934 player_msg_send(api, pc, ret_buf, ret);
1935 if (ret == PLAYER_ERROR_NONE) {
1936 player_msg_get(mute, ret_buf);
1937 *muted = (bool) mute;
1944 int player_set_looping(player_h player, bool looping)
1946 PLAYER_INSTANCE_CHECK(player);
1947 int ret = PLAYER_ERROR_NONE;
1948 muse_player_api_e api = MUSE_PLAYER_API_SET_LOOPING;
1949 player_cli_s *pc = (player_cli_s *) player;
1950 char *ret_buf = NULL;
1954 player_msg_send1(api, pc, ret_buf, ret, INT, looping);
1959 int player_is_looping(player_h player, bool * plooping)
1961 PLAYER_INSTANCE_CHECK(player);
1962 PLAYER_NULL_ARG_CHECK(plooping);
1963 int ret = PLAYER_ERROR_NONE;
1964 muse_player_api_e api = MUSE_PLAYER_API_IS_LOOPING;
1965 player_cli_s *pc = (player_cli_s *) player;
1966 char *ret_buf = NULL;
1971 player_msg_send(api, pc, ret_buf, ret);
1972 if (ret == PLAYER_ERROR_NONE) {
1973 player_msg_get(looping, ret_buf);
1974 *plooping = looping;
1980 int player_get_duration(player_h player, int *pduration)
1982 PLAYER_INSTANCE_CHECK(player);
1983 PLAYER_NULL_ARG_CHECK(pduration);
1984 int ret = PLAYER_ERROR_NONE;
1985 muse_player_api_e api = MUSE_PLAYER_API_GET_DURATION;
1986 player_cli_s *pc = (player_cli_s *) player;
1987 char *ret_buf = NULL;
1992 player_msg_send(api, pc, ret_buf, ret);
1993 if (ret == PLAYER_ERROR_NONE) {
1994 player_msg_get(duration, ret_buf);
1995 *pduration = duration;
2002 int player_set_display(player_h player, player_display_type_e type, player_display_h display)
2004 PLAYER_INSTANCE_CHECK(player);
2005 int ret = PLAYER_ERROR_NONE;
2006 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY;
2007 player_cli_s *pc = (player_cli_s *) player;
2008 char *ret_buf = NULL;
2009 Evas_Object *obj = NULL;
2010 const char *object_type = NULL;
2011 wl_win_msg_type wl_win;
2012 char *wl_win_msg = (char *)&wl_win;
2013 unsigned int wl_surface_id;
2014 struct wl_surface *wl_surface;
2015 struct wl_display *wl_display;
2016 Ecore_Wl_Window *wl_window = NULL;
2021 if (type != PLAYER_DISPLAY_TYPE_NONE) {
2022 obj = (Evas_Object *) display;
2024 return PLAYER_ERROR_INVALID_PARAMETER;
2026 object_type = evas_object_type_get(obj);
2028 if (type == PLAYER_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2029 /* wayland overlay surface */
2030 LOGI("Wayland overlay surface type");
2033 e = evas_object_evas_get(obj);
2034 return_val_if_fail(e != NULL, PLAYER_ERROR_INVALID_OPERATION);
2036 ret = _wl_window_geometry_get(obj, e, &wl_win.wl_window_x, &wl_win.wl_window_y,
2037 &wl_win.wl_window_width, &wl_win.wl_window_height);
2038 if (ret != MM_ERROR_NONE) {
2039 LOGE("Fail to get window geometry");
2042 if (_wl_window_evas_object_cb_add(player, obj) != MM_ERROR_NONE)
2043 LOGW("fail to set evas object callback");
2045 wl_window = elm_win_wl_window_get(obj);
2046 return_val_if_fail(wl_window != NULL, PLAYER_ERROR_INVALID_OPERATION);
2048 wl_surface = (struct wl_surface *)ecore_wl_window_surface_get(wl_window);
2050 /* get wl_display */
2051 wl_display = (struct wl_display *)ecore_wl_display_get();
2053 if (!pc->wlclient) {
2054 ret = _wl_client_create(&pc->wlclient);
2055 if (ret != MM_ERROR_NONE) {
2056 LOGE("Wayland client create failure");
2060 if (wl_surface && wl_display) {
2061 LOGD("surface = %p, wl_display = %p", wl_surface, wl_display);
2062 wl_surface_id = _wl_client_get_wl_window_wl_surface_id(pc->wlclient, wl_surface, wl_display);
2063 LOGD("wl_surface_id = %d", wl_surface_id);
2064 wl_win.wl_surface_id = wl_surface_id;
2065 LOGD("wl_win.wl_surface_id = %d", wl_win.wl_surface_id);
2067 LOGE("Fail to get wl_surface or wl_display");
2068 return PLAYER_ERROR_INVALID_OPERATION;
2071 g_free(pc->wlclient);
2072 pc->wlclient = NULL;
2075 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2076 else if (type == PLAYER_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2077 /* evas object surface */
2078 LOGI("evas surface type");
2081 evas_object_geometry_get(obj, &wl_win.wl_window_x, &wl_win.wl_window_y,
2082 &wl_win.wl_window_width, &wl_win.wl_window_height);
2084 if (EVAS_HANDLE(pc)) {
2085 LOGW("evas client already exists");
2086 if (mm_evas_renderer_destroy(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
2087 LOGW("fail to unset evas client");
2089 if (mm_evas_renderer_create(&EVAS_HANDLE(pc), obj) != MM_ERROR_NONE)
2090 LOGW("fail to set evas client");
2092 if (player_set_media_packet_video_frame_decoded_cb(player, mm_evas_renderer_write, (void *)EVAS_HANDLE(pc)) != PLAYER_ERROR_NONE)
2093 LOGW("fail to set decoded callback");
2097 return PLAYER_ERROR_INVALID_PARAMETER;
2099 return PLAYER_ERROR_INVALID_PARAMETER;
2100 } else { /* PLAYER_DISPLAY_TYPE_NONE */
2101 LOGI("Wayland surface type is NONE");
2103 wl_win.wl_window_x = 0;
2104 wl_win.wl_window_y = 0;
2105 wl_win.wl_window_width = 0;
2106 wl_win.wl_window_height = 0;
2108 player_msg_send_array(api, pc, ret_buf, ret, wl_win_msg, sizeof(wl_win_msg_type), sizeof(char));
2113 int player_set_display_mode(player_h player, player_display_mode_e mode)
2115 PLAYER_INSTANCE_CHECK(player);
2116 PLAYER_CHECK_CONDITION(PLAYER_DISPLAY_MODE_LETTER_BOX <= mode && mode < PLAYER_DISPLAY_MODE_NUM, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2117 int ret = PLAYER_ERROR_NONE;
2118 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_MODE;
2119 player_cli_s *pc = (player_cli_s *) player;
2120 char *ret_buf = NULL;
2123 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2124 if (EVAS_HANDLE(pc)) {
2125 ret = mm_evas_renderer_set_geometry(EVAS_HANDLE(pc), mode);
2129 player_msg_send1(api, pc, ret_buf, ret, INT, mode);
2134 int player_get_display_mode(player_h player, player_display_mode_e * pmode)
2136 PLAYER_INSTANCE_CHECK(player);
2137 PLAYER_NULL_ARG_CHECK(pmode);
2138 int ret = PLAYER_ERROR_NONE;
2139 muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_MODE;
2140 player_cli_s *pc = (player_cli_s *) player;
2141 char *ret_buf = NULL;
2145 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2146 if (EVAS_HANDLE(pc)) {
2147 ret = mm_evas_renderer_get_geometry(EVAS_HANDLE(pc), &mode);
2148 *pmode = (player_display_mode_e) mode;
2152 player_msg_send(api, pc, ret_buf, ret);
2153 if (ret == PLAYER_ERROR_NONE) {
2154 player_msg_get_type(mode, ret_buf, INT);
2162 int player_set_playback_rate(player_h player, float rate)
2164 PLAYER_INSTANCE_CHECK(player);
2165 PLAYER_CHECK_CONDITION(rate >= -5.0 && rate <= 5.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2166 int ret = PLAYER_ERROR_NONE;
2167 muse_player_api_e api = MUSE_PLAYER_API_SET_PLAYBACK_RATE;
2168 player_cli_s *pc = (player_cli_s *) player;
2169 char *ret_buf = NULL;
2173 player_msg_send1(api, pc, ret_buf, ret, DOUBLE, rate);
2178 int player_set_display_rotation(player_h player, player_display_rotation_e rotation)
2180 PLAYER_INSTANCE_CHECK(player);
2181 int ret = PLAYER_ERROR_NONE;
2182 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROTATION;
2183 player_cli_s *pc = (player_cli_s *) player;
2184 char *ret_buf = NULL;
2187 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2188 if (EVAS_HANDLE(pc)) {
2189 ret = mm_evas_renderer_set_rotation(EVAS_HANDLE(pc), rotation);
2193 player_msg_send1(api, pc, ret_buf, ret, INT, rotation);
2198 int player_get_display_rotation(player_h player, player_display_rotation_e * protation)
2200 PLAYER_INSTANCE_CHECK(player);
2201 PLAYER_NULL_ARG_CHECK(protation);
2202 int ret = PLAYER_ERROR_NONE;
2203 player_cli_s *pc = (player_cli_s *) player;
2204 muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_ROTATION;
2205 char *ret_buf = NULL;
2209 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2210 if (EVAS_HANDLE(pc)) {
2211 ret = mm_evas_renderer_get_rotation(EVAS_HANDLE(pc), &rotation);
2212 *protation = (player_display_rotation_e) rotation;
2216 player_msg_send(api, pc, ret_buf, ret);
2217 if (ret == PLAYER_ERROR_NONE) {
2218 player_msg_get_type(rotation, ret_buf, INT);
2219 *protation = rotation;
2226 int player_set_display_visible(player_h player, bool visible)
2228 PLAYER_INSTANCE_CHECK(player);
2229 int ret = PLAYER_ERROR_NONE;
2230 player_cli_s *pc = (player_cli_s *) player;
2231 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_VISIBLE;
2232 char *ret_buf = NULL;
2235 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2236 if (EVAS_HANDLE(pc)) {
2237 ret = mm_evas_renderer_set_visible(EVAS_HANDLE(pc), visible);
2241 player_msg_send1(api, pc, ret_buf, ret, INT, visible);
2246 int player_is_display_visible(player_h player, bool * pvisible)
2248 PLAYER_INSTANCE_CHECK(player);
2249 PLAYER_NULL_ARG_CHECK(pvisible);
2250 int ret = PLAYER_ERROR_NONE;
2251 player_cli_s *pc = (player_cli_s *) player;
2252 muse_player_api_e api = MUSE_PLAYER_API_IS_DISPLAY_VISIBLE;
2253 char *ret_buf = NULL;
2255 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2259 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2260 if (EVAS_HANDLE(pc)) {
2261 ret = mm_evas_renderer_get_visible(EVAS_HANDLE(pc), &visible);
2269 player_msg_send(api, pc, ret_buf, ret);
2270 if (ret == PLAYER_ERROR_NONE) {
2271 player_msg_get_type(value, ret_buf, INT);
2283 int player_get_content_info(player_h player, player_content_info_e key, char **pvalue)
2285 PLAYER_INSTANCE_CHECK(player);
2286 PLAYER_NULL_ARG_CHECK(pvalue);
2287 int ret = PLAYER_ERROR_NONE;
2288 muse_player_api_e api = MUSE_PLAYER_API_GET_CONTENT_INFO;
2289 player_cli_s *pc = (player_cli_s *) player;
2290 char *ret_buf = NULL;
2291 char value[MUSE_MSG_MAX_LENGTH] = { 0, };
2295 player_msg_send1(api, pc, ret_buf, ret, INT, key);
2296 if (ret == PLAYER_ERROR_NONE) {
2297 player_msg_get_string(value, ret_buf);
2298 *pvalue = strndup(value, MUSE_MSG_MAX_LENGTH);
2304 int player_get_codec_info(player_h player, char **paudio_codec, char **pvideo_codec)
2306 PLAYER_INSTANCE_CHECK(player);
2307 PLAYER_NULL_ARG_CHECK(paudio_codec);
2308 PLAYER_NULL_ARG_CHECK(pvideo_codec);
2309 int ret = PLAYER_ERROR_NONE;
2310 muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_INFO;
2311 player_cli_s *pc = (player_cli_s *) player;
2312 char *ret_buf = NULL;
2313 char video_codec[MUSE_MSG_MAX_LENGTH] = { 0, };
2314 char audio_codec[MUSE_MSG_MAX_LENGTH] = { 0, };
2315 bool ret_val = TRUE;
2319 player_msg_send(api, pc, ret_buf, ret);
2320 if (ret == PLAYER_ERROR_NONE) {
2321 player_msg_get_string2(ret_buf, video_codec, audio_codec, ret_val);
2323 *pvideo_codec = strndup(video_codec, MUSE_MSG_MAX_LENGTH);
2324 *paudio_codec = strndup(audio_codec, MUSE_MSG_MAX_LENGTH);
2326 ret = PLAYER_ERROR_INVALID_OPERATION;
2333 int player_get_audio_stream_info(player_h player, int *psample_rate, int *pchannel, int *pbit_rate)
2335 PLAYER_INSTANCE_CHECK(player);
2336 PLAYER_NULL_ARG_CHECK(psample_rate);
2337 PLAYER_NULL_ARG_CHECK(pchannel);
2338 PLAYER_NULL_ARG_CHECK(pbit_rate);
2339 int ret = PLAYER_ERROR_NONE;
2340 muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO;
2341 player_cli_s *pc = (player_cli_s *) player;
2342 char *ret_buf = NULL;
2343 int sample_rate = 0;
2349 player_msg_send(api, pc, ret_buf, ret);
2350 if (ret == PLAYER_ERROR_NONE) {
2351 bool ret_val = TRUE;
2352 player_msg_get3(ret_buf, sample_rate, INT, channel, INT, bit_rate, INT, ret_val);
2354 *psample_rate = sample_rate;
2355 *pchannel = channel;
2356 *pbit_rate = bit_rate;
2358 ret = PLAYER_ERROR_INVALID_OPERATION;
2365 int player_get_video_stream_info(player_h player, int *pfps, int *pbit_rate)
2367 PLAYER_INSTANCE_CHECK(player);
2368 PLAYER_NULL_ARG_CHECK(pfps);
2369 PLAYER_NULL_ARG_CHECK(pbit_rate);
2370 int ret = PLAYER_ERROR_NONE;
2371 muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO;
2372 player_cli_s *pc = (player_cli_s *) player;
2373 char *ret_buf = NULL;
2379 player_msg_send(api, pc, ret_buf, ret);
2380 if (ret == PLAYER_ERROR_NONE) {
2381 bool ret_val = TRUE;
2382 player_msg_get2(ret_buf, fps, INT, bit_rate, INT, ret_val);
2385 *pbit_rate = bit_rate;
2387 ret = PLAYER_ERROR_INVALID_OPERATION;
2394 int player_get_video_size(player_h player, int *pwidth, int *pheight)
2396 PLAYER_INSTANCE_CHECK(player);
2397 PLAYER_NULL_ARG_CHECK(pwidth);
2398 PLAYER_NULL_ARG_CHECK(pheight);
2399 int ret = PLAYER_ERROR_NONE;
2400 muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_SIZE;
2401 player_cli_s *pc = (player_cli_s *) player;
2402 char *ret_buf = NULL;
2408 player_msg_send(api, pc, ret_buf, ret);
2409 if (ret == PLAYER_ERROR_NONE) {
2410 bool ret_val = TRUE;
2411 player_msg_get2(ret_buf, width, INT, height, INT, ret_val);
2416 ret = PLAYER_ERROR_INVALID_OPERATION;
2423 int player_get_album_art(player_h player, void **palbum_art, int *psize)
2425 PLAYER_INSTANCE_CHECK(player);
2426 PLAYER_NULL_ARG_CHECK(palbum_art);
2427 PLAYER_NULL_ARG_CHECK(psize);
2428 int ret = PLAYER_ERROR_NONE;
2429 muse_player_api_e api = MUSE_PLAYER_API_GET_ALBUM_ART;
2430 player_cli_s *pc = (player_cli_s *) player;
2431 char *ret_buf = NULL;
2435 tbm_bo_handle thandle;
2441 player_msg_send(api, pc, ret_buf, ret);
2442 if (ret == PLAYER_ERROR_NONE) {
2443 muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
2444 jobj = muse_core_msg_json_object_new(ret_buf, NULL, &err);
2446 LOGE("failed to get msg obj, err:%d", err);
2447 ret = PLAYER_ERROR_INVALID_OPERATION;
2451 if (muse_core_msg_json_object_get_value("size", jobj, &size, MUSE_TYPE_INT) && (size > 0)) {
2452 LOGD("size : %d", size);
2453 if (!muse_core_msg_json_object_get_value("key", jobj, &key, MUSE_TYPE_INT)) {
2454 ret = PLAYER_ERROR_INVALID_OPERATION;
2458 bo = tbm_bo_import(pc->cb_info->bufmgr, key);
2460 LOGE("TBM get error : bo is NULL");
2461 ret = PLAYER_ERROR_INVALID_OPERATION;
2464 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE | TBM_OPTION_READ);
2465 if (thandle.ptr == NULL) {
2466 LOGE("TBM get error : handle pointer is NULL");
2467 ret = PLAYER_ERROR_INVALID_OPERATION;
2470 album_art = _get_mem(pc, size);
2472 memcpy(album_art, thandle.ptr, size);
2473 *palbum_art = album_art;
2475 LOGE("g_new failure");
2476 ret = PLAYER_ERROR_INVALID_OPERATION;
2487 muse_core_msg_json_object_free(jobj);
2497 LOGD("send msg to release buffer. key:%d", key);
2498 player_msg_send1_async(MUSE_PLAYER_API_RETURN_BUFFER, pc, INT, key);
2504 int player_audio_effect_get_equalizer_bands_count(player_h player, int *pcount)
2506 PLAYER_INSTANCE_CHECK(player);
2507 PLAYER_NULL_ARG_CHECK(pcount);
2508 int ret = PLAYER_ERROR_NONE;
2509 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT;
2510 player_cli_s *pc = (player_cli_s *) player;
2511 char *ret_buf = NULL;
2516 player_msg_send(api, pc, ret_buf, ret);
2517 if (ret == PLAYER_ERROR_NONE) {
2518 player_msg_get(count, ret_buf);
2525 int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length)
2527 PLAYER_INSTANCE_CHECK(player);
2528 PLAYER_NULL_ARG_CHECK(band_levels);
2529 int ret = PLAYER_ERROR_NONE;
2530 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS;
2531 player_cli_s *pc = (player_cli_s *) player;
2532 char *ret_buf = NULL;
2536 player_msg_send_array(api, pc, ret_buf, ret, band_levels, length, sizeof(int));
2543 int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level)
2545 PLAYER_INSTANCE_CHECK(player);
2546 int ret = PLAYER_ERROR_NONE;
2547 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL;
2548 player_cli_s *pc = (player_cli_s *) player;
2549 char *ret_buf = NULL;
2553 player_msg_send2(api, pc, ret_buf, ret, INT, index, INT, level);
2559 int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *plevel)
2561 PLAYER_INSTANCE_CHECK(player);
2562 PLAYER_NULL_ARG_CHECK(plevel);
2563 int ret = PLAYER_ERROR_NONE;
2564 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL;
2565 player_cli_s *pc = (player_cli_s *) player;
2566 char *ret_buf = NULL;
2571 player_msg_send1(api, pc, ret_buf, ret, INT, index);
2572 if (ret == PLAYER_ERROR_NONE) {
2573 player_msg_get(level, ret_buf);
2580 int player_audio_effect_get_equalizer_level_range(player_h player, int *pmin, int *pmax)
2582 PLAYER_INSTANCE_CHECK(player);
2583 PLAYER_NULL_ARG_CHECK(pmin);
2584 PLAYER_NULL_ARG_CHECK(pmax);
2585 int ret = PLAYER_ERROR_NONE;
2586 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE;
2587 player_cli_s *pc = (player_cli_s *) player;
2588 char *ret_buf = NULL;
2589 int min = 0, max = 0;
2593 player_msg_send(api, pc, ret_buf, ret);
2594 if (ret == PLAYER_ERROR_NONE) {
2595 bool ret_val = TRUE;
2596 player_msg_get2(ret_buf, min, INT, max, INT, ret_val);
2601 ret = PLAYER_ERROR_INVALID_OPERATION;
2608 int player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *pfrequency)
2610 PLAYER_INSTANCE_CHECK(player);
2611 PLAYER_NULL_ARG_CHECK(pfrequency);
2612 int ret = PLAYER_ERROR_NONE;
2613 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY;
2614 player_cli_s *pc = (player_cli_s *) player;
2615 char *ret_buf = NULL;
2620 player_msg_send1(api, pc, ret_buf, ret, INT, index);
2621 if (ret == PLAYER_ERROR_NONE) {
2622 player_msg_get(frequency, ret_buf);
2623 *pfrequency = frequency;
2629 int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *prange)
2631 PLAYER_INSTANCE_CHECK(player);
2632 PLAYER_NULL_ARG_CHECK(prange);
2633 int ret = PLAYER_ERROR_NONE;
2634 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE;
2635 player_cli_s *pc = (player_cli_s *) player;
2636 char *ret_buf = NULL;
2641 player_msg_send1(api, pc, ret_buf, ret, INT, index);
2642 if (ret == PLAYER_ERROR_NONE) {
2643 player_msg_get(range, ret_buf);
2650 int player_audio_effect_equalizer_clear(player_h player)
2652 PLAYER_INSTANCE_CHECK(player);
2653 int ret = PLAYER_ERROR_NONE;
2654 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR;
2655 player_cli_s *pc = (player_cli_s *) player;
2656 char *ret_buf = NULL;
2660 player_msg_send(api, pc, ret_buf, ret);
2665 int player_audio_effect_equalizer_is_available(player_h player, bool * pavailable)
2667 PLAYER_INSTANCE_CHECK(player);
2668 PLAYER_NULL_ARG_CHECK(pavailable);
2669 int ret = PLAYER_ERROR_NONE;
2670 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE;
2671 player_cli_s *pc = (player_cli_s *) player;
2672 char *ret_buf = NULL;
2677 player_msg_send(api, pc, ret_buf, ret);
2678 if (ret == PLAYER_ERROR_NONE) {
2679 player_msg_get(available, ret_buf);
2680 *pavailable = available;
2686 int player_set_subtitle_path(player_h player, const char *path)
2688 PLAYER_INSTANCE_CHECK(player);
2689 int ret = PLAYER_ERROR_NONE;
2690 muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_PATH;
2691 player_cli_s *pc = (player_cli_s *) player;
2692 char *ret_buf = NULL;
2696 player_msg_send1(api, pc, ret_buf, ret, STRING, path);
2701 int player_set_subtitle_position_offset(player_h player, int millisecond)
2703 PLAYER_INSTANCE_CHECK(player);
2704 int ret = PLAYER_ERROR_NONE;
2705 muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET;
2706 player_cli_s *pc = (player_cli_s *) player;
2707 char *ret_buf = NULL;
2711 player_msg_send1(api, pc, ret_buf, ret, INT, millisecond);
2717 int player_set_progressive_download_path(player_h player, const char *path)
2719 PLAYER_INSTANCE_CHECK(player);
2720 PLAYER_NULL_ARG_CHECK(path);
2721 int ret = PLAYER_ERROR_NONE;
2722 muse_player_api_e api = MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH;
2723 player_cli_s *pc = (player_cli_s *) player;
2724 char *ret_buf = NULL;
2728 player_msg_send1(api, pc, ret_buf, ret, STRING, path);
2733 int player_get_progressive_download_status(player_h player, unsigned long *pcurrent, unsigned long *ptotal_size)
2735 PLAYER_INSTANCE_CHECK(player);
2736 PLAYER_NULL_ARG_CHECK(pcurrent);
2737 PLAYER_NULL_ARG_CHECK(ptotal_size);
2738 int ret = PLAYER_ERROR_NONE;
2739 muse_player_api_e api = MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS;
2740 player_cli_s *pc = (player_cli_s *) player;
2741 char *ret_buf = NULL;
2742 unsigned long current, total_size;
2746 player_msg_send(api, pc, ret_buf, ret);
2747 if (ret == PLAYER_ERROR_NONE) {
2748 bool ret_val = TRUE;
2749 player_msg_get2(ret_buf, current, POINTER, total_size, POINTER, ret_val);
2751 *pcurrent = current;
2752 *ptotal_size = total_size;
2754 ret = PLAYER_ERROR_INVALID_OPERATION;
2762 int player_capture_video(player_h player, player_video_captured_cb callback, void *user_data)
2764 PLAYER_INSTANCE_CHECK(player);
2765 PLAYER_NULL_ARG_CHECK(callback);
2766 int ret = PLAYER_ERROR_NONE;
2767 muse_player_api_e api = MUSE_PLAYER_API_CAPTURE_VIDEO;
2768 player_cli_s *pc = (player_cli_s *) player;
2769 char *ret_buf = NULL;
2772 if (pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
2773 LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : capturing...", PLAYER_ERROR_VIDEO_CAPTURE_FAILED);
2774 return PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
2776 LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_CAPTURE);
2777 pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = callback;
2778 pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = user_data;
2781 player_msg_send(api, pc, ret_buf, ret);
2783 if (ret != PLAYER_ERROR_NONE)
2784 set_null_user_cb(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_CAPTURE);
2790 int player_set_streaming_cookie(player_h player, const char *cookie, int size)
2792 PLAYER_INSTANCE_CHECK(player);
2793 PLAYER_NULL_ARG_CHECK(cookie);
2794 PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2795 int ret = PLAYER_ERROR_NONE;
2796 muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_COOKIE;
2797 player_cli_s *pc = (player_cli_s *) player;
2798 char *ret_buf = NULL;
2802 player_msg_send2(api, pc, ret_buf, ret, STRING, cookie, INT, size);
2807 int player_set_streaming_user_agent(player_h player, const char *user_agent, int size)
2809 PLAYER_INSTANCE_CHECK(player);
2810 PLAYER_NULL_ARG_CHECK(user_agent);
2811 PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
2812 int ret = PLAYER_ERROR_NONE;
2813 muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_USER_AGENT;
2814 player_cli_s *pc = (player_cli_s *) player;
2815 char *ret_buf = NULL;
2819 player_msg_send2(api, pc, ret_buf, ret, STRING, user_agent, INT, size);
2824 int player_get_streaming_download_progress(player_h player, int *pstart, int *pcurrent)
2826 PLAYER_INSTANCE_CHECK(player);
2827 PLAYER_NULL_ARG_CHECK(pstart);
2828 PLAYER_NULL_ARG_CHECK(pcurrent);
2829 int ret = PLAYER_ERROR_NONE;
2830 muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS;
2831 player_cli_s *pc = (player_cli_s *) player;
2832 char *ret_buf = NULL;
2833 int start = 0, current = 0;
2837 player_msg_send(api, pc, ret_buf, ret);
2838 if (ret == PLAYER_ERROR_NONE) {
2839 bool ret_val = TRUE;
2840 player_msg_get2(ret_buf, start, INT, current, INT, ret_val);
2843 *pcurrent = current;
2845 ret = PLAYER_ERROR_INVALID_OPERATION;
2853 int player_set_completed_cb(player_h player, player_completed_cb callback, void *user_data)
2855 return __set_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player, callback, user_data);
2858 int player_unset_completed_cb(player_h player)
2860 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player);
2863 int player_set_interrupted_cb(player_h player, player_interrupted_cb callback, void *user_data)
2865 return __set_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player, callback, user_data);
2868 int player_unset_interrupted_cb(player_h player)
2870 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player);
2873 int player_set_error_cb(player_h player, player_error_cb callback, void *user_data)
2875 return __set_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player, callback, user_data);
2878 int player_unset_error_cb(player_h player)
2880 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player);
2883 int player_set_buffering_cb(player_h player, player_buffering_cb callback, void *user_data)
2885 return __set_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player, callback, user_data);
2888 int player_unset_buffering_cb(player_h player)
2890 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player);
2893 int player_set_subtitle_updated_cb(player_h player, player_subtitle_updated_cb callback, void *user_data)
2895 return __set_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player, callback, user_data);
2898 int player_unset_subtitle_updated_cb(player_h player)
2900 return __unset_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player);
2903 int player_set_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data)
2905 PLAYER_INSTANCE_CHECK(player);
2906 PLAYER_NULL_ARG_CHECK(callback);
2907 int ret = PLAYER_ERROR_NONE;
2908 player_cli_s *pc = (player_cli_s *) player;
2909 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
2910 char *ret_buf = NULL;
2911 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PD;
2916 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
2918 if (ret == PLAYER_ERROR_NONE) {
2919 pc->cb_info->user_cb[type] = callback;
2920 pc->cb_info->user_data[type] = user_data;
2921 LOGI("Event type : %d ", type);
2928 int player_unset_progressive_download_message_cb(player_h player)
2930 PLAYER_INSTANCE_CHECK(player);
2931 int ret = PLAYER_ERROR_NONE;
2932 player_cli_s *pc = (player_cli_s *) player;
2933 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
2934 char *ret_buf = NULL;
2935 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PD;
2940 set_null_user_cb_lock(pc->cb_info, type);
2942 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
2949 int player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data)
2951 PLAYER_INSTANCE_CHECK(player);
2952 PLAYER_NULL_ARG_CHECK(callback);
2953 int ret = PLAYER_ERROR_NONE;
2954 player_cli_s *pc = (player_cli_s *) player;
2955 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
2956 char *ret_buf = NULL;
2957 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
2962 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
2964 if (ret == PLAYER_ERROR_NONE) {
2965 pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = callback;
2966 pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = user_data;
2967 LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
2974 int player_unset_media_packet_video_frame_decoded_cb(player_h player)
2976 PLAYER_INSTANCE_CHECK(player);
2977 int ret = PLAYER_ERROR_NONE;
2978 player_cli_s *pc = (player_cli_s *) player;
2979 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
2980 char *ret_buf = NULL;
2981 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
2986 set_null_user_cb_lock(pc->cb_info, type);
2988 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
2994 int player_set_video_stream_changed_cb(player_h player, player_video_stream_changed_cb callback, void *user_data)
2996 PLAYER_INSTANCE_CHECK(player);
2997 PLAYER_NULL_ARG_CHECK(callback);
2998 int ret = PLAYER_ERROR_NONE;
2999 player_cli_s *pc = (player_cli_s *) player;
3000 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3001 char *ret_buf = NULL;
3002 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
3007 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3009 if (ret == PLAYER_ERROR_NONE) {
3010 pc->cb_info->user_cb[type] = callback;
3011 pc->cb_info->user_data[type] = user_data;
3012 LOGI("Event type : %d ", type);
3019 int player_unset_video_stream_changed_cb(player_h player)
3021 PLAYER_INSTANCE_CHECK(player);
3022 int ret = PLAYER_ERROR_NONE;
3023 player_cli_s *pc = (player_cli_s *) player;
3024 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3025 char *ret_buf = NULL;
3026 muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
3031 set_null_user_cb_lock(pc->cb_info, type);
3033 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3039 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)
3041 PLAYER_INSTANCE_CHECK(player);
3042 PLAYER_NULL_ARG_CHECK(callback);
3043 int ret = PLAYER_ERROR_NONE;
3044 player_cli_s *pc = (player_cli_s *) player;
3045 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3046 char *ret_buf = NULL;
3047 muse_player_event_e type;
3052 if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
3053 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
3054 else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
3055 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
3057 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
3058 return PLAYER_ERROR_INVALID_PARAMETER;
3061 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3063 if (ret == PLAYER_ERROR_NONE) {
3064 pc->cb_info->user_cb[type] = callback;
3065 pc->cb_info->user_data[type] = user_data;
3066 LOGI("Event type : %d ", type);
3073 int player_unset_media_stream_buffer_status_cb(player_h player, player_stream_type_e stream_type)
3075 PLAYER_INSTANCE_CHECK(player);
3076 int ret = PLAYER_ERROR_NONE;
3077 player_cli_s *pc = (player_cli_s *) player;
3078 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3079 char *ret_buf = NULL;
3080 muse_player_event_e type;
3085 if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
3086 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
3087 else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
3088 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
3090 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
3091 return PLAYER_ERROR_INVALID_PARAMETER;
3094 set_null_user_cb_lock(pc->cb_info, type);
3096 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3102 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)
3104 PLAYER_INSTANCE_CHECK(player);
3105 PLAYER_NULL_ARG_CHECK(callback);
3106 int ret = PLAYER_ERROR_NONE;
3107 player_cli_s *pc = (player_cli_s *) player;
3108 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3109 char *ret_buf = NULL;
3110 muse_player_event_e type;
3115 if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
3116 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
3117 else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
3118 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
3120 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
3121 return PLAYER_ERROR_INVALID_PARAMETER;
3124 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3126 if (ret == PLAYER_ERROR_NONE) {
3127 pc->cb_info->user_cb[type] = callback;
3128 pc->cb_info->user_data[type] = user_data;
3129 LOGI("Event type : %d ", type);
3136 int player_unset_media_stream_seek_cb(player_h player, player_stream_type_e stream_type)
3138 PLAYER_INSTANCE_CHECK(player);
3139 int ret = PLAYER_ERROR_NONE;
3140 player_cli_s *pc = (player_cli_s *) player;
3141 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
3142 char *ret_buf = NULL;
3143 muse_player_event_e type;
3148 if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
3149 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
3150 else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
3151 type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
3153 LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
3154 return PLAYER_ERROR_INVALID_PARAMETER;
3157 set_null_user_cb_lock(pc->cb_info, type);
3159 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
3165 /* TODO Implement raw data socket channel */
3166 int player_push_media_stream(player_h player, media_packet_h packet)
3168 PLAYER_INSTANCE_CHECK(player);
3169 PLAYER_NULL_ARG_CHECK(packet);
3170 int ret = PLAYER_ERROR_NONE;
3171 player_cli_s *pc = (player_cli_s *) player;
3172 muse_player_api_e api = MUSE_PLAYER_API_PUSH_MEDIA_STREAM;
3173 char *ret_buf = NULL;
3174 player_push_media_msg_type push_media;
3175 char *push_media_msg = (char *)&push_media;
3176 int msg_size = sizeof(player_push_media_msg_type);
3180 tbm_bo_handle thandle;
3183 media_format_h format;
3189 media_packet_get_buffer_data_ptr(packet, (void **)&buf);
3190 media_packet_get_buffer_size(packet, &push_media.size);
3191 media_packet_get_pts(packet, &push_media.pts);
3192 media_packet_get_format(packet, &format);
3193 media_packet_get_flags(packet, &push_media.flags);
3195 push_media.buf_type = PUSH_MEDIA_BUF_TYPE_RAW;
3197 media_packet_is_video(packet, &is_video);
3198 media_packet_is_audio(packet, &is_audio);
3200 media_format_get_video_info(format, &push_media.mimetype, &push_media.width, &push_media.height, NULL, NULL);
3202 media_format_get_audio_info(format, &push_media.mimetype, NULL, NULL, NULL, NULL);
3204 media_format_unref(format);
3207 if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM) {
3208 bo = tbm_bo_alloc(pc->cb_info->bufmgr, push_media.size, TBM_BO_DEFAULT);
3210 LOGE("TBM get error : bo is NULL");
3211 return PLAYER_ERROR_INVALID_OPERATION;
3213 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
3214 if (thandle.ptr == NULL) {
3215 LOGE("TBM get error : handle pointer is NULL");
3216 ret = PLAYER_ERROR_INVALID_OPERATION;
3219 memcpy(thandle.ptr, buf, push_media.size);
3222 push_media.key = tbm_bo_export(bo);
3223 if (push_media.key == 0) {
3224 LOGE("TBM get error : key is 0");
3225 ret = PLAYER_ERROR_INVALID_OPERATION;
3229 player_msg_send_array(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char));
3230 } else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG) {
3231 buf_size = (int)push_media.size;
3232 player_msg_send_array2(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char), buf, buf_size, sizeof(char));
3235 if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW) {
3236 buf_size = (int)push_media.size;
3237 muse_core_ipc_push_data(pc->cb_info->data_fd, buf, buf_size, push_media.pts);
3238 player_msg_send_array(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char));
3241 LOGD("ret_buf %s", ret_buf);
3245 if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
3253 int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format)
3255 PLAYER_INSTANCE_CHECK(player);
3256 g_return_val_if_fail(format, PLAYER_ERROR_INVALID_OPERATION);
3257 int ret = PLAYER_ERROR_NONE;
3258 player_cli_s *pc = (player_cli_s *) player;
3259 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO;
3260 char *ret_buf = NULL;
3261 media_format_mimetype_e mimetype;
3272 media_format_ref(format);
3273 if (type == PLAYER_STREAM_TYPE_VIDEO) {
3274 media_format_get_video_info(format, &mimetype, &width, &height, &avg_bps, &max_bps);
3275 player_msg_send6(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, width, INT, height, INT, avg_bps, INT, max_bps);
3276 } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
3277 media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &avg_bps);
3278 player_msg_send6(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, channel, INT, samplerate, INT, avg_bps, INT, bit);
3280 media_format_unref(format);
3281 pc->push_media_stream = TRUE;
3287 int player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size)
3289 int ret = PLAYER_ERROR_NONE;
3290 PLAYER_INSTANCE_CHECK(player);
3291 player_cli_s *pc = (player_cli_s *) player;
3292 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE;
3293 char *ret_buf = NULL;
3297 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT64, max_size);
3303 int player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *pmax_size)
3305 int ret = PLAYER_ERROR_NONE;
3306 PLAYER_INSTANCE_CHECK(player);
3307 PLAYER_NULL_ARG_CHECK(pmax_size);
3308 player_cli_s *pc = (player_cli_s *) player;
3309 muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE;
3310 char *ret_buf = NULL;
3311 unsigned long long max_size;
3315 player_msg_send1(api, pc, ret_buf, ret, INT, type);
3316 if (ret == PLAYER_ERROR_NONE) {
3317 player_msg_get_type(max_size, ret_buf, INT64);
3318 *pmax_size = max_size;
3324 int player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent)
3326 int ret = PLAYER_ERROR_NONE;
3327 PLAYER_INSTANCE_CHECK(player);
3328 player_cli_s *pc = (player_cli_s *) player;
3329 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
3330 char *ret_buf = NULL;
3334 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, percent);
3340 int player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *ppercent)
3342 int ret = PLAYER_ERROR_NONE;
3343 PLAYER_INSTANCE_CHECK(player);
3344 PLAYER_NULL_ARG_CHECK(ppercent);
3345 player_cli_s *pc = (player_cli_s *) player;
3346 muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
3347 char *ret_buf = NULL;
3352 player_msg_send1(api, pc, ret_buf, ret, INT, type);
3353 if (ret == PLAYER_ERROR_NONE) {
3354 player_msg_get(percent, ret_buf);
3355 *ppercent = percent;
3362 int player_get_track_count(player_h player, player_stream_type_e type, int *pcount)
3364 PLAYER_INSTANCE_CHECK(player);
3365 PLAYER_NULL_ARG_CHECK(pcount);
3366 int ret = PLAYER_ERROR_NONE;
3367 player_cli_s *pc = (player_cli_s *) player;
3368 muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_COUNT;
3369 char *ret_buf = NULL;
3374 player_msg_send1(api, pc, ret_buf, ret, INT, type);
3375 if (ret == PLAYER_ERROR_NONE) {
3376 player_msg_get(count, ret_buf);
3384 int player_get_current_track(player_h player, player_stream_type_e type, int *pindex)
3386 PLAYER_INSTANCE_CHECK(player);
3387 PLAYER_NULL_ARG_CHECK(pindex);
3388 int ret = PLAYER_ERROR_NONE;
3389 player_cli_s *pc = (player_cli_s *) player;
3390 muse_player_api_e api = MUSE_PLAYER_API_GET_CURRENT_TRACK;
3391 char *ret_buf = NULL;
3396 player_msg_send1(api, pc, ret_buf, ret, INT, type);
3397 if (ret == PLAYER_ERROR_NONE) {
3398 player_msg_get(index, ret_buf);
3406 int player_select_track(player_h player, player_stream_type_e type, int index)
3408 PLAYER_INSTANCE_CHECK(player);
3409 int ret = PLAYER_ERROR_NONE;
3410 player_cli_s *pc = (player_cli_s *) player;
3411 muse_player_api_e api = MUSE_PLAYER_API_SELECT_TRACK;
3412 char *ret_buf = NULL;
3416 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, index);
3422 int player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **pcode)
3424 PLAYER_INSTANCE_CHECK(player);
3425 PLAYER_NULL_ARG_CHECK(pcode);
3426 int ret = PLAYER_ERROR_NONE;
3427 player_cli_s *pc = (player_cli_s *) player;
3428 muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE;
3429 char *ret_buf = NULL;
3430 char code[MUSE_MSG_MAX_LENGTH] = { 0, };
3431 const int code_len = 2;
3435 player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, index);
3436 if (ret == PLAYER_ERROR_NONE) {
3437 if (player_msg_get_string(code, ret_buf))
3438 *pcode = strndup(code, code_len);