#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sched.h>
#include <sys/types.h>
+#include <sys/stat.h>
+#include <syscall.h>
+#include <inttypes.h>
#include <unistd.h>
#include <tbm_bufmgr.h>
#include <tbm_surface.h>
#include "player_private.h"
#include "player_msg.h"
-#define INVALID_DEFAULT_VALUE -1
+#define INVALID_MUSE_TYPE_VALUE 0
#define MAX_S_PATH_LEN 32
-
-typedef enum {
- TIZEN_PROFILE_UNKNOWN = 0,
- TIZEN_PROFILE_MOBILE = 0x1,
- TIZEN_PROFILE_WEARABLE = 0x2,
- TIZEN_PROFILE_TV = 0x4,
- TIZEN_PROFILE_IVI = 0x8,
- TIZEN_PROFILE_COMMON = 0x10,
-} tizen_profile_t;
-static tizen_profile_t _get_tizen_profile()
-{
- char *profileName;
- static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
-
- if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
- return profile;
-
- system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
- switch (*profileName) {
- case 'm':
- case 'M':
- profile = TIZEN_PROFILE_MOBILE;
- break;
- case 'w':
- case 'W':
- profile = TIZEN_PROFILE_WEARABLE;
- break;
- case 't':
- case 'T':
- profile = TIZEN_PROFILE_TV;
- break;
- case 'i':
- case 'I':
- profile = TIZEN_PROFILE_IVI;
- break;
- default: // common or unknown ==> ALL ARE COMMON.
- profile = TIZEN_PROFILE_COMMON;
- }
- free(profileName);
-
- return profile;
-}
+#define MODULE_NAME "player"
+#define PLAYER_FEATURE_SOUND_STREAM "http://tizen.org/feature/multimedia.player.stream_info"
+#define PLAYER_FEATURE_OPENGL "http://tizen.org/feature/opengles.version.2_0"
+#define PLAYER_FEATURE_SPHERICAL_VIDEO "http://tizen.org/feature/multimedia.player.spherical_video"
+#define PLAYER_FEATURE_AUDIO_OFFLOAD "http://tizen.org/feature/multimedia.player.audio_offload"
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
typedef struct {
tbm_fd tfd[MUSE_NUM_FD];
- char* buffer;
+ char *buffer;
} _player_recv_data;
typedef struct {
int int_data;
callback_cb_info_s *cb_info;
_player_recv_data *recv_data;
- GMutex event_mutex;
} _player_cb_data;
typedef struct {
- intptr_t remote_pkt;
+ intptr_t remote_v_data;
gint fd;
gint fd_id;
bool use_tsurf_pool;
-} _media_pkt_fin_data;
+} _media_pkt_video_fin_data;
-/*
- Global varialbe
-*/
+typedef struct {
+ gint key;
+ gint fd;
+ gint fd_id;
+ tbm_bo bo;
+} _media_pkt_audio_fin_data;
-/*
-* Internal Implementation
-*/
-static int _player_deinit_memory_buffer(player_cli_s * pc);
-static void _player_event_queue_add(player_event_queue * ev, _player_cb_data * data);
+static int _player_deinit_memory_buffer(player_cli_s *pc);
+static void _player_event_queue_add(player_event_queue *ev, _player_cb_data *data);
static bool _player_need_sync_context(int event_id);
static void _player_remove_idle_event(callback_cb_info_s *cb_info, muse_player_event_e event_type, bool remove_all);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
typedef void (*player_retrieve_buffer_cb)(void *user_data);
static void __retrieve_buffer_cb(void *user_data);
+static void __player_media_packet_video_decoded_cb(media_packet_h packet, void *user_data);
static int __player_set_retrieve_buffer_cb(player_h player, player_retrieve_buffer_cb callback, void *user_data);
static int __player_unset_retrieve_buffer_cb(player_h player);
-#endif
-static void _player_release_internal_memory(player_cli_s * pc);
+static void _player_release_internal_memory(player_cli_s *pc, bool deinit_server_mem);
+
+/*
+* Internal Implementation
+*/
+int _player_send_msg(muse_player_api_e api, player_cli_s *player, char *msg, tbm_fd tfd, char **retbuf)
+{
+ int ret = PLAYER_ERROR_NONE;
+ int send_len = 0;
+ int send_fd = INVALID_DEFAULT_VALUE;
+ int send_tfd[MUSE_NUM_FD];
+ int timeout = client_get_api_timeout(player, api);
+
+ memset(send_tfd, INVALID_DEFAULT_VALUE, sizeof(send_tfd));
+
+ if (player && CALLBACK_INFO(player)) {
+ send_fd = MSG_FD(player);
+ } else {
+ LOGE("can not access to cb_info");
+ return PLAYER_ERROR_INVALID_STATE;
+ }
+
+ if ((send_fd <= 0) || !muse_core_fd_is_valid(send_fd)) {
+ LOGE("invalid socket fd %d", send_fd);
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ if (tfd != INVALID_DEFAULT_VALUE) {
+ send_tfd[0] = tfd;
+ send_len = muse_core_msg_send_fd(send_fd, send_tfd, msg);
+ } else {
+ send_len = muse_core_msg_send(send_fd, msg);
+ }
+ if (send_len <= 0) {
+ LOGE("sending message failed");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ } else {
+ ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), retbuf, timeout);
+ }
+
+ return ret;
+}
+
+int _player_send_msg_async(int send_fd, char *msg)
+{
+ int send_len = 0;
+
+ if ((send_fd <= 0) || !muse_core_fd_is_valid(send_fd)) {
+ LOGE("invalid socket fd %d", send_fd);
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ send_len = muse_core_msg_send(send_fd, msg);
+ if (send_len <= 0) {
+ LOGE("sending message failed");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ return PLAYER_ERROR_NONE;
+}
+
+static int _get_current_state(player_cli_s *pc, player_state_e *pstate)
+{
+ PLAYER_INSTANCE_CHECK(pc);
+ PLAYER_NULL_ARG_CHECK(pstate);
+ muse_player_api_e api = MUSE_PLAYER_API_GET_STATE;
+ int ret = PLAYER_ERROR_NONE;
+ int state = PLAYER_STATE_NONE;
+ char *ret_buf = NULL;
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
+ if (ret == PLAYER_ERROR_NONE) {
+ player_msg_get(state, ret_buf);
+ *pstate = state;
+ LOGD("current state %d", *pstate);
+ }
+
+ g_free(ret_buf);
+ return ret;
+}
+
+static bool _player_get_param_value(char *buf, ...)
+{
+ muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
+ bool ret = true;
+ va_list var_args;
+ int type = MUSE_TYPE_ANY;
+ char *param_name = NULL;
+ void *value = NULL;
+
+ void *jobj = muse_core_msg_object_new(buf, NULL, &err);
+
+ if (!jobj) {
+ LOGE("failed to get msg object. err:%d", err);
+ return false;
+ }
+
+ va_start(var_args, buf);
+
+ while ((type = va_arg(var_args, int)) != INVALID_MUSE_TYPE_VALUE) {
+ param_name = va_arg(var_args, char *);
+ switch (type) {
+ case MUSE_TYPE_INT:
+ case MUSE_TYPE_INT64:
+ case MUSE_TYPE_DOUBLE:
+ case MUSE_TYPE_STRING:
+ case MUSE_TYPE_POINTER:
+ value = va_arg(var_args, void *);
+
+ if (!muse_core_msg_object_get_value(param_name, jobj, type, value)) {
+ ret = false;
+ LOGE("failed to get %s value", param_name);
+ }
+ break;
+ default:
+ LOGE("Unexpected type");
+ ret = false;
+ break;
+ }
+ }
+
+ muse_core_msg_object_free(jobj);
+
+ va_end(var_args);
+ return ret;
+}
-int _player_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
+int _player_video_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
{
int ret = MEDIA_PACKET_FINALIZE;
- muse_player_api_e api = MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB;
- _media_pkt_fin_data *fin_data = (_media_pkt_fin_data *) user_data;
- intptr_t packet = 0;
+ muse_player_api_e api = MUSE_PLAYER_API_RETURN_VIDEO_DATA;
+ _media_pkt_video_fin_data *fin_data = (_media_pkt_video_fin_data *)user_data;
+ intptr_t v_data = 0;
char *snd_msg = NULL;
int snd_len = 0;
/* continue the remained job */
}
if (tsurf) {
- /* LOGD("_player_media_packet_finalize tsurf destroy %p", tsurf); */
+ /* LOGD("tsurf destroy %p", tsurf); */
tbm_surface_destroy(tsurf);
tsurf = NULL;
}
goto EXIT;
}
- packet = fin_data->remote_pkt;
- snd_msg = muse_core_msg_new(api, MUSE_TYPE_POINTER, "packet", packet, 0);
+ v_data = fin_data->remote_v_data;
+ snd_msg = muse_core_msg_new(api, MUSE_TYPE_POINTER, "v_data", v_data, 0);
snd_len = muse_core_msg_send(fin_data->fd, snd_msg);
muse_core_msg_free(snd_msg);
return ret;
}
+int _player_audio_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
+{
+ int ret = MEDIA_PACKET_FINALIZE;
+ muse_player_api_e api = MUSE_PLAYER_API_RETURN_BUFFER;
+ _media_pkt_audio_fin_data *fin_data = (_media_pkt_audio_fin_data *)user_data;
+
+ if (!pkt) {
+ LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
+ return ret;
+ }
+
+ if (!fin_data) {
+ LOGE("invalid fin_data");
+ goto EXIT;
+ }
+
+ if (fin_data->bo) {
+ /* LOGD("release memory - %p", fin_data->bo); */
+ tbm_bo_unref(fin_data->bo);
+ }
+
+ if (fin_data->fd > INVALID_DEFAULT_VALUE && muse_core_fd_is_valid(fin_data->fd)) {
+ if (muse_client_check_fd_id_value(fin_data->fd, fin_data->fd_id) == FALSE) {
+ LOGE("[fd:%d,id:%d] is invalid.", fin_data->fd, fin_data->fd_id);
+ goto EXIT;
+ }
+
+ PLAYER_SEND_MSG_ASYNC_WITH_NO_RETURN(api, fin_data->fd, MUSE_TYPE_INT, "key", fin_data->key);
+ } else {
+ LOGE("[fd:%d] is invalid.", fin_data->fd);
+ }
+
+EXIT:
+ if (fin_data) {
+ g_free(fin_data);
+ fin_data = NULL;
+ }
+
+ return ret;
+}
+
+static bool _player_video_roi_area_is_valid(double x_scale, double y_scale,
+ double w_scale, double h_scale)
+{
+ if (x_scale >= 0.0 && x_scale <= 1.0 && y_scale >= 0.0 && y_scale <= 1.0
+ && w_scale > 0.0 && w_scale <= 1.0 && h_scale > 0.0 && h_scale <= 1.0)
+ return true;
+
+ LOGE("Video roi area is not valid");
+ return false;
+}
+
static bool _player_check_network_availability(void)
{
#define _FEATURE_NAME_WIFI "http://tizen.org/feature/network.wifi"
return TRUE;
}
-static void *_get_mem(player_cli_s * player, int size)
+static void *_get_mem(player_cli_s *player, int size)
{
player_data_s *mem = g_new(player_data_s, sizeof(player_data_s));
if (mem) {
return NULL;
}
-static void _del_mem(player_cli_s * player)
+static void _del_mem(player_cli_s *player)
{
player_data_s *mem;
while (player->head) {
}
}
-static int player_recv_msg(callback_cb_info_s * cb_info, tbm_fd *tfd)
+static int player_recv_msg(callback_cb_info_s *cb_info, tbm_fd *tfd)
{
int recvLen = 0;
msg_buff_s *buff = &cb_info->buff;
- memset(buff->recvMsg, 0x00, sizeof(char)*buff->bufLen);
- recvLen = muse_core_msg_recv_fd(cb_info->fd, buff->recvMsg, tfd);
+ memset(buff->recvMsg, 0x00, sizeof(char) * buff->bufLen);
+ memset(tfd, INVALID_DEFAULT_VALUE, sizeof(*tfd) * MUSE_NUM_FD);
+ recvLen = muse_core_msg_recv_fd(cb_info->fd, buff->recvMsg, MUSE_MSG_MAX_LENGTH, tfd);
if (recvLen <= 0) {
LOGE("failed to recv msg %d", recvLen);
return 0;
/* check the first msg */
if (buff->part_of_msg && buff->recvMsg[0] != '{')
{
- gchar *tmp = strndup(buff->recvMsg, recvLen);
+ gchar *tmp = g_strndup(buff->recvMsg, recvLen);
if (!tmp) {
LOGE("failed to copy msg.");
return 0;
}
- LOGD("get remained part of msg %d + %d, %d", recvLen, strlen(buff->part_of_msg), buff->bufLen);
+ LOGD("get remained part of msg %d + %zu, %d", recvLen, strlen(buff->part_of_msg), buff->bufLen);
/* realloc buffer */
- if (recvLen+strlen(buff->part_of_msg) >= buff->bufLen) {
- LOGD("realloc Buffer %d -> %d", buff->bufLen, recvLen+strlen(buff->part_of_msg)+1);
- buff->bufLen = recvLen+strlen(buff->part_of_msg)+1;
+ if (recvLen + strlen(buff->part_of_msg) >= buff->bufLen) {
+ LOGD("realloc Buffer %d -> %d", buff->bufLen, (int)(recvLen + strlen(buff->part_of_msg) + 1));
+ buff->bufLen = recvLen + strlen(buff->part_of_msg) + 1;
buff->recvMsg = g_renew(char, buff->recvMsg, buff->bufLen);
if (!buff->recvMsg) {
LOGE("failed renew buffer.");
- if (tmp)
- free(tmp);
+ g_free(tmp);
return 0;
}
- memset(buff->recvMsg, 0x00, sizeof(char)*buff->bufLen);
+ memset(buff->recvMsg, 0x00, sizeof(char) * buff->bufLen);
}
- snprintf(buff->recvMsg, buff->bufLen, "%s%s", buff->part_of_msg, tmp);
+ g_snprintf(buff->recvMsg, buff->bufLen, "%s%s", buff->part_of_msg, tmp);
recvLen += strlen(buff->part_of_msg);
- free(buff->part_of_msg);
+ g_free(buff->part_of_msg);
buff->part_of_msg = NULL;
- free(tmp);
+ g_free(tmp);
tmp = NULL;
}
/* check the last msg */
- if (buff->recvMsg[recvLen-1] != '}') {
+ if (buff->recvMsg[recvLen - 1] != '}') {
char *part_pos = strrchr(buff->recvMsg, '}');
- int part_len = ((part_pos) ? (strlen(part_pos+1)) : (0));
+ int part_len = ((part_pos) ? (strlen(part_pos + 1)) : (0));
if (part_len > 0) {
- buff->part_of_msg = strndup(part_pos+1, part_len);
+ buff->part_of_msg = g_strndup(part_pos + 1, part_len);
if (!buff->part_of_msg) {
LOGE("failed to alloc buffer for part of msg.");
return 0;
}
- LOGD("get part of msg: %d, %s", strlen(buff->part_of_msg), buff->part_of_msg);
+ LOGD("get part of msg: %zu, %s", strlen(buff->part_of_msg), buff->part_of_msg);
recvLen -= part_len;
}
}
return recvLen;
}
-static void set_null_user_cb(callback_cb_info_s * cb_info, muse_player_event_e event)
+static void set_null_user_cb(callback_cb_info_s *cb_info, muse_player_event_e event)
{
if (cb_info && event < MUSE_PLAYER_EVENT_TYPE_NUM) {
cb_info->user_cb[event] = NULL;
/* Notice : have to be called via API to avoid deadlock
* to clear the cb setting at the cb thread, set_null_user_cb() have to be called instead.
*/
-static void set_null_user_cb_lock(callback_cb_info_s * cb_info, muse_player_event_e event)
+static void set_null_user_cb_lock(callback_cb_info_s *cb_info, muse_player_event_e event)
{
bool lock = false;
+ LOGD("event %d cb will be cleared", event);
+
if (!cb_info) {
LOGE("cb_info is NULL, event: %d", event);
return;
static int __set_callback(muse_player_event_e type, player_h player, void *callback, void *user_data)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ char *ret_buf = NULL;
int set = 1;
- if (MUSE_PLAYER_EVENT_TYPE_BUFFERING == type) {
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(callback);
+
+ if (type == MUSE_PLAYER_EVENT_TYPE_BUFFERING) {
if (!_player_check_network_availability())
return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+ pc->cb_info->drop_buffering_message = FALSE;
}
+ if (!CALLBACK_INFO(pc))
+ return PLAYER_ERROR_INVALID_OPERATION;
+
LOGI("Event type : %d ", type);
- player_msg_set_callback(api, pc, ret, type, set);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "type", type,
+ MUSE_TYPE_INT, "set", set);
if (ret == PLAYER_ERROR_NONE) {
pc->cb_info->user_cb[type] = callback;
pc->cb_info->user_data[type] = user_data;
}
+
+ g_free(ret_buf);
return ret;
}
static int __unset_callback(muse_player_event_e type, player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ char *ret_buf = NULL;
int set = 0;
+ PLAYER_INSTANCE_CHECK(player);
+
LOGI("Event type : %d ", type);
PLAYER_NULL_ARG_CHECK(CALLBACK_INFO(pc));
+
+ if ((type == MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME) ||
+ (type == MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME)) {
+ /* check state condition */
+ player_state_e state = PLAYER_STATE_NONE;
+
+ if (_get_current_state(pc, &state) != PLAYER_ERROR_NONE) {
+ LOGE("Failed to get current state");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ if (state > PLAYER_STATE_READY) {
+ LOGE("Invalid state %d", state);
+ return PLAYER_ERROR_INVALID_STATE;
+ }
+ }
+
set_null_user_cb_lock(CALLBACK_INFO(pc), type);
- player_msg_set_callback(api, pc, ret, type, set);
- ret = PLAYER_ERROR_NONE;
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "type", type,
+ MUSE_TYPE_INT, "set", set);
+ g_free(ret_buf);
return ret;
}
-static void __prepare_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __prepare_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_PREPARE;
- ((player_prepared_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
+ ((player_prepared_cb)cb_info->user_cb[ev])(cb_info->user_data[ev]);
set_null_user_cb(cb_info, ev);
}
-static void __complete_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __complete_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_COMPLETE;
- ((player_completed_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
+ ((player_completed_cb)cb_info->user_cb[ev])(cb_info->user_data[ev]);
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
-static void __retrieve_buffer_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
-
+static void __player_media_packet_video_decoded_cb(media_packet_h packet, void *user_data)
{
- muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER;
- ((player_retrieve_buffer_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
+ if (!packet || !user_data) {
+ LOGE("invalid param [packet:%p, user_data:%p]", packet, user_data);
+ return;
+ }
+
+ LOGD("render packet %p", packet);
+
+ mm_display_interface_evas_render(DP_INTERFACE((player_cli_s *)user_data), packet);
}
-#endif
-static char* _convert_code_to_str(int code)
-{
- switch (code) {
- case PLAYER_INTERRUPTED_COMPLETED: /* Deprecated since 3.0 */
- return "PLAYER_INTERRUPTED_COMPLETED";
- case PLAYER_INTERRUPTED_BY_MEDIA: /* Deprecated since 3.0 */
- return "PLAYER_INTERRUPTED_BY_MEDIA";
- case PLAYER_INTERRUPTED_BY_CALL: /* Deprecated since 3.0 */
- return "PLAYER_INTERRUPTED_BY_CALL";
- case PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG: /* Deprecated since 3.0 */
- return "PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG";
- case PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT:
- return "PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT";
- case PLAYER_INTERRUPTED_BY_ALARM: /* Deprecated since 3.0 */
- return "PLAYER_INTERRUPTED_BY_ALARM";
- case PLAYER_INTERRUPTED_BY_EMERGENCY: /* Deprecated since 3.0 */
- return "PLAYER_INTERRUPTED_BY_EMERGENCY";
- case PLAYER_INTERRUPTED_BY_NOTIFICATION: /* Deprecated since 3.0 */
- return "PLAYER_INTERRUPTED_BY_NOTIFICATION";
- default:
- LOGE("Invalid interrupted code %d (Never enter here)", code);
- return NULL;
- }
+static void __retrieve_buffer_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
+
+{
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER;
+ ((player_retrieve_buffer_cb)cb_info->user_cb[ev])(cb_info->user_data[ev]);
}
-static void __interrupt_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __interrupt_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
- int code;
muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_INTERRUPT;
-
- if (player_msg_get(code, recv_data->buffer)) {
-
- if (code >= PLAYER_INTERRUPTED_COMPLETED &&
- code <= PLAYER_INTERRUPTED_BY_NOTIFICATION &&
- code != PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT) {
- LOGW("DEPRECATION WARNING: %s is deprecated and will be removed from next release.", _convert_code_to_str(code));
- }
-
- ((player_interrupted_cb) cb_info->user_cb[ev]) (code, cb_info->user_data[ev]);
- }
+ ((player_interrupted_cb)cb_info->user_cb[ev])(PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT, cb_info->user_data[ev]);
}
-static void __error_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __error_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
int code;
muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR;
set_null_user_cb(cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE);
}
}
- ((player_error_cb) cb_info->user_cb[ev]) (code, cb_info->user_data[ev]);
+ ((player_error_cb)cb_info->user_cb[ev])(code, cb_info->user_data[ev]);
}
}
-static void __disconnected_error_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __disconnected_error_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR;
- ((player_error_cb) cb_info->user_cb[ev]) (PLAYER_ERROR_SERVICE_DISCONNECTED, cb_info->user_data[ev]);
+ ((player_error_cb)cb_info->user_cb[ev])(PLAYER_ERROR_SERVICE_DISCONNECTED, cb_info->user_data[ev]);
}
-static void __buffering_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __buffering_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
int percent;
muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_BUFFERING;
- if (player_msg_get(percent, recv_data->buffer))
- ((player_buffering_cb) cb_info->user_cb[ev]) (percent, cb_info->user_data[ev]);
+ if (player_msg_get(percent, recv_data->buffer)) {
+ g_mutex_lock(&cb_info->buffering_cb_mutex);
+ if (cb_info->drop_buffering_message) {
+ LOGD("Drop buffering callback");
+ g_mutex_unlock(&cb_info->buffering_cb_mutex);
+ return;
+ }
+ g_mutex_unlock(&cb_info->buffering_cb_mutex);
+ ((player_buffering_cb)cb_info->user_cb[ev])(percent, cb_info->user_data[ev]);
+ }
+
}
-static void __subtitle_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __subtitle_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
int duration = 0;
char text[MUSE_URI_MAX_LENGTH] = { 0, };
muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SUBTITLE;
- bool ret = TRUE;
+ bool ret = true;
- player_msg_get1_string(recv_data->buffer, duration, INT, text, ret);
+ ret = _player_get_param_value(recv_data->buffer,
+ MUSE_TYPE_INT, "duration", (void *)&duration,
+ MUSE_TYPE_STRING, "text", (void *)text,
+ INVALID_MUSE_TYPE_VALUE);
if (ret)
- ((player_subtitle_updated_cb) cb_info->user_cb[ev]) (duration, text, cb_info->user_data[ev]);
+ ((player_subtitle_updated_cb)cb_info->user_cb[ev])(duration, text, cb_info->user_data[ev]);
}
-static void __capture_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __capture_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
unsigned char *data = NULL;
int width = 0;
tbm_bo bo = NULL;
tbm_bo_handle thandle;
int key = INVALID_DEFAULT_VALUE;
- bool ret_val = TRUE;
-
- player_msg_get4(recv_data->buffer, width, INT, height, INT, size, INT, key, INT, ret_val);
- if (ret_val) {
+ bool get_ret = true;
+ get_ret = _player_get_param_value(recv_data->buffer,
+ MUSE_TYPE_INT, "width", (void *)&width,
+ MUSE_TYPE_INT, "height", (void *)&height,
+ MUSE_TYPE_INT, "size", (void *)&size,
+ MUSE_TYPE_INT, "key", (void *)&key,
+ INVALID_MUSE_TYPE_VALUE);
+ if (get_ret) {
if (recv_data->tfd[0] < 0) {
LOGE("There is no valid tbm_fd");
goto EXIT;
data = g_new(unsigned char, size);
if (data) {
memcpy(data, thandle.ptr, size);
- ((player_video_captured_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) (data, width, height, size, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
+ ((player_video_captured_cb)cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE])(data, width, height, size, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
g_free(data);
- } else
+ } else {
LOGE("g_new failure");
+ }
tbm_bo_unmap(bo);
}
EXIT:
- if (recv_data->tfd[0] > INVALID_DEFAULT_VALUE)
- close(recv_data->tfd[0]);
+ PLAYER_CLOSE_FD(recv_data->tfd[0]);
+
memset(recv_data->tfd, INVALID_DEFAULT_VALUE, sizeof(recv_data->tfd));
if (bo)
/* return buffer */
if (key > INVALID_DEFAULT_VALUE) {
LOGD("send msg to release buffer. key:%d", key);
- player_msg_send1_no_return(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, INT, key);
+ PLAYER_SEND_MSG_ASYNC_WITH_NO_RETURN(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, MUSE_TYPE_INT, "key", key);
}
set_null_user_cb(cb_info, MUSE_PLAYER_EVENT_TYPE_CAPTURE);
}
-static void __seek_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __seek_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
+ int ret = MM_ERROR_NONE;
muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SEEK;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- void *dl_handle;
- int (*p_disp_set_evas_display_visible)(void *, bool) = NULL;
-#endif
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
g_mutex_lock(&cb_info->seek_cb_mutex);
- if (cb_info->user_cb[ev] && cb_info->seek_cb_state == PLAYER_SEEK_CB_STATE_NONE) {
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (cb_info->evas_info && cb_info->evas_info->support_video) {
- if (cb_info->evas_info->handle && cb_info->evas_info->visible != EVAS_VISIBLE_FALSE) {
- dl_handle = dlopen(PATH_DISP_LIB, RTLD_LAZY);
- if (dl_handle == NULL)
- LOGW("not support video rendering");
- PLAYER_DISP_DLSYM(dl_handle, p_disp_set_evas_display_visible, "disp_set_evas_display_visible");
- int ret = p_disp_set_evas_display_visible(cb_info->evas_info->handle, true);
- dlclose(dl_handle);
- if (ret != MM_ERROR_NONE)
- LOGW("failed to set visible at evas 0x%x", ret);
- else
- cb_info->evas_info->visible = EVAS_VISIBLE_TRUE;
- }
+
+ switch (cb_info->seek_cb_state) {
+ case PLAYER_SEEK_CB_STATE_NONE:
+ {
+ if (!cb_info->user_cb[ev]) {
+ LOGW("invalid seek callback info, skip");
+ break;
}
-#endif
+
+ ret = mm_display_interface_get_type(cb_info->dp_info.interface, &display_type);
+ if (ret == MM_ERROR_NONE && display_type == MM_DISPLAY_TYPE_EVAS &&
+ cb_info->dp_info.visible != PLAYER_VISIBLE_INFO_FALSE) {
+ LOGW("set display visible true for EVAS");
+ if (mm_display_interface_evas_set_visible(cb_info->dp_info.interface, true) != MM_ERROR_NONE)
+ LOGE("mm_display_interface_evas_set_visible failed");
+ } else {
+ LOGW("get display type ret 0x%x, type %d", ret, display_type);
+ }
+
LOGD("call seek cb");
- ((player_seek_completed_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
+ ((player_seek_completed_cb)cb_info->user_cb[ev])(cb_info->user_data[ev]);
set_null_user_cb(cb_info, ev);
- } else {
- LOGW("ignored. seek cb %p", cb_info->user_cb[ev]);
+
+ break;
}
+ case PLAYER_SEEK_CB_STATE_DROP:
+ case PLAYER_SEEK_CB_STATE_WAIT: /* not expected */
+ LOGW("ignored. seek cb %p, state %d", cb_info->user_cb[ev], cb_info->seek_cb_state);
+ break;
+ default:
+ LOGE("invalid state value");
+ break;
+ }
+
g_mutex_unlock(&cb_info->seek_cb_mutex);
}
-static void __player_remove_tsurf_list(player_cli_s * pc)
+static void __player_remove_tsurf_list(player_cli_s *pc)
{
GList *l = NULL;
LOGD("total num of tsurf list = %d", g_list_length(pc->cb_info->tsurf_list));
for (l = g_list_first(pc->cb_info->tsurf_list); l; l = g_list_next(l)) {
- player_tsurf_info_t* tmp = (player_tsurf_info_t *)l->data;
+ player_tsurf_info_s *tmp = (player_tsurf_info_s *)l->data;
LOGD("%p will be removed", tmp);
if (tmp) {
return;
}
-static player_tsurf_info_t* __player_get_tsurf_from_list(callback_cb_info_s * cb_info, int *key, int height, int width)
+static player_tsurf_info_s *__player_get_tsurf_from_list(callback_cb_info_s *cb_info, intptr_t key, int height, int width)
{
GList *l = NULL;
g_mutex_lock(&cb_info->data_mutex);
for (l = g_list_first(cb_info->tsurf_list); l; l = g_list_next(l)) {
- player_tsurf_info_t *tmp = (player_tsurf_info_t *)l->data;
- if (tmp && key && (tmp->key[0] == key[0])) {
- LOGD("found tsurf_data of tbm_key %d", key[0]);
+ player_tsurf_info_s *tmp = (player_tsurf_info_s *)l->data;
+ if (tmp && key && (tmp->key == key)) {
+ LOGD("found tsurf_data of tbm_key %" PRIdPTR, key);
/* need to check tsuf info to support DRC */
if ((tbm_surface_get_height(tmp->tsurf) != height) ||
return NULL;
}
-static void __media_packet_video_frame_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static media_packet_rotate_method_e __convert_packet_orient_info(int orientation)
+{
+ media_packet_rotate_method_e rotate = MEDIA_PACKET_ROTATE_IDENTITY;
+
+ switch (orientation) {
+ case 90:
+ rotate = MEDIA_PACKET_ROTATE_90;
+ break;
+ case 180:
+ rotate = MEDIA_PACKET_ROTATE_180;
+ break;
+ case 270:
+ rotate = MEDIA_PACKET_ROTATE_270;
+ break;
+ default:
+ rotate = MEDIA_PACKET_ROTATE_IDENTITY;
+ break;
+ }
+
+ return rotate;
+}
+
+static void __media_packet_video_frame_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
tbm_bo bo[4] = { NULL, };
- int key[4] = { INVALID_DEFAULT_VALUE, };
tbm_surface_info_s sinfo;
char *surface_info = (char *)&sinfo;
media_packet_h pkt = NULL;
tbm_surface_h tsurf = NULL;
- player_tsurf_info_t *tsurf_data = NULL;
+ player_tsurf_info_s *tsurf_data = NULL;
int bo_num = 0;
media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
bool make_pkt_fmt = false;
int ret = MEDIA_FORMAT_ERROR_NONE;
- _media_pkt_fin_data *fin_data = NULL;
- intptr_t packet = 0;
+ _media_pkt_video_fin_data *fin_data = NULL;
+ intptr_t key = 0;
+ intptr_t v_data = 0;
uint64_t pts = 0;
- int i = 0;
+ int i = 0, orientation = 0;
muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
void *jobj = muse_core_msg_object_new(recv_data->buffer, NULL, &err);
if (!jobj ||
- !muse_core_msg_object_get_value("key[0]", jobj, MUSE_TYPE_ANY, &key[0]) ||
- !muse_core_msg_object_get_value("key[1]", jobj, MUSE_TYPE_ANY, &key[1]) ||
- !muse_core_msg_object_get_value("key[2]", jobj, MUSE_TYPE_ANY, &key[2]) ||
- !muse_core_msg_object_get_value("key[3]", jobj, MUSE_TYPE_ANY, &key[3]) ||
- !muse_core_msg_object_get_value("packet", jobj, MUSE_TYPE_POINTER, &packet) ||
+ !muse_core_msg_object_get_value("key", jobj, MUSE_TYPE_POINTER, &key) ||
+ !muse_core_msg_object_get_value("v_data", jobj, MUSE_TYPE_POINTER, &v_data) ||
!muse_core_msg_object_get_value("mimetype", jobj, MUSE_TYPE_ANY, &mimetype) ||
!muse_core_msg_object_get_value("pts", jobj, MUSE_TYPE_INT64, &pts) ||
+ !muse_core_msg_object_get_value("orientation", jobj, MUSE_TYPE_INT, &orientation) ||
!muse_core_msg_object_get_value("surface_info", jobj, MUSE_TYPE_ARRAY, surface_info)) {
LOGE("failed to get value from msg. jobj:%p, err:%d", jobj, err);
}
if (!cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
- /* send msg to release packet. */
+ /* send msg to release v_data. */
LOGE("_video_decoded_cb is not set");
goto ERROR;
}
bo[i] = tbm_bo_import_fd(cb_info->bufmgr, recv_data->tfd[i]);
}
- tsurf_data = g_new(player_tsurf_info_t, 1);
- if (!tsurf_data) {
- LOGE("failed to alloc tsurf info");
- goto ERROR;
- }
- memset(tsurf_data->key, INVALID_DEFAULT_VALUE, sizeof(tsurf_data->key));
-
tsurf = tbm_surface_internal_create_with_bos(&sinfo, bo, bo_num);
if (!tsurf) {
LOGE("failed to create tbm surface");
- g_free(tsurf_data);
goto ERROR;
}
- memcpy(tsurf_data->key, key, sizeof(tsurf_data->key));
- tsurf_data->tsurf = tsurf;
+
if (cb_info->use_tsurf_pool) {
+ tsurf_data = g_try_new(player_tsurf_info_s, 1);
+ if (!tsurf_data) {
+ LOGE("failed to alloc tsurf info");
+ goto ERROR;
+ }
+ tsurf_data->key = key;
+ tsurf_data->tsurf = tsurf;
+
g_mutex_lock(&cb_info->data_mutex);
cb_info->tsurf_list = g_list_append(cb_info->tsurf_list, tsurf_data);
- LOGD("key %d is added to the pool", key[0]);
+ LOGD("key %" PRIdPTR " is added to the pool", key);
if (cb_info->video_frame_pool_size < g_list_length(cb_info->tsurf_list))
LOGE("need to check the pool size: %d < %d", cb_info->video_frame_pool_size, g_list_length(cb_info->tsurf_list));
g_mutex_unlock(&cb_info->data_mutex);
}
}
- fin_data = g_new0(_media_pkt_fin_data, 1);
+ fin_data = g_try_new0(_media_pkt_video_fin_data, 1);
if (!fin_data) {
LOGE("failed to alloc fin_data");
goto ERROR;
}
- fin_data->remote_pkt = packet;
+ fin_data->remote_v_data = v_data;
fin_data->fd = cb_info->fd;
fin_data->use_tsurf_pool = cb_info->use_tsurf_pool;
/* Keep the fd id to check validation when the pkt is destroyed. */
fin_data->fd_id = muse_client_get_fd_id_value(fin_data->fd);
- ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt, tsurf, (media_packet_finalize_cb) _player_media_packet_finalize, (void *)fin_data, &pkt);
+ ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt, tsurf, (media_packet_finalize_cb)_player_video_media_packet_finalize, (void *)fin_data, &pkt);
if (ret != MEDIA_PACKET_ERROR_NONE || !pkt) {
LOGE("media_packet_create_from_tbm_surface failed %d %p", ret, pkt);
goto ERROR;
}
if (pts != 0) {
- ret = media_packet_set_pts(pkt, (uint64_t) pts);
+ ret = media_packet_set_pts(pkt, (uint64_t)pts);
if (ret != MEDIA_PACKET_ERROR_NONE)
LOGE("media_packet_set_pts failed");
}
+
+ ret = media_packet_set_rotate_method(pkt, __convert_packet_orient_info(orientation));
+ if (ret != MEDIA_PACKET_ERROR_NONE)
+ LOGE("media_packet_set_rotate_method failed");
+
if (cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
/* call media packet callback */
- ((player_media_packet_video_decoded_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) (pkt, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]);
+ ((player_media_packet_video_decoded_cb)cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME])(pkt, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]);
} else {
LOGE("_video_decoded_cb is not set");
media_packet_destroy(pkt);
}
- for (i = 0; i < MUSE_NUM_FD; i++) { /* if tsruf pool is enabled, bo_num can be zero. */
- if (recv_data->tfd[i] > INVALID_DEFAULT_VALUE)
- close(recv_data->tfd[i]);
- }
+ /* if tsruf pool is enabled, bo_num can be zero. */
+ for (i = 0; i < MUSE_NUM_FD; i++)
+ PLAYER_CLOSE_FD(recv_data->tfd[i]);
for (i = 0; i < bo_num; i++) {
if (bo[i])
ERROR:
if (pkt)
media_packet_destroy(pkt);
+ else if (!tsurf_data && tsurf)
+ tbm_surface_destroy(tsurf);
if (fin_data)
g_free(fin_data);
- for (i = 0; i < MUSE_NUM_FD; i++) { /* if tsruf pool is enabled, bo_num can be zero. */
- if (recv_data->tfd[i] > INVALID_DEFAULT_VALUE)
- close(recv_data->tfd[i]);
- }
+ /* if tsruf pool is enabled, bo_num can be zero. */
+ for (i = 0; i < MUSE_NUM_FD; i++)
+ PLAYER_CLOSE_FD(recv_data->tfd[i]);
for (i = 0; i < bo_num; i++) {
if (bo[i])
}
memset(recv_data->tfd, INVALID_DEFAULT_VALUE, sizeof(recv_data->tfd));
- if (cb_info && packet)
- player_msg_send1_no_return(MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB, cb_info->fd, POINTER, packet);
+ if (cb_info && v_data)
+ PLAYER_SEND_MSG_ASYNC_WITH_NO_RETURN(MUSE_PLAYER_API_RETURN_VIDEO_DATA, cb_info->fd, MUSE_TYPE_POINTER, "v_data", v_data);
return;
}
-static void __audio_frame_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __media_packet_audio_frame_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
+ int ret = MEDIA_FORMAT_ERROR_NONE;
tbm_bo bo = NULL;
tbm_bo_handle thandle;
int key = INVALID_DEFAULT_VALUE;
- player_audio_raw_data_s audio;
+ player_audio_decoded_data_info_t audio;
+ media_packet_h pkt = NULL;
+ media_format_h fmt = NULL;
+ _media_pkt_audio_fin_data *fin_data = NULL;
if (!player_msg_get(key, recv_data->buffer)) {
LOGE("failed to get key value from msg.");
goto EXIT;
}
- memcpy(&audio, thandle.ptr, sizeof(player_audio_raw_data_s));
- audio.data = thandle.ptr + sizeof(player_audio_raw_data_s);
+ memcpy(&audio, thandle.ptr, sizeof(player_audio_decoded_data_info_t));
+ audio.data = thandle.ptr + sizeof(player_audio_decoded_data_info_t);
+ tbm_bo_unmap(bo);
/* LOGD("user callback data %p, size %d", audio.data, audio.size); */
- ((player_audio_pcm_extraction_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME]) (&audio, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME]);
- tbm_bo_unmap(bo);
+ if (cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME]) {
+ ret = media_format_create(&fmt);
+ if (ret != MEDIA_FORMAT_ERROR_NONE || !fmt) {
+ LOGE("failed to create media format 0x%X %p", ret, fmt);
+ goto EXIT;
+ }
+
+ ret = media_format_set_audio_mime(fmt, audio.pcm_format);
+ ret |= media_format_set_audio_samplerate(fmt, audio.rate);
+ ret |= media_format_set_audio_channel(fmt, audio.channel);
+ ret |= media_format_set_audio_channel_mask(fmt, audio.channel_mask);
+ if (ret != MEDIA_FORMAT_ERROR_NONE) {
+ LOGE("failed to set audio format 0x%X", ret);
+ goto EXIT;
+ }
+
+ fin_data = g_new0(_media_pkt_audio_fin_data, 1);
+ if (!fin_data) {
+ LOGE("failed to alloc fin_data");
+ goto EXIT;
+ }
+
+ fin_data->key = key;
+ fin_data->fd = cb_info->fd;
+ fin_data->bo = bo;
+
+ /* Keep the fd id to check validation when the pkt is destroyed. */
+ fin_data->fd_id = muse_client_get_fd_id_value(fin_data->fd);
+
+ ret = media_packet_create_from_external_memory(fmt, audio.data, audio.size,
+ (media_packet_finalize_cb)_player_audio_media_packet_finalize, (void *)fin_data, &pkt);
+ if (ret != MEDIA_PACKET_ERROR_NONE || !pkt) {
+ LOGE("failed to create media packet 0x%X %p", ret, pkt);
+ if (pkt)
+ media_packet_destroy(pkt); /* fin_data will be free in finalize function. */
+ else
+ g_free(fin_data);
+ goto EXIT;
+ }
+
+ media_format_unref(fmt);
+ fmt = NULL;
+
+ ((player_media_packet_audio_decoded_cb)cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME])
+ (pkt, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME]);
+ } else {
+ LOGE("there is no registered cb");
+ goto EXIT;
+ }
EXIT:
- if (recv_data->tfd[0] > INVALID_DEFAULT_VALUE)
- close(recv_data->tfd[0]);
+ PLAYER_CLOSE_FD(recv_data->tfd[0]);
+
memset(recv_data->tfd, INVALID_DEFAULT_VALUE, sizeof(recv_data->tfd));
- if (bo)
- tbm_bo_unref(bo);
+ if (fmt)
+ media_format_unref(fmt);
/* return buffer */
- if (key > INVALID_DEFAULT_VALUE) {
+ if ((cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME] == NULL) &&
+ (key > INVALID_DEFAULT_VALUE)) {
+
+ if (bo) tbm_bo_unref(bo);
+
/* LOGD("send msg to release buffer. key:%d", key); */
- player_msg_send1_no_return(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, INT, key);
+ PLAYER_SEND_MSG_ASYNC_WITH_NO_RETURN(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, MUSE_TYPE_INT, "key", key);
}
-}
-static void __video_frame_render_error_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
-{
+ return;
}
-static void __pd_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __video_frame_render_error_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
- int type;
- muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_PD;
-
- if (player_msg_get(type, recv_data->buffer))
- ((player_pd_message_cb) cb_info->user_cb[ev]) (type, cb_info->user_data[ev]);
}
-static void __supported_audio_effect_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __supported_audio_effect_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
}
-static void __supported_audio_effect_preset_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __supported_audio_effect_preset_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
}
-static void __missed_plugin_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __missed_plugin_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
}
-static void __media_stream_video_buffer_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __media_stream_video_buffer_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
/* player_media_stream_buffer_status_e status; */
int status;
if (player_msg_get(status, recv_data->buffer)) {
((player_media_stream_buffer_status_cb)
- cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS]) ((player_media_stream_buffer_status_e) status, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS]);
+ cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS])
+ ((player_media_stream_buffer_status_e)status,
+ cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS]);
}
}
-static void __media_stream_audio_buffer_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __media_stream_audio_buffer_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
/* player_media_stream_buffer_status_e status; */
int status;
if (player_msg_get(status, recv_data->buffer)) {
((player_media_stream_buffer_status_cb)
cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS])
- ((player_media_stream_buffer_status_e) status, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS]);
+ ((player_media_stream_buffer_status_e) status,
+ cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS]);
}
}
-static void __media_stream_video_buffer_cb_handler_ex(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __media_stream_video_buffer_cb_handler_ex(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
/* player_media_stream_buffer_status_e status; */
int status;
unsigned long long bytes;
- bool ret = TRUE;
+ bool ret = true;
- player_msg_get2(recv_data->buffer, status, INT, bytes, INT64, ret);
- if (ret == TRUE) {
+ ret = _player_get_param_value(recv_data->buffer,
+ MUSE_TYPE_INT, "status", (void *)&status,
+ MUSE_TYPE_INT64, "bytes", (void *)&bytes,
+ INVALID_MUSE_TYPE_VALUE);
+ if (ret == true) {
((player_media_stream_buffer_status_cb_ex)
cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO])
((player_media_stream_buffer_status_e) status, bytes, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO]);
}
}
-static void __media_stream_audio_buffer_cb_handler_ex(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __media_stream_audio_buffer_cb_handler_ex(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
/* player_media_stream_buffer_status_e status; */
int status;
unsigned long long bytes;
- bool ret = TRUE;
+ bool ret = true;
- player_msg_get2(recv_data->buffer, status, INT, bytes, INT64, ret);
- if (ret == TRUE) {
+ ret = _player_get_param_value(recv_data->buffer,
+ MUSE_TYPE_INT, "status", (void *)&status,
+ MUSE_TYPE_INT64, "bytes", (void *)&bytes,
+ INVALID_MUSE_TYPE_VALUE);
+ if (ret == true) {
((player_media_stream_buffer_status_cb_ex)
cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO])
((player_media_stream_buffer_status_e) status, bytes, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO]);
}
-static void __media_stream_video_seek_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __media_stream_video_seek_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
unsigned long long offset;
}
}
-static void __media_stream_audio_seek_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __media_stream_audio_seek_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
unsigned long long offset;
}
}
-static void __video_stream_changed_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+static void __video_stream_changed_cb_handler(callback_cb_info_s *cb_info, _player_recv_data *recv_data)
{
int width;
int height;
int fps;
int bit_rate;
bool ret_val = TRUE;
-
- player_msg_get4(recv_data->buffer, width, INT, height, INT, fps, INT, bit_rate, INT, ret_val);
+ ret_val = _player_get_param_value(recv_data->buffer,
+ MUSE_TYPE_INT, "width", (void *)&width,
+ MUSE_TYPE_INT, "height", (void *)&height,
+ MUSE_TYPE_INT, "fps", (void *)&fps,
+ MUSE_TYPE_INT, "bit_rate", (void *)&bit_rate,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
- ((player_video_stream_changed_cb) cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED])
+ ((player_video_stream_changed_cb)cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED])
(width, height, fps, bit_rate, cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED]);
}
}
-static void (*_user_callbacks[MUSE_PLAYER_EVENT_TYPE_NUM]) (callback_cb_info_s * cb_info, _player_recv_data *recv_data) = {
- __prepare_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
+static void (*_user_callbacks[MUSE_PLAYER_EVENT_TYPE_NUM])(callback_cb_info_s *cb_info, _player_recv_data *recv_data) = {
+ __prepare_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
__complete_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_COMPLETE */
__interrupt_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_INTERRUPT */
__error_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_ERROR */
__capture_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_CAPTURE */
__seek_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SEEK */
__media_packet_video_frame_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME */
- __audio_frame_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME */
+ __media_packet_audio_frame_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME */
__video_frame_render_error_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
- __pd_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_PD */
__supported_audio_effect_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT */
__supported_audio_effect_preset_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET */
__missed_plugin_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN */
__media_stream_audio_seek_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK */
NULL, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED */
__video_stream_changed_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED */
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
__retrieve_buffer_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER */
-#endif
__disconnected_error_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED */
};
_player_cb_data *data = (_player_cb_data *)user_data;
muse_player_event_e ev;
- if (data == NULL) {
- LOGE("data is null");
+ if (!data || !data->cb_info) {
+ LOGE("invalid user data");
return FALSE;
}
- LOGD("enter ev:%d", data->int_data);
-
- g_mutex_lock(&data->event_mutex);
ev = data->int_data;
-
- if (data->cb_info == NULL) {
- /* tried to remove before at _player_remove_idle_event */
- LOGW("cb_info is NULL. event %d", data->int_data);
- goto DONE;
- }
+ if ((ev != MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME) &&
+ (ev != MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME))
+ LOGD("enter ev:%d(%p)", ev, data);
/* remove event from list */
g_mutex_lock(&data->cb_info->event_queue.idle_ev_mutex);
}
g_mutex_unlock(&data->cb_info->event_queue.idle_ev_mutex);
- if (data->cb_info->user_cb[ev])
- _user_callbacks[ev] (data->cb_info, data->recv_data);
+ if ((data->cb_info->user_cb[ev] || ev == MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED) &&
+ (_user_callbacks[ev]))
+ _user_callbacks[ev](data->cb_info, data->recv_data);
else
LOGW("user callback is unset. type : %d", ev);
-DONE:
- /* unlock and release event */
- g_mutex_unlock(&data->event_mutex);
- g_mutex_clear(&data->event_mutex);
-
- if (data->recv_data) {
- g_free(data->recv_data->buffer);
- g_free(data->recv_data);
- }
- g_free(data);
-
- return FALSE; /* remove from the event list */
-}
+ return FALSE; /* remove from the event list */
+}
static bool _player_need_sync_context(int event_id)
{
if ((event_id == MUSE_PLAYER_EVENT_TYPE_INTERRUPT) ||
(event_id == MUSE_PLAYER_EVENT_TYPE_BUFFERING) ||
- (event_id == MUSE_PLAYER_EVENT_TYPE_PD) ||
(event_id == MUSE_PLAYER_EVENT_TYPE_COMPLETE) ||
(event_id == MUSE_PLAYER_EVENT_TYPE_ERROR) ||
(event_id == MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED) ||
}
}
+static void _destroy_event_data(gpointer user_data)
+{
+ _player_cb_data *data = (_player_cb_data *)user_data;
+
+ if (data == NULL) {
+ LOGW("data is null");
+ return;
+ }
+
+ LOGD("remove event data %p (%d)", data, data->int_data);
+ if (data->recv_data) {
+ g_free(data->recv_data->buffer);
+ data->recv_data->buffer = NULL;
+ g_free(data->recv_data);
+ data->recv_data = NULL;
+ }
+
+ g_free(data);
+}
+
static void *_player_event_queue_loop(void *param)
{
if (!param) {
while (1) {
g_mutex_lock(&ev->qlock);
- event_data = (_player_cb_data *) g_queue_pop_head(ev->queue);
+ event_data = (_player_cb_data *)g_queue_pop_head(ev->queue);
g_mutex_unlock(&ev->qlock);
- if (event_data) {
- muse_player_event_e event_type = ((_player_cb_data *)event_data)->int_data;
-
- if (event_type == MUSE_PLAYER_EVENT_TYPE_SEEK) {
- g_mutex_lock(&cb_info->seek_cb_mutex);
- if (cb_info->seek_cb_state == PLAYER_SEEK_CB_STATE_WAIT) {
- /* push event into queue again. */
- _player_event_queue_add(ev, event_data);
- g_mutex_unlock(&cb_info->seek_cb_mutex);
- break;
- }
+
+ if (!event_data)
+ break;
+
+ muse_player_event_e event_type = event_data->int_data;
+
+ if (event_type == MUSE_PLAYER_EVENT_TYPE_SEEK) {
+ g_mutex_lock(&cb_info->seek_cb_mutex);
+ if (cb_info->seek_cb_state == PLAYER_SEEK_CB_STATE_WAIT) {
+ /* push event into queue again. */
+ _player_event_queue_add(ev, event_data);
g_mutex_unlock(&cb_info->seek_cb_mutex);
+ break;
}
+ g_mutex_unlock(&cb_info->seek_cb_mutex);
+ } else if (event_type == MUSE_PLAYER_EVENT_TYPE_BUFFERING) {
+ g_mutex_lock(&cb_info->buffering_cb_mutex);
+ if (cb_info->drop_buffering_message) {
+ LOGD("Drop buffering event");
+ g_mutex_unlock(&cb_info->buffering_cb_mutex);
+
+ _destroy_event_data(event_data);
+ break;
+ }
+ g_mutex_unlock(&cb_info->buffering_cb_mutex);
+ }
- if (_player_need_sync_context(event_data->int_data)) {
- if (cb_info->user_cb[event_data->int_data] &&
- _user_callbacks[event_data->int_data]) {
- g_mutex_lock(&ev->idle_ev_mutex);
- ev->idle_ev_list = g_list_append(ev->idle_ev_list, (gpointer)event_data);
- g_mutex_unlock(&ev->idle_ev_mutex);
-
- LOGD("add ev %d to main loop", event_data->int_data);
-
- g_idle_add_full(G_PRIORITY_DEFAULT,
- (GSourceFunc)_player_event_job_function,
- (gpointer)event_data,
- NULL);
- } else {
- LOGW("there is no registered cb for ev:%d", event_data->int_data);
- if (event_data->recv_data) {
- g_free(event_data->recv_data->buffer);
- g_free(event_data->recv_data);
- }
- g_free(event_data);
- }
+ if (_player_need_sync_context(event_type)) {
+ if ((cb_info->user_cb[event_type] || (event_type == MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED)) &&
+ _user_callbacks[event_type]) {
+ g_mutex_lock(&ev->idle_ev_mutex);
+ ev->idle_ev_list = g_list_append(ev->idle_ev_list, (gpointer)event_data);
+ g_mutex_unlock(&ev->idle_ev_mutex);
+
+ LOGD("add ev %d to main loop", event_type);
+
+ g_idle_add_full(G_PRIORITY_DEFAULT,
+ (GSourceFunc)_player_event_job_function,
+ (gpointer)event_data,
+ (GDestroyNotify)_destroy_event_data);
} else {
- _player_event_job_function(event_data);
+ LOGW("there is no registered cb for ev:%d", event_type);
+ _destroy_event_data(event_data);
}
} else {
- break;
+ _player_event_job_function(event_data);
+ _destroy_event_data(event_data);
}
}
}
return NULL;
}
-static gboolean _player_event_queue_new(callback_cb_info_s * cb_info)
+static gboolean _player_event_queue_new(callback_cb_info_s *cb_info)
{
g_return_val_if_fail(cb_info, FALSE);
player_event_queue *ev = &cb_info->event_queue;
g_mutex_init(&ev->idle_ev_mutex);
- ev->thread = g_thread_new("cb_event_thread", _player_event_queue_loop, (gpointer) cb_info);
+ ev->thread = g_thread_new("cb_event_thread", _player_event_queue_loop, (gpointer)cb_info);
g_return_val_if_fail(ev->thread, FALSE);
LOGI("event queue thread %p", ev->thread);
continue;
}
- if (g_mutex_trylock(&event_data->event_mutex)) {
-
- gboolean ret = FALSE;
- if (remove_all || (event_data->int_data == event_type)) {
-
- LOGD("remove idle event [%p:%d]", event_data, event_data->int_data);
-
- ret = g_idle_remove_by_data(event_data);
- if (ret == FALSE) {
- /* will be handled at _player_event_job_function() as an exception */
- event_data->cb_info = NULL;
- LOGW("failed to remove, idle callback will be called later");
- }
+ if ((event_data->int_data != event_type) && !remove_all)
+ continue;
- /* set cb to null */
- set_null_user_cb(cb_info, event_data->int_data);
- ev->idle_ev_list = g_list_remove(ev->idle_ev_list, (gpointer)event_data);
+ LOGD("remove idle event [%p:%d]", event_data, event_data->int_data);
- g_mutex_unlock(&event_data->event_mutex);
+ /* set cb to null */
+ if (remove_all)
+ set_null_user_cb(cb_info, event_data->int_data);
- if (ret == TRUE) {
- g_mutex_clear(&event_data->event_mutex);
- if (event_data->recv_data) {
- g_free(event_data->recv_data->buffer);
- g_free(event_data->recv_data);
- }
- g_free(event_data);
- event_data = NULL;
- LOGD("remove idle event done");
- } /* else : will be handled if the cb is called. */
- } else {
- g_mutex_unlock(&event_data->event_mutex);
- }
- } else {
- LOGW("event(%d) lock failed. it's being called...", event_data->int_data);
- }
+ ev->idle_ev_list = g_list_remove(ev->idle_ev_list, (gpointer)event_data);
- /* continue: keep checking next event_data */
+ if (!g_idle_remove_by_data(event_data))
+ LOGW("failed to find source with %p", event_data);
}
if (remove_all) {
return;
}
-static void _player_event_queue_destroy(callback_cb_info_s * cb_info)
+static void _player_event_queue_destroy(callback_cb_info_s *cb_info)
{
g_return_if_fail(cb_info);
player_event_queue *ev = &cb_info->event_queue;
ev->thread = NULL;
while (!g_queue_is_empty(ev->queue)) {
- event_data = (_player_cb_data *) g_queue_pop_head(ev->queue);
+ event_data = (_player_cb_data *)g_queue_pop_head(ev->queue);
if (event_data) {
g_free(event_data->recv_data->buffer);
g_free(event_data->recv_data);
g_mutex_clear(&ev->idle_ev_mutex);
}
-static void _player_event_queue_remove(player_event_queue * ev_queue, int ev)
+static void _player_event_queue_remove(player_event_queue *ev_queue, int ev)
{
GList *item;
g_mutex_unlock(&ev_queue->qlock);
}
-static void _player_event_queue_add(player_event_queue * ev, _player_cb_data * data)
+static void _player_event_queue_add(player_event_queue *ev, _player_cb_data *data)
{
if (ev->running) {
g_mutex_lock(&ev->qlock);
- g_queue_push_tail(ev->queue, (gpointer) data);
+ g_queue_push_tail(ev->queue, (gpointer)data);
g_mutex_unlock(&ev->qlock);
g_cond_signal(&ev->cond);
}
}
-static bool _user_callback_handler(callback_cb_info_s * cb_info, muse_player_event_e event, _player_recv_data *recv_data)
+static bool _user_callback_handler(callback_cb_info_s *cb_info, muse_player_event_e event, _player_recv_data *recv_data)
{
/* LOGD("get event %d", event); */
data->int_data = (int)event;
data->cb_info = cb_info;
data->recv_data = recv_data;
- g_mutex_init(&data->event_mutex);
_player_event_queue_add(&cb_info->event_queue, data);
return true;
}
}
- LOGE("failed to add event to queue");
+ LOGE("failed to add event to queue %d", event);
return false;
}
-static void _add_ret_msg(muse_player_api_e api, callback_cb_info_s * cb_info, int offset, int parse_len)
+static void _add_ret_msg(muse_player_api_e api, callback_cb_info_s *cb_info, int offset, int parse_len)
{
ret_msg_s *msg = NULL;
ret_msg_s *last = cb_info->buff.retMsgHead;
msg = g_new(ret_msg_s, 1);
if (msg) {
msg->api = api;
- msg->msg = strndup(cb_info->buff.recvMsg + offset, parse_len);
+ msg->msg = g_strndup(cb_info->buff.recvMsg + offset, parse_len);
msg->next = NULL;
if (last == NULL)
cb_info->buff.retMsgHead = msg;
LOGE("g_new failure");
}
-static ret_msg_s *_get_ret_msg(muse_player_api_e api, callback_cb_info_s * cb_info)
+static ret_msg_s *_get_ret_msg(muse_player_api_e api, callback_cb_info_s *cb_info)
{
ret_msg_s *msg = cb_info->buff.retMsgHead;
ret_msg_s *prev = NULL;
return NULL;
}
-static void _remove_all_ret_msg(callback_cb_info_s * cb_info)
+static void _remove_all_ret_msg(callback_cb_info_s *cb_info)
{
ret_msg_s *msg = cb_info->buff.retMsgHead;
ret_msg_s *prev = NULL;
}
}
-static void _notify_disconnected(callback_cb_info_s * cb_info)
+static void _notify_disconnected(callback_cb_info_s *cb_info)
{
muse_player_event_e event = MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED;
if (!cb_info || !cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])
data->int_data = (int)event;
data->cb_info = cb_info;
data->recv_data = NULL;
- g_mutex_init(&data->event_mutex);
_player_event_queue_add(&cb_info->event_queue, data);
}
}
muse_core_msg_parse_err_e err;
tbm_fd tfd[MUSE_NUM_FD];
- memset(tfd, INVALID_DEFAULT_VALUE, sizeof(tfd));
while (g_atomic_int_get(&cb_info->running)) {
len = 0;
err = MUSE_MSG_PARSE_ERROR_NONE;
while (offset < len) {
api = MUSE_PLAYER_API_MAX;
// LOGD(">>>>>> [%d/%d] %p, %s", offset, len, recvMsg + offset, recvMsg + offset);
-// usleep(10*1000);
+// usleep(10 * 1000);
void *jobj = muse_core_msg_object_new(recvMsg + offset, &parse_len, &err);
if (jobj) {
recv_data = g_new0(_player_recv_data, 1);
if (recv_data != NULL) {
memcpy(recv_data->tfd, tfd, sizeof(recv_data->tfd));
- recv_data->buffer = strndup(recvMsg+offset, parse_len);
+ recv_data->buffer = g_strndup(recvMsg + offset, parse_len);
} else {
LOGE("failed to alloc recv_data.");
g_mutex_unlock(&cb_info->player_mutex);
g_mutex_unlock(&cb_info->player_mutex);
}
} else {
- LOGE("Failed to get value. offset:%d/%d, [msg][ %s ]", offset, len, (recvMsg+offset));
+ LOGE("Failed to get value. offset:%d/%d, [msg][ %s ]", offset, len, (recvMsg + offset));
}
muse_core_msg_object_free(jobj);
} else {
}
if (g_atomic_int_get(&cb_info->running))
_notify_disconnected(cb_info);
+
+ g_atomic_int_set(&cb_info->running, 0);
LOGD("client cb exit");
return NULL;
g_mutex_init(&cb_info->data_mutex);
g_mutex_init(&cb_info->seek_cb_mutex);
+ g_mutex_init(&cb_info->buffering_cb_mutex);
+ cb_info->drop_buffering_message = FALSE;
buff = &cb_info->buff;
buff->recvMsg = g_new(char, MUSE_MSG_MAX_LENGTH + 1);
g_atomic_int_set(&cb_info->running, 1);
cb_info->fd = sockfd;
- cb_info->thread = g_thread_new("callback_thread", client_cb_handler, (gpointer) cb_info);
cb_info->tfd = INVALID_DEFAULT_VALUE;
+ cb_info->data_fd = INVALID_DEFAULT_VALUE;
+ cb_info->thread = g_thread_new("callback_thread", client_cb_handler, (gpointer) cb_info);
return cb_info;
}
-static void callback_destroy(callback_cb_info_s * cb_info)
+static void callback_destroy(callback_cb_info_s *cb_info)
{
int i;
g_return_if_fail(cb_info);
LOGI("%p Callback destroyed", cb_info);
- g_mutex_clear(&cb_info->player_mutex);
- for (i = 0; i < MUSE_PLAYER_API_MAX; i++)
+ for (i = 0; i < MUSE_PLAYER_API_MAX; i++) {
+ g_mutex_lock(&cb_info->player_mutex);
+ g_cond_signal(&cb_info->player_cond[i]);
+ g_mutex_unlock(&cb_info->player_mutex);
g_cond_clear(&cb_info->player_cond[i]);
+ }
+
+ /* to make sure the return of other pending api */
+ sched_yield();
+ g_mutex_lock(&cb_info->player_mutex);
+ g_mutex_unlock(&cb_info->player_mutex);
+ g_mutex_clear(&cb_info->player_mutex);
+
g_cond_clear(&cb_info->server_ack_cond);
g_mutex_clear(&cb_info->data_mutex);
g_mutex_clear(&cb_info->seek_cb_mutex);
+ g_mutex_clear(&cb_info->buffering_cb_mutex);
g_free(cb_info->buff.recvMsg);
_remove_all_ret_msg(cb_info);
- if (cb_info->buff.part_of_msg)
- g_free(cb_info->buff.part_of_msg);
+ g_free(cb_info->buff.part_of_msg);
+
g_free(cb_info);
}
-int client_get_api_timeout(player_cli_s * pc, muse_player_api_e api)
+int client_get_api_timeout(player_cli_s *pc, muse_player_api_e api)
{
int timeout = 0;
return timeout; /* ms */
}
-int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s * cb_info, char **ret_buf, int time_out)
+int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s *cb_info, char **ret_buf, int time_out)
{
int ret = PLAYER_ERROR_NONE;
gint64 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_MILLISECOND;
break;
}
}
+
if (!msg)
msg = _get_ret_msg(api, cb_info);
if (msg) {
g_free(msg);
if (!player_msg_get(ret, *ret_buf))
ret = PLAYER_ERROR_INVALID_OPERATION;
+ else if (ret != PLAYER_ERROR_NONE)
+ LOGE("Get error return from server 0x%X", ret);
+ break;
+ }
+
+ if (!g_atomic_int_get(&cb_info->running)) {
+ LOGE("callback thread is stopped. %d api did not get return in time", api);
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ break;
} else {
- LOGE("api %d is the spurious wakeup", api);
+ LOGW("api %d is the spurious wakeup, wait again", api);
}
- } while (!msg);
+ } while (!msg && g_atomic_int_get(&cb_info->running));
g_mutex_unlock(&cb_info->player_mutex);
return ret;
}
-int client_wait_for_server_ack(muse_player_api_e api, callback_cb_info_s * cb_info, int time_out)
+int client_wait_for_server_ack(muse_player_api_e api, callback_cb_info_s *cb_info, int time_out)
{
int ret = PLAYER_ERROR_NONE;
gint64 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_MILLISECOND;
* Public Implementation
*/
-int player_create(player_h * player)
+int player_create(player_h *player)
{
- PLAYER_INSTANCE_CHECK(player);
-
int ret = PLAYER_ERROR_NONE;
int sock_fd = INVALID_DEFAULT_VALUE;
int pid = getpid();
muse_player_api_e api = MUSE_PLAYER_API_CREATE;
- muse_core_api_module_e module = MUSE_PLAYER;
+ int module_index = INVALID_DEFAULT_VALUE;
player_cli_s *pc = NULL;
- char *ret_buf = NULL;
+ gchar *ret_buf = NULL;
int retry_count = CONNECTION_RETRY;
- bool retry = false;
+
+ PLAYER_INSTANCE_CHECK(player);
LOGD("ENTER");
if (pc == NULL)
return PLAYER_ERROR_OUT_OF_MEMORY;
- while (--retry_count) {
+ while (retry_count--) {
+ ret = PLAYER_ERROR_NONE;
sock_fd = muse_client_new();
if (sock_fd <= INVALID_DEFAULT_VALUE) {
LOGE("connection failure %d", errno);
ret = PLAYER_ERROR_INVALID_OPERATION;
- retry = true;
usleep(CONNECTION_TIME_OUT * G_TIME_SPAN_MILLISECOND);
+ goto ERROR_RETRY;
+ }
+
+ if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
+ LOGE("muse client get module index failed");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
goto ERROR;
}
- player_msg_create_handle(api, sock_fd, INT, module, INT, pid);
+ PLAYER_SEND_MSG_ASYNC(api, sock_fd, ret,
+ MUSE_TYPE_INT, "module", module_index,
+ MUSE_TYPE_INT, "pid", pid);
+ if (ret == PLAYER_ERROR_INVALID_OPERATION)
+ goto ERROR;
pc->cb_info = callback_new(sock_fd);
if (!pc->cb_info) {
}
ret = client_wait_for_server_ack(api, pc->cb_info, CREATE_CB_TIME_OUT);
- if (ret == PLAYER_ERROR_INVALID_OPERATION) {
- retry = true;
- goto ERROR;
- }
- retry = false;
+ if (ret == PLAYER_ERROR_INVALID_OPERATION)
+ goto ERROR_RETRY;
if (!_player_event_queue_new(pc->cb_info)) {
LOGE("fail to create event queue");
ret = client_wait_for_cb_return(api, pc->cb_info, &ret_buf, CALLBACK_TIME_OUT * 2);
if (ret == PLAYER_ERROR_NONE) {
intptr_t module_addr = 0;
- *player = (player_h) pc;
+ *player = (player_h)pc;
if (player_msg_get_type(module_addr, ret_buf, POINTER)) {
pc->cb_info->data_fd = muse_client_new_data_ch();
- if (!muse_core_fd_is_valid(pc->cb_info->data_fd)) {
+ if ((pc->cb_info->data_fd < 0) || (!muse_core_fd_is_valid(pc->cb_info->data_fd))) {
LOGE("Failed to get data_fd");
ret = PLAYER_ERROR_INVALID_OPERATION;
goto ERROR;
}
- muse_core_send_module_addr(module_addr, pc->cb_info->data_fd, ret);
- LOGD("Data channel fd %d, muse module addr %p", pc->cb_info->data_fd, module_addr);
+ /* share the module addr info to the data_fd */
+ PLAYER_SEND_MSG_ASYNC(MUSE_PLAYER_API_CREATE, pc->cb_info->data_fd, ret,
+ MUSE_TYPE_POINTER, "module_addr", module_addr);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("Failed to send module address to the data fd");
+ goto ERROR;
+ }
+ LOGD("Data channel fd %d, muse module addr %"PRIxPTR, pc->cb_info->data_fd, module_addr);
} else {
ret = PLAYER_ERROR_INVALID_OPERATION;
goto ERROR;
} else {
goto ERROR;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- pc->cb_info->evas_info = g_new0(player_evas_info_s, 1);
- if (pc->cb_info->evas_info == NULL) {
- ret = PLAYER_ERROR_OUT_OF_MEMORY;
- goto ERROR;
- }
- EVAS_INFO(pc)->visible = EVAS_VISIBLE_NONE;
-#endif
+
pc->cb_info->bufmgr = tbm_bufmgr_init(-1);
pc->push_media_stream = FALSE;
- pc->support_video = FALSE;
- EVAS_INFO(pc)->support_video = FALSE;
- pc->is_audio_only = FALSE;
- PLAYER_DISP_DLOPEN(pc); /* update supported_video */
+ /* get display interface handle */
+ if (mm_display_interface_init(&DP_INTERFACE(pc)) != MM_ERROR_NONE)
+ LOGW("display interface init failed");
g_free(ret_buf);
+
+ LOGD("LEAVE 0x%X", ret);
return ret;
- ERROR:
+ERROR:
+ retry_count = 0;
+ERROR_RETRY:
if (pc && pc->cb_info) {
if (pc->cb_info->event_queue.running)
_player_event_queue_destroy(pc->cb_info);
callback_destroy(pc->cb_info);
pc->cb_info = NULL;
+ } else if (sock_fd > INVALID_DEFAULT_VALUE) {
+ muse_client_close(sock_fd);
}
+ sock_fd = INVALID_DEFAULT_VALUE;
+
g_free(ret_buf);
ret_buf = NULL;
LOGE("ret value : %d, retry #%d", ret, CONNECTION_RETRY - retry_count);
- if (!retry)
- break;
}
g_free(pc);
pc = NULL;
+ *player = NULL;
+
+ LOGD("LEAVE 0x%X", ret);
return ret;
}
int player_destroy(player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
-
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_DESTROY;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_destroy_evas_display)(void **) = NULL;
-#endif
- LOGD("ENTER");
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
+ PLAYER_INSTANCE_CHECK(player);
+
+ LOGD("ENTER %p", pc);
/* clear cb and release mem */
set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- _player_release_internal_memory(pc);
+ _player_release_internal_memory(pc, true);
+
+ if (DP_INTERFACE(pc)) {
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (CALLBACK_INFO(pc) && EVAS_INFO(pc)->support_video) {
- if (EVAS_HANDLE(pc)) {
+ if (display_type == MM_DISPLAY_TYPE_EVAS) {
player_unset_media_packet_video_frame_decoded_cb(player);
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_destroy_evas_display, "disp_destroy_evas_display");
- if (p_disp_destroy_evas_display(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
- LOGW("fail to unset evas client");
__player_unset_retrieve_buffer_cb(player);
- g_free(pc->cb_info->evas_info);
}
+
+ mm_display_interface_deinit(DP_INTERFACE(pc));
+ DP_INTERFACE(pc) = NULL;
}
-#endif
- player_msg_send(api, pc, ret_buf, ret);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (CALLBACK_INFO(pc)) {
__player_remove_tsurf_list(pc);
callback_destroy(CALLBACK_INFO(pc));
}
- if (pc->dl_handle)
- PLAYER_DISP_DLCLOSE(pc->dl_handle); /* update supported_video */
-
g_free(pc);
pc = NULL;
int player_prepare_async(player_h player, player_prepared_cb callback, void *user_data)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_PREPARE_ASYNC;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- LOGD("ENTER");
+ PLAYER_INSTANCE_CHECK(player);
+
+ LOGD("ENTER %p %p", pc, callback);
if (pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
LOGE("PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing...", PLAYER_ERROR_INVALID_OPERATION);
pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = callback;
pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = user_data;
}
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
int timeout = 0;
player_msg_get_type(timeout, ret_buf, INT);
int player_prepare(player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_PREPARE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- LOGD("ENTER");
+ PLAYER_INSTANCE_CHECK(player);
+
+ LOGD("ENTER %p", pc);
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
int timeout = 0;
player_msg_get_type(timeout, ret_buf, INT);
}
g_free(ret_buf);
+
+ LOGD("LEAVE 0x%X", ret);
return ret;
}
int player_unprepare(player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
+ int mm_ret = MM_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_UNPREPARE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ player_state_e state = PLAYER_STATE_NONE;
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
- LOGD("ENTER");
+ PLAYER_INSTANCE_CHECK(player);
- if (!CALLBACK_INFO(pc))
- return PLAYER_ERROR_INVALID_STATE;
+ LOGD("ENTER %p", pc);
+
+ if (_get_current_state(pc, &state) != PLAYER_ERROR_NONE) {
+ LOGE("Failed to get state");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ goto EXIT;
+ }
- player_msg_send(api, pc, ret_buf, ret);
+ if (state < PLAYER_STATE_READY) {
+ if ((!CALLBACK_INFO(pc)) || (!CALLBACK_INFO(pc)->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])) {
+ LOGE("Invalid state %d", state);
+ ret = PLAYER_ERROR_INVALID_STATE;
+ goto EXIT;
+ }
+ }
set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- _player_release_internal_memory(pc);
+ if (!DP_INTERFACE(pc))
+ goto _PLAYER_UNPREPARE;
+
+
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
+
+ if (display_type != MM_DISPLAY_TYPE_EVAS)
+ goto _PLAYER_UNPREPARE;
+
+ if (CALLBACK_INFO(pc)->dp_info.visible != PLAYER_VISIBLE_INFO_FALSE) {
+ mm_ret = mm_display_interface_evas_set_visible(DP_INTERFACE(pc), false);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("mm_display_interface_evas_set_visible failed 0x%x", mm_ret);
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+ }
+
+ mm_ret = mm_display_interface_evas_flush(DP_INTERFACE(pc), false);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("mm_display_interface_evas_flush failed 0x%x", mm_ret);
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+_PLAYER_UNPREPARE:
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
+ _player_release_internal_memory(pc, false);
pc->cb_info->video_frame_pool_size = 0;
__player_remove_tsurf_list(pc);
- pc->is_audio_only = FALSE;
g_free(ret_buf);
+EXIT:
LOGD("LEAVE 0x%X", ret);
return ret;
}
-/* 1. covert '/opt/usr/media/xxx' file path to '/opt/usr/home/owner/media/xxx'
- * 2. remove 'file://' prefix */
-int _player_get_origin_internal_path(const char* uri, char* origin)
+/* 1. correct the protocol prefix to lower case
+ * 2. remove 'file://' prefix
+ * 3. covert '/opt/usr/media/xxx' file path to '/opt/usr/home/owner/media/xxx' */
+int _player_get_valid_path(const char *uri, char *valid_path)
{
gchar *file_path = NULL;
GError *err = NULL;
+ gchar *colon = NULL;
- if (!uri || !origin) {
+ if (!uri || !valid_path) {
LOGD("invalid parameter");
return PLAYER_ERROR_INVALID_PARAMETER;
}
- if (strstr(uri, "file://")) {
- file_path = g_filename_from_uri(uri, NULL, &err);
+ if ((colon = strstr(uri, "://")) != NULL) {
+ gchar *protocol = g_ascii_strdown(uri, colon - uri);
+
+ if (protocol) {
+
+ file_path = g_strconcat(protocol, uri + strlen(protocol), NULL);
+ strncpy(valid_path, (file_path) ? (file_path) : (uri), MAX_URL_LEN - 1);
+
+ g_free(protocol);
+ g_free(file_path);
+ file_path = NULL;
- if (!file_path || (err != NULL)) {
- LOGE("Invalid URI '%s', err: %s", uri,
- (err != NULL) ? err->message : "unknown error");
+ if (strstr(valid_path, "file://")) { /* handle the 'file://' prefix */
- if (err) g_error_free(err);
- if (file_path) g_free(file_path);
+ file_path = g_filename_from_uri(valid_path, NULL, &err);
+ if (!file_path || (err != NULL)) {
+ SECURE_LOGE("Invalid URI '%s', err: %s", uri,
+ (err != NULL) ? err->message : "unknown error");
- return PLAYER_ERROR_INVALID_PARAMETER;
+ g_error_free(err);
+ g_free(file_path);
+
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ LOGD("get file path from uri");
+ } else {
+ LOGD("use the original path.");
+ return PLAYER_ERROR_NONE;
+ }
}
- LOGD("get file path from uri");
}
- if (storage_get_origin_internal_path((file_path) ? (file_path) : (uri), MAX_URL_LEN, origin) < 0) {
+ if (storage_get_origin_internal_path((file_path) ? (file_path) : (uri), MAX_URL_LEN, valid_path) < 0) {
/* cannot convert path. use the original one. */
- strncpy(origin, (file_path) ? (file_path) : (uri), MAX_URL_LEN-1);
+ strncpy(valid_path, (file_path) ? (file_path) : (uri), MAX_URL_LEN - 1);
} else {
/* need to use converted path. */
- LOGD("Converted path : %s -> %s", uri, origin);
+ SECURE_LOGD("Converted path : %s -> %s", uri, valid_path);
}
- if (file_path)
- g_free(file_path);
+ g_free(file_path);
return PLAYER_ERROR_NONE;
}
int player_set_uri(player_h player, const char *uri)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(uri);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_URI;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
char path[MAX_URL_LEN] = {0, };
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(uri);
+
LOGD("ENTER");
- if (_player_get_origin_internal_path(uri, path) != PLAYER_ERROR_NONE)
+ if (_player_get_valid_path(uri, path) != PLAYER_ERROR_NONE)
return PLAYER_ERROR_INVALID_PARAMETER;
- player_msg_send1(api, pc, ret_buf, ret, STRING, path);
+ SECURE_LOGD("new path : %s", path);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_STRING, "path", (const char *)path);
pc->push_media_stream = FALSE;
g_free(ret_buf);
int player_set_memory_buffer(player_h player, const void *data, int size)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(data);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_MEMORY_BUFFER;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
tbm_bo bo = NULL;
tbm_bo_handle thandle;
tbm_fd tfd = INVALID_DEFAULT_VALUE;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(data);
+
+ LOGD("ENTER");
+
+ /* before setting mem buffer, player state have to be checked. */
+ PLAYER_STATE_CHECK(pc, PLAYER_STATE_IDLE);
+
if (SERVER_TBM_BO(pc)) {
- LOGE("Already set the memory buffer. unprepare please");
- return PLAYER_ERROR_INVALID_OPERATION;
+ LOGW("The previous memory buffer will be cleared.");
+ _player_deinit_memory_buffer(pc);
}
bo = tbm_bo_alloc(pc->cb_info->bufmgr, size, TBM_BO_DEFAULT);
goto EXIT;
}
- player_msg_send1_fd(api, pc, ret_buf, ret, INT, size, tfd);
+ PLAYER_SEND_MSG_WITH_TFD(api, pc, tfd, ret_buf, ret, MUSE_TYPE_INT, "size", size);
pc->push_media_stream = FALSE;
EXIT:
- if (tfd > INVALID_DEFAULT_VALUE)
- close(tfd);
+ PLAYER_CLOSE_FD(tfd);
tbm_bo_unref(bo);
return ret;
}
-static void _player_release_internal_memory(player_cli_s * pc)
+static void _player_release_internal_memory(player_cli_s *pc, bool deinit_server_mem)
{
if (!pc)
return;
_del_mem(pc);
- _player_deinit_memory_buffer(pc);
+
+ if (deinit_server_mem)
+ _player_deinit_memory_buffer(pc);
}
-static int _player_deinit_memory_buffer(player_cli_s * pc)
+static int _player_deinit_memory_buffer(player_cli_s *pc)
{
PLAYER_INSTANCE_CHECK(pc);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_DEINIT_MEMORY_BUFFER;
intptr_t bo_addr = SERVER_TBM_BO(pc);
- if (!bo_addr)
+ if (!bo_addr || !CALLBACK_INFO(pc))
return ret;
- player_msg_send1_async(api, pc, POINTER, bo_addr);
-
+ PLAYER_SEND_MSG_ASYNC(api, MSG_FD(pc), ret, MUSE_TYPE_POINTER, "bo_addr", bo_addr);
SERVER_TBM_BO(pc) = 0;
return ret;
}
-int player_get_state(player_h player, player_state_e * pstate)
+int player_get_state(player_h player, player_state_e *pstate)
{
+ int ret = PLAYER_ERROR_NONE;
+ player_cli_s *pc = (player_cli_s *)player;
+
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(pstate);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_STATE;
- player_cli_s *pc = (player_cli_s *) player;
- int state;
- char *ret_buf = NULL;
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
-
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(state, ret_buf);
- *pstate = state;
- }
-
- g_free(ret_buf);
+ ret = _get_current_state(pc, pstate);
return ret;
}
int player_set_volume(player_h player, float left, float right)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_CHECK_CONDITION(left >= 0 && left <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
- PLAYER_CHECK_CONDITION(right >= 0 && right <= 1.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_VOLUME;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- LOGD("ENTER");
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(left, 0, 1.0);
+ PLAYER_RANGE_ARG_CHECK(right, 0, 1.0);
+
+ /* not support to set different value into each channel */
+ PLAYER_CHECK_CONDITION(left == right, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
+ LOGD("ENTER %f", left);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_DOUBLE, "volume", (double)left);
- player_msg_send2(api, pc, ret_buf, ret, DOUBLE, right, DOUBLE, left);
g_free(ret_buf);
return ret;
}
-int player_get_volume(player_h player, float *pleft, float *pright)
+int player_get_volume(player_h player, float *left, float *right)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pleft && pright);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_VOLUME;
- player_cli_s *pc = (player_cli_s *) player;
- double left = -1;
- double right = -1;
+ player_cli_s *pc = (player_cli_s *)player;
+ double volume = 0.0;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(left && right);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
- player_msg_get2(ret_buf, left, DOUBLE, right, DOUBLE, ret_val);
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_DOUBLE, "volume", (void *)&volume,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
- *pleft = (float)left;
- *pright = (float)right;
+ *left = (float)volume;
+ *right = (float)volume;
} else {
LOGE("failed to get value from msg");
ret = PLAYER_ERROR_INVALID_OPERATION;
return ret;
}
-int player_set_sound_type(player_h player, sound_type_e type)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_SOUND_TYPE;
- player_cli_s *pc = (player_cli_s *) player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
- LOGW("DEPRECATION WARNING: player_set_sound_type() is deprecated and will be removed from next release. Use player_set_sound_stream_info() instead.");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
- g_free(ret_buf);
- return ret;
-}
-
int player_set_sound_stream_info(player_h player, sound_stream_info_h stream_info)
{
- PLAYER_INSTANCE_CHECK(player);
-
muse_player_api_e api = MUSE_PLAYER_API_SET_SOUND_STREAM_INFO;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
bool is_available = false;
char *ret_buf = NULL;
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SOUND_STREAM);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(stream_info);
+
LOGD("ENTER");
/* check if stream_info is valid */
}
if (is_available == false) {
- ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+ ret = PLAYER_ERROR_INVALID_PARAMETER;
} else {
char *stream_type = NULL;
int stream_index = 0;
ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
ret = sound_manager_get_index_from_stream_information(stream_info, &stream_index);
if (ret == SOUND_MANAGER_ERROR_NONE)
- player_msg_send2(api, pc, ret_buf, ret, STRING, stream_type, INT, stream_index);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_STRING, "stream_type", (const char *)stream_type,
+ MUSE_TYPE_INT, "stream_index", stream_index);
else
ret = PLAYER_ERROR_INVALID_OPERATION;
}
int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(latency_mode, AUDIO_LATENCY_MODE_LOW, AUDIO_LATENCY_MODE_HIGH);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, latency_mode);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "latency_mode", (int)latency_mode);
g_free(ret_buf);
return ret;
}
-int player_get_audio_latency_mode(player_h player, audio_latency_mode_e * platency_mode)
+int player_get_audio_latency_mode(player_h player, audio_latency_mode_e *platency_mode)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(platency_mode);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int latency_mode = -1;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(platency_mode);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(latency_mode, ret_buf);
int player_start(player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_START;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
- LOGD("ENTER");
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_set_evas_display_visible)(void *, bool) = NULL;
-
- if (CALLBACK_INFO(pc) && EVAS_INFO(pc)->support_video) {
- if (EVAS_HANDLE(pc) && (EVAS_INFO(pc)->visible == EVAS_VISIBLE_NONE
- || EVAS_INFO(pc)->visible == EVAS_VISIBLE_TRUE)) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_visible, "disp_set_evas_display_visible");
- ret = p_disp_set_evas_display_visible(EVAS_HANDLE(pc), true);
- if (ret != MM_ERROR_NONE) {
- LOGE("mm_evas_renderer_set_visible err 0x%x", ret);
- return PLAYER_ERROR_INVALID_OPERATION;
- }
- /* avoid setting true at all times, when player is resumed */
- EVAS_INFO(pc)->visible = EVAS_VISIBLE_TRUE;
- }
+ PLAYER_INSTANCE_CHECK(player);
+
+ LOGD("ENTER %p", pc);
+
+ if (!DP_INTERFACE(pc))
+ goto _PLAYER_START;
+
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
+
+ if (display_type != MM_DISPLAY_TYPE_EVAS ||
+ CALLBACK_INFO(pc)->dp_info.visible == PLAYER_VISIBLE_INFO_FALSE)
+ goto _PLAYER_START;
+
+ /* set proper visible to evas renderer */
+ if (mm_display_interface_evas_set_visible(DP_INTERFACE(pc), true) != MM_ERROR_NONE) {
+ LOGE("mm_display_interface_evas_set_visible failed");
+ return PLAYER_ERROR_INVALID_OPERATION;
}
-#endif
- player_msg_send(api, pc, ret_buf, ret);
+ /* avoid setting true at all times, when player is resumed */
+ CALLBACK_INFO(pc)->dp_info.visible = PLAYER_VISIBLE_INFO_TRUE;
+
+_PLAYER_START:
+ g_mutex_lock(&pc->cb_info->buffering_cb_mutex);
+ pc->cb_info->drop_buffering_message = TRUE;
+ g_mutex_unlock(&pc->cb_info->buffering_cb_mutex);
+
+ _player_remove_idle_event(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_BUFFERING, false);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
+ g_mutex_lock(&pc->cb_info->buffering_cb_mutex);
+ pc->cb_info->drop_buffering_message = FALSE;
+ g_mutex_unlock(&pc->cb_info->buffering_cb_mutex);
g_free(ret_buf);
+
+ LOGD("LEAVE 0x%X", ret);
return ret;
}
int player_stop(player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
+ int mm_ret = MM_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_STOP;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
player_state_e state = PLAYER_STATE_NONE;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_set_evas_display_visible)(void *, bool) = NULL;
-#endif
- LOGD("ENTER");
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
- player_msg_send(MUSE_PLAYER_API_GET_STATE, pc, ret_buf, ret);
+ PLAYER_INSTANCE_CHECK(player);
- /* check player state */
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(state, ret_buf);
- g_free(ret_buf);
- ret_buf = NULL;
+ LOGD("ENTER %p", pc);
- if ((state != PLAYER_STATE_PLAYING) && (state != PLAYER_STATE_PAUSED)) {
- LOGE("Invalid state %d", state);
- return PLAYER_ERROR_INVALID_STATE;
- }
- } else {
- g_free(ret_buf);
- ret_buf = NULL;
+ /* check player state */
+ if (_get_current_state(pc, &state) != PLAYER_ERROR_NONE) {
+ LOGE("Failed to get state");
return PLAYER_ERROR_INVALID_OPERATION;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (CALLBACK_INFO(pc) && EVAS_HANDLE(pc) &&
- EVAS_INFO(pc)->support_video && (EVAS_INFO(pc)->visible == EVAS_VISIBLE_NONE
- || EVAS_INFO(pc)->visible == EVAS_VISIBLE_TRUE)) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_visible, "disp_set_evas_display_visible");
- ret = p_disp_set_evas_display_visible(EVAS_HANDLE(pc), false);
- if (ret != MM_ERROR_NONE) {
- LOGE("mm_evas_renderer_set_visible err 0x%x", ret);
- return PLAYER_ERROR_INVALID_OPERATION;
- }
- /* do not update EVAS_INFO(pc)->visible to set visible true if start again */
+ if ((state != PLAYER_STATE_PLAYING) && (state != PLAYER_STATE_PAUSED)) {
+ LOGE("Invalid state %d", state);
+ return PLAYER_ERROR_INVALID_STATE;
}
-#endif
- player_msg_send(api, pc, ret_buf, ret);
+ if (!DP_INTERFACE(pc))
+ goto _PLAYER_STOP;
+
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
+
+ if (display_type != MM_DISPLAY_TYPE_EVAS ||
+ CALLBACK_INFO(pc)->dp_info.visible == PLAYER_VISIBLE_INFO_FALSE)
+ goto _PLAYER_STOP;
+
+ mm_ret = mm_display_interface_evas_set_visible(DP_INTERFACE(pc), false);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("mm_display_interface_evas_set_visible failed 0x%x", mm_ret);
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+_PLAYER_STOP:
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE)
set_null_user_cb_lock(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_SEEK);
g_free(ret_buf);
+
+ LOGD("LEAVE 0x%X", ret);
return ret;
}
int player_pause(player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_PAUSE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- LOGD("ENTER");
+ PLAYER_INSTANCE_CHECK(player);
+
+ LOGD("ENTER %p", pc);
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
g_free(ret_buf);
+
+ LOGD("LEAVE 0x%X", ret);
return ret;
}
-int player_set_play_position(player_h player, int millisecond, bool accurate, player_seek_completed_cb callback, void *user_data)
+static int _set_play_position(player_h player, int64_t pos, bool accurate, player_seek_completed_cb callback, void *user_data)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_CHECK_CONDITION(millisecond >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
-
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_PLAY_POSITION;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- int pos = millisecond;
- LOGD("ENTER");
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_CHECK_CONDITION(pos >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
+ LOGD("ENTER %p", pc);
+
if (!pc->cb_info) {
LOGE("cb_info is null");
return PLAYER_ERROR_INVALID_OPERATION;
pc->cb_info->seek_cb_state = PLAYER_SEEK_CB_STATE_DROP;
else
pc->cb_info->seek_cb_state = PLAYER_SEEK_CB_STATE_WAIT;
- LOGI("Event type : %d, pos : %d, accurate : %d", MUSE_PLAYER_EVENT_TYPE_SEEK, millisecond, accurate);
+ LOGI("Event type : %d, pos : %"PRId64", accurate : %d", MUSE_PLAYER_EVENT_TYPE_SEEK, pos, accurate);
pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback;
pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data;
}
g_mutex_unlock(&pc->cb_info->seek_cb_mutex);
- player_msg_send2(api, pc, ret_buf, ret, INT, pos, INT, accurate);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT64, "pos", pos,
+ MUSE_TYPE_INT, "accurate", (int)accurate);
if (ret != PLAYER_ERROR_NONE) {
g_mutex_lock(&pc->cb_info->seek_cb_mutex);
pc->cb_info->seek_cb_state = PLAYER_SEEK_CB_STATE_NONE;
g_mutex_unlock(&pc->cb_info->seek_cb_mutex);
- LOGD("LEAVE");
+ LOGD("LEAVE 0x%X", ret);
+ return ret;
+}
+
+
+int player_set_play_position(player_h player, int milliseconds, bool accurate, player_seek_completed_cb callback, void *user_data)
+{
+ int ret = PLAYER_ERROR_NONE;
+ int64_t pos = (int64_t)(milliseconds * G_GINT64_CONSTANT(1000000));
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_CHECK_CONDITION(milliseconds >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
+ LOGD("ENTER");
+
+ ret = _set_play_position(player, pos, accurate, callback, user_data);
+
+ LOGD("LEAVE 0x%X", ret);
return ret;
}
-int player_get_play_position(player_h player, int *millisecond)
+int player_set_play_position_nsec(player_h player, int64_t nanoseconds, bool accurate, player_seek_completed_cb callback, void *user_data)
{
+ int ret = PLAYER_ERROR_NONE;
+ int64_t pos = nanoseconds;
+
PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(millisecond);
+ PLAYER_CHECK_CONDITION(nanoseconds >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
+ LOGD("ENTER");
+
+ ret = _set_play_position(player, pos, accurate, callback, user_data);
+
+ LOGD("LEAVE 0x%X", ret);
+ return ret;
+}
+static int _get_play_position(player_h player, int64_t *pos)
+{
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_PLAY_POSITION;
- player_cli_s *pc = (player_cli_s *) player;
- int pos;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- LOGD("ENTER");
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pos);
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(pos, ret_buf);
- *millisecond = pos;
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT64, "pos", (void *)pos,
+ INVALID_MUSE_TYPE_VALUE);
+ if (!ret_val)
+ ret = PLAYER_ERROR_INVALID_OPERATION;
}
g_free(ret_buf);
return ret;
}
-int player_set_mute(player_h player, bool muted)
+
+int player_get_play_position(player_h player, int *milliseconds)
+{
+ int ret = PLAYER_ERROR_NONE;
+ int64_t pos = 0;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(milliseconds);
+
+ /* LOGD("ENTER"); */
+
+ ret = _get_play_position(player, &pos);
+ if (ret == PLAYER_ERROR_NONE)
+ *milliseconds = (int)(pos / G_GINT64_CONSTANT(1000000));
+
+ return ret;
+}
+
+int player_get_play_position_nsec(player_h player, int64_t *nanoseconds)
{
+ int ret = PLAYER_ERROR_NONE;
+ int64_t pos = 0;
+
PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(nanoseconds);
+
+ /* LOGD("ENTER"); */
+
+ ret = _get_play_position(player, &pos);
+ if (ret == PLAYER_ERROR_NONE)
+ *nanoseconds = pos;
+
+ return ret;
+}
+
+int player_set_mute(player_h player, bool muted)
+{
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_MUTE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int mute = (int)muted;
+ PLAYER_INSTANCE_CHECK(player);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, mute);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "mute", mute);
g_free(ret_buf);
return ret;
}
-int player_is_muted(player_h player, bool * muted)
+int player_is_muted(player_h player, bool *muted)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(muted);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_IS_MUTED;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int mute = -1;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(muted);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(mute, ret_buf);
- *muted = (bool) mute;
+ *muted = (bool)mute;
}
g_free(ret_buf);
int player_set_looping(player_h player, bool looping)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_LOOPING;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, looping);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "looping", (int)looping);
g_free(ret_buf);
return ret;
}
-int player_is_looping(player_h player, bool * plooping)
+int player_is_looping(player_h player, bool *plooping)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(plooping);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_IS_LOOPING;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int looping = 0;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(plooping);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(looping, ret_buf);
*plooping = looping;
return ret;
}
-int player_get_duration(player_h player, int *pduration)
+static int _get_duration(player_h player, int64_t *duration)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pduration);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_DURATION;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- int duration = 0;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(duration);
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(duration, ret_buf);
- *pduration = duration;
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT64, "duration", (void *)duration,
+ INVALID_MUSE_TYPE_VALUE);
+ if (!ret_val)
+ ret = PLAYER_ERROR_INVALID_OPERATION;
}
g_free(ret_buf);
return ret;
}
+
+int player_get_duration(player_h player, int *milliseconds)
+{
+ int ret = PLAYER_ERROR_NONE;
+ int64_t duration = 0; /* nsec */
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(milliseconds);
+
+ LOGD("ENTER");
+
+ ret = _get_duration(player, &duration);
+ if (ret == PLAYER_ERROR_NONE) {
+ /* convert time from ns to ms */
+ *milliseconds = (int)(duration / G_GINT64_CONSTANT(1000000));
+ }
+
+ LOGD("LEAVE 0x%X", ret);
+ return ret;
+}
+
+int player_get_duration_nsec(player_h player, int64_t *nanoseconds)
+{
+ int ret = PLAYER_ERROR_NONE;
+ int64_t duration = 0; /* nsec */
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(nanoseconds);
+
+ LOGD("ENTER");
+
+ ret = _get_duration(player, &duration);
+ if (ret == PLAYER_ERROR_NONE)
+ *nanoseconds = duration;
+
+ LOGD("LEAVE 0x%X", ret);
+ return ret;
+}
+
/* The player_display_type_e is different at wearable profile */
-int _player_convert_display_type(player_display_type_e type, player_private_display_type_e *out_type)
+int _player_convert_display_type(player_display_type_e type, mm_display_type_e *out_type)
{
int ret = PLAYER_ERROR_NONE;
+
PLAYER_NULL_ARG_CHECK(out_type);
switch (type) {
case PLAYER_DISPLAY_TYPE_OVERLAY:
- *out_type = PLAYER_PRIVATE_DISPLAY_TYPE_OVERLAY;
- break;
- case PLAYER_DISPLAY_TYPE_OBSOLETE_EVAS_WNONE:
- if (_get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
- *out_type = PLAYER_PRIVATE_DISPLAY_TYPE_NONE;
- else
- *out_type = PLAYER_PRIVATE_DISPLAY_TYPE_EVAS;
+ *out_type = MM_DISPLAY_TYPE_OVERLAY;
break;
- case PLAYER_DISPLAY_TYPE_OBSOLETE_NONE_WEVAS:
- if (_get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
- *out_type = PLAYER_PRIVATE_DISPLAY_TYPE_EVAS;
- else
- *out_type = PLAYER_PRIVATE_DISPLAY_TYPE_NONE;
+ case PLAYER_DISPLAY_TYPE_OVERLAY_SYNC_UI:
+ *out_type = MM_DISPLAY_TYPE_OVERLAY_SYNC_UI;
break;
case PLAYER_DISPLAY_TYPE_EVAS:
- *out_type = PLAYER_PRIVATE_DISPLAY_TYPE_EVAS;
+ *out_type = MM_DISPLAY_TYPE_EVAS;
break;
case PLAYER_DISPLAY_TYPE_NONE:
- *out_type = PLAYER_PRIVATE_DISPLAY_TYPE_NONE;
+ *out_type = MM_DISPLAY_TYPE_NONE;
break;
default:
ret = PLAYER_ERROR_INVALID_PARAMETER;
}
LOGD("display type(%d) -> (%d)", type, *out_type);
+
return ret;
}
int player_set_display(player_h player, player_display_type_e type, player_display_h display)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
+ int mm_ret = MM_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
wl_win_msg_type wl_win;
char *wl_win_msg = (char *)&wl_win;
- unsigned int wl_surface_id;
- player_private_display_type_e conv_type;
- player_state_e state = PLAYER_STATE_NONE;
- unsigned int (*p_disp_set_wl_display)(int, void *) = NULL;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_destroy_evas_display)(void **) = NULL;
- int (*p_disp_create_evas_display)(void *, void **) = NULL;
- int (*p_disp_set_evas_display_old_info)(void *, void *, int, int, int) = NULL;
- int (*p_disp_set_evas_display_roi_area)(void *, int, int, int, int) = NULL;
- void (*p_disp_get_evas_display_geometry_info)(void *, int *, int *, int *, int *) = NULL;
- void (*p_disp_media_packet_video_decode_cb)(media_packet_h, void *) = NULL;
-#endif
+ mm_display_type_e conv_type = MM_DISPLAY_TYPE_NONE;
+ int arr_msg_len = 0;
+ pid_t pid = getpid();
+ pid_t tid = syscall(SYS_gettid);
- LOGD("ENTER");
- PLAYER_VIDEO_SUPPORTABLE_CHECK(pc);
-
- /* init */
- wl_win.wl_window_x = 0;
- wl_win.wl_window_y = 0;
- wl_win.wl_window_width = 0;
- wl_win.wl_window_height = 0;
+ PLAYER_INSTANCE_CHECK(player);
- LOGD("ENTER type: %d", type);
- if (type == PLAYER_DISPLAY_TYPE_OBSOLETE_EVAS_WNONE ||
- type == PLAYER_DISPLAY_TYPE_OBSOLETE_NONE_WEVAS) {
- LOGW("DEPRECATION WARNING: display type(%d) is deprecated and will be removed from next release. Use newly defined type value instead.", type);
+ if (type != PLAYER_DISPLAY_TYPE_NONE) {
+ LOGD("Check if API is called in main thread. pid [%d], tid [%d]", pid, tid);
+ if (pid != tid) {
+ LOGE("API isn't called in main thread");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
}
- player_msg_send(MUSE_PLAYER_API_GET_STATE, pc, ret_buf, ret);
-
- /* check player state */
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(state, ret_buf);
- g_free(ret_buf);
- ret_buf = NULL;
-
- if (state > PLAYER_STATE_IDLE) {
- LOGE("Invalid state %d", state);
- return PLAYER_ERROR_INVALID_STATE;
- }
- } else {
- g_free(ret_buf);
- ret_buf = NULL;
+ /* check display interface handle */
+ if (!DP_INTERFACE(pc)) {
+ LOGE("display interface not supported");
return PLAYER_ERROR_INVALID_OPERATION;
}
+ LOGD("ENTER type: %d", type);
+
+ /* before setting display, player state have to be checked. */
+ PLAYER_STATE_CHECK(pc, PLAYER_STATE_IDLE);
+
ret = _player_convert_display_type(type, &conv_type);
if (ret != PLAYER_ERROR_NONE)
return ret;
- if (conv_type != PLAYER_PRIVATE_DISPLAY_TYPE_NONE) {
- if (!display)
+ if (conv_type != MM_DISPLAY_TYPE_NONE) {
+ if (!display) {
+ LOGE("type[%d] NULL handle for display", type);
return PLAYER_ERROR_INVALID_PARAMETER;
-
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- /**
- * To support repeating play and stop, Evas_handle should not be destroyed in player_unprepare.
- * When the display type changes, Player need to destroy Evas_handle to set values of video output,
- * Otherwise, the values is not set because of checking Evas_handle.
- */
- if (CALLBACK_INFO(pc) && EVAS_HANDLE(pc)) {
- LOGW("evas client already exists");
- player_unset_media_packet_video_frame_decoded_cb(player);
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_destroy_evas_display, "disp_destroy_evas_display");
- if (p_disp_destroy_evas_display(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
- LOGW("fail to unset evas client");
- __player_unset_retrieve_buffer_cb(player);
- /* need to set display information again to new handle */
- EVAS_INFO(pc)->update_needed = TRUE;
}
-#endif
- /* set evas_render or wayland */
- if (conv_type == PLAYER_PRIVATE_DISPLAY_TYPE_OVERLAY) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_wl_display, "disp_set_wl_display");
- wl_surface_id = p_disp_set_wl_display(ELM_WAYLAND_WIN, display);
- if (wl_surface_id > 0) {
- wl_win.wl_surface_id = wl_surface_id;
- wl_win.type = conv_type;
- } else return PLAYER_ERROR_INVALID_OPERATION;
+
+ mm_ret = mm_display_interface_set_display(DP_INTERFACE(pc), conv_type, display, &wl_win.surface_id);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
+ return PLAYER_ERROR_INVALID_OPERATION;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- else if (conv_type == PLAYER_PRIVATE_DISPLAY_TYPE_EVAS) {
- if (!CALLBACK_INFO(pc)) {
- LOGE("there is no cb info in player handle");
+
+ if (conv_type == MM_DISPLAY_TYPE_OVERLAY_SYNC_UI) {
+ g_strlcpy(wl_win.exported_shell_handle, (char *)display, MAX_EXPORTED_SHELL_HANDLE_LEN);
+ } else if (conv_type == MM_DISPLAY_TYPE_EVAS) {
+ /* before evas handle is created, user could set display information */
+ player_display_mode_e mode = PLAYER_DISPLAY_MODE_LETTER_BOX;
+ player_display_rotation_e rotation = PLAYER_DISPLAY_ROTATION_NONE;
+ bool visible = false;
+
+ ret = player_get_display_mode(player, &mode);
+ ret |= player_get_display_rotation(player, &rotation);
+ ret |= player_is_display_visible(player, &visible);
+
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("get current display settings");
return PLAYER_ERROR_INVALID_OPERATION;
}
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_create_evas_display, "disp_create_evas_display");
- ret = p_disp_create_evas_display(display, &EVAS_HANDLE(pc));
- if (ret != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION;
+ LOGD("current setting : mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
+ mode, rotation, visible,
+ CALLBACK_INFO(pc)->dp_info.roi_x,
+ CALLBACK_INFO(pc)->dp_info.roi_y,
+ CALLBACK_INFO(pc)->dp_info.roi_w,
+ CALLBACK_INFO(pc)->dp_info.roi_h);
+
+ mm_ret = mm_display_interface_evas_set_mode(DP_INTERFACE(pc), mode);
+ mm_ret |= mm_display_interface_evas_set_rotation(DP_INTERFACE(pc), rotation);
+ mm_ret |= mm_display_interface_evas_set_visible(DP_INTERFACE(pc), visible);
+ if (mode == PLAYER_DISPLAY_MODE_DST_ROI) {
+ mm_ret |= mm_display_interface_evas_set_roi_area(DP_INTERFACE(pc),
+ CALLBACK_INFO(pc)->dp_info.roi_x, CALLBACK_INFO(pc)->dp_info.roi_y,
+ CALLBACK_INFO(pc)->dp_info.roi_w, CALLBACK_INFO(pc)->dp_info.roi_h);
+ }
- /* before evas handle is created, user could set display information */
- if (EVAS_INFO(pc)->update_needed) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_old_info, "disp_set_evas_display_old_info");
- ret = p_disp_set_evas_display_old_info(display, EVAS_HANDLE(pc), EVAS_INFO(pc)->mode, EVAS_INFO(pc)->rotation, EVAS_INFO(pc)->visible);
- if (ret != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION;
- if (EVAS_INFO(pc)->mode == PLAYER_DISPLAY_MODE_DST_ROI) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_roi_area, "disp_set_evas_display_roi_area");
- ret = p_disp_set_evas_display_roi_area(EVAS_HANDLE(pc), EVAS_INFO(pc)->roi_x, EVAS_INFO(pc)->roi_y, EVAS_INFO(pc)->roi_w, EVAS_INFO(pc)->roi_h);
- if (ret != MM_ERROR_NONE) return PLAYER_ERROR_INVALID_OPERATION;
- }
- EVAS_INFO(pc)->update_needed = FALSE;
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("set mm_display_interface failed");
+ return PLAYER_ERROR_INVALID_OPERATION;
}
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_get_evas_display_geometry_info, "disp_get_evas_display_geometry_info");
- p_disp_get_evas_display_geometry_info(display, &wl_win.wl_window_x, &wl_win.wl_window_y, &wl_win.wl_window_width, &wl_win.wl_window_height);
- wl_win.type = conv_type;
-
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_media_packet_video_decode_cb, "disp_media_packet_video_decode_cb");
- ret = player_set_media_packet_video_frame_decoded_cb(player, p_disp_media_packet_video_decode_cb, (void *)EVAS_HANDLE(pc));
- if (ret != PLAYER_ERROR_NONE)
- LOGW("fail to set decoded callback");
+
+ if (player_set_media_packet_video_frame_decoded_cb(player,
+ __player_media_packet_video_decoded_cb, player) != MM_ERROR_NONE) {
+ LOGE("fail to set decoded callback");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
if (__player_set_retrieve_buffer_cb(player, __retrieve_buffer_cb, pc))
LOGW("fail to set __retrieve_buffer_cb");
}
-#endif
- } else { /* PLAYER_DISPLAY_TYPE_NONE */
- LOGI("Wayland surface type is NONE");
- wl_win.type = conv_type;
}
- player_msg_send_array(api, pc, ret_buf, ret, wl_win_msg, sizeof(wl_win_msg_type), sizeof(char));
+
+ wl_win.type = conv_type;
+
+ arr_msg_len = (sizeof(wl_win_msg_type) / sizeof(int) + (sizeof(wl_win_msg_type) % sizeof(int) ? 1 : 0));
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_ARRAY, "wl_win_msg", arr_msg_len, (int *)wl_win_msg);
+
g_free(ret_buf);
return ret;
int player_set_display_mode(player_h player, player_display_mode_e mode)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_CHECK_CONDITION(PLAYER_DISPLAY_MODE_LETTER_BOX <= mode && mode < PLAYER_DISPLAY_MODE_NUM, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
int ret = PLAYER_ERROR_NONE;
+ int mm_ret = MM_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_MODE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_set_evas_display_disp_mode)(void *, int) = NULL;
-#endif
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(mode, PLAYER_DISPLAY_MODE_LETTER_BOX, PLAYER_DISPLAY_MODE_DST_ROI);
+
LOGD("ENTER");
- PLAYER_VIDEO_SUPPORTABLE_CHECK(pc);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (EVAS_HANDLE(pc)) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_disp_mode, "disp_set_evas_display_disp_mode");
- ret = p_disp_set_evas_display_disp_mode(EVAS_HANDLE(pc), mode);
- if (ret != MM_ERROR_NONE)
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
+
+ if (display_type == MM_DISPLAY_TYPE_OVERLAY_SYNC_UI) {
+ LOGE("Function is not available in MM_DISPLAY_TYPE_OVERLAY_SYNC_UI type");
+ return PLAYER_ERROR_NOT_AVAILABLE;
+ }
+
+ if (display_type == MM_DISPLAY_TYPE_EVAS) {
+ mm_ret = mm_display_interface_evas_set_mode(DP_INTERFACE(pc), mode);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("mm_display_interface_evas_set_mode failed 0x%x", mm_ret);
return PLAYER_ERROR_INVALID_OPERATION;
- else
- return PLAYER_ERROR_NONE;
- } else {
- EVAS_INFO(pc)->mode = mode;
- EVAS_INFO(pc)->update_needed = TRUE;
+ }
}
-#endif
- player_msg_send1(api, pc, ret_buf, ret, INT, mode);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "mode", (int)mode);
+
g_free(ret_buf);
+
return ret;
}
-int player_get_display_mode(player_h player, player_display_mode_e * pmode)
+int player_get_display_mode(player_h player, player_display_mode_e *pmode)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pmode);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_MODE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int mode = -1;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_get_evas_display_disp_mode)(void *, int *) = NULL;
-#endif
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pmode);
LOGD("ENTER");
- PLAYER_VIDEO_SUPPORTABLE_CHECK(pc);
-
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (EVAS_HANDLE(pc)) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_get_evas_display_disp_mode, "disp_get_evas_display_disp_mode");
- ret = p_disp_get_evas_display_disp_mode(EVAS_HANDLE(pc), &mode);
- *pmode = (player_display_mode_e) mode;
- if (ret != MM_ERROR_NONE)
- return PLAYER_ERROR_INVALID_OPERATION;
- else
- return PLAYER_ERROR_NONE;
+
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
+
+ if (display_type == MM_DISPLAY_TYPE_OVERLAY_SYNC_UI) {
+ LOGE("Function is not available in MM_DISPLAY_TYPE_OVERLAY_SYNC_UI type");
+ return PLAYER_ERROR_NOT_AVAILABLE;
}
-#endif
- player_msg_send(api, pc, ret_buf, ret);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
if (ret == PLAYER_ERROR_NONE) {
player_msg_get_type(mode, ret_buf, INT);
*pmode = mode;
}
g_free(ret_buf);
+
return ret;
}
-
-int player_set_display_roi_area(player_h player, int x, int y, int width, int height)
+int player_set_video_roi_area(player_h player, double x_scale, double y_scale,
+ double w_scale, double h_scale)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_CHECK_CONDITION(width > 0 && height > 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
-
int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROI_AREA;
- player_cli_s *pc = (player_cli_s *) player;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_VIDEO_ROI_AREA;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- wl_win_msg_type wl_win;
- char *wl_win_msg = (char *)&wl_win;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_set_evas_display_roi_area)(void *, int, int, int, int) = NULL;
-#endif
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
+ PLAYER_INSTANCE_CHECK(player);
LOGD("ENTER");
- PLAYER_VIDEO_SUPPORTABLE_CHECK(pc);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (EVAS_HANDLE(pc)) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_roi_area, "disp_set_evas_display_roi_area");
- ret = p_disp_set_evas_display_roi_area(EVAS_HANDLE(pc), x, y, width, height);
- if (ret == MM_ERROR_EVASRENDER_INVALID_ARGUMENT)
- return PLAYER_ERROR_INVALID_PARAMETER;
- else if (ret != MM_ERROR_NONE)
- return PLAYER_ERROR_INVALID_OPERATION;
- else
- return PLAYER_ERROR_NONE;
- } else {
- EVAS_INFO(pc)->roi_x = x;
- EVAS_INFO(pc)->roi_y = y;
- EVAS_INFO(pc)->roi_w = width;
- EVAS_INFO(pc)->roi_h = height;
- EVAS_INFO(pc)->update_needed = TRUE;
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
+
+ if (display_type == MM_DISPLAY_TYPE_OVERLAY_SYNC_UI) {
+ LOGE("Function is not available in MM_DISPLAY_TYPE_OVERLAY_SYNC_UI type");
+ return PLAYER_ERROR_NOT_AVAILABLE;
}
-#endif
- wl_win.wl_window_x = x;
- wl_win.wl_window_y = y;
- wl_win.wl_window_width = width;
- wl_win.wl_window_height = height;
- player_msg_send_array(api, pc, ret_buf, ret, wl_win_msg, sizeof(wl_win_msg_type), sizeof(char));
- g_free(ret_buf);
- return ret;
-}
+ if (display_type == MM_DISPLAY_TYPE_EVAS) {
+ LOGE("Display type is EVAS, video display interface is not supported");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
-int player_set_playback_rate(player_h player, float rate)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_CHECK_CONDITION(rate >= -5.0 && rate <= 5.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PLAYBACK_RATE;
- player_cli_s *pc = (player_cli_s *) player;
- char *ret_buf = NULL;
+ if (!_player_video_roi_area_is_valid(x_scale, y_scale, w_scale, h_scale))
+ return PLAYER_ERROR_INVALID_PARAMETER;
- LOGD("ENTER");
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_DOUBLE, "x_scale", x_scale,
+ MUSE_TYPE_DOUBLE, "y_scale", y_scale,
+ MUSE_TYPE_DOUBLE, "w_scale", w_scale,
+ MUSE_TYPE_DOUBLE, "h_scale", h_scale);
- player_msg_send1(api, pc, ret_buf, ret, DOUBLE, rate);
g_free(ret_buf);
+
return ret;
}
-int player_set_display_rotation(player_h player, player_display_rotation_e rotation)
+
+int player_get_video_roi_area(player_h player, double *x_scale, double *y_scale,
+ double *w_scale, double *h_scale)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROTATION;
- player_cli_s *pc = (player_cli_s *) player;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_ROI_AREA;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_set_evas_display_rotation)(void *, int) = NULL;
-#endif
+ double scale_x = 0, scale_y = 0, scale_w = 0, scale_h = 0;
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
- LOGD("ENTER");
- PLAYER_VIDEO_SUPPORTABLE_CHECK(pc);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (EVAS_HANDLE(pc)) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_rotation, "disp_set_evas_display_rotation");
- ret = p_disp_set_evas_display_rotation(EVAS_HANDLE(pc), rotation);
- if (ret != MM_ERROR_NONE)
- return PLAYER_ERROR_INVALID_OPERATION;
+ if (display_type == MM_DISPLAY_TYPE_OVERLAY_SYNC_UI) {
+ LOGE("Function is not available in MM_DISPLAY_TYPE_OVERLAY_SYNC_UI type");
+ return PLAYER_ERROR_NOT_AVAILABLE;
+ }
+
+ PLAYER_NULL_ARG_CHECK(x_scale && y_scale && w_scale && h_scale);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
+ if (ret == PLAYER_ERROR_NONE) {
+ if (player_msg_get_type(scale_x, ret_buf, DOUBLE))
+ *x_scale = scale_x;
else
- return PLAYER_ERROR_NONE;
- } else {
- EVAS_INFO(pc)->rotation = rotation;
- EVAS_INFO(pc)->update_needed = TRUE;
+ LOGE("failed to get value from msg");
+ if (player_msg_get_type(scale_y, ret_buf, DOUBLE))
+ *y_scale = scale_y;
+ else
+ LOGE("failed to get value from msg");
+ if (player_msg_get_type(scale_w, ret_buf, DOUBLE))
+ *w_scale = scale_w;
+ else
+ LOGE("failed to get value from msg");
+ if (player_msg_get_type(scale_h, ret_buf, DOUBLE))
+ *h_scale = scale_h;
+ else
+ LOGE("failed to get value from msg");
}
-#endif
- player_msg_send1(api, pc, ret_buf, ret, INT, rotation);
+
g_free(ret_buf);
+
return ret;
}
-int player_get_display_rotation(player_h player, player_display_rotation_e * protation)
+
+int player_set_display_roi_area(player_h player, int x, int y, int width, int height)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(protation);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_ROTATION;
+ int mm_ret = MM_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROI_AREA;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- int rotation = -1;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_get_evas_display_rotation)(void *, int *) = NULL;
-#endif
+ wl_win_msg_type wl_win;
+ char *wl_win_msg = (char *)&wl_win;
+ int arr_msg_len = 0;
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_CHECK_CONDITION(width > 0 && height > 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
LOGD("ENTER");
- PLAYER_VIDEO_SUPPORTABLE_CHECK(pc);
-
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (EVAS_HANDLE(pc)) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_get_evas_display_rotation, "disp_get_evas_display_rotation");
- ret = p_disp_get_evas_display_rotation(EVAS_HANDLE(pc), &rotation);
- *protation = (player_display_rotation_e) rotation;
- if (ret != MM_ERROR_NONE)
+
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
+
+ if (display_type == MM_DISPLAY_TYPE_EVAS) {
+ mm_ret = mm_display_interface_evas_set_roi_area(DP_INTERFACE(pc), x, y, width, height);
+ if (mm_ret == MM_ERROR_EVASRENDER_INVALID_ARGUMENT)
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ else if (mm_ret != MM_ERROR_NONE)
return PLAYER_ERROR_INVALID_OPERATION;
- else
- return PLAYER_ERROR_NONE;
}
-#endif
- player_msg_send(api, pc, ret_buf, ret);
+
+ wl_win.win_roi_x = x;
+ wl_win.win_roi_y = y;
+ wl_win.win_roi_width = width;
+ wl_win.win_roi_height = height;
+
+ arr_msg_len = (sizeof(wl_win_msg_type) / sizeof(int) + (sizeof(wl_win_msg_type) % sizeof(int) ? 1 : 0));
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_ARRAY, "wl_win_msg", arr_msg_len, (int *)wl_win_msg);
+
+ if (ret == PLAYER_ERROR_NONE) {
+ CALLBACK_INFO(pc)->dp_info.roi_x = x;
+ CALLBACK_INFO(pc)->dp_info.roi_y = y;
+ CALLBACK_INFO(pc)->dp_info.roi_w = width;
+ CALLBACK_INFO(pc)->dp_info.roi_h = height;
+ }
+
+ g_free(ret_buf);
+
+ return ret;
+}
+
+int player_set_playback_rate(player_h player, float rate)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_PLAYBACK_RATE;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(rate, -5.0, 5.0);
+
+ LOGD("ENTER");
+ if (rate != 0) {
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_DOUBLE, "rate", (double)rate);
+ g_free(ret_buf);
+ }
+ LOGD("LEAVE 0x%X", ret);
+ return ret;
+}
+
+int player_set_display_rotation(player_h player, player_display_rotation_e rotation)
+{
+ int ret = PLAYER_ERROR_NONE;
+ int mm_ret = MM_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROTATION;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(rotation, PLAYER_DISPLAY_ROTATION_NONE, PLAYER_DISPLAY_ROTATION_270);
+
+ LOGD("ENTER");
+
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
+
+ if (display_type == MM_DISPLAY_TYPE_OVERLAY_SYNC_UI) {
+ LOGE("Function is not available in MM_DISPLAY_TYPE_OVERLAY_SYNC_UI type");
+ return PLAYER_ERROR_NOT_AVAILABLE;
+ }
+
+ if (display_type == MM_DISPLAY_TYPE_EVAS) {
+ mm_ret = mm_display_interface_evas_set_rotation(DP_INTERFACE(pc), rotation);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("mm_display_interface_evas_set_rotation failed 0x%x", mm_ret);
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+ }
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "rotation", (int)rotation);
+
+ g_free(ret_buf);
+
+ return ret;
+}
+
+int player_get_display_rotation(player_h player, player_display_rotation_e *protation)
+{
+ int ret = PLAYER_ERROR_NONE;
+ player_cli_s *pc = (player_cli_s *)player;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_ROTATION;
+ char *ret_buf = NULL;
+ int rotation = -1;
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
+
+ if (display_type == MM_DISPLAY_TYPE_OVERLAY_SYNC_UI) {
+ LOGE("Function is not available in MM_DISPLAY_TYPE_OVERLAY_SYNC_UI type");
+ return PLAYER_ERROR_NOT_AVAILABLE;
+ }
+
+ PLAYER_NULL_ARG_CHECK(protation);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
if (ret == PLAYER_ERROR_NONE) {
player_msg_get_type(rotation, ret_buf, INT);
*protation = rotation;
}
g_free(ret_buf);
+
return ret;
}
int player_set_display_visible(player_h player, bool visible)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ int mm_ret = MM_ERROR_NONE;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_VISIBLE;
char *ret_buf = NULL;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- int (*p_disp_set_evas_display_visible)(void *, bool) = NULL;
-#endif
+ mm_display_type_e display_type = MM_DISPLAY_TYPE_NONE;
+
+ PLAYER_INSTANCE_CHECK(player);
LOGD("ENTER");
- PLAYER_VIDEO_SUPPORTABLE_CHECK(pc);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (EVAS_HANDLE(pc)) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_set_evas_display_visible, "disp_set_evas_display_visible");
- ret = p_disp_set_evas_display_visible(EVAS_HANDLE(pc), visible);
- if (ret != MM_ERROR_NONE)
- return PLAYER_ERROR_INVALID_OPERATION;
+ PLAYER_GET_DISPLAY_TYPE(pc, display_type);
- EVAS_INFO(pc)->visible = visible ? EVAS_VISIBLE_TRUE : EVAS_VISIBLE_FALSE;
- return PLAYER_ERROR_NONE;
- } else {
- EVAS_INFO(pc)->visible = visible ? EVAS_VISIBLE_TRUE : EVAS_VISIBLE_FALSE;
- EVAS_INFO(pc)->update_needed = TRUE;
+ if (display_type == MM_DISPLAY_TYPE_EVAS) {
+ mm_ret = mm_display_interface_evas_set_visible(DP_INTERFACE(pc), visible);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("mm_display_interface_evas_set_visible failed 0x%x", mm_ret);
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
}
-#endif
- player_msg_send1(api, pc, ret_buf, ret, INT, visible);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "visible", (int)visible);
+
g_free(ret_buf);
+
+ if (ret == PLAYER_ERROR_NONE)
+ CALLBACK_INFO(pc)->dp_info.visible = visible ? PLAYER_VISIBLE_INFO_TRUE : PLAYER_VISIBLE_INFO_FALSE;
+
return ret;
}
-int player_is_display_visible(player_h player, bool * pvisible)
+int player_is_display_visible(player_h player, bool *pvisible)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pvisible);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_IS_DISPLAY_VISIBLE;
char *ret_buf = NULL;
int value = -1;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- bool visible = 0;
- int (*p_disp_get_evas_display_visible)(void *, bool *) = NULL;
-#endif
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pvisible);
LOGD("ENTER");
- PLAYER_VIDEO_SUPPORTABLE_CHECK(pc);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (EVAS_HANDLE(pc)) {
- PLAYER_DISP_DLSYM(pc->dl_handle, p_disp_get_evas_display_visible, "disp_get_evas_display_visible");
- ret = p_disp_get_evas_display_visible(EVAS_HANDLE(pc), &visible);
- if (visible)
- *pvisible = TRUE;
- else
- *pvisible = FALSE;
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
- if (ret != MM_ERROR_NONE)
- return PLAYER_ERROR_INVALID_OPERATION;
- else
- return PLAYER_ERROR_NONE;
- }
-#endif
- player_msg_send(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get_type(value, ret_buf, INT);
}
g_free(ret_buf);
+
return ret;
}
int player_get_content_info(player_h player, player_content_info_e key, char **pvalue)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pvalue);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_CONTENT_INFO;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
char value[MUSE_MSG_MAX_LENGTH] = { 0, };
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pvalue);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, key);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "key", (int)key);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get_string(value, ret_buf);
*pvalue = strndup(value, MUSE_MSG_MAX_LENGTH);
int player_get_codec_info(player_h player, char **paudio_codec, char **pvideo_codec)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(paudio_codec && pvideo_codec);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_INFO;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
char video_codec[MUSE_MSG_MAX_LENGTH] = { 0, };
char audio_codec[MUSE_MSG_MAX_LENGTH] = { 0, };
bool ret_val = TRUE;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(paudio_codec || pvideo_codec);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- player_msg_get_string2(ret_buf, video_codec, audio_codec, ret_val);
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_STRING, "video_codec", (void *)video_codec,
+ MUSE_TYPE_STRING, "audio_codec", (void *)audio_codec,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
- *pvideo_codec = strndup(video_codec, MUSE_MSG_MAX_LENGTH);
- *paudio_codec = strndup(audio_codec, MUSE_MSG_MAX_LENGTH);
+ if (pvideo_codec)
+ *pvideo_codec = strndup(video_codec, MUSE_MSG_MAX_LENGTH);
+ if (paudio_codec)
+ *paudio_codec = strndup(audio_codec, MUSE_MSG_MAX_LENGTH);
} else {
ret = PLAYER_ERROR_INVALID_OPERATION;
}
int player_get_audio_stream_info(player_h player, int *psample_rate, int *pchannel, int *pbit_rate)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(psample_rate && pchannel && pbit_rate);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int sample_rate = 0;
int channel = 0;
int bit_rate = 0;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(psample_rate || pchannel || pbit_rate);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
- player_msg_get3(ret_buf, sample_rate, INT, channel, INT, bit_rate, INT, ret_val);
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT, "sample_rate", (void *)&sample_rate,
+ MUSE_TYPE_INT, "channel", (void *)&channel,
+ MUSE_TYPE_INT, "bit_rate", (void *)&bit_rate,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
- *psample_rate = sample_rate;
- *pchannel = channel;
- *pbit_rate = bit_rate;
+ if (psample_rate)
+ *psample_rate = sample_rate;
+ if (pchannel)
+ *pchannel = channel;
+ if (pbit_rate)
+ *pbit_rate = bit_rate;
} else {
ret = PLAYER_ERROR_INVALID_OPERATION;
}
int player_get_video_stream_info(player_h player, int *pfps, int *pbit_rate)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pfps && pbit_rate);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int fps = 0;
int bit_rate = 0;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pfps || pbit_rate);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
- player_msg_get2(ret_buf, fps, INT, bit_rate, INT, ret_val);
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT, "fps", (void *)&fps,
+ MUSE_TYPE_INT, "bit_rate", (void *)&bit_rate,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
- *pfps = fps;
- *pbit_rate = bit_rate;
+ if (pfps)
+ *pfps = fps;
+ if (pbit_rate)
+ *pbit_rate = bit_rate;
} else {
ret = PLAYER_ERROR_INVALID_OPERATION;
}
int player_get_video_size(player_h player, int *pwidth, int *pheight)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pwidth && pheight);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_SIZE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int width = 0;
int height = 0;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pwidth && pheight);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
- player_msg_get2(ret_buf, width, INT, height, INT, ret_val);
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT, "width", (void *)&width,
+ MUSE_TYPE_INT, "height", (void *)&height,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
*pwidth = width;
*pheight = height;
int player_get_album_art(player_h player, void **palbum_art, int *psize)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(palbum_art && psize);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_ALBUM_ART;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
char *album_art;
int size = 0;
int key = INVALID_DEFAULT_VALUE;
void *jobj = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(palbum_art && psize);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
muse_core_msg_parse_err_e err = MUSE_MSG_PARSE_ERROR_NONE;
jobj = muse_core_msg_object_new(ret_buf, NULL, &err);
if (jobj)
muse_core_msg_object_free(jobj);
- if (ret_buf)
- g_free(ret_buf);
+ g_free(ret_buf);
- if (tfd > INVALID_DEFAULT_VALUE)
- close(tfd);
+ PLAYER_CLOSE_FD(tfd);
if (CALLBACK_INFO(pc))
pc->cb_info->tfd = INVALID_DEFAULT_VALUE;
tbm_bo_unref(bo);
/* return buffer */
- if (key > INVALID_DEFAULT_VALUE) {
+ if (key > INVALID_DEFAULT_VALUE && CALLBACK_INFO(pc)) {
LOGD("send msg to release buffer. key:%d", key);
- player_msg_send1_async(MUSE_PLAYER_API_RETURN_BUFFER, pc, INT, key);
+ PLAYER_SEND_MSG_ASYNC(MUSE_PLAYER_API_RETURN_BUFFER, MSG_FD(pc), ret, MUSE_TYPE_INT, "key", key);
}
return ret;
int player_audio_effect_get_equalizer_bands_count(player_h player, int *pcount)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pcount);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int count;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pcount);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(count, ret_buf);
*pcount = count;
int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(band_levels);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(band_levels);
+
LOGD("ENTER");
- player_msg_send_array(api, pc, ret_buf, ret, band_levels, length, sizeof(int));
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "length", length,
+ MUSE_TYPE_ARRAY, "band_levels", length, band_levels);
g_free(ret_buf);
return ret;
int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+
LOGD("ENTER");
- player_msg_send2(api, pc, ret_buf, ret, INT, index, INT, level);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "index", index,
+ MUSE_TYPE_INT, "level", level);
g_free(ret_buf);
return ret;
int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *plevel)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(plevel);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int level;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(plevel);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, index);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "index", index);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(level, ret_buf);
*plevel = level;
int player_audio_effect_get_equalizer_level_range(player_h player, int *pmin, int *pmax)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pmin && pmax);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int min = 0, max = 0;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pmin && pmax);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
- player_msg_get2(ret_buf, min, INT, max, INT, ret_val);
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT, "min", (void *)&min,
+ MUSE_TYPE_INT, "max", (void *)&max,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
*pmin = min;
*pmax = max;
int player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *pfrequency)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pfrequency);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int frequency;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pfrequency);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, index);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "index", index);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(frequency, ret_buf);
*pfrequency = frequency;
int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *prange)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(prange);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int range;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(prange);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, index);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "index", index);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(range, ret_buf);
*prange = range;
int player_audio_effect_equalizer_clear(player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
g_free(ret_buf);
return ret;
}
-int player_audio_effect_equalizer_is_available(player_h player, bool * pavailable)
+int player_audio_effect_equalizer_is_available(player_h player, bool *pavailable)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pavailable);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int available;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pavailable);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(available, ret_buf);
*pavailable = available;
int player_set_subtitle_path(player_h player, const char *path)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_PATH;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
char subtitle_path[MAX_URL_LEN] = {0, };
+ PLAYER_INSTANCE_CHECK(player);
+
LOGD("ENTER");
- if (path && _player_get_origin_internal_path(path, subtitle_path) != PLAYER_ERROR_NONE)
+ if (path && _player_get_valid_path(path, subtitle_path) != PLAYER_ERROR_NONE)
return PLAYER_ERROR_INVALID_PARAMETER;
- player_msg_send1(api, pc, ret_buf, ret, STRING, subtitle_path);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_STRING, "subtitle_path", (const char *)subtitle_path);
g_free(ret_buf);
return ret;
}
-int player_set_subtitle_position_offset(player_h player, int millisecond)
+int player_set_subtitle_position_offset(player_h player, int milliseconds)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, millisecond);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_progressive_download_path(player_h player, const char *path)
-{
PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(path);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH;
- player_cli_s *pc = (player_cli_s *) player;
- char *ret_buf = NULL;
- char dw_path[MAX_URL_LEN] = {0, };
LOGD("ENTER");
- LOGW("DEPRECATION WARNING: player_set_progressive_download_path() is deprecated and will be removed from next release.");
- if (!_player_check_network_availability())
- return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "milliseconds", milliseconds);
- if (_player_get_origin_internal_path(path, dw_path) != PLAYER_ERROR_NONE)
- return PLAYER_ERROR_INVALID_PARAMETER;
-
- player_msg_send1(api, pc, ret_buf, ret, STRING, dw_path);
g_free(ret_buf);
return ret;
}
-int player_get_progressive_download_status(player_h player, unsigned long *pcurrent, unsigned long *ptotal_size)
+int player_capture_video(player_h player, player_video_captured_cb callback, void *user_data)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pcurrent && ptotal_size);
int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS;
- player_cli_s *pc = (player_cli_s *) player;
+ muse_player_api_e api = MUSE_PLAYER_API_CAPTURE_VIDEO;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- unsigned long current, total_size;
-
- LOGD("ENTER");
- LOGW("DEPRECATION WARNING: player_get_progressive_download_status() is deprecated and will be removed from next release.");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
- player_msg_get2(ret_buf, current, POINTER, total_size, POINTER, ret_val);
- if (ret_val) {
- *pcurrent = current;
- *ptotal_size = total_size;
- } else {
- ret = PLAYER_ERROR_INVALID_OPERATION;
- }
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_capture_video(player_h player, player_video_captured_cb callback, void *user_data)
-{
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_CAPTURE_VIDEO;
- player_cli_s *pc = (player_cli_s *) player;
- char *ret_buf = NULL;
LOGD("ENTER");
if (pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = user_data;
}
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret != PLAYER_ERROR_NONE)
set_null_user_cb(pc->cb_info, MUSE_PLAYER_EVENT_TYPE_CAPTURE);
int player_set_streaming_cookie(player_h player, const char *cookie, int size)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(cookie);
- PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_COOKIE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(cookie);
+ PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
LOGD("ENTER");
- player_msg_send2(api, pc, ret_buf, ret, STRING, cookie, INT, size);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_STRING, "cookie", cookie,
+ MUSE_TYPE_INT, "size", size);
g_free(ret_buf);
return ret;
}
int player_set_streaming_user_agent(player_h player, const char *user_agent, int size)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(user_agent);
- PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_USER_AGENT;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(user_agent);
+ PLAYER_CHECK_CONDITION(size >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
LOGD("ENTER");
- player_msg_send2(api, pc, ret_buf, ret, STRING, user_agent, INT, size);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_STRING, "user_agent", user_agent,
+ MUSE_TYPE_INT, "size", size);
g_free(ret_buf);
return ret;
}
-int player_get_streaming_download_progress(player_h player, int *pstart, int *pcurrent)
+int player_get_streaming_download_progress(player_h player, int *start, int *end)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pstart && pcurrent);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- int start = 0, current = 0;
+ int start_pos = 0, end_pos = 0;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(start && end);
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
- player_msg_get2(ret_buf, start, INT, current, INT, ret_val);
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT, "start_pos", (void *)&start_pos,
+ MUSE_TYPE_INT, "end_pos", (void *)&end_pos,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
- *pstart = start;
- *pcurrent = current;
+ *start = start_pos;
+ *end = end_pos;
} else {
ret = PLAYER_ERROR_INVALID_OPERATION;
}
}
g_free(ret_buf);
return ret;
-
}
int player_set_completed_cb(player_h player, player_completed_cb callback, void *user_data)
return __set_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player, callback, user_data);
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
static void __retrieve_buffer_cb(void *user_data)
{
player_cli_s *player = (player_cli_s *)user_data;
int ret = PLAYER_ERROR_NONE;
bool gapless = false;
- int (*p_disp_evas_display_retrieve_all_packets)(void *, bool) = NULL;
- ret = player_is_gapless((player_h)user_data, &gapless);
+ ret = player_is_gapless((player_h)player, &gapless);
if (ret != PLAYER_ERROR_NONE) {
LOGW("player_is_gapless is failed");
return;
}
- PLAYER_DISP_DLSYM(player->dl_handle, p_disp_evas_display_retrieve_all_packets, "disp_evas_display_retrieve_all_packets");
- ret = p_disp_evas_display_retrieve_all_packets(EVAS_HANDLE(player), gapless);
- if (ret != PLAYER_ERROR_NONE)
- LOGI("mm_evas_renderer_retrieve_all_packets returned error");
+ ret = mm_display_interface_evas_flush(DP_INTERFACE(player), gapless);
+
+ LOGW("flush all packet : 0x%x [gapless %d]", ret, gapless);
}
static int __player_set_retrieve_buffer_cb(player_h player, player_retrieve_buffer_cb callback, void *user_data)
{
return __unset_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player);
}
-#endif
int player_unset_completed_cb(player_h player)
{
return __unset_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player);
}
-int player_set_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data)
+int player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data)
+{
+ return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME, player, callback, user_data);
+}
+
+int player_unset_media_packet_video_frame_decoded_cb(player_h player)
+{
+ return __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME, player);
+}
+
+int player_set_media_packet_audio_frame_decoded_cb(player_h player, media_format_h format,
+ player_audio_extract_option_e opt, player_media_packet_audio_decoded_cb callback, void *user_data)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ player_cli_s *pc = (player_cli_s *)player;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_PACKET_AUDIO_FRAME_DECODED_CB;
char *ret_buf = NULL;
- muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PD;
- int set = 1;
+ media_format_mimetype_e mimetype = MEDIA_FORMAT_MAX;
+ int channel = 0;
+ int samplerate = 0;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(callback);
+ PLAYER_RANGE_ARG_CHECK(opt, PLAYER_AUDIO_EXTRACT_DEFAULT, PLAYER_AUDIO_EXTRACT_NO_SYNC_AND_DEINTERLEAVE);
LOGD("ENTER");
- LOGW("DEPRECATION WARNING: player_set_progressive_download_message_cb() is deprecated and will be removed from next release.");
- if (!_player_check_network_availability())
- return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+ if (format) {
+ media_format_ref(format);
+ if (media_format_get_audio_info(format, &mimetype, &channel, &samplerate, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE) {
+ LOGE("failed to get audio info from media format.");
+ media_format_unref(format);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ media_format_unref(format);
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
+ if (mimetype < MEDIA_FORMAT_PCM || mimetype > MEDIA_FORMAT_PCM_U32BE) {
+ LOGW("Not supported audio format type : 0x%X", mimetype);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ }
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- LOGI("Event type : %d ", type);
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_unset_progressive_download_message_cb(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PD;
- int set = 0;
-
- LOGD("ENTER");
- LOGW("DEPRECATION WARNING: player_unset_progressive_download_message_cb() is deprecated and will be removed from next release.");
-
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
-
-}
-
-int player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
- int set = 1;
+ LOGD("pcm spec : 0x%X, %d, %d", mimetype, channel, samplerate);
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "opt", opt,
+ MUSE_TYPE_INT, "mimetype", mimetype,
+ MUSE_TYPE_INT, "channel", channel,
+ MUSE_TYPE_INT, "samplerate", samplerate);
if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = callback;
- pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = user_data;
- LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
+ pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME] = callback;
+ pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME] = user_data;
+ LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME);
}
g_free(ret_buf);
return ret;
}
-int player_unset_media_packet_video_frame_decoded_cb(player_h player)
+int player_unset_media_packet_audio_frame_decoded_cb(player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
- int set = 0;
-
- LOGD("ENTER");
-
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
+ return __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME, player);
}
int player_set_video_stream_changed_cb(player_h player, player_video_stream_changed_cb callback, void *user_data)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
- int set = 1;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- LOGI("Event type : %d ", type);
- }
-
- g_free(ret_buf);
- return ret;
+ return __set_callback(MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player, callback, user_data);
}
int player_unset_video_stream_changed_cb(player_h player)
{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
- int set = 0;
-
- LOGD("ENTER");
-
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
+ return __unset_callback(MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player);
}
-int player_set_media_stream_buffer_status_cb(player_h player, player_stream_type_e stream_type, player_media_stream_buffer_status_cb callback, void *user_data)
+int player_set_media_stream_buffer_status_cb(player_h player,
+ player_stream_type_e stream_type, player_media_stream_buffer_status_cb callback, void *user_data)
{
+ muse_player_event_e type;
+
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- muse_player_event_e type;
- int set = 1;
LOGD("ENTER");
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
+ if (stream_type == PLAYER_STREAM_TYPE_VIDEO) {
type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
+ } else if (stream_type == PLAYER_STREAM_TYPE_AUDIO) {
type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
- else {
+ } else {
LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
return PLAYER_ERROR_INVALID_PARAMETER;
}
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- LOGI("Event type : %d ", type);
- }
-
- g_free(ret_buf);
- return ret;
+ return __set_callback(type, player, callback, user_data);
}
int player_unset_media_stream_buffer_status_cb(player_h player, player_stream_type_e stream_type)
{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
muse_player_event_e type;
- int set = 0;
+
+ PLAYER_INSTANCE_CHECK(player);
LOGD("ENTER");
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
+ if (stream_type == PLAYER_STREAM_TYPE_VIDEO) {
type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
+ } else if (stream_type == PLAYER_STREAM_TYPE_AUDIO) {
type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
- else {
+ } else {
LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
return PLAYER_ERROR_INVALID_PARAMETER;
}
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
+ return __unset_callback(type, player);
}
-int player_set_media_stream_seek_cb(player_h player, player_stream_type_e stream_type, player_media_stream_seek_cb callback, void *user_data)
+int player_set_media_stream_seek_cb(player_h player,
+ player_stream_type_e stream_type, player_media_stream_seek_cb callback, void *user_data)
{
+ muse_player_event_e type;
+
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- muse_player_event_e type;
- int set = 1;
LOGD("ENTER");
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
+ if (stream_type == PLAYER_STREAM_TYPE_VIDEO) {
type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
+ } else if (stream_type == PLAYER_STREAM_TYPE_AUDIO) {
type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
- else {
+ } else {
LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
return PLAYER_ERROR_INVALID_PARAMETER;
}
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- LOGI("Event type : %d ", type);
- }
-
- g_free(ret_buf);
- return ret;
+ return __set_callback(type, player, callback, user_data);
}
int player_unset_media_stream_seek_cb(player_h player, player_stream_type_e stream_type)
{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
muse_player_event_e type;
- int set = 0;
+
+ PLAYER_INSTANCE_CHECK(player);
LOGD("ENTER");
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
+ if (stream_type == PLAYER_STREAM_TYPE_VIDEO) {
type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
+ } else if (stream_type == PLAYER_STREAM_TYPE_AUDIO) {
type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
- else {
+ } else {
LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
return PLAYER_ERROR_INVALID_PARAMETER;
}
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
+ return __unset_callback(type, player);
}
/* TODO Implement raw data socket channel */
int player_push_media_stream(player_h player, media_packet_h packet)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(packet);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ int packet_ret = MEDIA_PACKET_ERROR_NONE;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_PUSH_MEDIA_STREAM;
char *ret_buf = NULL;
player_push_media_msg_type push_media;
media_format_h format;
bool is_video;
bool is_audio;
+ bool is_eos;
+ int arr_msg_len = 0;
+ char *codec_data = NULL;
+ unsigned int codec_data_size = 0;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(packet);
LOGD("ENTER");
- media_packet_get_buffer_data_ptr(packet, (void **)&buf);
- media_packet_get_buffer_size(packet, &push_media.size);
- media_packet_get_pts(packet, &push_media.pts);
- media_packet_get_format(packet, &format);
- media_packet_get_flags(packet, &push_media.flags);
+ if (media_packet_get_buffer_data_ptr(packet, (void **)&buf) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed to get buffer data ptr");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
- push_media.buf_type = PUSH_MEDIA_BUF_TYPE_RAW;
+ if (media_packet_get_buffer_size(packet, &push_media.size) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed to get buffer size");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ if (media_packet_get_pts(packet, &push_media.pts) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed to get buffer pts");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ if (media_packet_get_format(packet, &format) != MEDIA_PACKET_ERROR_NONE) { /* format ref count is increased */
+ LOGE("failed to get media format");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
- media_packet_is_video(packet, &is_video);
- media_packet_is_audio(packet, &is_audio);
+ packet_ret = media_packet_get_flags(packet, &push_media.flags);
+ packet_ret |= media_packet_is_video(packet, &is_video);
+ packet_ret |= media_packet_is_audio(packet, &is_audio);
+ packet_ret |= media_packet_is_end_of_stream(packet, &is_eos);
if (is_video)
- media_format_get_video_info(format, &push_media.mimetype, &push_media.width, &push_media.height, NULL, NULL);
+ packet_ret |= media_format_get_video_info(format, &push_media.mimetype,
+ &push_media.width, &push_media.height, NULL, NULL);
else if (is_audio)
- media_format_get_audio_info(format, &push_media.mimetype, NULL, NULL, NULL, NULL);
+ packet_ret |= media_format_get_audio_info(format, &push_media.mimetype,
+ &push_media.channels, &push_media.samplerate, NULL, NULL);
media_format_unref(format);
+ if (packet_ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed to get media packet info");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ if (media_packet_get_codec_data(packet, (void **)&codec_data, &codec_data_size) == MEDIA_PACKET_ERROR_NONE) {
+ if (codec_data_size > 0 && codec_data_size <= sizeof(push_media.codec_data))
+ memcpy(push_media.codec_data, codec_data, codec_data_size);
+ }
+
+ push_media.codec_data_size = codec_data_size;
+ push_media.buf_type = PUSH_MEDIA_BUF_TYPE_RAW;
+
#ifdef __UN_USED
+ int arr_buf_len = 0;
+
if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM) {
bo = tbm_bo_alloc(pc->cb_info->bufmgr, push_media.size, TBM_BO_DEFAULT);
if (bo == NULL) {
goto ERROR;
}
- player_msg_send_array_fd(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char), tfd);
+ arr_msg_len = (msg_size / sizeof(int) + (msg_size % sizeof(int) ? 1 : 0));
+ PLAYER_SEND_MSG_WITH_TFD(api, pc, tfd, ret_buf, ret,
+ MUSE_TYPE_ARRAY, "push_media_msg", arr_msg_len, (int *)push_media_msg);
+
} else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG) {
buf_size = (int)push_media.size;
- player_msg_send_array2(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char), buf, buf_size, sizeof(char));
+
+ arr_msg_len = (msg_size / sizeof(int) + (msg_size % sizeof(int) ? 1 : 0));
+ arr_buf_len = (buf_size / sizeof(int) + (buf_size % sizeof(int) ? 1 : 0));
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_ARRAY, "push_media_msg", arr_msg_len, (int *)push_media_msg,
+ MUSE_TYPE_ARRAY, "buf", arr_buf_len, (int *)buf);
+
} else
#endif
if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW) {
buf_size = (int)push_media.size;
- muse_client_ipc_push_data(pc->cb_info->data_fd, buf, buf_size, push_media.pts);
- player_msg_send_array(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char));
+ if ((muse_client_ipc_push_data(pc->cb_info->data_fd, buf, buf_size, push_media.pts) < 0) && (!is_eos)) {
+ LOGE("failed to send data");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ arr_msg_len = (msg_size / sizeof(int) + (msg_size % sizeof(int) ? 1 : 0));
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_ARRAY, "push_media_msg", arr_msg_len, (int *)push_media_msg);
}
LOGD("ret_buf %s", ret_buf);
#ifdef __UN_USED
- ERROR:
- if (tfd > INVALID_DEFAULT_VALUE)
- close(tfd);
+ERROR:
+
+ PLAYER_CLOSE_FD(tfd);
if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
tbm_bo_unref(bo);
return ret;
}
-int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format)
+int player_foreach_media_stream_supported_format(player_h player, player_supported_media_format_cb callback, void *user_data)
{
+ int ret = PLAYER_ERROR_NONE;
+ player_cli_s *pc = (player_cli_s *)player;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_SUPPORTED_FORMAT;
+ char *ret_buf = NULL;
+ int format_info[MAX_SUPPORTED_MEDIA_FORMAT] = {0,};
+ int len = 0, idx = 0;
+
PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(callback);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
+ player_msg_get_type(len, ret_buf, INT);
+ player_msg_get_array(format_info, ret_buf);
+
+ LOGD("num of format %d", len);
+ for (idx = 0 ; idx < len ; idx++) {
+ if (!callback(format_info[idx], user_data)) {
+ LOGW("stop foreach callback");
+ break;
+ }
+ }
+
+ LOGD("LEAVE 0x%X", ret);
+ g_free(ret_buf);
+ return ret;
+}
+
+int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format)
+{
g_return_val_if_fail(format, PLAYER_ERROR_INVALID_OPERATION);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO;
char *ret_buf = NULL;
media_format_mimetype_e mimetype;
int bit = 0;
int frame_rate = 0;
+ PLAYER_INSTANCE_CHECK(player);
+
LOGD("ENTER");
media_format_ref(format);
return PLAYER_ERROR_INVALID_PARAMETER;
}
- player_msg_send7(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, width, INT, height, INT, avg_bps, INT, max_bps, INT, frame_rate);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "type", type,
+ MUSE_TYPE_INT, "mimetype", mimetype,
+ MUSE_TYPE_INT, "width", width,
+ MUSE_TYPE_INT, "height", height,
+ MUSE_TYPE_INT, "avg_bps", avg_bps,
+ MUSE_TYPE_INT, "max_bps", max_bps,
+ MUSE_TYPE_INT, "frame_rate", frame_rate);
+
} else if (type == PLAYER_STREAM_TYPE_AUDIO) {
if (media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &avg_bps) != MEDIA_FORMAT_ERROR_NONE) {
LOGE("failed to get audio info from format.");
return PLAYER_ERROR_INVALID_PARAMETER;
}
- player_msg_send6(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, channel, INT, samplerate, INT, avg_bps, INT, bit);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "type", type,
+ MUSE_TYPE_INT, "mimetype", mimetype,
+ MUSE_TYPE_INT, "channel", channel,
+ MUSE_TYPE_INT, "samplerate", samplerate,
+ MUSE_TYPE_INT, "avg_bps", avg_bps,
+ MUSE_TYPE_INT, "bit", bit);
+
}
media_format_unref(format);
pc->push_media_stream = TRUE;
int player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size)
{
int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(type, PLAYER_STREAM_TYPE_AUDIO, PLAYER_STREAM_TYPE_VIDEO);
+ PLAYER_CHECK_CONDITION(max_size > 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
LOGD("ENTER");
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT64, max_size);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "type", type,
+ MUSE_TYPE_INT64, "max_size", (INT64)max_size);
g_free(ret_buf);
return ret;
int player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *pmax_size)
{
int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pmax_size);
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE;
char *ret_buf = NULL;
unsigned long long max_size;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pmax_size);
+ PLAYER_RANGE_ARG_CHECK(type, PLAYER_STREAM_TYPE_AUDIO, PLAYER_STREAM_TYPE_VIDEO);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "type", type);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get_type(max_size, ret_buf, INT64);
*pmax_size = max_size;
int player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent)
{
int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(type, PLAYER_STREAM_TYPE_DEFAULT, PLAYER_STREAM_TYPE_TEXT);
+
LOGD("ENTER");
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, percent);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "type", type,
+ MUSE_TYPE_INT, "percent", (int)percent);
g_free(ret_buf);
return ret;
int player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *ppercent)
{
int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(ppercent);
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
char *ret_buf = NULL;
- uint percent;
+ unsigned int percent;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(ppercent);
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "type", type);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(percent, ret_buf);
*ppercent = percent;
int player_get_track_count(player_h player, player_stream_type_e type, int *pcount)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pcount);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_COUNT;
char *ret_buf = NULL;
int count;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pcount);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "type", type);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(count, ret_buf);
*pcount = count;
int player_get_current_track(player_h player, player_stream_type_e type, int *pindex)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pindex);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_GET_CURRENT_TRACK;
char *ret_buf = NULL;
int index;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pindex);
+
LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "type", type);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(index, ret_buf);
*pindex = index;
int player_select_track(player_h player, player_stream_type_e type, int index)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SELECT_TRACK;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+
LOGD("ENTER");
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, index);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "type", type, MUSE_TYPE_INT, "index", index);
g_free(ret_buf);
return ret;
int player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **pcode)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pcode);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE;
char *ret_buf = NULL;
char code[MUSE_MSG_MAX_LENGTH] = { 0, };
int code_len = 0;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pcode);
+
LOGD("ENTER");
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, index);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "type", type, MUSE_TYPE_INT, "index", index);
if (ret == PLAYER_ERROR_NONE) {
- bool recv_ret = TRUE;
- player_msg_get1_string(ret_buf, code_len, INT, code, recv_ret);
+ bool recv_ret = true;
+ recv_ret = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT, "code_len", (void *)&code_len,
+ MUSE_TYPE_STRING, "code", (void *)code,
+ INVALID_MUSE_TYPE_VALUE);
if (recv_ret)
*pcode = strndup(code, code_len);
else
int player_foreach_adaptive_variant(player_h player, player_adaptive_variant_cb callback, void *user_data)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_GET_ADAPTIVE_VARIANT_INFO;
char *ret_buf = NULL;
char var_info[MUSE_MSG_MAX_LENGTH] = { 0, };
char *token = NULL;
char *ptr = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(callback);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get_type(num, ret_buf, INT);
if (num > 0)
int player_set_max_adaptive_variant_limit(player_h player, int bandwidth, int width, int height)
{
int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SET_MAX_ADAPTIVE_VARIANT_LIMIT;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_CHECK_CONDITION(bandwidth >= -1 && width >= -1 && height >= -1,
+ PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
LOGD("ENTER");
- player_msg_send3(api, pc, ret_buf, ret, INT, bandwidth, INT, width, INT, height);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "bandwidth", bandwidth,
+ MUSE_TYPE_INT, "width", width,
+ MUSE_TYPE_INT, "height", height);
g_free(ret_buf);
LOGD("LEAVE 0x%X", ret);
int player_get_max_adaptive_variant_limit(player_h player, int *pbandwidth, int *pwidth, int *pheight)
{
int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pbandwidth || pwidth || pheight);
-
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_GET_MAX_ADAPTIVE_VARIANT_LIMIT;
char *ret_buf = NULL;
int bandwidth = -1, width = -1, height = -1;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(pbandwidth || pwidth || pheight);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
-
- player_msg_get3(ret_buf, bandwidth, INT, width, INT, height, INT, ret_val);
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT, "bandwidth", (void *)&bandwidth,
+ MUSE_TYPE_INT, "width", (void *)&width,
+ MUSE_TYPE_INT, "height", (void *)&height,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
if (pbandwidth) *pbandwidth = bandwidth;
if (pwidth) *pwidth = width;
int player_set_audio_only(player_h player, bool audio_only)
{
int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_ONLY;
char *ret_buf = NULL;
player_state_e state = PLAYER_STATE_NONE;
- LOGD("ENTER audio_only: %d", audio_only);
+ PLAYER_INSTANCE_CHECK(player);
- player_msg_send(MUSE_PLAYER_API_GET_STATE, pc, ret_buf, ret);
+ LOGD("ENTER audio_only: %d", audio_only);
/* check player state */
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(state, ret_buf);
- g_free(ret_buf);
- ret_buf = NULL;
-
- if (state < PLAYER_STATE_READY) {
- LOGE("Invalid state %d", state);
- return PLAYER_ERROR_INVALID_STATE;
- }
- } else {
- g_free(ret_buf);
- ret_buf = NULL;
+ if (_get_current_state(pc, &state) != PLAYER_ERROR_NONE) {
+ LOGE("Failed to get state");
return PLAYER_ERROR_INVALID_OPERATION;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (EVAS_HANDLE(pc)) {
- pc->is_audio_only = (gboolean)audio_only;
- return PLAYER_ERROR_NONE;
+ if (state < PLAYER_STATE_READY) {
+ LOGE("Invalid state %d", state);
+ return PLAYER_ERROR_INVALID_STATE;
}
-#endif
- player_msg_send1(api, pc, ret_buf, ret, INT, audio_only);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "audio_only", (int)audio_only);
+
g_free(ret_buf);
LOGD("LEAVE 0x%X", ret);
- return ret;
+ return ret;
}
int player_is_audio_only(player_h player, bool *paudio_only)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(paudio_only);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_IS_AUDIO_ONLY;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int audio_only = 0;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(paudio_only);
+
LOGD("ENTER");
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (EVAS_HANDLE(pc)) {
- *paudio_only = (bool)pc->is_audio_only;
- return PLAYER_ERROR_NONE;
- }
-#endif
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(audio_only, ret_buf);
*paudio_only = (bool)audio_only;
}
+
g_free(ret_buf);
LOGD("LEAVE 0x%X", ret);
+
return ret;
}
-int player_set_streaming_buffering_time(player_h player, int buffer_ms, int rebuffer_ms)
+int player_set_streaming_buffering_time(player_h player, int prebuffer_ms, int rebuffer_ms)
{
+#define MIN_BUFFER_TIME -1
int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_BUFFERING_TIME;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_CHECK_CONDITION(prebuffer_ms >= MIN_BUFFER_TIME && rebuffer_ms >= MIN_BUFFER_TIME,
+ PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
LOGD("ENTER");
- player_msg_send2(api, pc, ret_buf, ret, INT, buffer_ms, INT, rebuffer_ms);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "prebuffer_ms", prebuffer_ms,
+ MUSE_TYPE_INT, "rebuffer_ms", rebuffer_ms);
g_free(ret_buf);
LOGD("LEAVE 0x%X", ret);
return ret;
}
-int player_get_streaming_buffering_time(player_h player, int *buffer_ms, int *rebuffer_ms)
+int player_get_streaming_buffering_time(player_h player, int *prebuffer_ms, int *rebuffer_ms)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(buffer_ms || rebuffer_ms);
-
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_BUFFERING_TIME;
- player_cli_s *pc = (player_cli_s *) player;
- int buffering_time = 0, rebuffering_time = 0;
+ player_cli_s *pc = (player_cli_s *)player;
+ int prebuffering_time = 0, rebuffering_time = 0;
char *ret_buf = NULL;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(prebuffer_ms || rebuffer_ms);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
bool ret_val = true;
-
- player_msg_get2(ret_buf, buffering_time, INT, rebuffering_time, INT, ret_val);
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT, "prebuffer_ms", (void *)&prebuffering_time,
+ MUSE_TYPE_INT, "rebuffer_ms", (void *)&rebuffering_time,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
- if (buffer_ms) *buffer_ms = buffering_time;
+ if (prebuffer_ms) *prebuffer_ms = prebuffering_time;
if (rebuffer_ms) *rebuffer_ms = rebuffering_time;
} else {
ret = PLAYER_ERROR_INVALID_OPERATION;
return ret;
}
-int player_360_set_enable(player_h player, bool enable)
+int player_360_is_content_spherical(player_h player, bool *is_spherical)
{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_360_IS_CONTENT_SPHERICAL;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ int val = 0;
+
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(is_spherical);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+ if (ret == PLAYER_ERROR_NONE) {
+ player_msg_get(val, ret_buf);
+ *is_spherical = val;
+ }
+ g_free(ret_buf);
+
+ LOGD("LEAVE 0x%X", ret);
+ return ret;
+}
+
+int player_360_set_enabled(player_h player, bool enabled)
+{
int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_360_SET_ENABLE;
- player_cli_s *pc = (player_cli_s *) player;
+ muse_player_api_e api = MUSE_PLAYER_API_360_SET_ENABLED;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
- int val = (int)enable;
+ int val = (int)enabled;
- LOGD("ENTER %d", enable);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
+ PLAYER_INSTANCE_CHECK(player);
+
+ LOGD("ENTER %d", enabled);
- player_msg_send1(api, pc, ret_buf, ret, INT, val);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "val", val);
g_free(ret_buf);
LOGD("LEAVE 0x%X", ret);
int player_360_is_enabled(player_h player, bool *enabled)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(enabled);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_360_IS_ENABLED;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
int val = 0;
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(enabled);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
player_msg_get(val, ret_buf);
*enabled = val;
int player_360_set_direction_of_view(player_h player, float yaw, float pitch)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_360_SET_DIRECTION_OF_VIEW;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(yaw, (float)-M_PI, (float)M_PI);
+ PLAYER_RANGE_ARG_CHECK(pitch, ((float)-M_PI / 2), ((float)M_PI / 2));
+
LOGD("ENTER %f %f", yaw, pitch);
- player_msg_send2(api, pc, ret_buf, ret, DOUBLE, yaw, DOUBLE, pitch);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_DOUBLE, "yaw", (double)yaw,
+ MUSE_TYPE_DOUBLE, "pitch", (double)pitch);
+
g_free(ret_buf);
LOGD("LEAVE 0x%X", ret);
int player_360_get_direction_of_view(player_h player, float *yaw, float *pitch)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(yaw && pitch);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_360_GET_DIRECTION_OF_VIEW;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
double yaw_val = -1;
double pitch_val = -1;
char *ret_buf = NULL;
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(yaw && pitch);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
- player_msg_get2(ret_buf, yaw_val, DOUBLE, pitch_val, DOUBLE, ret_val);
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_DOUBLE, "yaw_val", (void *)&yaw_val,
+ MUSE_TYPE_DOUBLE, "pitch_val", (void *)&pitch_val,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
*yaw = (float)yaw_val;
*pitch = (float)pitch_val;
int player_360_set_zoom(player_h player, float level)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_360_SET_ZOOM;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(level, 1.0, 10.0);
+
LOGD("ENTER %f", level);
- player_msg_send1(api, pc, ret_buf, ret, DOUBLE, level);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_DOUBLE, "level", (double)level);
g_free(ret_buf);
LOGD("LEAVE 0x%X", ret);
int player_360_get_zoom(player_h player, float *level)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(level);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_360_GET_ZOOM;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
double zoom = -1;
char *ret_buf = NULL;
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(level);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
if (player_msg_get_type(zoom, ret_buf, DOUBLE)) {
LOGD("LEAVE 0x%X", ret);
return ret;
-
}
int player_360_set_field_of_view(player_h player, int horizontal_degrees, int vertical_degrees)
{
- PLAYER_INSTANCE_CHECK(player);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_360_SET_FIELD_OF_VIEW;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
char *ret_buf = NULL;
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(horizontal_degrees, 1, 360);
+ PLAYER_RANGE_ARG_CHECK(vertical_degrees, 1, 180);
+
LOGD("ENTER %d %d", horizontal_degrees, vertical_degrees);
- player_msg_send2(api, pc, ret_buf, ret, INT, horizontal_degrees, INT, vertical_degrees);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "horizontal_degrees", horizontal_degrees,
+ MUSE_TYPE_INT, "vertical_degrees", vertical_degrees);
g_free(ret_buf);
LOGD("LEAVE 0x%X", ret);
int player_360_get_field_of_view(player_h player, int *horizontal_degrees, int *vertical_degrees)
{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(horizontal_degrees && vertical_degrees);
int ret = PLAYER_ERROR_NONE;
muse_player_api_e api = MUSE_PLAYER_API_360_GET_FIELD_OF_VIEW;
- player_cli_s *pc = (player_cli_s *) player;
+ player_cli_s *pc = (player_cli_s *)player;
int h_val = -1;
int v_val = -1;
char *ret_buf = NULL;
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(horizontal_degrees && vertical_degrees);
+
LOGD("ENTER");
- player_msg_send(api, pc, ret_buf, ret);
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
if (ret == PLAYER_ERROR_NONE) {
- bool ret_val = TRUE;
- player_msg_get2(ret_buf, h_val, INT, v_val, INT, ret_val);
+ bool ret_val = true;
+ ret_val = _player_get_param_value(ret_buf,
+ MUSE_TYPE_INT, "h_val", (void *)&h_val,
+ MUSE_TYPE_INT, "v_val", (void *)&v_val,
+ INVALID_MUSE_TYPE_VALUE);
if (ret_val) {
*horizontal_degrees = h_val;
*vertical_degrees = v_val;
LOGD("LEAVE 0x%X", ret);
return ret;
}
+
+int player_360_set_zoom_with_field_of_view(player_h player, float level, int horizontal_degrees, int vertical_degrees)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_360_SET_ZOOM_WITH_FIELD_OF_VIEW;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_OPENGL);
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_SPHERICAL_VIDEO);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(horizontal_degrees, 1, 360);
+ PLAYER_RANGE_ARG_CHECK(vertical_degrees, 1, 180);
+ PLAYER_RANGE_ARG_CHECK(level, 1.0, 10.0);
+
+ LOGD("ENTER %f %d %d", level, horizontal_degrees, vertical_degrees);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_DOUBLE, "level", (double)level,
+ MUSE_TYPE_INT, "horizontal_degrees", horizontal_degrees,
+ MUSE_TYPE_INT, "vertical_degrees", vertical_degrees);
+
+ g_free(ret_buf);
+ LOGD("LEAVE 0x%X", ret);
+ return ret;
+}
+
+int player_set_replaygain_enabled(player_h player, bool enabled)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_REPLAYGAIN_ENABLED;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ int val = (int)enabled;
+
+ PLAYER_INSTANCE_CHECK(player);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "val", val);
+ g_free(ret_buf);
+ return ret;
+}
+
+int player_is_replaygain_enabled(player_h player, bool *enabled)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_IS_REPLAYGAIN_ENABLED;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ int val = -1;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(enabled);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+ if (ret == PLAYER_ERROR_NONE) {
+ player_msg_get(val, ret_buf);
+ *enabled = (bool)val;
+ }
+
+ g_free(ret_buf);
+ return ret;
+}
+
+int player_audio_pitch_set_enabled(player_h player, bool enabled)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_PITCH_SET_ENABLED;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ int val = (int)enabled;
+
+ PLAYER_INSTANCE_CHECK(player);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "val", val);
+ g_free(ret_buf);
+ return ret;
+}
+
+int player_audio_pitch_is_enabled(player_h player, bool *enabled)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_PITCH_IS_ENABLED;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ int val = -1;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(enabled);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+ if (ret == PLAYER_ERROR_NONE) {
+ player_msg_get(val, ret_buf);
+ *enabled = (bool)val;
+ }
+
+ g_free(ret_buf);
+ return ret;
+}
+
+int player_audio_pitch_set_value(player_h player, float value)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_PITCH_SET_VALUE;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(value, 0.5, 2.0);
+
+ LOGD("ENTER %1.3f", value);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_DOUBLE, "pitch", (double)value);
+ g_free(ret_buf);
+
+ LOGD("LEAVE 0x%X", ret);
+ return ret;
+}
+
+int player_audio_pitch_get_value(player_h player, float *value)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_PITCH_GET_VALUE;
+ player_cli_s *pc = (player_cli_s *)player;
+ double pitch = 0.0;
+ char *ret_buf = NULL;
+
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(value);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
+ if (ret == PLAYER_ERROR_NONE) {
+ if (player_msg_get_type(pitch, ret_buf, DOUBLE)) {
+ *value = (float)pitch;
+ } else {
+ LOGE("failed to get pitch value");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ }
+ }
+
+ g_free(ret_buf);
+
+ LOGD("LEAVE 0x%X", ret);
+ return ret;
+}
+
+int player_audio_offload_foreach_supported_format(player_h player, player_supported_media_format_cb callback, void *user_data)
+{
+ int ret = PLAYER_ERROR_NONE;
+ player_cli_s *pc = (player_cli_s *)player;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_GET_SUPPORTED_FORMAT;
+ char *ret_buf = NULL;
+ int format_info[MAX_SUPPORTED_MEDIA_FORMAT] = {0,};
+ int len = 0, idx = 0;
+
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_AUDIO_OFFLOAD);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(callback);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
+ player_msg_get_type(len, ret_buf, INT);
+ player_msg_get_array(format_info, ret_buf);
+
+ LOGD("num of format %d", len);
+ for (idx = 0 ; idx < len ; idx++) {
+ if (!callback(format_info[idx], user_data)) {
+ LOGW("stop foreach callback");
+ break;
+ }
+ }
+
+ LOGD("LEAVE 0x%X", ret);
+ g_free(ret_buf);
+ return ret;
+}
+
+int player_audio_offload_set_enabled(player_h player, bool enabled)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_SET_ENABLED;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ int val = (int)enabled;
+
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_AUDIO_OFFLOAD);
+ PLAYER_INSTANCE_CHECK(player);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "val", val);
+ g_free(ret_buf);
+ return ret;
+}
+
+int player_audio_offload_is_enabled(player_h player, bool *enabled)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_IS_ENABLED;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ int val = -1;
+
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_AUDIO_OFFLOAD);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(enabled);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+ if (ret == PLAYER_ERROR_NONE) {
+ player_msg_get(val, ret_buf);
+ *enabled = (bool)val;
+ }
+
+ g_free(ret_buf);
+ return ret;
+}
+
+int player_audio_offload_is_activated(player_h player, bool *activated)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_IS_ACTIVATED;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ int val = -1;
+
+ PLAYER_FEATURE_CHECK(PLAYER_FEATURE_AUDIO_OFFLOAD);
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(activated);
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+ if (ret == PLAYER_ERROR_NONE) {
+ player_msg_get(val, ret_buf);
+ *activated = (bool)val;
+ }
+
+ g_free(ret_buf);
+ return ret;
+}
+
+int player_set_audio_codec_type(player_h player, player_codec_type_e codec_type)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_RANGE_ARG_CHECK(codec_type, PLAYER_CODEC_TYPE_HW, PLAYER_CODEC_TYPE_SW);
+
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CODEC_TYPE;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+
+ LOGD("ENTER codec: %d", codec_type);
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "stream_type", PLAYER_STREAM_TYPE_AUDIO,
+ MUSE_TYPE_INT, "codec_type", codec_type);
+
+ g_free(ret_buf);
+ LOGD("LEAVE");
+ return ret;
+
+}
+
+int player_get_audio_codec_type(player_h player, player_codec_type_e *codec_type)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(codec_type);
+
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_TYPE;
+ player_cli_s *pc = (player_cli_s *)player;
+ char *ret_buf = NULL;
+ int type = 0;
+
+ LOGD("ENTER");
+
+ PLAYER_SEND_MSG(api, pc, ret_buf, ret,
+ MUSE_TYPE_INT, "stream_type", PLAYER_STREAM_TYPE_AUDIO);
+ if (ret == PLAYER_ERROR_NONE) {
+ player_msg_get(type, ret_buf);
+ *codec_type = type;
+ }
+
+ g_free(ret_buf);
+ LOGD("LEAVE codec: %d", *codec_type);
+ return ret;
+}