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.
24 #include <sys/socket.h>
25 #include <tbm_bufmgr.h>
26 #include <tbm_surface.h>
27 #include <tbm_surface_internal.h>
28 #include <media_packet.h>
29 #include <media_packet_internal.h>
30 #include <muse_server.h>
31 #include <tzplatform_config.h>
32 #include <system_info.h>
33 #include "muse_player.h"
34 #include "muse_player_msg.h"
35 #include "muse_player_private.h"
36 #include "muse_player_api.h" /* generated during build, ref ../make_api.py */
37 #include "legacy_player_private.h"
38 #include "legacy_player_internal.h"
40 #define DEFAULT_VDEC_TOTAL_SIZE_OF_BUFFER 0
41 #define DEFAULT_VDEC_EXTRA_SIZE_OF_BUFFER 3
43 #define INVALID_DEFAULT_VALUE -1
44 #define ADAPTIVE_VARIANT_DEFAULT_VALUE -1 /* auto */
46 #define MEDIA_PATH_EXTERNAL tzplatform_getenv(TZ_SYS_STORAGE) /* external storage, or TZ_SYS_MEDIA */
47 #define MEDIA_PATH_USER tzplatform_getenv(TZ_USER_CONTENT) /* user media storage */
49 #define MEDIA_STORAGE_PRIVILEGE_NAME "http://tizen.org/privilege/mediastorage"
50 #define EXTERNAL_STORAGE_PRIVILEGE_NAME "http://tizen.org/privilege/externalstorage"
51 #define INTERNET_PRIVILEGE_NAME "http://tizen.org/privilege/internet"
52 #define NUM_OF_URI_PREFIX 7
53 #define INVALID_MUSE_TYPE_VALUE 0
55 static const char *uri_prefix[NUM_OF_URI_PREFIX] = {
66 * msg dispatcher functions
67 * To add new disp function with new player API,
68 * by running python cmd, the function template will be added at the bottom of this file.
69 * see ../README_FOR_NEW_API
73 static bool _create_export_data(muse_player_handle_t *muse_player, void *data, int size, void *ext_data, int ext_size, tbm_fd *out_tfd, int *out_key)
75 muse_player_export_data_t *export_data = NULL;
77 tbm_fd tfd = INVALID_DEFAULT_VALUE;
78 tbm_bo_handle thandle;
79 int bo_size = size + ext_size;
83 *out_tfd = *out_key = INVALID_DEFAULT_VALUE;
85 if (muse_player == NULL) {
86 LOGE("handle is NULL");
90 if (data == NULL || size <= 0) {
91 LOGE("data is empty");
95 export_data = g_try_new0(muse_player_export_data_t, 1);
96 if (export_data == NULL) {
97 LOGE("failed to alloc export_data");
101 /* alloc and map the bo */
102 bo = tbm_bo_alloc(muse_player->bufmgr, bo_size, TBM_BO_DEFAULT);
104 LOGE("TBM get error : tbm_bo_alloc return NULL");
108 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
109 if (thandle.ptr == NULL) {
110 LOGE("TBM get error : handle pointer is NULL");
114 /* copy data to bo and export tbm fd */
115 if (ext_size > 0 && ext_data != NULL)
116 memcpy(thandle.ptr, ext_data, ext_size);
118 memcpy(thandle.ptr + ext_size, data, size);
122 tfd = tbm_bo_export_fd(bo);
124 LOGE("tbm_bo_export_fd err 0x%x", tfd);
128 /* LOGD("bo %p, vaddr %p, size %d(%d, %d), tbm_fd %d", bo, thandle.ptr, bo_size, ext_size, size, tfd); */
131 export_data->tfd = tfd;
132 export_data->bo = bo;
133 export_data->key = tfd; /* keep the tfd integer value as a unique key */
135 /* add bo info to list */
136 g_mutex_lock(&muse_player->list_lock);
137 muse_player->data_list = g_list_append(muse_player->data_list, (gpointer)export_data);
138 g_mutex_unlock(&muse_player->list_lock);
140 *out_tfd = export_data->tfd;
141 *out_key = export_data->key;
156 static bool _remove_export_data(muse_module_h module, int key, bool remove_all)
159 muse_player_handle_t *muse_player = NULL;
162 if (module == NULL || (key < 0 && !remove_all)) {
163 LOGE("invalid parameter %p, %d", module, key);
167 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
169 if (muse_player && muse_player->data_list) {
172 muse_player_export_data_t *export_data = NULL;
173 g_mutex_lock(&muse_player->list_lock);
175 /* LOGE("number of remained buffer %d", g_list_length(muse_player->data_list)); */
177 iter = g_list_first(muse_player->data_list);
179 export_data = (muse_player_export_data_t *)iter->data;
181 (export_data->key == key || remove_all)) {
182 LOGD("buffer key : %d matched, remove it (remove_all %d)", key, remove_all);
183 if (export_data->tfd > INVALID_DEFAULT_VALUE) {
184 close(export_data->tfd);
185 export_data->tfd = INVALID_DEFAULT_VALUE;
187 if (export_data->bo) {
188 tbm_bo_unref(export_data->bo);
189 export_data->bo = NULL;
191 LOGW("bo for key:%d is NULL", key);
194 iter = g_list_next(iter);
196 muse_player->data_list = g_list_remove(muse_player->data_list, export_data);
201 /* LOGD("buffer key:%d, remove done", key); */
202 g_mutex_unlock(&muse_player->list_lock);
206 iter = g_list_next(iter);
210 g_mutex_unlock(&muse_player->list_lock);
213 LOGE("There is no key:%d in data_list", key);
221 static void _remove_video_stream_data(muse_module_h module, mmplayer_video_decoded_data_info_t *video_data)
223 int i = 0, bo_num = 0;
224 muse_player_handle_t *muse_player = NULL;
226 if (video_data == NULL) {
227 LOGE("video_data is null, module %p", module);
232 for (i = 0, bo_num = 0; i < BUFFER_MAX_PLANE_NUM; i++) {
233 if (video_data->bo[i])
237 /* In case of Tizen native format used on videosink video_data->internal_buffer
238 * contains reference to the original Gst buffer. Otherwise it is null.
240 if (!video_data->internal_buffer) { /* sw codec */
241 #define NUM_OF_SW_CODEC_BO 1
244 if (bo_num == NUM_OF_SW_CODEC_BO) {
245 bo = video_data->bo[0];
246 if (bo) { /* sw codec bo list */
247 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
248 if (muse_player == NULL) {
249 LOGE("muse_player is NULL");
253 legacy_player_release_video_stream_bo(muse_player->player_handle, bo);
263 for (i = 0; i < bo_num; i++) {
264 tbm_bo_unref(video_data->bo[i]);
265 video_data->bo[i] = NULL;
268 if (video_data->internal_buffer) {
269 mm_player_video_stream_internal_buffer_unref(video_data->internal_buffer);
270 video_data->internal_buffer = NULL;
273 // LOGD("release exported video_data %p", video_data);
279 static void _remove_export_media_packet(muse_module_h module)
281 muse_player_handle_t *muse_player = NULL;
284 if (module == NULL) {
285 LOGE("invalid parameter");
289 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
290 if (muse_player == NULL) {
291 LOGE("invalid handle");
295 muse_player->export_video_data = false;
297 if (muse_player->video_data_list) {
298 GList *video_list = NULL;
299 g_mutex_lock(&muse_player->list_lock);
301 LOGW("number of remained video_list %d", g_list_length(muse_player->video_data_list));
302 for (video_list = g_list_first(muse_player->video_data_list); video_list; video_list = g_list_next(video_list)) {
303 LOGW("%p will be removed", video_list->data);
304 _remove_video_stream_data(module, (mmplayer_video_decoded_data_info_t *)video_list->data);
306 g_list_free(muse_player->video_data_list);
307 muse_player->video_data_list = NULL;
309 g_mutex_unlock(&muse_player->list_lock);
313 /* check the given path is indicating sdp file */
314 static bool _is_sdp_file(const char *path)
320 LOGE("invalid path param");
324 uri = g_ascii_strdown(path, -1);
332 /* strlen(".sdp") == 4 */
333 if (strlen(uri) <= 4) {
334 LOGW("path is too short.\n");
338 /* first, check extension name */
339 ret = g_str_has_suffix(uri, "sdp");
341 /* second, if no suffix is there, check it's contents */
343 /* FIXIT : do it soon */
352 static bool _check_network_availability(void)
354 #define _FEATURE_NAME_WIFI "http://tizen.org/feature/network.wifi"
355 #define _FEATURE_NAME_TELEPHONY "http://tizen.org/feature/network.telephony"
356 #define _FEATURE_NAME_ETHERNET "http://tizen.org/feature/network.ethernet"
357 bool enabled = false;
358 bool supported = false;
360 if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_WIFI, &enabled)) {
361 LOGI("wifi status = %d", enabled);
365 LOGE("SYSTEM_INFO_ERROR");
368 if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &enabled)) {
369 LOGI("telephony status = %d", enabled);
373 LOGE("SYSTEM_INFO_ERROR");
376 if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, &enabled)) {
377 LOGI("ethernet status = %d", enabled);
381 LOGE("SYSTEM_INFO_ERROR");
390 static int _check_supportable(muse_module_h module, char *path)
392 int ret = PLAYER_ERROR_NONE;
395 char *privilege = NULL;
396 char *internal_path = NULL;
400 LOGE("invalid path param");
401 return PLAYER_ERROR_INVALID_PARAMETER;
404 client_fd = muse_server_module_get_msg_fd(module);
406 if ((client_fd < 0) || !muse_core_fd_is_valid(client_fd)) {
407 LOGE("get msg fd failed : %d", client_fd);
408 return PLAYER_ERROR_INVALID_OPERATION;
411 for (idx = 0; idx < NUM_OF_URI_PREFIX; idx++) {
412 if (strncmp(path, uri_prefix[idx], strlen(uri_prefix[idx])) == 0) {
413 LOGD("internet privilege will be checked for %s path", uri_prefix[idx]);
418 if (idx != NUM_OF_URI_PREFIX) {
419 privilege = INTERNET_PRIVILEGE_NAME;
421 char *file_path = path;
423 if (strncmp(path, "file://", strlen("file://")) == 0)
424 file_path = path + 7; /* remove file prefix */
426 if (_is_sdp_file(file_path)) /* check internet privilege */
427 privilege = INTERNET_PRIVILEGE_NAME;
430 if (strncmp(file_path, MEDIA_PATH_EXTERNAL, strlen(MEDIA_PATH_EXTERNAL)) == 0) { /* external media storage */
431 privilege = EXTERNAL_STORAGE_PRIVILEGE_NAME;
433 socklen_t len = sizeof(struct ucred);
434 if (getsockopt(client_fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) < 0) {
435 LOGE("failed to get peer client uid of socketfd %d", client_fd);
436 return PLAYER_ERROR_INVALID_OPERATION;
439 /* get home/media path of client and can be different in case of multi-user */
440 tzplatform_set_user(cred.uid);
441 internal_path = g_strdup(MEDIA_PATH_USER);
442 tzplatform_reset_user();
444 // LOGD("internal storage path %s", internal_path);
446 if (strncmp(file_path, internal_path, strlen(internal_path)) == 0) { /* internal media storage */
447 privilege = MEDIA_STORAGE_PRIVILEGE_NAME;
448 g_free(internal_path);
449 } else { /* can access without permission */
450 g_free(internal_path);
451 return PLAYER_ERROR_NONE;
457 LOGD("privilege check : %s", privilege);
458 if (!muse_server_security_check_cynara(client_fd, privilege)) {
459 ret = PLAYER_ERROR_PERMISSION_DENIED;
460 LOGE("security check failed %s", privilege);
462 if (strncmp(privilege, INTERNET_PRIVILEGE_NAME, strlen(INTERNET_PRIVILEGE_NAME)) == 0) {
463 /*check internet feature*/
464 if (!_check_network_availability()) {
465 ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
466 LOGE("feature is not supportable.");
474 static void _prepare_async_cb(void *user_data)
476 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_PREPARE;
477 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
478 prepare_data_t *prepare_data = (prepare_data_t *)user_data;
479 muse_module_h module;
480 muse_player_handle_t *muse_player = NULL;
481 int ret = PLAYER_ERROR_NONE;
482 int num = 0, extra_num = 0;
485 LOGE("user data of callback is NULL");
488 module = prepare_data->module;
489 g_free(prepare_data);
491 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
492 if (muse_player == NULL) {
493 LOGE("muse handle is NULL");
497 ret = legacy_player_get_num_of_video_out_buffers(muse_player->player_handle, &num, &extra_num);
498 if (ret == PLAYER_ERROR_NONE) {
499 muse_player->total_size_of_buffers = num;
500 muse_player->extra_size_of_buffers = extra_num;
501 LOGD("num of vdec out buffer, total:%d, extra:%d", num, extra_num);
504 PLAYER_SEND_EVENT_MSG(api, ev, module);
507 static void __player_callback(muse_player_event_e ev, muse_module_h module)
509 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
513 PLAYER_SEND_EVENT_MSG(api, ev, module);
516 static void _seek_complate_cb(void *user_data)
518 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SEEK;
519 __player_callback(ev, (muse_module_h)user_data);
522 static void _completed_cb(void *user_data)
524 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_COMPLETE;
525 __player_callback(ev, (muse_module_h)user_data);
528 #ifdef TIZEN_FEATURE_EVAS_RENDERER
529 static void _retrieve_buffer_cb(void *user_data)
531 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER;
532 __player_callback(ev, (muse_module_h)user_data);
536 static void _set_completed_cb(legacy_player_h player, void *module, bool set)
539 legacy_player_set_completed_cb(player, _completed_cb, module);
541 legacy_player_unset_completed_cb(player);
544 #ifdef TIZEN_FEATURE_EVAS_RENDERER
545 static void _set_retrieve_buffer_cb(legacy_player_h player, void *module, bool set)
548 legacy_player_set_retrieve_buffer_cb(player, _retrieve_buffer_cb, module);
550 legacy_player_unset_retrieve_buffer_cb(player);
554 static void _capture_video_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
556 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
557 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_CAPTURE;
558 muse_module_h module = (muse_module_h)user_data;
559 muse_player_handle_t *muse_player = NULL;
561 tbm_fd tfd = INVALID_DEFAULT_VALUE;
562 int key = INVALID_DEFAULT_VALUE;
565 if (data == NULL || size == 0) {
566 LOGE("cature data is empty");
570 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
571 if (muse_player == NULL) {
572 LOGE("handle is NULL");
576 ret = _create_export_data(muse_player, (void *)data, size, NULL, 0, &tfd, &key);
578 LOGE("failed to create export data");
582 PLAYER_SEND_EVENT_MSG_WITH_TFD(api, ev, module, tfd,
583 MUSE_TYPE_INT, "width", width, MUSE_TYPE_INT, "height", height,
584 MUSE_TYPE_INT, "size", (int)size, MUSE_TYPE_INT, "key", key);
588 static int _get_tbm_surface_format(int in_format, uint32_t *out_format)
590 if (in_format <= MM_PIXEL_FORMAT_INVALID || in_format >= MM_PIXEL_FORMAT_NUM || out_format == NULL) {
591 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
592 return PLAYER_ERROR_INVALID_PARAMETER;
596 case MM_PIXEL_FORMAT_NV12:
597 *out_format = TBM_FORMAT_NV12;
599 case MM_PIXEL_FORMAT_NV12T:
600 *out_format = TBM_FORMAT_NV12MT;
602 case MM_PIXEL_FORMAT_NV16:
603 *out_format = TBM_FORMAT_NV16;
605 case MM_PIXEL_FORMAT_NV21:
606 *out_format = TBM_FORMAT_NV21;
608 case MM_PIXEL_FORMAT_YUYV:
609 *out_format = TBM_FORMAT_YUYV;
611 case MM_PIXEL_FORMAT_UYVY:
612 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
613 *out_format = TBM_FORMAT_UYVY;
615 case MM_PIXEL_FORMAT_422P:
616 *out_format = TBM_FORMAT_YUV422;
618 case MM_PIXEL_FORMAT_I420:
619 *out_format = TBM_FORMAT_YUV420;
621 case MM_PIXEL_FORMAT_YV12:
622 *out_format = TBM_FORMAT_YVU420;
624 case MM_PIXEL_FORMAT_RGB565:
625 *out_format = TBM_FORMAT_RGB565;
627 case MM_PIXEL_FORMAT_RGB888:
628 *out_format = TBM_FORMAT_RGB888;
630 case MM_PIXEL_FORMAT_RGBA:
631 *out_format = TBM_FORMAT_ARGB8888;
633 case MM_PIXEL_FORMAT_ARGB:
634 *out_format = TBM_FORMAT_ARGB8888;
637 LOGE("invalid in_format %d", in_format);
638 return PLAYER_ERROR_INVALID_PARAMETER;
641 return PLAYER_ERROR_NONE;
644 static int _get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
646 if (in_format <= MM_PIXEL_FORMAT_INVALID || in_format >= MM_PIXEL_FORMAT_NUM || mimetype == NULL) {
647 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
648 return PLAYER_ERROR_INVALID_PARAMETER;
652 case MM_PIXEL_FORMAT_NV12:
653 *mimetype = MEDIA_FORMAT_NV12;
655 case MM_PIXEL_FORMAT_NV12T:
656 *mimetype = MEDIA_FORMAT_NV12T;
658 case MM_PIXEL_FORMAT_NV16:
659 *mimetype = MEDIA_FORMAT_NV16;
661 case MM_PIXEL_FORMAT_NV21:
662 *mimetype = MEDIA_FORMAT_NV21;
664 case MM_PIXEL_FORMAT_YUYV:
665 *mimetype = MEDIA_FORMAT_YUYV;
667 case MM_PIXEL_FORMAT_UYVY:
668 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
669 *mimetype = MEDIA_FORMAT_UYVY;
671 case MM_PIXEL_FORMAT_422P:
672 *mimetype = MEDIA_FORMAT_422P;
674 case MM_PIXEL_FORMAT_I420:
675 *mimetype = MEDIA_FORMAT_I420;
677 case MM_PIXEL_FORMAT_YV12:
678 *mimetype = MEDIA_FORMAT_YV12;
680 case MM_PIXEL_FORMAT_RGB565:
681 *mimetype = MEDIA_FORMAT_RGB565;
683 case MM_PIXEL_FORMAT_RGB888:
684 *mimetype = MEDIA_FORMAT_RGB888;
686 case MM_PIXEL_FORMAT_RGBA:
687 *mimetype = MEDIA_FORMAT_RGBA;
689 case MM_PIXEL_FORMAT_ARGB:
690 *mimetype = MEDIA_FORMAT_ARGB;
693 LOGE("invalid in_format %d", in_format);
694 return PLAYER_ERROR_INVALID_PARAMETER;
697 return PLAYER_ERROR_NONE;
699 static bool __video_decoded_callback(void *video_data, void *user_data)
702 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
703 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
704 muse_module_h module = (muse_module_h)user_data;
705 mmplayer_video_decoded_data_info_t *video_stream = (mmplayer_video_decoded_data_info_t *)video_data;
706 muse_player_handle_t *muse_player = NULL;
707 uint32_t bo_format = 0;
711 tbm_surface_info_s sinfo;
713 char *surface_info = (char *)&sinfo;
714 int surface_info_size = sizeof(tbm_surface_info_s);
715 intptr_t v_data = (intptr_t)video_data;
716 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
717 bool ret_val = false;
722 memset(&sinfo, 0, sizeof(tbm_surface_info_s));
723 memset(tfd, INVALID_DEFAULT_VALUE, sizeof(tfd));
724 memset(key, INVALID_DEFAULT_VALUE, sizeof(key));
726 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
727 if (muse_player == NULL) {
728 LOGE("handle is NULL");
729 /* resource will be released after return */
733 if (muse_player->export_video_data == false) {
734 LOGE("do not export video data");
739 for (i = 0, bo_num = 0; i < BUFFER_MAX_PLANE_NUM; i++) {
740 if (video_stream->bo[i]) {
741 key[i] = tbm_bo_export(video_stream->bo[i]); /* FIXME: will be exchanged to the unique index */
742 tfd[i] = tbm_bo_export_fd(video_stream->bo[i]);
744 if (i == 0 && tfd[0] <= INVALID_DEFAULT_VALUE) {
745 LOGE("failed to get tbm fd from %p", video_stream->bo[0]);
746 /* resource will be released after return */
754 LOGE("There is no valid tbm bo");
758 /* get format info */
759 ret = _get_tbm_surface_format(video_stream->format, &bo_format);
760 ret |= _get_media_packet_mimetype(video_stream->format, &mimetype);
762 if (ret != PLAYER_ERROR_NONE) {
763 LOGE("Fail to get format info");
767 sinfo.width = video_stream->width;
768 sinfo.height = video_stream->height;
769 sinfo.format = bo_format;
770 sinfo.bpp = tbm_surface_internal_get_bpp(bo_format);
771 sinfo.num_planes = tbm_surface_internal_get_num_planes(bo_format);
774 for (i = 0; i < sinfo.num_planes; i++) {
775 sinfo.planes[i].stride = video_stream->stride[i];
776 sinfo.planes[i].size = video_stream->stride[i] * video_stream->elevation[i];
778 sinfo.planes[i].offset = 0;
780 sinfo.planes[i].offset = sinfo.planes[i - 1].offset + sinfo.planes[i - 1].size;
781 sinfo.size += sinfo.planes[i].size;
782 if (video_stream->format == MM_PIXEL_FORMAT_RGBA)
783 sinfo.size = video_stream->stride[0] * video_stream->height;
786 pts = (uint64_t)video_stream->timestamp * 1000000;
787 orientation = video_stream->orientation;
789 g_mutex_lock(&muse_player->list_lock);
790 if (g_list_length(muse_player->video_data_list) > muse_player->extra_size_of_buffers) {
791 LOGE("Too many buffers are not released. video(%p) will be drop.", video_data);
792 g_mutex_unlock(&muse_player->list_lock);
796 muse_player->video_data_list = g_list_append(muse_player->video_data_list, (gpointer)video_data);
797 g_mutex_unlock(&muse_player->list_lock);
799 msg_len = (surface_info_size / sizeof(int) + (surface_info_size % sizeof(int) ? 1 : 0));
800 PLAYER_SEND_EVENT_MSG_WITH_TFDS(api, ev, module, tfd,
801 MUSE_TYPE_INT, "key[0]", key[0], MUSE_TYPE_INT, "key[1]", key[1],
802 MUSE_TYPE_INT, "key[2]", key[2], MUSE_TYPE_INT, "key[3]", key[3],
803 MUSE_TYPE_POINTER, "v_data", v_data, MUSE_TYPE_INT, "mimetype", (int)mimetype,
804 MUSE_TYPE_INT64, "pts", (INT64)pts, MUSE_TYPE_INT, "orientation", orientation,
805 MUSE_TYPE_ARRAY, "surface_info", msg_len, surface_info);
810 for (i = 0; i < bo_num; i++) {
811 if (tfd[i] > INVALID_DEFAULT_VALUE)
818 static void _video_stream_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
820 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
821 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
822 muse_module_h module = (muse_module_h)user_data;
824 PLAYER_SEND_EVENT_MSG(api, ev, module,
825 MUSE_TYPE_INT, "width", width, MUSE_TYPE_INT, "height", height,
826 MUSE_TYPE_INT, "fps", fps, MUSE_TYPE_INT, "bit_rate", bit_rate);
829 static void _media_stream_audio_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
831 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
832 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
833 muse_module_h module = (muse_module_h)user_data;
835 PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT, "status", (int)status);
838 static void _media_stream_video_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
840 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
841 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
842 muse_module_h module = (muse_module_h)user_data;
844 PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT, "status", (int)status);
847 static void _media_stream_audio_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
849 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
850 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
851 muse_module_h module = (muse_module_h)user_data;
853 PLAYER_SEND_EVENT_MSG(api, ev, module,
854 MUSE_TYPE_INT, "status", (int)status, MUSE_TYPE_INT64, "bytes", (INT64)bytes);
857 static void _media_stream_video_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
859 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
860 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
861 muse_module_h module = (muse_module_h)user_data;
863 PLAYER_SEND_EVENT_MSG(api, ev, module,
864 MUSE_TYPE_INT, "status", (int)status, MUSE_TYPE_INT64, "bytes", (INT64)bytes);
867 static void _media_stream_audio_seek_cb(unsigned long long offset, void *user_data)
869 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
870 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
871 muse_module_h module = (muse_module_h)user_data;
873 PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT64, "offset", (INT64)offset);
876 static void _media_stream_video_seek_cb(unsigned long long offset, void *user_data)
878 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
879 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
880 muse_module_h module = (muse_module_h)user_data;
882 PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT64, "offset", (INT64)offset);
885 static void _interrupted_cb(void *user_data)
887 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_INTERRUPT;
888 __player_callback(ev, (muse_module_h)user_data);
891 static void _set_interrupted_cb(legacy_player_h player, void *module, bool set)
894 legacy_player_set_interrupted_cb(player, _interrupted_cb, module);
896 legacy_player_unset_interrupted_cb(player);
899 static void _error_cb(int code, void *user_data)
901 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
902 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR;
903 muse_module_h module = (muse_module_h)user_data;
905 LOGD("ENTER code 0x%X", code);
907 PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT, "code", code);
910 static void _set_error_cb(legacy_player_h player, void *module, bool set)
913 legacy_player_set_error_cb(player, _error_cb, module);
915 legacy_player_unset_error_cb(player);
918 static void _subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
920 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
921 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SUBTITLE;
922 muse_module_h module = (muse_module_h)user_data;
926 PLAYER_SEND_EVENT_MSG(api, ev, module,
927 MUSE_TYPE_INT, "duration", (int)duration, MUSE_TYPE_STRING, "text", (const char *)text);
930 static void _set_subtitle_cb(legacy_player_h player, void *module, bool set)
933 legacy_player_set_subtitle_updated_cb(player, _subtitle_updated_cb, module);
935 legacy_player_unset_subtitle_updated_cb(player);
938 static void _buffering_cb(int percent, void *user_data)
940 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
941 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_BUFFERING;
942 muse_module_h module = (muse_module_h)user_data;
946 PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT, "percent", percent);
950 static void _set_buffering_cb(legacy_player_h player, void *module, bool set)
953 legacy_player_set_buffering_cb(player, _buffering_cb, module);
955 legacy_player_unset_buffering_cb(player);
958 static void _set_media_packet_video_frame_cb(legacy_player_h player, void *data, bool set)
960 int ret = PLAYER_ERROR_NONE;
961 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
962 muse_module_h module = (muse_module_h)data;
963 muse_player_handle_t *muse_player = NULL;
964 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
967 muse_player->export_video_data = true;
968 ret = legacy_player_set_media_packet_video_frame_decoded_cb(player, __video_decoded_callback, module);
970 muse_player->export_video_data = false;
971 LOGD("video data will not be exported.");
974 PLAYER_RETURN_MSG(api, ret, module);
977 static void _set_video_stream_changed_cb(legacy_player_h player, void *data, bool set)
979 int ret = PLAYER_ERROR_NONE;
980 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
981 muse_module_h module = (muse_module_h)data;
984 ret = legacy_player_set_video_stream_changed_cb(player, _video_stream_changed_cb, module);
986 ret = legacy_player_unset_video_stream_changed_cb(player);
988 PLAYER_RETURN_MSG(api, ret, module);
991 static void _set_media_stream_audio_seek_cb(legacy_player_h player, void *data, bool set)
993 int ret = PLAYER_ERROR_NONE;
994 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
995 muse_module_h module = (muse_module_h)data;
998 ret = legacy_player_set_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_seek_cb, module);
1000 ret = legacy_player_unset_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_AUDIO);
1002 PLAYER_RETURN_MSG(api, ret, module);
1005 static void _set_media_stream_video_seek_cb(legacy_player_h player, void *data, bool set)
1007 int ret = PLAYER_ERROR_NONE;
1008 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
1009 muse_module_h module = (muse_module_h)data;
1012 ret = legacy_player_set_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_seek_cb, module);
1014 ret = legacy_player_unset_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_VIDEO);
1016 PLAYER_RETURN_MSG(api, ret, module);
1019 static void _set_media_stream_audio_buffer_cb(legacy_player_h player, void *data, bool set)
1021 int ret = PLAYER_ERROR_NONE;
1022 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
1023 muse_module_h module = (muse_module_h)data;
1026 ret = legacy_player_set_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_buffer_status_cb, module);
1028 ret = legacy_player_unset_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_AUDIO);
1030 PLAYER_RETURN_MSG(api, ret, module);
1033 static void _set_media_stream_video_buffer_cb(legacy_player_h player, void *data, bool set)
1035 int ret = PLAYER_ERROR_NONE;
1036 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
1037 muse_module_h module = (muse_module_h)data;
1040 ret = legacy_player_set_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_buffer_status_cb, module);
1042 ret = legacy_player_unset_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_VIDEO);
1044 PLAYER_RETURN_MSG(api, ret, module);
1047 static void _set_media_stream_audio_buffer_cb_ex(legacy_player_h player, void *data, bool set)
1049 int ret = PLAYER_ERROR_NONE;
1050 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
1051 muse_module_h module = (muse_module_h)data;
1054 ret = legacy_player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_buffer_status_cb_ex, module);
1056 ret = legacy_player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO);
1058 PLAYER_RETURN_MSG(api, ret, module);
1061 static void _set_media_stream_video_buffer_cb_ex(legacy_player_h player, void *data, bool set)
1063 int ret = PLAYER_ERROR_NONE;
1064 muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
1065 muse_module_h module = (muse_module_h)data;
1068 ret = legacy_player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_buffer_status_cb_ex, module);
1070 ret = legacy_player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO);
1072 PLAYER_RETURN_MSG(api, ret, module);
1075 static void (*set_callback_func[MUSE_PLAYER_EVENT_TYPE_NUM])(legacy_player_h player, void *user_data, bool set) = {
1076 NULL, /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
1077 _set_completed_cb, /* MUSE_PLAYER_EVENT_TYPE_COMPLETE */
1078 _set_interrupted_cb, /* MUSE_PLAYER_EVENT_TYPE_INTERRUPT */
1079 _set_error_cb, /* MUSE_PLAYER_EVENT_TYPE_ERROR */
1080 _set_buffering_cb, /* MUSE_PLAYER_EVENT_TYPE_BUFFERING */
1081 _set_subtitle_cb, /* MUSE_PLAYER_EVENT_TYPE_SUBTITLE */
1082 NULL, /* MUSE_PLAYER_EVENT_TYPE_CAPTURE */
1083 NULL, /* MUSE_PLAYER_EVENT_TYPE_SEEK */
1084 _set_media_packet_video_frame_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME */
1085 NULL, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME */
1086 NULL, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
1087 NULL, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT */
1088 NULL, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET */
1089 NULL, /* MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN */
1090 #ifdef _PLAYER_FOR_PRODUCT
1091 NULL, /* MUSE_PLAYER_EVENT_TYPE_IMAGE_BUFFER */
1092 NULL, /* MUSE_PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE */
1094 _set_media_stream_video_buffer_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS */
1095 _set_media_stream_audio_buffer_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS */
1096 _set_media_stream_video_buffer_cb_ex, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO */
1097 _set_media_stream_audio_buffer_cb_ex, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO */
1098 _set_media_stream_video_seek_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK */
1099 _set_media_stream_audio_seek_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK */
1100 NULL, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED */
1101 _set_video_stream_changed_cb, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED */
1102 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1103 _set_retrieve_buffer_cb, /* MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER */
1105 NULL, /* MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED */
1108 static int _push_media_stream(muse_player_handle_t *muse_player, player_push_media_msg_type *push_media, char *buf)
1110 int ret = MEDIA_FORMAT_ERROR_NONE;
1111 media_format_h format;
1112 media_packet_h packet;
1113 media_format_mimetype_e mimetype;
1117 if (push_media->mimetype & MEDIA_FORMAT_VIDEO) {
1118 if (!muse_player->video_format) {
1119 media_format_create(&muse_player->video_format);
1120 if (!muse_player->video_format) {
1121 LOGE("fail to create media format");
1122 return PLAYER_ERROR_INVALID_PARAMETER;
1124 ret |= media_format_set_video_mime(muse_player->video_format, push_media->mimetype);
1125 ret |= media_format_set_video_width(muse_player->video_format, push_media->width);
1126 ret |= media_format_set_video_height(muse_player->video_format, push_media->height);
1128 ret |= media_format_get_video_info(muse_player->video_format, &mimetype, &width, &height, NULL, NULL);
1129 if (mimetype != push_media->mimetype) {
1130 media_format_unref(muse_player->video_format);
1131 media_format_create(&muse_player->video_format);
1132 ret |= media_format_set_video_mime(muse_player->video_format, push_media->mimetype);
1133 ret |= media_format_set_video_width(muse_player->video_format, push_media->width);
1134 ret |= media_format_set_video_height(muse_player->video_format, push_media->height);
1136 format = muse_player->video_format;
1137 } else if (push_media->mimetype & MEDIA_FORMAT_AUDIO) {
1138 if (!muse_player->audio_format) {
1139 media_format_create(&muse_player->audio_format);
1140 if (!muse_player->audio_format) {
1141 LOGE("fail to create media format");
1142 return PLAYER_ERROR_INVALID_PARAMETER;
1144 ret |= media_format_set_audio_mime(muse_player->audio_format, push_media->mimetype);
1146 ret |= media_format_get_audio_info(muse_player->audio_format, &mimetype, NULL, NULL, NULL, NULL);
1147 if (mimetype != push_media->mimetype) {
1148 media_format_unref(muse_player->audio_format);
1149 media_format_create(&muse_player->audio_format);
1150 ret |= media_format_set_audio_mime(muse_player->audio_format, push_media->mimetype);
1152 format = muse_player->audio_format;
1154 ret = MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
1157 if (ret != MEDIA_FORMAT_ERROR_NONE) {
1158 LOGE("Invalid MIME %d", push_media->mimetype);
1159 return PLAYER_ERROR_INVALID_PARAMETER;
1163 ret = media_packet_create_from_external_memory(format, buf, push_media->size, NULL, NULL, &packet);
1164 if (ret != MEDIA_PACKET_ERROR_NONE) {
1165 LOGE("fail to create media packet with external mem");
1166 return PLAYER_ERROR_INVALID_PARAMETER;
1169 ret = media_packet_create(format, NULL, NULL, &packet);
1170 if (ret != MEDIA_PACKET_ERROR_NONE) {
1171 LOGE("fail to create media packet");
1172 return PLAYER_ERROR_INVALID_PARAMETER;
1176 if (push_media->codec_data_size > 0)
1177 media_packet_set_codec_data(packet, push_media->codec_data, push_media->codec_data_size);
1179 media_packet_set_pts(packet, push_media->pts);
1180 media_packet_set_flags(packet, push_media->flags);
1182 ret = legacy_player_push_media_stream(muse_player->player_handle, packet);
1183 if (ret != PLAYER_ERROR_NONE)
1184 LOGE("ret %d", ret);
1186 media_packet_destroy(packet);
1191 static void _audio_decoded_cb(player_audio_raw_data_s *audio_frame, void *user_data)
1193 muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
1194 muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME;
1195 muse_module_h module = (muse_module_h)user_data;
1196 muse_player_handle_t *muse_player = NULL;
1200 tbm_fd tfd = INVALID_DEFAULT_VALUE;
1201 int key = INVALID_DEFAULT_VALUE;
1203 /* LOGD("ENTER"); */
1206 data = audio_frame->data;
1207 size = audio_frame->size;
1210 if (data == NULL || size == 0) {
1211 LOGE("audio frame is NULL");
1215 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1216 if (muse_player == NULL) {
1217 LOGE("handle is NULL");
1221 ret = _create_export_data(muse_player, data, size, audio_frame, sizeof(player_audio_raw_data_s), &tfd, &key);
1223 LOGE("failed to create export data");
1228 PLAYER_SEND_EVENT_MSG_WITH_TFD(api, ev, module, tfd, MUSE_TYPE_INT, "key", key);
1232 int _player_disp_send_msg(int send_fd, char *msg, int *tfd)
1236 if ((send_fd <= 0) || !muse_core_fd_is_valid(send_fd)) {
1237 LOGE("invalid socket fd %d", send_fd);
1238 return PLAYER_ERROR_INVALID_OPERATION;
1242 send_len = muse_core_msg_send_fd(send_fd, tfd, msg);
1244 send_len = muse_core_msg_send(send_fd, msg);
1246 if (send_len <= 0) {
1247 LOGE("sending message failed");
1248 return PLAYER_ERROR_INVALID_OPERATION;
1251 return PLAYER_ERROR_NONE;
1254 int _player_disp_send_msg_async(int send_fd, char *msg)
1258 if ((send_fd <= 0) || !muse_core_fd_is_valid(send_fd)) {
1259 LOGE("invalid socket fd %d", send_fd);
1260 return PLAYER_ERROR_INVALID_OPERATION;
1263 send_len = muse_core_msg_send(send_fd, msg);
1264 if (send_len <= 0) {
1265 LOGE("sending message failed");
1266 return PLAYER_ERROR_INVALID_OPERATION;
1269 return PLAYER_ERROR_NONE;
1272 static bool _player_disp_get_param_value(char *buf, ...)
1274 muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
1277 int type = MUSE_TYPE_ANY;
1278 char *param_name = NULL;
1283 void *jobj = muse_core_msg_object_new(buf, NULL, &err);
1286 LOGE("failed to get msg object. err:%d", err);
1290 va_start(var_args, buf);
1292 while ((type = va_arg(var_args, int)) != INVALID_MUSE_TYPE_VALUE) {
1293 param_name = va_arg(var_args, char *);
1296 case MUSE_TYPE_INT64:
1297 case MUSE_TYPE_DOUBLE:
1298 case MUSE_TYPE_STRING:
1299 value = va_arg(var_args, void *);
1301 if (!muse_core_msg_object_get_value(param_name, jobj, type, value)) {
1303 LOGE("failed to get %s value", param_name);
1307 LOGE("Unexpected type %d", type);
1313 muse_core_msg_object_free(jobj);
1319 int player_disp_create(muse_module_h module)
1321 int ret = PLAYER_ERROR_NONE;
1322 muse_player_api_e api = MUSE_PLAYER_API_CREATE;
1323 muse_player_handle_t *muse_player = NULL;
1326 intptr_t handle = 0;
1327 intptr_t module_addr = (intptr_t)module;
1329 player_msg_get(pid, muse_server_module_get_msg(module));
1332 muse_player = g_try_new0(muse_player_handle_t, 1);
1334 ret = PLAYER_ERROR_OUT_OF_MEMORY;
1335 LOGE("failed to alloc handle 0x%x", ret);
1336 PLAYER_RETURN_MSG(api, ret, module);
1340 /* get buffer mgr */
1341 if (muse_server_ipc_get_bufmgr(&muse_player->bufmgr) != MM_ERROR_NONE) {
1342 LOGE("muse_server_ipc_get_bufmgr failed");
1343 ret = PLAYER_ERROR_INVALID_OPERATION;
1347 /* create player handle */
1348 ret = legacy_player_create(&muse_player->player_handle);
1349 if (ret != PLAYER_ERROR_NONE)
1352 muse_player->total_size_of_buffers = DEFAULT_VDEC_TOTAL_SIZE_OF_BUFFER;
1353 muse_player->extra_size_of_buffers = DEFAULT_VDEC_EXTRA_SIZE_OF_BUFFER;
1354 g_mutex_init(&muse_player->list_lock);
1356 LOGD("handle : %p, module : %p", muse_player, module);
1358 handle = (intptr_t)muse_player;
1359 muse_server_ipc_set_handle(module, handle);
1360 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_POINTER, "module_addr", module_addr);
1361 if (ret != PLAYER_ERROR_NONE) {
1362 LOGE("failed to return msg");
1368 legacy_player_destroy(muse_player->player_handle);
1370 g_free(muse_player);
1372 PLAYER_RETURN_MSG(api, ret, module);
1376 int player_disp_destroy(muse_module_h module)
1378 int ret = PLAYER_ERROR_NONE;
1379 muse_player_api_e api = MUSE_PLAYER_API_DESTROY;
1380 muse_player_handle_t *muse_player = NULL;
1382 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1384 /* decoder buffer need to be released first to destroy pipeline */
1385 _remove_export_media_packet(module);
1387 ret = legacy_player_destroy(muse_player->player_handle);
1389 if (muse_player->audio_format) {
1390 media_format_unref(muse_player->audio_format);
1391 muse_player->audio_format = NULL;
1393 if (muse_player->video_format) {
1394 media_format_unref(muse_player->video_format);
1395 muse_player->video_format = NULL;
1398 _remove_export_data(module, 0, true);
1399 g_mutex_clear(&muse_player->list_lock);
1401 muse_player->bufmgr = NULL;
1403 g_free(muse_player);
1406 PLAYER_RETURN_MSG(api, ret, module);
1408 return PLAYER_ERROR_NONE; /* to clean up the resource */
1411 int player_disp_prepare(muse_module_h module)
1413 int ret = PLAYER_ERROR_NONE;
1414 muse_player_api_e api = MUSE_PLAYER_API_PREPARE;
1415 muse_player_handle_t *muse_player = NULL;
1417 int num = 0, extra_num = 0;
1419 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1420 muse_player->export_video_data = true;
1422 ret = legacy_player_prepare(muse_player->player_handle);
1423 if (ret == PLAYER_ERROR_NONE) {
1424 ret = legacy_player_get_num_of_video_out_buffers(muse_player->player_handle, &num, &extra_num);
1425 LOGD("num of vdec out buffer, total:%d, extra:%d", num, extra_num);
1428 if (ret == PLAYER_ERROR_NONE) {
1429 legacy_player_get_timeout_for_muse(muse_player->player_handle, &timeout);
1430 muse_player->total_size_of_buffers = num;
1431 muse_player->extra_size_of_buffers = extra_num;
1432 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "timeout", timeout);
1434 PLAYER_RETURN_MSG(api, ret, module);
1440 int player_disp_prepare_async(muse_module_h module)
1442 int ret = PLAYER_ERROR_NONE;
1443 muse_player_api_e api = MUSE_PLAYER_API_PREPARE_ASYNC;
1444 muse_player_handle_t *muse_player = NULL;
1445 prepare_data_t *prepare_data;
1448 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1450 prepare_data = g_try_new(prepare_data_t, 1);
1451 if (!prepare_data) {
1452 ret = PLAYER_ERROR_INVALID_OPERATION;
1456 prepare_data->player = muse_player->player_handle;
1457 prepare_data->module = module;
1459 ret = legacy_player_prepare_async(muse_player->player_handle, _prepare_async_cb, prepare_data);
1460 if (ret == PLAYER_ERROR_NONE) {
1461 legacy_player_get_timeout_for_muse(muse_player->player_handle, &timeout);
1462 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "timeout", timeout);
1464 } /* else is error */
1467 g_free(prepare_data);
1469 PLAYER_RETURN_MSG(api, ret, module);
1473 int player_disp_unprepare(muse_module_h module)
1475 int ret = PLAYER_ERROR_NONE;
1476 muse_player_api_e api = MUSE_PLAYER_API_UNPREPARE;
1477 muse_player_handle_t *muse_player = NULL;
1479 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1481 /* decoder buffer need to be released first to destroy pipeline */
1482 _remove_export_media_packet(module);
1484 ret = legacy_player_unprepare(muse_player->player_handle);
1486 _remove_export_data(module, 0, true);
1488 PLAYER_RETURN_MSG(api, ret, module);
1493 int player_disp_set_uri(muse_module_h module)
1495 int ret = PLAYER_ERROR_NONE;
1496 muse_player_api_e api = MUSE_PLAYER_API_SET_URI;
1497 muse_player_handle_t *muse_player = NULL;
1498 char path[MUSE_URI_MAX_LENGTH] = { 0, };
1500 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1501 player_msg_get_string(path, muse_server_module_get_msg(module));
1503 if ((ret = _check_supportable(module, path)) == PLAYER_ERROR_NONE)
1504 ret = legacy_player_set_uri(muse_player->player_handle, path);
1506 PLAYER_RETURN_MSG(api, ret, module);
1510 int player_disp_start(muse_module_h module)
1512 int ret = PLAYER_ERROR_NONE;
1513 muse_player_api_e api = MUSE_PLAYER_API_START;
1514 muse_player_handle_t *muse_player = NULL;
1516 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1518 ret = legacy_player_start(muse_player->player_handle);
1520 PLAYER_RETURN_MSG(api, ret, module);
1525 int player_disp_stop(muse_module_h module)
1527 int ret = PLAYER_ERROR_NONE;
1528 muse_player_api_e api = MUSE_PLAYER_API_STOP;
1529 muse_player_handle_t *muse_player = NULL;
1531 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1533 ret = legacy_player_stop(muse_player->player_handle);
1535 PLAYER_RETURN_MSG(api, ret, module);
1540 int player_disp_pause(muse_module_h module)
1542 int ret = PLAYER_ERROR_NONE;
1543 muse_player_api_e api = MUSE_PLAYER_API_PAUSE;
1544 muse_player_handle_t *muse_player = NULL;
1546 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1548 ret = legacy_player_pause(muse_player->player_handle);
1550 PLAYER_RETURN_MSG(api, ret, module);
1555 int player_disp_set_memory_buffer(muse_module_h module)
1557 int ret = PLAYER_ERROR_NONE;
1558 muse_player_api_e api = MUSE_PLAYER_API_SET_MEMORY_BUFFER;
1559 muse_player_handle_t *muse_player = NULL;
1562 tbm_bo_handle thandle = {NULL, };
1563 tbm_fd tfd = INVALID_DEFAULT_VALUE;
1565 intptr_t bo_addr = 0;
1567 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1568 player_msg_get_type(size, muse_server_module_get_msg(module), INT);
1570 muse_server_ipc_get_fd(module, &tfd);
1571 if (tfd > INVALID_DEFAULT_VALUE)
1572 bo = tbm_bo_import_fd(muse_player->bufmgr, tfd);
1575 LOGE("TBM get error : bo is NULL");
1576 ret = PLAYER_ERROR_INVALID_OPERATION;
1579 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
1580 if (thandle.ptr == NULL) {
1581 LOGE("TBM get error : handle pointer is NULL");
1582 ret = PLAYER_ERROR_INVALID_OPERATION;
1586 bo_addr = (intptr_t)bo;
1587 ret = legacy_player_set_memory_buffer(muse_player->player_handle, thandle.ptr, size);
1588 if (ret != PLAYER_ERROR_NONE) {
1593 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "bo_addr", bo_addr);
1595 /* don't call bo unmap/unref here *
1596 * it will be released at player_disp_deinit_memory_buffer() during _destroy */
1602 if (tfd > INVALID_DEFAULT_VALUE)
1608 PLAYER_RETURN_MSG(api, ret, module);
1612 int player_disp_deinit_memory_buffer(muse_module_h module) /* MUSE_PLAYER_API_DEINIT_MEMORY_BUFFER */
1617 if (player_msg_get(bo_addr, muse_server_module_get_msg(module))) {
1619 bo = (tbm_bo)bo_addr;
1625 return PLAYER_ERROR_NONE;
1628 int player_disp_get_state(muse_module_h module)
1630 int ret = PLAYER_ERROR_NONE;
1631 muse_player_api_e api = MUSE_PLAYER_API_GET_STATE;
1632 muse_player_handle_t *muse_player = NULL;
1633 player_state_e state;
1635 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1637 ret = legacy_player_get_state(muse_player->player_handle, &state);
1639 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "state", (int)state);
1644 int player_disp_set_volume(muse_module_h module)
1646 int ret = PLAYER_ERROR_NONE;
1647 muse_player_api_e api = MUSE_PLAYER_API_SET_VOLUME;
1648 muse_player_handle_t *muse_player = NULL;
1649 double volume = 0.0;
1650 bool ret_val = true;
1652 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
1653 MUSE_TYPE_DOUBLE, "volume", (void *)&volume,
1654 INVALID_MUSE_TYPE_VALUE);
1656 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1657 ret = legacy_player_set_volume(muse_player->player_handle, (float)volume);
1659 ret = PLAYER_ERROR_INVALID_OPERATION;
1661 PLAYER_RETURN_MSG(api, ret, module);
1666 int player_disp_get_volume(muse_module_h module)
1668 int ret = PLAYER_ERROR_NONE;
1669 muse_player_api_e api = MUSE_PLAYER_API_GET_VOLUME;
1670 muse_player_handle_t *muse_player = NULL;
1673 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1675 ret = legacy_player_get_volume(muse_player->player_handle, &volume);
1677 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_DOUBLE, "volume", (double)volume);
1682 int player_disp_set_sound_stream_info(muse_module_h module)
1684 int ret = PLAYER_ERROR_NONE;
1685 muse_player_api_e api = MUSE_PLAYER_API_SET_SOUND_STREAM_INFO;
1686 muse_player_handle_t *muse_player = NULL;
1687 int stream_index = 0;
1688 char stream_type[MUSE_URI_MAX_LENGTH] = { 0, };
1689 bool ret_val = true;
1691 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
1692 MUSE_TYPE_INT, "stream_index", (void *)&stream_index,
1693 MUSE_TYPE_STRING, "stream_type", (void *)stream_type,
1694 INVALID_MUSE_TYPE_VALUE);
1696 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1697 ret = legacy_player_set_sound_stream_info_for_mused(muse_player->player_handle, stream_type, stream_index);
1699 ret = PLAYER_ERROR_INVALID_OPERATION;
1702 PLAYER_RETURN_MSG(api, ret, module);
1707 int player_disp_set_audio_latency_mode(muse_module_h module)
1709 int ret = PLAYER_ERROR_NONE;
1710 muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE;
1711 muse_player_handle_t *muse_player = NULL;
1712 int latency_mode = 0;
1714 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1715 player_msg_get(latency_mode, muse_server_module_get_msg(module));
1717 ret = legacy_player_set_audio_latency_mode(muse_player->player_handle, (audio_latency_mode_e)latency_mode);
1719 PLAYER_RETURN_MSG(api, ret, module);
1724 int player_disp_get_audio_latency_mode(muse_module_h module)
1726 int ret = PLAYER_ERROR_NONE;
1727 muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE;
1728 muse_player_handle_t *muse_player = NULL;
1729 audio_latency_mode_e latency_mode;
1731 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1733 ret = legacy_player_get_audio_latency_mode(muse_player->player_handle, &latency_mode);
1735 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "latency_mode", (int)latency_mode);
1740 int player_disp_set_play_position(muse_module_h module)
1742 int ret = PLAYER_ERROR_NONE;
1743 muse_player_api_e api = MUSE_PLAYER_API_SET_PLAY_POSITION;
1744 muse_player_handle_t *muse_player = NULL;
1747 bool ret_val = true;
1749 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
1750 MUSE_TYPE_INT64, "pos", (void *)&pos,
1751 MUSE_TYPE_INT, "accurate", (void *)&accurate,
1752 INVALID_MUSE_TYPE_VALUE);
1754 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1755 ret = legacy_player_set_play_position(muse_player->player_handle, pos, accurate, _seek_complate_cb, module);
1757 ret = PLAYER_ERROR_INVALID_OPERATION;
1760 PLAYER_RETURN_MSG(api, ret, module);
1765 int player_disp_get_play_position(muse_module_h module)
1767 int ret = PLAYER_ERROR_NONE;
1768 muse_player_api_e api = MUSE_PLAYER_API_GET_PLAY_POSITION;
1769 muse_player_handle_t *muse_player = NULL;
1772 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1774 ret = legacy_player_get_play_position(muse_player->player_handle, &pos);
1776 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT64, "pos", pos);
1781 int player_disp_set_mute(muse_module_h module)
1783 int ret = PLAYER_ERROR_NONE;
1784 muse_player_api_e api = MUSE_PLAYER_API_SET_MUTE;
1785 muse_player_handle_t *muse_player = NULL;
1788 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1789 player_msg_get(mute, muse_server_module_get_msg(module));
1791 ret = legacy_player_set_mute(muse_player->player_handle, (bool)mute);
1793 PLAYER_RETURN_MSG(api, ret, module);
1798 int player_disp_is_muted(muse_module_h module)
1800 int ret = PLAYER_ERROR_NONE;
1801 muse_player_api_e api = MUSE_PLAYER_API_IS_MUTED;
1802 muse_player_handle_t *muse_player = NULL;
1805 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1807 ret = legacy_player_is_muted(muse_player->player_handle, &mute);
1809 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "mute", (int)mute);
1814 int player_disp_set_looping(muse_module_h module)
1816 int ret = PLAYER_ERROR_NONE;
1817 muse_player_api_e api = MUSE_PLAYER_API_SET_LOOPING;
1818 muse_player_handle_t *muse_player = NULL;
1821 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1822 player_msg_get(looping, muse_server_module_get_msg(module));
1824 ret = legacy_player_set_looping(muse_player->player_handle, (bool)looping);
1826 PLAYER_RETURN_MSG(api, ret, module);
1831 int player_disp_is_looping(muse_module_h module)
1833 int ret = PLAYER_ERROR_NONE;
1834 muse_player_api_e api = MUSE_PLAYER_API_IS_LOOPING;
1835 muse_player_handle_t *muse_player = NULL;
1838 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1840 ret = legacy_player_is_looping(muse_player->player_handle, &looping);
1842 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "looping", (int)looping);
1847 int player_disp_get_duration(muse_module_h module)
1849 int ret = PLAYER_ERROR_NONE;
1850 muse_player_api_e api = MUSE_PLAYER_API_GET_DURATION;
1851 muse_player_handle_t *muse_player = NULL;
1852 int64_t duration = 0;
1854 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1856 ret = legacy_player_get_duration(muse_player->player_handle, &duration);
1858 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT64, "duration", duration);
1863 int player_disp_set_display(muse_module_h module)
1865 int ret = PLAYER_ERROR_NONE;
1866 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY;
1867 muse_player_handle_t *muse_player = NULL;
1868 wl_win_msg_type wl_win;
1869 char *wl_win_msg = (char *)&wl_win;
1871 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1872 player_msg_get_array(wl_win_msg, muse_server_module_get_msg(module));
1873 ret = legacy_player_set_display(muse_player->player_handle, wl_win.type, wl_win.surface_id);
1874 PLAYER_RETURN_MSG(api, ret, module);
1880 int player_disp_set_display_mode(muse_module_h module)
1882 int ret = PLAYER_ERROR_NONE;
1883 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_MODE;
1884 muse_player_handle_t *muse_player = NULL;
1887 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1888 player_msg_get(mode, muse_server_module_get_msg(module));
1890 ret = legacy_player_set_display_mode(muse_player->player_handle, (player_display_mode_e)mode);
1892 PLAYER_RETURN_MSG(api, ret, module);
1898 int player_disp_get_display_mode(muse_module_h module)
1900 int ret = PLAYER_ERROR_NONE;
1901 muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_MODE;
1902 muse_player_handle_t *muse_player = NULL;
1903 player_display_mode_e mode = 0;
1905 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1907 ret = legacy_player_get_display_mode(muse_player->player_handle, &mode);
1909 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "mode", (int)mode);
1914 int player_disp_set_video_roi_area(muse_module_h module)
1916 int ret = PLAYER_ERROR_NONE;
1917 muse_player_api_e api = MUSE_PLAYER_API_SET_VIDEO_ROI_AREA;
1918 muse_player_handle_t *muse_player = NULL;
1919 double x_scale = 0, y_scale = 0, w_scale = 0, h_scale = 0;
1920 bool ret_val = true;
1922 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
1923 MUSE_TYPE_DOUBLE, "x_scale", (void *)&x_scale,
1924 MUSE_TYPE_DOUBLE, "y_scale", (void *)&y_scale,
1925 MUSE_TYPE_DOUBLE, "w_scale", (void *)&w_scale,
1926 MUSE_TYPE_DOUBLE, "h_scale", (void *)&h_scale,
1927 INVALID_MUSE_TYPE_VALUE);
1929 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1930 ret = legacy_player_set_video_roi_area(muse_player->player_handle, x_scale,
1931 y_scale, w_scale, h_scale);
1934 PLAYER_RETURN_MSG(api, ret, module);
1939 int player_disp_get_video_roi_area(muse_module_h module)
1941 int ret = PLAYER_ERROR_NONE;
1942 muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_ROI_AREA;
1943 muse_player_handle_t *muse_player = NULL;
1944 double scale_x = 0, scale_y = 0, scale_w = 0, scale_h = 0;
1946 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1948 ret = legacy_player_get_video_roi_area(muse_player->player_handle, &scale_x,
1949 &scale_y, &scale_w, &scale_h);
1951 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_DOUBLE, "scale_x", scale_x,
1952 MUSE_TYPE_DOUBLE, "scale_y", scale_y,
1953 MUSE_TYPE_DOUBLE, "scale_w", scale_w,
1954 MUSE_TYPE_DOUBLE, "scale_h", scale_h);
1959 int player_disp_set_display_roi_area(muse_module_h module)
1961 int ret = PLAYER_ERROR_NONE;
1962 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROI_AREA;
1963 muse_player_handle_t *muse_player = NULL;
1964 wl_win_msg_type wl_win;
1965 char *wl_win_msg = (char *)&wl_win;
1967 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1969 player_msg_get_array(wl_win_msg, muse_server_module_get_msg(module));
1971 ret = legacy_player_set_roi_area(muse_player->player_handle, wl_win.win_roi_x,
1972 wl_win.win_roi_y, wl_win.win_roi_width, wl_win.win_roi_height);
1974 PLAYER_RETURN_MSG(api, ret, module);
1979 int player_disp_set_playback_rate(muse_module_h module)
1981 int ret = PLAYER_ERROR_NONE;
1982 muse_player_api_e api = MUSE_PLAYER_API_SET_PLAYBACK_RATE;
1983 muse_player_handle_t *muse_player = NULL;
1986 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
1987 player_msg_get_type(rate, muse_server_module_get_msg(module), DOUBLE);
1989 ret = legacy_player_set_playback_rate(muse_player->player_handle, (float)rate);
1991 PLAYER_RETURN_MSG(api, ret, module);
1996 int player_disp_set_display_rotation(muse_module_h module)
1998 int ret = PLAYER_ERROR_NONE;
1999 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROTATION;
2000 muse_player_handle_t *muse_player = NULL;
2003 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2004 player_msg_get(rotation, muse_server_module_get_msg(module));
2006 ret = legacy_player_set_display_rotation(muse_player->player_handle, (player_display_rotation_e)rotation);
2008 PLAYER_RETURN_MSG(api, ret, module);
2013 int player_disp_get_display_rotation(muse_module_h module)
2015 int ret = PLAYER_ERROR_NONE;
2016 muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_ROTATION;
2017 muse_player_handle_t *muse_player = NULL;
2018 player_display_rotation_e rotation;
2020 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2022 ret = legacy_player_get_display_rotation(muse_player->player_handle, &rotation);
2024 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "rotation", (int)rotation);
2029 int player_disp_set_display_visible(muse_module_h module)
2031 int ret = PLAYER_ERROR_NONE;
2032 muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_VISIBLE;
2033 muse_player_handle_t *muse_player = NULL;
2036 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2037 player_msg_get(visible, muse_server_module_get_msg(module));
2039 ret = legacy_player_set_display_visible(muse_player->player_handle, visible);
2041 PLAYER_RETURN_MSG(api, ret, module);
2046 int player_disp_is_display_visible(muse_module_h module)
2048 int ret = PLAYER_ERROR_NONE;
2049 muse_player_api_e api = MUSE_PLAYER_API_IS_DISPLAY_VISIBLE;
2050 muse_player_handle_t *muse_player = NULL;
2053 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2055 ret = legacy_player_is_display_visible(muse_player->player_handle, &value);
2057 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "value", (int)value);
2062 int player_disp_get_content_info(muse_module_h module)
2064 int ret = PLAYER_ERROR_NONE;
2065 muse_player_handle_t *muse_player = NULL;
2066 muse_player_api_e api = MUSE_PLAYER_API_GET_CONTENT_INFO;
2068 player_content_info_e key;
2070 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2071 player_msg_get(key, muse_server_module_get_msg(module));
2073 ret = legacy_player_get_content_info(muse_player->player_handle, key, &value);
2075 if (ret == PLAYER_ERROR_NONE) {
2076 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_STRING, "value", (const char *)value);
2080 PLAYER_RETURN_MSG(api, ret, module);
2086 int player_disp_get_codec_info(muse_module_h module)
2088 int ret = PLAYER_ERROR_NONE;
2089 muse_player_handle_t *muse_player = NULL;
2090 muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_INFO;
2091 char *video_codec = NULL;
2092 char *audio_codec = NULL;
2094 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2096 ret = legacy_player_get_codec_info(muse_player->player_handle, &audio_codec, &video_codec);
2098 if (ret == PLAYER_ERROR_NONE) {
2099 PLAYER_RETURN_MSG(api, ret, module,
2100 MUSE_TYPE_STRING, "audio_codec", (const char *)audio_codec,
2101 MUSE_TYPE_STRING, "video_codec", (const char *)video_codec);
2107 PLAYER_RETURN_MSG(api, ret, module);
2113 int player_disp_get_audio_stream_info(muse_module_h module)
2115 int ret = PLAYER_ERROR_NONE;
2116 muse_player_handle_t *muse_player = NULL;
2117 muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO;
2118 int sample_rate = 0;
2122 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2124 ret = legacy_player_get_audio_stream_info(muse_player->player_handle, &sample_rate, &channel, &bit_rate);
2126 PLAYER_RETURN_MSG(api, ret, module,
2127 MUSE_TYPE_INT, "sample_rate", sample_rate,
2128 MUSE_TYPE_INT, "channel", channel,
2129 MUSE_TYPE_INT, "bit_rate", bit_rate);
2134 int player_disp_get_video_stream_info(muse_module_h module)
2136 int ret = PLAYER_ERROR_NONE;
2137 muse_player_handle_t *muse_player = NULL;
2138 muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO;
2142 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2144 ret = legacy_player_get_video_stream_info(muse_player->player_handle, &fps, &bit_rate);
2146 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "fps", fps, MUSE_TYPE_INT, "bit_rate", bit_rate);
2151 int player_disp_get_video_size(muse_module_h module)
2153 int ret = PLAYER_ERROR_NONE;
2154 muse_player_handle_t *muse_player = NULL;
2155 muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_SIZE;
2159 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2161 ret = legacy_player_get_video_size(muse_player->player_handle, &width, &height);
2163 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "width", width, MUSE_TYPE_INT, "height", height);
2168 int player_disp_get_album_art(muse_module_h module)
2170 int ret = PLAYER_ERROR_NONE;
2171 muse_player_handle_t *muse_player = NULL;
2172 muse_player_api_e api = MUSE_PLAYER_API_GET_ALBUM_ART;
2173 void *album_art = NULL;
2175 bool ret_val = true;
2176 tbm_fd tfd = INVALID_DEFAULT_VALUE;
2177 int key = INVALID_DEFAULT_VALUE;
2179 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2180 if (muse_player == NULL) {
2181 LOGE("handle is NULL");
2182 ret = PLAYER_ERROR_INVALID_OPERATION;
2186 ret = legacy_player_get_album_art(muse_player->player_handle, &album_art, &size);
2187 if (ret != PLAYER_ERROR_NONE)
2190 if ((album_art != NULL) && (size > 0)) {
2191 ret_val = _create_export_data(muse_player, album_art, size, NULL, 0, &tfd, &key);
2193 LOGE("failed to create export data");
2194 ret = PLAYER_ERROR_INVALID_OPERATION;
2197 PLAYER_RETURN_MSG_WITH_TFD(api, ret, module, tfd,
2198 MUSE_TYPE_INT, "size", size, MUSE_TYPE_INT, "key", key);
2200 LOGD("album art is empty, didn't make tbm_bo");
2202 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "size", size);
2208 PLAYER_RETURN_MSG(api, ret, module);
2212 int player_disp_audio_effect_get_equalizer_bands_count(muse_module_h module)
2214 int ret = PLAYER_ERROR_NONE;
2215 muse_player_handle_t *muse_player = NULL;
2216 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT;
2219 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2221 ret = legacy_player_audio_effect_get_equalizer_bands_count(muse_player->player_handle, &count);
2223 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "count", count);
2228 int player_disp_audio_effect_set_equalizer_all_bands(muse_module_h module)
2230 int ret = PLAYER_ERROR_NONE;
2231 muse_player_handle_t *muse_player = NULL;
2232 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS;
2233 muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
2234 int *band_levels = NULL;
2237 void *jobj = muse_core_msg_object_new(muse_server_module_get_msg(module), NULL, &err);
2238 if (!jobj || !muse_core_msg_object_get_value("length", jobj, MUSE_TYPE_INT, &length)) {
2239 LOGE("failed to get msg object. jobj:%p, err:%d, length:%d", jobj, err, length);
2240 ret = PLAYER_ERROR_INVALID_OPERATION;
2244 band_levels = (int *)g_try_new0(int, length);
2246 if (muse_core_msg_object_get_value("band_levels", jobj, MUSE_TYPE_ARRAY, band_levels)) {
2247 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2248 ret = legacy_player_audio_effect_set_equalizer_all_bands(muse_player->player_handle, band_levels, length);
2250 LOGE("failed to get cookie value from msg");
2251 ret = PLAYER_ERROR_INVALID_OPERATION;
2253 g_free(band_levels);
2255 ret = PLAYER_ERROR_INVALID_OPERATION;
2260 muse_core_msg_object_free(jobj);
2262 PLAYER_RETURN_MSG(api, ret, module);
2267 int player_disp_audio_effect_set_equalizer_band_level(muse_module_h module)
2269 int ret = PLAYER_ERROR_NONE;
2270 muse_player_handle_t *muse_player = NULL;
2271 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL;
2272 int index = 0, level = 0;
2273 bool ret_val = true;
2275 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
2276 MUSE_TYPE_INT, "index", (void *)&index,
2277 MUSE_TYPE_INT, "level", (void *)&level,
2278 INVALID_MUSE_TYPE_VALUE);
2280 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2281 ret = legacy_player_audio_effect_set_equalizer_band_level(muse_player->player_handle, index, level);
2283 ret = PLAYER_ERROR_INVALID_OPERATION;
2286 PLAYER_RETURN_MSG(api, ret, module);
2291 int player_disp_audio_effect_get_equalizer_band_level(muse_module_h module)
2293 int ret = PLAYER_ERROR_NONE;
2294 muse_player_handle_t *muse_player = NULL;
2295 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL;
2298 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2299 player_msg_get(index, muse_server_module_get_msg(module));
2301 ret = legacy_player_audio_effect_get_equalizer_band_level(muse_player->player_handle, index, &level);
2303 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "level", level);
2308 int player_disp_audio_effect_get_equalizer_level_range(muse_module_h module)
2310 int ret = PLAYER_ERROR_NONE;
2311 muse_player_handle_t *muse_player = NULL;
2312 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE;
2315 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2317 ret = legacy_player_audio_effect_get_equalizer_level_range(muse_player->player_handle, &min, &max);
2319 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "min", min, MUSE_TYPE_INT, "max", max);
2324 int player_disp_audio_effect_get_equalizer_band_frequency(muse_module_h module)
2326 int ret = PLAYER_ERROR_NONE;
2327 muse_player_handle_t *muse_player = NULL;
2328 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY;
2329 int index, frequency;
2331 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2332 player_msg_get(index, muse_server_module_get_msg(module));
2334 ret = legacy_player_audio_effect_get_equalizer_band_frequency(muse_player->player_handle, index, &frequency);
2336 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "frequency", frequency);
2341 int player_disp_audio_effect_get_equalizer_band_frequency_range(muse_module_h module)
2343 int ret = PLAYER_ERROR_NONE;
2344 muse_player_handle_t *muse_player = NULL;
2345 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE;
2348 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2349 player_msg_get(index, muse_server_module_get_msg(module));
2351 ret = legacy_player_audio_effect_get_equalizer_band_frequency_range(muse_player->player_handle, index, &range);
2353 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "range", range);
2358 int player_disp_audio_effect_equalizer_clear(muse_module_h module)
2360 int ret = PLAYER_ERROR_NONE;
2361 muse_player_handle_t *muse_player = NULL;
2362 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR;
2364 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2366 ret = legacy_player_audio_effect_equalizer_clear(muse_player->player_handle);
2368 PLAYER_RETURN_MSG(api, ret, module);
2373 int player_disp_audio_effect_equalizer_is_available(muse_module_h module)
2375 int ret = PLAYER_ERROR_NONE;
2376 muse_player_handle_t *muse_player = NULL;
2377 muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE;
2380 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2382 ret = legacy_player_audio_effect_equalizer_is_available(muse_player->player_handle, &available);
2384 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "available", (int)available);
2389 int player_disp_capture_video(muse_module_h module)
2391 int ret = PLAYER_ERROR_NONE;
2392 muse_player_handle_t *muse_player = NULL;
2393 muse_player_api_e api = MUSE_PLAYER_API_CAPTURE_VIDEO;
2395 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2397 ret = legacy_player_capture_video(muse_player->player_handle, _capture_video_cb, module);
2399 PLAYER_RETURN_MSG(api, ret, module);
2404 int player_disp_set_streaming_cookie(muse_module_h module)
2406 int ret = PLAYER_ERROR_NONE;
2407 muse_player_handle_t *muse_player = NULL;
2408 muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_COOKIE;
2409 muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
2410 char *cookie = NULL;
2413 void *jobj = muse_core_msg_object_new(muse_server_module_get_msg(module), NULL, &err);
2414 if (!jobj || !muse_core_msg_object_get_value("size", jobj, MUSE_TYPE_INT, &size)) {
2415 LOGE("failed to get msg object. jobj:%p, err:%d, size:%d", jobj, err, size);
2416 ret = PLAYER_ERROR_INVALID_OPERATION;
2420 cookie = (char *)g_try_new0(char, size + 1);
2422 if (muse_core_msg_object_get_value("cookie", jobj, MUSE_TYPE_STRING, cookie)) {
2423 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2424 ret = legacy_player_set_streaming_cookie(muse_player->player_handle, cookie, size);
2426 LOGE("failed to get cookie value from msg");
2427 ret = PLAYER_ERROR_INVALID_OPERATION;
2431 ret = PLAYER_ERROR_INVALID_OPERATION;
2436 muse_core_msg_object_free(jobj);
2438 PLAYER_RETURN_MSG(api, ret, module);
2443 int player_disp_set_streaming_user_agent(muse_module_h module)
2445 int ret = PLAYER_ERROR_NONE;
2446 muse_player_handle_t *muse_player = NULL;
2447 muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_USER_AGENT;
2448 muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
2449 char *user_agent = NULL;
2452 void *jobj = muse_core_msg_object_new(muse_server_module_get_msg(module), NULL, &err);
2453 if (!jobj || !muse_core_msg_object_get_value("size", jobj, MUSE_TYPE_INT, &size)) {
2454 LOGE("failed to get msg object jobj:%p, err:%d", jobj, err);
2455 ret = PLAYER_ERROR_INVALID_OPERATION;
2459 user_agent = (char *)g_try_new0(char, size + 1);
2461 if (muse_core_msg_object_get_value("user_agent", jobj, MUSE_TYPE_STRING, user_agent)) {
2462 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2463 ret = legacy_player_set_streaming_user_agent(muse_player->player_handle, user_agent, size);
2465 LOGE("failed to get user_agent value from msg");
2466 ret = PLAYER_ERROR_INVALID_OPERATION;
2470 ret = PLAYER_ERROR_INVALID_OPERATION;
2475 muse_core_msg_object_free(jobj);
2477 PLAYER_RETURN_MSG(api, ret, module);
2482 int player_disp_get_streaming_download_progress(muse_module_h module)
2484 int ret = PLAYER_ERROR_NONE;
2485 muse_player_handle_t *muse_player = NULL;
2486 muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS;
2487 int start_pos = 0, end_pos = 0;
2489 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2491 ret = legacy_player_get_streaming_download_progress(muse_player->player_handle, &start_pos, &end_pos);
2493 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "start_pos", start_pos, MUSE_TYPE_INT, "end_pos", end_pos);
2498 int player_disp_set_subtitle_path(muse_module_h module)
2500 int ret = PLAYER_ERROR_NONE;
2501 muse_player_handle_t *muse_player = NULL;
2502 muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_PATH;
2503 char subtitle_path[MUSE_URI_MAX_LENGTH] = { 0, };
2505 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2506 player_msg_get_string(subtitle_path, muse_server_module_get_msg(module));
2508 if (strncmp(subtitle_path, "", 1)) {
2509 if ((ret = _check_supportable(module, subtitle_path)) == PLAYER_ERROR_NONE)
2510 ret = legacy_player_set_subtitle_path(muse_player->player_handle, subtitle_path);
2512 ret = legacy_player_set_subtitle_path(muse_player->player_handle, NULL);
2515 PLAYER_RETURN_MSG(api, ret, module);
2520 int player_disp_set_subtitle_position_offset(muse_module_h module)
2522 int ret = PLAYER_ERROR_NONE;
2523 muse_player_handle_t *muse_player = NULL;
2524 muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET;
2527 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2528 player_msg_get(milliseconds, muse_server_module_get_msg(module));
2530 ret = legacy_player_set_subtitle_position_offset(muse_player->player_handle, milliseconds);
2532 PLAYER_RETURN_MSG(api, ret, module);
2537 int player_disp_push_media_stream(muse_module_h module)
2539 int ret = MEDIA_FORMAT_ERROR_NONE;
2540 muse_player_handle_t *muse_player = NULL;
2541 muse_player_api_e api = MUSE_PLAYER_API_PUSH_MEDIA_STREAM;
2542 muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
2543 player_push_media_msg_type push_media;
2544 char *push_media_msg = (char *)&push_media;
2546 tbm_bo_handle thandle;
2547 tbm_fd tfd = INVALID_DEFAULT_VALUE;
2550 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2551 void *jobj = muse_core_msg_object_new(muse_server_module_get_msg(module), NULL, &err);
2552 if (!jobj || !muse_core_msg_object_get_value("push_media_msg", jobj, MUSE_TYPE_ARRAY, push_media_msg)) {
2553 LOGE("failed to get msg object. jobj:%p, err:%d", jobj, err);
2554 ret = PLAYER_ERROR_INVALID_OPERATION;
2555 goto push_media_stream_exit1;
2558 if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM) {
2559 muse_server_ipc_get_fd(module, &tfd);
2560 if (tfd > INVALID_DEFAULT_VALUE)
2561 bo = tbm_bo_import_fd(muse_player->bufmgr, tfd);
2563 LOGE("TBM get error : bo is NULL");
2564 ret = PLAYER_ERROR_INVALID_OPERATION;
2565 goto push_media_stream_exit1;
2567 thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
2568 if (thandle.ptr == NULL) {
2569 LOGE("TBM get error : handle pointer is NULL");
2570 ret = PLAYER_ERROR_INVALID_OPERATION;
2571 goto push_media_stream_exit2;
2574 } else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG) {
2575 buf = g_new(char, push_media.size);
2577 ret = PLAYER_ERROR_OUT_OF_MEMORY;
2578 goto push_media_stream_exit1;
2580 if (!muse_core_msg_object_get_value("buf", jobj, MUSE_TYPE_ARRAY, buf)) {
2581 LOGE("failed to get buf from msg.");
2582 ret = PLAYER_ERROR_INVALID_OPERATION;
2583 goto push_media_stream_exit2;
2585 } else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW) {
2586 if (push_media.size > 0)
2587 buf = muse_server_ipc_get_data(module);
2590 ret = _push_media_stream(muse_player, &push_media, buf);
2592 if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
2594 push_media_stream_exit2:
2595 if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
2597 else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG)
2599 else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW && buf)
2600 muse_server_ipc_delete_data(buf);
2601 push_media_stream_exit1:
2602 if (tfd > INVALID_DEFAULT_VALUE)
2606 muse_core_msg_object_free(jobj);
2607 PLAYER_RETURN_MSG(api, ret, module);
2611 int player_disp_set_media_stream_info(muse_module_h module)
2613 int ret = PLAYER_ERROR_NONE;
2614 muse_player_handle_t *muse_player = NULL;
2615 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO;
2616 media_format_mimetype_e mimetype;
2617 player_stream_type_e type;
2618 media_format_h format = NULL;
2628 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2629 player_msg_get(mimetype, muse_server_module_get_msg(module));
2630 player_msg_get(type, muse_server_module_get_msg(module));
2631 player_msg_get(avg_bps, muse_server_module_get_msg(module));
2632 if (type == PLAYER_STREAM_TYPE_VIDEO) {
2633 player_msg_get(width, muse_server_module_get_msg(module));
2634 player_msg_get(height, muse_server_module_get_msg(module));
2635 player_msg_get(max_bps, muse_server_module_get_msg(module));
2636 player_msg_get(frame_rate, muse_server_module_get_msg(module));
2637 } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
2638 player_msg_get(channel, muse_server_module_get_msg(module));
2639 player_msg_get(samplerate, muse_server_module_get_msg(module));
2640 player_msg_get(bit, muse_server_module_get_msg(module));
2642 ret = PLAYER_ERROR_INVALID_PARAMETER;
2643 goto set_media_stream_info_exit;
2646 if (media_format_create(&format) == MEDIA_FORMAT_ERROR_NONE) {
2647 if (type == PLAYER_STREAM_TYPE_VIDEO) {
2648 ret = media_format_set_video_mime(format, mimetype);
2649 ret |= media_format_set_video_width(format, width);
2650 ret |= media_format_set_video_height(format, height);
2651 ret |= media_format_set_video_avg_bps(format, avg_bps);
2652 ret |= media_format_set_video_max_bps(format, max_bps);
2653 ret |= media_format_set_video_frame_rate(format, frame_rate);
2654 } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
2655 ret = media_format_set_audio_mime(format, mimetype);
2656 ret |= media_format_set_audio_channel(format, channel);
2657 ret |= media_format_set_audio_samplerate(format, samplerate);
2658 ret |= media_format_set_audio_bit(format, bit);
2659 ret |= media_format_set_audio_avg_bps(format, avg_bps);
2661 if (ret != MEDIA_FORMAT_ERROR_NONE) {
2662 ret = PLAYER_ERROR_INVALID_OPERATION;
2663 goto set_media_stream_info_exit;
2666 ret = PLAYER_ERROR_OUT_OF_MEMORY;
2667 goto set_media_stream_info_exit;
2670 ret = legacy_player_set_media_stream_info(muse_player->player_handle, type, format);
2672 set_media_stream_info_exit:
2673 media_format_unref(format);
2674 PLAYER_RETURN_MSG(api, ret, module);
2679 int player_disp_set_callback(muse_module_h module)
2681 int ret = PLAYER_ERROR_NONE;
2682 muse_player_handle_t *muse_player = NULL;
2683 muse_player_event_e type;
2685 bool ret_val = true;
2687 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
2688 MUSE_TYPE_INT, "type", (void *)&type,
2689 MUSE_TYPE_INT, "set", (void *)&set,
2690 INVALID_MUSE_TYPE_VALUE);
2693 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2694 if (type < MUSE_PLAYER_EVENT_TYPE_NUM && set_callback_func[type] != NULL)
2695 set_callback_func[type] (muse_player->player_handle, module, set);
2697 ret = PLAYER_ERROR_INVALID_OPERATION;
2698 PLAYER_RETURN_MSG(MUSE_PLAYER_API_SET_CALLBACK, ret, module);
2704 int player_disp_return_video_data(muse_module_h module) /* MUSE_PLAYER_API_RETURN_VIDEO_DATA */
2706 mmplayer_video_decoded_data_info_t *v_data = NULL;
2707 muse_player_handle_t *muse_player = NULL;
2708 bool find_data = false;
2710 player_msg_get_type(v_data, muse_server_module_get_msg(module), POINTER);
2712 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2713 if (muse_player && muse_player->video_data_list) {
2714 g_mutex_lock(&muse_player->list_lock);
2715 if (g_list_find(muse_player->video_data_list, v_data)) {
2716 muse_player->video_data_list = g_list_remove(muse_player->video_data_list, v_data);
2719 LOGW("the v_data(%p) is not in the exported list.", v_data);
2721 g_mutex_unlock(&muse_player->list_lock);
2724 _remove_video_stream_data(module, v_data);
2727 return PLAYER_ERROR_NONE;
2730 int player_disp_set_media_stream_buffer_max_size(muse_module_h module)
2732 int ret = PLAYER_ERROR_NONE;
2733 muse_player_handle_t *muse_player = NULL;
2734 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE;
2735 player_stream_type_e type;
2736 unsigned long long max_size;
2737 bool ret_val = true;
2739 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
2740 MUSE_TYPE_INT, "type", (void *)&type,
2741 MUSE_TYPE_INT64, "max_size", (void *)&max_size,
2742 INVALID_MUSE_TYPE_VALUE);
2744 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2745 ret = legacy_player_set_media_stream_buffer_max_size(muse_player->player_handle, type, max_size);
2747 ret = PLAYER_ERROR_INVALID_OPERATION;
2750 PLAYER_RETURN_MSG(api, ret, module);
2756 int player_disp_get_media_stream_buffer_max_size(muse_module_h module)
2758 int ret = PLAYER_ERROR_NONE;
2759 muse_player_handle_t *muse_player = NULL;
2760 muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE;
2761 player_stream_type_e type;
2762 unsigned long long max_size;
2763 /* unsigned upper_max_size, lower_max_size; */
2765 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2766 player_msg_get(type, muse_server_module_get_msg(module));
2768 ret = legacy_player_get_media_stream_buffer_max_size(muse_player->player_handle, type, &max_size);
2769 if (ret == PLAYER_ERROR_NONE)
2770 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT64, "max_size", (INT64)max_size);
2772 PLAYER_RETURN_MSG(api, ret, module);
2777 int player_disp_set_media_stream_buffer_min_threshold(muse_module_h module)
2779 int ret = PLAYER_ERROR_NONE;
2780 muse_player_handle_t *muse_player = NULL;
2781 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
2782 player_stream_type_e type;
2783 unsigned percent = 0;
2784 bool ret_val = true;
2786 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
2787 MUSE_TYPE_INT, "type", (void *)&type,
2788 MUSE_TYPE_INT, "percent", (void *)&percent,
2789 INVALID_MUSE_TYPE_VALUE);
2791 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2792 ret = legacy_player_set_media_stream_buffer_min_threshold(muse_player->player_handle, type, percent);
2794 ret = PLAYER_ERROR_INVALID_OPERATION;
2796 PLAYER_RETURN_MSG(api, ret, module);
2801 int player_disp_get_media_stream_buffer_min_threshold(muse_module_h module)
2803 int ret = PLAYER_ERROR_NONE;
2804 muse_player_handle_t *muse_player = NULL;
2805 muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
2806 player_stream_type_e type;
2809 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2810 player_msg_get(type, muse_server_module_get_msg(module));
2812 ret = legacy_player_get_media_stream_buffer_min_threshold(muse_player->player_handle, type, &percent);
2813 if (ret == PLAYER_ERROR_NONE)
2814 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "percent", (int)percent);
2816 PLAYER_RETURN_MSG(api, ret, module);
2821 int player_disp_set_media_stream_dynamic_resolution(muse_module_h module)
2823 int ret = PLAYER_ERROR_NONE;
2824 muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_DYNAMIC_RESOLUTION;
2825 muse_player_handle_t *muse_player = NULL;
2828 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2829 player_msg_get(drc, muse_server_module_get_msg(module));
2831 ret = legacy_player_set_media_stream_dynamic_resolution(muse_player->player_handle, (bool)drc);
2833 PLAYER_RETURN_MSG(api, ret, module);
2839 int player_disp_get_track_count(muse_module_h module)
2841 int ret = PLAYER_ERROR_NONE;
2842 muse_player_handle_t *muse_player = NULL;
2843 muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_COUNT;
2844 player_stream_type_e type;
2847 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2848 player_msg_get(type, muse_server_module_get_msg(module));
2850 ret = legacy_player_get_track_count(muse_player->player_handle, type, &count);
2851 if (ret == PLAYER_ERROR_NONE)
2852 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "count", count);
2854 PLAYER_RETURN_MSG(api, ret, module);
2859 int player_disp_get_current_track(muse_module_h module)
2861 int ret = PLAYER_ERROR_NONE;
2862 muse_player_handle_t *muse_player = NULL;
2863 muse_player_api_e api = MUSE_PLAYER_API_GET_CURRENT_TRACK;
2864 player_stream_type_e type;
2867 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2868 player_msg_get(type, muse_server_module_get_msg(module));
2870 ret = legacy_player_get_current_track(muse_player->player_handle, type, &index);
2871 if (ret == PLAYER_ERROR_NONE)
2872 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "index", index);
2874 PLAYER_RETURN_MSG(api, ret, module);
2879 int player_disp_select_track(muse_module_h module)
2881 int ret = PLAYER_ERROR_NONE;
2882 muse_player_handle_t *muse_player = NULL;
2883 muse_player_api_e api = MUSE_PLAYER_API_SELECT_TRACK;
2884 player_stream_type_e type;
2886 bool ret_val = true;
2888 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
2889 MUSE_TYPE_INT, "type", (void *)&type,
2890 MUSE_TYPE_INT, "index", (void *)&index,
2891 INVALID_MUSE_TYPE_VALUE);
2893 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2894 ret = legacy_player_select_track(muse_player->player_handle, type, index);
2896 ret = PLAYER_ERROR_INVALID_OPERATION;
2898 PLAYER_RETURN_MSG(api, ret, module);
2903 int player_disp_get_track_language_code(muse_module_h module)
2905 int ret = PLAYER_ERROR_NONE;
2906 muse_player_handle_t *muse_player = NULL;
2907 muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE;
2908 player_stream_type_e type = PLAYER_STREAM_TYPE_DEFAULT;
2912 bool ret_val = true;
2914 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
2915 MUSE_TYPE_INT, "type", (void *)&type,
2916 MUSE_TYPE_INT, "index", (void *)&index,
2917 INVALID_MUSE_TYPE_VALUE);
2919 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2920 ret = legacy_player_get_track_language_code(muse_player->player_handle, type, index, &code, &code_len);
2922 ret = PLAYER_ERROR_INVALID_OPERATION;
2925 if (ret == PLAYER_ERROR_NONE)
2926 PLAYER_RETURN_MSG(api, ret, module,
2927 MUSE_TYPE_INT, "code_len", code_len,
2928 MUSE_TYPE_STRING, "code", (const char *)code);
2930 PLAYER_RETURN_MSG(api, ret, module);
2938 int player_disp_set_pcm_extraction_mode(muse_module_h module)
2940 int ret = PLAYER_ERROR_NONE;
2941 muse_player_handle_t *muse_player = NULL;
2942 muse_player_api_e api = MUSE_PLAYER_API_SET_PCM_EXTRACTION_MODE;
2945 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2946 player_msg_get(sync, muse_server_module_get_msg(module));
2948 ret = legacy_player_set_pcm_extraction_mode(muse_player->player_handle, sync, _audio_decoded_cb, module);
2950 PLAYER_RETURN_MSG(api, ret, module);
2955 int player_disp_set_pcm_spec(muse_module_h module)
2957 int ret = PLAYER_ERROR_NONE;
2958 muse_player_handle_t *muse_player = NULL;
2959 muse_player_api_e api = MUSE_PLAYER_API_SET_PCM_SPEC;
2960 char format[MUSE_URI_MAX_LENGTH] = { 0, };
2963 bool ret_val = true;
2965 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
2966 MUSE_TYPE_INT, "samplerate", (void *)&samplerate,
2967 MUSE_TYPE_INT, "channel", (void *)&channel,
2968 MUSE_TYPE_STRING, "format", (void *)format,
2969 INVALID_MUSE_TYPE_VALUE);
2971 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2972 ret = legacy_player_set_pcm_spec(muse_player->player_handle, format, samplerate, channel);
2974 ret = PLAYER_ERROR_INVALID_OPERATION;
2977 PLAYER_RETURN_MSG(api, ret, module);
2982 int player_disp_set_streaming_playback_rate(muse_module_h module)
2984 int ret = PLAYER_ERROR_NONE;
2985 muse_player_handle_t *muse_player = NULL;
2986 muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_PLAYBACK_RATE;
2989 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
2990 player_msg_get_type(rate, muse_server_module_get_msg(module), DOUBLE);
2992 ret = legacy_player_set_streaming_playback_rate(muse_player->player_handle, (float)rate);
2994 PLAYER_RETURN_MSG(api, ret, module);
2999 int player_disp_return_buffer(muse_module_h module) /* MUSE_PLAYER_API_RETURN_BUFFER */
3002 /* muse_player_handle_t *muse_player = NULL; */
3004 /* muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module); */
3006 player_msg_get(key, muse_server_module_get_msg(module));
3008 /* LOGD("handle : %p, key : %d", muse_player, key); */
3010 if (!_remove_export_data(module, key, false))
3011 LOGE("failed to remove export data : key %d", key);
3013 /* This funct does not send return value to client. *
3014 * You have to use PLAYER_SEND_MSG_ASYNC to return buffer. */
3016 return PLAYER_ERROR_NONE;
3019 int player_disp_set_next_uri(muse_module_h module)
3021 int ret = PLAYER_ERROR_NONE;
3022 muse_player_api_e api = MUSE_PLAYER_API_SET_NEXT_URI;
3023 muse_player_handle_t *muse_player = NULL;
3024 char path[MUSE_URI_MAX_LENGTH] = { 0, };
3026 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3027 player_msg_get_string(path, muse_server_module_get_msg(module));
3029 ret = legacy_player_set_next_uri(muse_player->player_handle, path);
3031 PLAYER_RETURN_MSG(api, ret, module);
3036 int player_disp_get_next_uri(muse_module_h module)
3038 int ret = PLAYER_ERROR_NONE;
3039 muse_player_api_e api = MUSE_PLAYER_API_GET_NEXT_URI;
3040 muse_player_handle_t *muse_player = NULL;
3041 char *next_uri = NULL;
3043 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3045 ret = legacy_player_get_next_uri(muse_player->player_handle, &next_uri);
3046 if (ret == PLAYER_ERROR_NONE) {
3047 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_STRING, "next_uri", (const char *)next_uri);
3051 PLAYER_RETURN_MSG(api, ret, module);
3057 int player_disp_set_gapless(muse_module_h module)
3059 int ret = PLAYER_ERROR_NONE;
3060 muse_player_api_e api = MUSE_PLAYER_API_SET_GAPLESS;
3061 muse_player_handle_t *muse_player = NULL;
3064 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3065 player_msg_get(gapless, muse_server_module_get_msg(module));
3067 ret = legacy_player_set_gapless(muse_player->player_handle, (bool)gapless);
3069 PLAYER_RETURN_MSG(api, ret, module);
3074 int player_disp_is_gapless(muse_module_h module)
3076 int ret = PLAYER_ERROR_NONE;
3077 muse_player_api_e api = MUSE_PLAYER_API_IS_GAPLESS;
3078 muse_player_handle_t *muse_player = NULL;
3081 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3083 ret = legacy_player_is_gapless(muse_player->player_handle, &value);
3085 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "value", (int)value);
3090 int player_disp_get_media_packet_video_frame_pool_size(muse_module_h module)
3092 int ret = PLAYER_ERROR_NONE;
3093 muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_PACKET_VIDEO_FRAME_POOL_SIZE;
3094 muse_player_handle_t *muse_player = NULL;
3097 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3099 LOGD("size of v buffer: %d", muse_player->total_size_of_buffers);
3100 if (muse_player->total_size_of_buffers > DEFAULT_VDEC_TOTAL_SIZE_OF_BUFFER) {
3101 value = muse_player->total_size_of_buffers;
3102 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "value", value);
3104 ret = PLAYER_ERROR_INVALID_STATE;
3105 PLAYER_RETURN_MSG(api, ret, module);
3111 int player_disp_enable_media_packet_video_frame_decoded_cb(muse_module_h module)
3113 int ret = PLAYER_ERROR_NONE;
3114 muse_player_api_e api = MUSE_PLAYER_API_ENABLE_MEDIA_PACKET_VIDEO_FRAME_DECODED_CB;
3115 muse_player_handle_t *muse_player = NULL;
3118 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3119 player_msg_get(enable, muse_server_module_get_msg(module));
3121 ret = legacy_player_enable_media_packet_video_frame_decoded_cb(muse_player->player_handle, (bool)enable);
3123 PLAYER_RETURN_MSG(api, ret, module);
3128 int player_disp_get_adaptive_variant_info(muse_module_h module)
3130 int ret = PLAYER_ERROR_NONE;
3131 muse_player_api_e api = MUSE_PLAYER_API_GET_ADAPTIVE_VARIANT_INFO;
3132 muse_player_handle_t *muse_player = NULL;
3133 char *var_info = NULL;
3136 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3138 ret = legacy_player_get_adaptive_variant_info(muse_player->player_handle, &num, &var_info);
3140 if (ret != PLAYER_ERROR_NONE || num <= 0)
3141 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "num", num);
3143 PLAYER_RETURN_MSG(api, ret, module,
3144 MUSE_TYPE_INT, "num", num,
3145 MUSE_TYPE_STRING, "var_info", (const char *)var_info);
3152 int player_disp_set_max_adaptive_variant_limit(muse_module_h module)
3154 int ret = PLAYER_ERROR_NONE;
3155 muse_player_api_e api = MUSE_PLAYER_API_SET_MAX_ADAPTIVE_VARIANT_LIMIT;
3156 muse_player_handle_t *muse_player = NULL;
3157 bool ret_val = true;
3158 int bandwidth = ADAPTIVE_VARIANT_DEFAULT_VALUE;
3159 int width = ADAPTIVE_VARIANT_DEFAULT_VALUE;
3160 int height = ADAPTIVE_VARIANT_DEFAULT_VALUE;
3162 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
3163 MUSE_TYPE_INT, "bandwidth", (void *)&bandwidth,
3164 MUSE_TYPE_INT, "width", (void *)&width,
3165 MUSE_TYPE_INT, "height", (void *)&height,
3166 INVALID_MUSE_TYPE_VALUE);
3168 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3169 ret = legacy_player_set_max_adaptive_variant_limit(muse_player->player_handle, bandwidth, width, height);
3171 ret = PLAYER_ERROR_INVALID_OPERATION;
3174 PLAYER_RETURN_MSG(api, ret, module);
3178 int player_disp_get_max_adaptive_variant_limit(muse_module_h module)
3180 int ret = PLAYER_ERROR_NONE;
3181 muse_player_api_e api = MUSE_PLAYER_API_GET_MAX_ADAPTIVE_VARIANT_LIMIT;
3182 muse_player_handle_t *muse_player = NULL;
3183 int bandwidth = ADAPTIVE_VARIANT_DEFAULT_VALUE;
3184 int width = ADAPTIVE_VARIANT_DEFAULT_VALUE;
3185 int height = ADAPTIVE_VARIANT_DEFAULT_VALUE;
3187 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3189 ret = legacy_player_get_max_adaptive_variant_limit(muse_player->player_handle, &bandwidth, &width, &height);
3190 if (ret == PLAYER_ERROR_NONE)
3191 PLAYER_RETURN_MSG(api, ret, module,
3192 MUSE_TYPE_INT, "bandwidth", bandwidth,
3193 MUSE_TYPE_INT, "width", width,
3194 MUSE_TYPE_INT, "height", height);
3196 PLAYER_RETURN_MSG(api, ret, module);
3201 int player_disp_set_audio_only(muse_module_h module)
3203 int ret = PLAYER_ERROR_NONE;
3204 muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_ONLY;
3205 muse_player_handle_t *muse_player = NULL;
3208 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3209 player_msg_get(audio_only, muse_server_module_get_msg(module));
3211 ret = legacy_player_set_audio_only(muse_player->player_handle, (bool)audio_only);
3213 PLAYER_RETURN_MSG(api, ret, module);
3218 int player_disp_is_audio_only(muse_module_h module)
3220 int ret = PLAYER_ERROR_NONE;
3221 muse_player_api_e api = MUSE_PLAYER_API_IS_AUDIO_ONLY;
3222 muse_player_handle_t *muse_player = NULL;
3225 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3227 ret = legacy_player_is_audio_only(muse_player->player_handle, &audio_only);
3229 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "audio_only", (int)audio_only);
3234 int player_disp_set_streaming_buffering_time(muse_module_h module)
3236 int ret = PLAYER_ERROR_NONE;
3237 muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_BUFFERING_TIME;
3238 muse_player_handle_t *muse_player = NULL;
3239 int prebuffer_ms = -1, rebuffer_ms = -1;
3240 bool ret_val = true;
3242 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
3243 MUSE_TYPE_INT, "prebuffer_ms", (void *)&prebuffer_ms,
3244 MUSE_TYPE_INT, "rebuffer_ms", (void *)&rebuffer_ms,
3245 INVALID_MUSE_TYPE_VALUE);
3247 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3248 ret = legacy_player_set_streaming_buffering_time(muse_player->player_handle, prebuffer_ms, rebuffer_ms);
3250 ret = PLAYER_ERROR_INVALID_OPERATION; /* FIXME: mismatch with API return type */
3253 PLAYER_RETURN_MSG(api, ret, module);
3257 int player_disp_get_streaming_buffering_time(muse_module_h module)
3259 int ret = PLAYER_ERROR_NONE;
3260 muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_BUFFERING_TIME;
3261 muse_player_handle_t *muse_player = NULL;
3262 int prebuffer_ms = 0, rebuffer_ms = 0;
3264 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3266 ret = legacy_player_get_streaming_buffering_time(muse_player->player_handle, &prebuffer_ms, &rebuffer_ms);
3267 if (ret == PLAYER_ERROR_NONE)
3268 PLAYER_RETURN_MSG(api, ret, module,
3269 MUSE_TYPE_INT, "prebuffer_ms", prebuffer_ms, MUSE_TYPE_INT, "rebuffer_ms", rebuffer_ms);
3271 PLAYER_RETURN_MSG(api, ret, module);
3276 int player_disp_360_is_content_spherical(muse_module_h module)
3278 int ret = PLAYER_ERROR_NONE;
3279 muse_player_api_e api = MUSE_PLAYER_API_360_IS_CONTENT_SPHERICAL;
3280 muse_player_handle_t *muse_player = NULL;
3283 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3285 ret = legacy_player_360_is_content_spherical(muse_player->player_handle, &val);
3287 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "val", (int)val);
3291 int player_disp_360_set_enabled(muse_module_h module)
3293 int ret = PLAYER_ERROR_NONE;
3294 muse_player_api_e api = MUSE_PLAYER_API_360_SET_ENABLED;
3295 muse_player_handle_t *muse_player = NULL;
3298 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3299 player_msg_get(val, muse_server_module_get_msg(module));
3301 ret = legacy_player_360_set_enabled(muse_player->player_handle, (bool)val);
3303 PLAYER_RETURN_MSG(api, ret, module);
3307 int player_disp_360_is_enabled(muse_module_h module)
3309 int ret = PLAYER_ERROR_NONE;
3310 muse_player_api_e api = MUSE_PLAYER_API_360_IS_ENABLED;
3311 muse_player_handle_t *muse_player = NULL;
3314 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3316 ret = legacy_player_360_is_enabled(muse_player->player_handle, &val);
3318 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "val", (int)val);
3322 int player_disp_360_set_direction_of_view(muse_module_h module)
3324 int ret = PLAYER_ERROR_NONE;
3325 muse_player_api_e api = MUSE_PLAYER_API_360_SET_DIRECTION_OF_VIEW;
3326 muse_player_handle_t *muse_player = NULL;
3328 bool ret_val = true;
3330 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
3331 MUSE_TYPE_DOUBLE, "yaw", (void *)&yaw,
3332 MUSE_TYPE_DOUBLE, "pitch", (void *)&pitch,
3333 INVALID_MUSE_TYPE_VALUE);
3335 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3336 ret = legacy_player_360_set_direction_of_view(muse_player->player_handle, (float)yaw, (float)pitch);
3338 ret = PLAYER_ERROR_INVALID_OPERATION;
3340 PLAYER_RETURN_MSG(api, ret, module);
3344 int player_disp_360_get_direction_of_view(muse_module_h module)
3346 int ret = PLAYER_ERROR_NONE;
3347 muse_player_api_e api = MUSE_PLAYER_API_360_GET_DIRECTION_OF_VIEW;
3348 muse_player_handle_t *muse_player = NULL;
3349 float yaw_val, pitch_val;
3351 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3353 ret = legacy_player_360_get_direction_of_view(muse_player->player_handle, &yaw_val, &pitch_val);
3355 PLAYER_RETURN_MSG(api, ret, module,
3356 MUSE_TYPE_DOUBLE, "yaw_val", (double)yaw_val,
3357 MUSE_TYPE_DOUBLE, "pitch_val", (double)pitch_val);
3362 int player_disp_360_set_zoom(muse_module_h module)
3364 int ret = PLAYER_ERROR_NONE;
3365 muse_player_api_e api = MUSE_PLAYER_API_360_SET_ZOOM;
3366 muse_player_handle_t *muse_player = NULL;
3369 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3370 player_msg_get_type(level, muse_server_module_get_msg(module), DOUBLE);
3372 ret = legacy_player_360_set_zoom(muse_player->player_handle, (float)level);
3374 PLAYER_RETURN_MSG(api, ret, module);
3378 int player_disp_360_get_zoom(muse_module_h module)
3380 int ret = PLAYER_ERROR_NONE;
3381 muse_player_api_e api = MUSE_PLAYER_API_360_GET_ZOOM;
3382 muse_player_handle_t *muse_player = NULL;
3385 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3387 ret = legacy_player_360_get_zoom(muse_player->player_handle, &zoom);
3389 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_DOUBLE, "zoom", (double)zoom);
3393 int player_disp_360_set_field_of_view(muse_module_h module)
3395 int ret = PLAYER_ERROR_NONE;
3396 muse_player_api_e api = MUSE_PLAYER_API_360_SET_FIELD_OF_VIEW;
3397 muse_player_handle_t *muse_player = NULL;
3398 int horizontal_degrees = 0, vertical_degrees = 0;
3399 bool ret_val = true;
3401 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
3402 MUSE_TYPE_INT, "horizontal_degrees", (void *)&horizontal_degrees,
3403 MUSE_TYPE_INT, "vertical_degrees", (void *)&vertical_degrees,
3404 INVALID_MUSE_TYPE_VALUE);
3406 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3407 ret = legacy_player_360_set_field_of_view(muse_player->player_handle, horizontal_degrees, vertical_degrees);
3409 ret = PLAYER_ERROR_INVALID_OPERATION;
3411 PLAYER_RETURN_MSG(api, ret, module);
3416 int player_disp_360_get_field_of_view(muse_module_h module)
3418 int ret = PLAYER_ERROR_NONE;
3419 muse_player_api_e api = MUSE_PLAYER_API_360_GET_FIELD_OF_VIEW;
3420 muse_player_handle_t *muse_player = NULL;
3421 int h_val = -1, v_val = -1;
3423 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3425 ret = legacy_player_360_get_field_of_view(muse_player->player_handle, &h_val, &v_val);
3427 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "h_val", h_val, MUSE_TYPE_INT, "v_val", v_val);
3431 int player_disp_360_set_zoom_with_field_of_view(muse_module_h module)
3433 int ret = PLAYER_ERROR_NONE;
3434 muse_player_api_e api = MUSE_PLAYER_API_360_SET_ZOOM_WITH_FIELD_OF_VIEW;
3435 muse_player_handle_t *muse_player = NULL;
3436 int horizontal_degrees = 0, vertical_degrees = 0;
3438 bool ret_val = true;
3440 ret_val = _player_disp_get_param_value(muse_server_module_get_msg(module),
3441 MUSE_TYPE_DOUBLE, "level", (void *)&level,
3442 MUSE_TYPE_INT, "horizontal_degrees", (void *)&horizontal_degrees,
3443 MUSE_TYPE_INT, "vertical_degrees", (void *)&vertical_degrees,
3444 INVALID_MUSE_TYPE_VALUE);
3446 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3448 ret = legacy_player_360_set_zoom(muse_player->player_handle, (float)level);
3449 if (ret == MM_ERROR_NONE)
3450 ret = legacy_player_360_set_field_of_view(muse_player->player_handle, horizontal_degrees, vertical_degrees);
3452 ret = PLAYER_ERROR_INVALID_OPERATION;
3455 PLAYER_RETURN_MSG(api, ret, module);
3459 int player_disp_set_codec_type(muse_module_h module)
3461 int ret = PLAYER_ERROR_NONE;
3462 muse_player_handle_t *muse_player = NULL;
3463 muse_player_api_e api = MUSE_PLAYER_API_SET_CODEC_TYPE;
3464 int stream_type = 0, codec_type = 0;
3466 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3467 player_msg_get(stream_type, muse_server_module_get_msg(module));
3468 player_msg_get(codec_type, muse_server_module_get_msg(module));
3470 if (stream_type != PLAYER_STREAM_TYPE_AUDIO && stream_type != PLAYER_STREAM_TYPE_VIDEO) {
3471 ret = PLAYER_ERROR_INVALID_PARAMETER;
3474 if (codec_type < PLAYER_CODEC_TYPE_DEFAULT || codec_type > PLAYER_CODEC_TYPE_SW) {
3475 ret = PLAYER_ERROR_INVALID_PARAMETER;
3479 ret = legacy_player_set_codec_type(muse_player->player_handle, (player_stream_type_e)stream_type, (player_codec_type_e)codec_type);
3482 PLAYER_RETURN_MSG(api, ret, module);
3487 int player_disp_get_codec_type(muse_module_h module)
3489 int ret = PLAYER_ERROR_NONE;
3490 muse_player_handle_t *muse_player = NULL;
3491 muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_TYPE;
3492 int stream_type = 0;
3493 player_codec_type_e codec_type = 0;
3495 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3496 player_msg_get(stream_type, muse_server_module_get_msg(module));
3498 ret = legacy_player_get_codec_type(muse_player->player_handle, (player_stream_type_e)stream_type, &codec_type);
3500 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "codec_type", (int)codec_type);
3505 int player_disp_set_replaygain_enabled(muse_module_h module)
3507 int ret = PLAYER_ERROR_NONE;
3508 muse_player_api_e api = MUSE_PLAYER_API_SET_REPLAYGAIN_ENABLED;
3509 muse_player_handle_t *muse_player = NULL;
3511 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3512 player_msg_get(val, muse_server_module_get_msg(module));
3514 ret = legacy_player_set_replaygain_enabled(muse_player->player_handle, (bool)val);
3516 PLAYER_RETURN_MSG(api, ret, module);
3521 int player_disp_is_replaygain_enabled(muse_module_h module)
3523 int ret = PLAYER_ERROR_NONE;
3524 muse_player_api_e api = MUSE_PLAYER_API_IS_REPLAYGAIN_ENABLED;
3525 muse_player_handle_t *muse_player = NULL;
3528 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3530 ret = legacy_player_is_replaygain_enabled(muse_player->player_handle, &val);
3532 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "val", (int)val);
3537 int player_disp_set_audio_offload_enabled(muse_module_h module)
3539 int ret = PLAYER_ERROR_NONE;
3540 muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_OFFLOAD_ENABLED;
3541 muse_player_handle_t *muse_player = NULL;
3543 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3544 player_msg_get(val, muse_server_module_get_msg(module));
3546 ret = legacy_player_set_audio_offload_enabled(muse_player->player_handle, (bool)val);
3548 PLAYER_RETURN_MSG(api, ret, module);
3553 int player_disp_is_audio_offload_enabled(muse_module_h module)
3555 int ret = PLAYER_ERROR_NONE;
3556 muse_player_api_e api = MUSE_PLAYER_API_IS_AUDIO_OFFLOAD_ENABLED;
3557 muse_player_handle_t *muse_player = NULL;
3560 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3562 ret = legacy_player_is_audio_offload_enabled(muse_player->player_handle, &val);
3564 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "val", (int)val);
3569 int player_disp_pitch_set_enabled(muse_module_h module)
3571 int ret = PLAYER_ERROR_NONE;
3572 muse_player_api_e api = MUSE_PLAYER_API_PITCH_SET_ENABLED;
3573 muse_player_handle_t *muse_player = NULL;
3575 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3576 player_msg_get(val, muse_server_module_get_msg(module));
3578 ret = legacy_player_pitch_set_enabled(muse_player->player_handle, (bool)val);
3580 PLAYER_RETURN_MSG(api, ret, module);
3585 int player_disp_pitch_is_enabled(muse_module_h module)
3587 int ret = PLAYER_ERROR_NONE;
3588 muse_player_api_e api = MUSE_PLAYER_API_PITCH_IS_ENABLED;
3589 muse_player_handle_t *muse_player = NULL;
3592 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3594 ret = legacy_player_pitch_is_enabled(muse_player->player_handle, &val);
3596 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_INT, "val", (int)val);
3601 int player_disp_pitch_set_value(muse_module_h module)
3603 int ret = PLAYER_ERROR_NONE;
3604 muse_player_api_e api = MUSE_PLAYER_API_PITCH_SET_VALUE;
3605 muse_player_handle_t *muse_player = NULL;
3607 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3608 player_msg_get_type(pitch, muse_server_module_get_msg(module), DOUBLE);
3610 ret = legacy_player_pitch_set_value(muse_player->player_handle, (float)pitch);
3612 PLAYER_RETURN_MSG(api, ret, module);
3617 int player_disp_pitch_get_value(muse_module_h module)
3619 int ret = PLAYER_ERROR_NONE;
3620 muse_player_api_e api = MUSE_PLAYER_API_PITCH_GET_VALUE;
3621 muse_player_handle_t *muse_player = NULL;
3624 muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
3626 ret = legacy_player_pitch_get_value(muse_player->player_handle, &pitch);
3628 PLAYER_RETURN_MSG(api, ret, module, MUSE_TYPE_DOUBLE, "pitch", (double)pitch);