#include <sound_manager.h>
#include <sound_manager_internal.h>
#include <dlog.h>
-#include "muse_player.h"
#include "legacy_player.h"
#include "legacy_player_internal.h"
#include "legacy_player_private.h"
static bool __lplayer_check_enabled_user_cb_lock(int type)
{
switch (type) {
- case MUSE_PLAYER_EVENT_TYPE_PREPARE: /* fall through */
- case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO: /* fall through */
- case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO: /* fall through */
+ case LEGACY_PLAYER_CALLBACK_TYPE_PREPARE: /* fall through */
+ case LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO: /* fall through */
+ case LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO: /* fall through */
return true;
default:
return false;
static void __lplayer_buffer_status_callback(legacy_player_t *handle, MMMessageParamType *msg)
{
- muse_player_event_e event_type;
- muse_player_event_e event_type_internal;
+ legacy_player_callback_type_e event_type;
+ legacy_player_callback_type_e event_type_internal;
player_media_stream_buffer_status_e buffer_status;
unsigned long long buffer_bytes;
/* check public api callback, higher priority */
if (msg->buffer_status.stream_type == MM_PLAYER_STREAM_TYPE_AUDIO) {
- event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
- event_type_internal = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+ event_type = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
+ event_type_internal = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
} else if (msg->buffer_status.stream_type == MM_PLAYER_STREAM_TYPE_VIDEO) {
- event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
- event_type_internal = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+ event_type = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
+ event_type_internal = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
} else {
LOGE("invalid stream type %d", msg->buffer_status.stream_type);
return;
static void __lplayer_video_stream_changed_callback(legacy_player_t *handle)
{
int ret = MM_ERROR_NONE;
- muse_player_event_e event_type = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
+ legacy_player_callback_type_e event_type = LEGACY_PLAYER_CALLBACK_TYPE_VIDEO_STREAM_CHANGED;
int width = 0;
int height = 0;
int fps = 0;
return;
}
-static void __lplayer_default_callback(legacy_player_t *handle, muse_player_event_e type)
+static void __lplayer_default_callback(legacy_player_t *handle, legacy_player_callback_type_e type)
{
LOGD("type %d", type);
L_PLAYER_USER_CB_UNLOCK(handle, type);
}
+static void __lplayer_unset_callback(legacy_player_t *handle,
+ legacy_player_callback_type_e type, bool release_data)
+{
+ LOGD("type : %d ", type);
+
+ L_PLAYER_USER_CB_LOCK(handle, type);
+
+ handle->user_cb[type] = NULL;
+
+ if (release_data)
+ g_free(handle->user_data[type]);
+ handle->user_data[type] = NULL;
+
+ L_PLAYER_USER_CB_UNLOCK(handle, type);
+}
+
static int __lplayer_message_callback(int message, void *param, void *user_data)
{
legacy_player_t *handle = (legacy_player_t *)user_data;
switch (message) {
case MM_MESSAGE_ERROR: /* 0x01 */
err_code = _lplayer_convert_error_code(msg->code, (char *)__FUNCTION__);
-
- L_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- if (PLAYER_ERROR_NOT_SUPPORTED_FILE == err_code && handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
- LOGW("Failed to pause, so prepare cb will be released soon");
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- if (handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
- g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- }
+ if (err_code == PLAYER_ERROR_NOT_SUPPORTED_FILE) {
+ LOGE("failed to pause, so prepare cb will be released soon");
+ __lplayer_unset_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE, true);
}
- L_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
break;
case MM_MESSAGE_STATE_CHANGED: /* 0x03 */
LOGI("state chagned from: %d, to: %d (CAPI State: %d)", msg->state.previous, msg->state.current, handle->state);
if (msg->state.previous == MM_PLAYER_STATE_READY && msg->state.current == MM_PLAYER_STATE_PAUSED) {
- L_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
+ L_PLAYER_USER_CB_LOCK(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE);
+ if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE]) {
/* async && prepared cb has been set */
LOGD("Prepared! [current state : %d]", handle->state);
PLAYER_TRACE_ASYNC_END("MM:PLAYER:PREPARE_ASYNC", *(int *)handle);
__lplayer_update_state(handle, PLAYER_INTERNAL_STATE_READY);
- ((legacy_player_prepared_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
+ ((legacy_player_prepared_cb)handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE])(handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE]);
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
+ handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE] = NULL;
+ handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE] = NULL;
}
- L_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ L_PLAYER_USER_CB_UNLOCK(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE);
}
break;
case MM_MESSAGE_BEGIN_OF_STREAM: /* 0x104 */
break;
case MM_MESSAGE_END_OF_STREAM: /* 0x105 */
LOGD("Playback is completed.");
- __lplayer_default_callback(handle, MUSE_PLAYER_EVENT_TYPE_COMPLETE);
+ __lplayer_default_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_COMPLETE);
break;
#ifdef TIZEN_FEATURE_EVAS_RENDERER
case MM_MESSAGE_GAPLESS_CONSTRUCTION: /* 0x105 */
LOGD("Retrieve exported buffers.");
- __lplayer_default_callback(handle, MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER);
+ __lplayer_default_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_RETURN_BUFFER);
break;
#endif
case MM_MESSAGE_BUFFERING: /* 0x103 */
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING])
- ((legacy_player_buffering_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING]) \
- (msg->connection.buffering, handle->user_data[MUSE_PLAYER_EVENT_TYPE_BUFFERING]);
+ if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_BUFFERING])
+ ((legacy_player_buffering_cb)handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_BUFFERING]) \
+ (msg->connection.buffering, handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_BUFFERING]);
break;
case MM_MESSAGE_STATE_INTERRUPTED: /* 0x04 */
if (msg->union_type == MM_MSG_UNION_STATE) {
}
LOGD("Interrupted");
- __lplayer_default_callback(handle, MUSE_PLAYER_EVENT_TYPE_INTERRUPT);
+ __lplayer_default_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_INTERRUPT);
break;
case MM_MESSAGE_CONNECTION_TIMEOUT: /* 0x102 */
LOGE("PLAYER_ERROR_CONNECTION_FAILED : CONNECTION_TIMEOUT");
err_code = PLAYER_ERROR_CONNECTION_FAILED;
break;
case MM_MESSAGE_UPDATE_SUBTITLE: /* 0x109 */
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SUBTITLE])
- ((legacy_player_subtitle_updated_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SUBTITLE]) \
- (msg->subtitle.duration, (char *)msg->data, handle->user_data[MUSE_PLAYER_EVENT_TYPE_SUBTITLE]);
+ if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_SUBTITLE])
+ ((legacy_player_subtitle_updated_cb)handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_SUBTITLE]) \
+ (msg->subtitle.duration, (char *)msg->data, handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_SUBTITLE]);
break;
case MM_MESSAGE_VIDEO_NOT_CAPTURED: /* 0x113 */
LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED");
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])
- ((legacy_player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) \
- (PLAYER_ERROR_VIDEO_CAPTURE_FAILED, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]);
+ if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_ERROR])
+ ((legacy_player_error_cb)handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_ERROR]) \
+ (PLAYER_ERROR_VIDEO_CAPTURE_FAILED, handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_ERROR]);
break;
case MM_MESSAGE_VIDEO_CAPTURED: /* 0x110 */
{
mmplayer_video_capture_t *capture = (mmplayer_video_capture_t *)msg->data;
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
+ if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE]) {
if (!capture || !capture->data) {
LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED : Failed to get capture data");
err_code = PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
capture->orientation, capture->width, capture->height, capture->size);
/* call application callback */
- ((legacy_player_video_captured_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE])(capture->data, \
- capture->width, capture->height, capture->size, handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
+ ((legacy_player_video_captured_cb)handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE])(capture->data, \
+ capture->width, capture->height, capture->size, handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE]);
}
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
+ handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE] = NULL;
+ handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE] = NULL;
}
/* capure->data have to be released to avoid mem leak in all cases. */
}
LOGD("Seek is completed");
- __lplayer_default_callback(handle, MUSE_PLAYER_EVENT_TYPE_SEEK);
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
+ __lplayer_default_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_SEEK);
+ __lplayer_unset_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_SEEK, false);
break;
case MM_MESSAGE_PLAY_POSITION:
LOGI("MM_MESSAGE_PLAY_POSITION (%"PRId64" ns)", msg->time.elapsed);
handle->last_play_position = msg->time.elapsed;
break;
case MM_MESSAGE_VIDEO_STREAM_CHANGED:
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED])
+ if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_VIDEO_STREAM_CHANGED])
__lplayer_video_stream_changed_callback(handle);
break;
case MM_MESSAGE_PUSH_BUFFER_STATUS:
break;
case MM_MESSAGE_PUSH_BUFFER_SEEK_DATA:
{
- muse_player_event_e event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
+ legacy_player_callback_type_e event_type = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_VIDEO_SEEK;
if (msg->seek_data.stream_type == MM_PLAYER_STREAM_TYPE_AUDIO)
- event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
+ event_type = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_AUDIO_SEEK;
if (handle->user_cb[event_type])
((legacy_player_media_stream_seek_cb)handle->user_cb[event_type])(event_type, msg->seek_data.offset, handle->user_data[event_type]);
break;
}
- if (err_code != PLAYER_ERROR_NONE && handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) {
+ if (err_code != PLAYER_ERROR_NONE && handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_ERROR]) {
handle->error_code = err_code;
LOGE("ERROR is occurred 0x%X", err_code);
- ((legacy_player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])(err_code, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]);
+ ((legacy_player_error_cb)handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_ERROR])(err_code, handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_ERROR]);
}
LPLAYER_FLEAVE();
}
}
-static int __lplayer_check_callback_precondition(legacy_player_t *handle, muse_player_event_e type, bool set)
+static int __lplayer_check_callback_precondition(legacy_player_t *handle, legacy_player_callback_type_e type, bool set)
{
int i = 0;
int size = 0;
player_internal_state_e cb_state = PLAYER_INTERNAL_STATE_NONE;
legacy_player_callback_pre_state_t callback_pre_state[] = {
- {MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_IDLE},
- {MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_IDLE},
- {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
- {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
- {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
- {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
- {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
- {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
- {MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
+ {LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_PACKET_VIDEO_FRAME, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_IDLE},
+ {LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_PACKET_AUDIO_FRAME, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_IDLE},
+ {LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
+ {LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
+ {LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
+ {LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
+ {LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_VIDEO_SEEK, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
+ {LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_STREAM_AUDIO_SEEK, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
+ {LEGACY_PLAYER_CALLBACK_TYPE_VIDEO_STREAM_CHANGED, PLAYER_INTERNAL_STATE_IDLE, PLAYER_INTERNAL_STATE_NONE},
};
size = sizeof(callback_pre_state)/sizeof(legacy_player_callback_pre_state_t);
__lplayer_set_buffer_export_callback(legacy_player_t *handle)
{
int ret = MM_ERROR_NONE;
- muse_player_event_e video_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
- muse_player_event_e audio_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME;
+ legacy_player_callback_type_e video_type = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_PACKET_VIDEO_FRAME;
+ legacy_player_callback_type_e audio_type = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_PACKET_AUDIO_FRAME;
if (handle->user_cb[video_type])
ret = mm_player_set_video_decoded_callback(handle->mm_handle,
{
legacy_player_t *handle;
int ret = MM_ERROR_NONE;
+ legacy_player_callback_type_e type = LEGACY_PLAYER_CALLBACK_TYPE_PREPARE;
PLAYER_INSTANCE_CHECK(player);
PLAYER_TRACE_BEGIN("MM:PLAYER:CREATE");
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
}
- muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE;
-
*player = (legacy_player_h)handle;
__lplayer_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
handle->is_display_visible = true;
handle->is_media_stream = false;
- for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) {
+ for (type = LEGACY_PLAYER_CALLBACK_TYPE_PREPARE; type < LEGACY_PLAYER_CALLBACK_TYPE_NUM; type++) {
if (__lplayer_check_enabled_user_cb_lock(type))
g_mutex_init(&handle->user_cb_lock[type]);
}
{
legacy_player_t *handle = (legacy_player_t *)player;
int ret = MM_ERROR_NONE;
+ legacy_player_callback_type_e type = LEGACY_PLAYER_CALLBACK_TYPE_PREPARE;
LOGI("<Enter: %p>", player);
PLAYER_TRACE_BEGIN("MM:PLAYER:DESTROY");
handle->is_shutdown = true;
- L_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- }
- L_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ __lplayer_unset_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE, true);
/* stop the pause state trasition to release prepare thread */
if (handle->internal_state == PLAYER_INTERNAL_STATE_PRE_READY)
}
LOGI("Done mm_player_destroy");
- muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE;
-
__lplayer_update_state(handle, PLAYER_INTERNAL_STATE_NONE);
- for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) {
+ for (type = LEGACY_PLAYER_CALLBACK_TYPE_PREPARE; type < LEGACY_PLAYER_CALLBACK_TYPE_NUM; type++) {
if (__lplayer_check_enabled_user_cb_lock(type))
g_mutex_clear(&handle->user_cb_lock[type]);
}
int legacy_player_prepare_async(legacy_player_h player, legacy_player_prepared_cb callback, void *user_data)
{
legacy_player_t *handle = (legacy_player_t *)player;
- int ret = MM_ERROR_NONE;
+ int ret = PLAYER_ERROR_NONE;
+ int mm_ret = MM_ERROR_NONE;
int visible = 0;
int value = 0;
PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
__lplayer_update_state(handle, PLAYER_INTERNAL_STATE_PRE_READY);
- L_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ L_PLAYER_USER_CB_LOCK(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE);
handle->last_play_position = 0;
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
+ if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE]) {
LOGE("player is already prepareing");
- L_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ L_PLAYER_USER_CB_UNLOCK(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE);
__lplayer_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
return PLAYER_ERROR_INVALID_OPERATION;
}
- /* LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_PREPARE); */
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = callback;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = user_data;
+ handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE] = callback;
+ handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE] = user_data;
- L_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ L_PLAYER_USER_CB_UNLOCK(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE);
- ret = mm_player_set_message_callback(handle->mm_handle, __lplayer_message_callback, (void *)handle);
- if (ret != MM_ERROR_NONE)
- LOGW("Failed to set message callback function (0x%x)", ret);
+ mm_ret = mm_player_set_message_callback(handle->mm_handle, __lplayer_message_callback, (void *)handle);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("failed to set message callback function (0x%x)", mm_ret);
+ goto ERROR;
+ }
- ret = __lplayer_set_buffer_export_callback(handle);
- if (ret != MM_ERROR_NONE) {
- LOGW("Failed to set buffer export callback function (0x%x)", ret);
- return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+ mm_ret = __lplayer_set_buffer_export_callback(handle);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("failed to set buffer export callback function (0x%x)", mm_ret);
+ goto ERROR;
}
if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE) {
- ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char *)NULL);
- if (ret != MM_ERROR_NONE)
- LOGW("Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)", ret);
+ mm_ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char *)NULL);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGW("failed to set none display type (0x%x)", mm_ret);
+ goto ERROR;
+ }
} else {
/* FIXME : new funct path is needed to update video instead of set attr again */
- ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &visible, (char *)NULL);
- if (ret != MM_ERROR_NONE) goto ERROR;
+ mm_ret = mm_player_get_attribute(handle->mm_handle, NULL, "display_visible", &visible, (char *)NULL);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("failed to get display visible attr");
+ goto ERROR;
+ }
if (!visible)
value = FALSE;
else
value = TRUE;
- ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL);
- if (ret != MM_ERROR_NONE) goto ERROR;
+ mm_ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("failed to set display visible attr");
+ goto ERROR;
+ }
}
- ret = mm_player_realize(handle->mm_handle);
- if (ret != MM_ERROR_NONE) {
- LOGE("Failed to realize - 0x%x", ret);
+ mm_ret = mm_player_realize(handle->mm_handle);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("failed to realize - 0x%x", mm_ret);
goto ERROR;
}
- ret = pthread_create(&handle->prepare_async_thread, NULL, (void *)__lplayer_prepare_async_thread_func, (void *)handle);
-
- if (ret != 0) {
- LOGE("Failed to create thread ret = %d", ret);
- L_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- /* user_data will be free at player_disp_prepare_async() */
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- }
- L_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- __lplayer_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
- return PLAYER_ERROR_OUT_OF_MEMORY;
+ if (pthread_create(&handle->prepare_async_thread, NULL,
+ (void *)__lplayer_prepare_async_thread_func, (void *)handle) != 0) {
+ LOGE("failed to create thread for async prepare");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ goto ERROR_WITH_RETURN_VALUE;
}
LPLAYER_FLEAVE();
return PLAYER_ERROR_NONE;
ERROR:
- LOGW("prepare cb is released");
- L_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- /* user_data will be free at player_disp_prepare_async() */
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- }
- L_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ if (mm_ret != MM_ERROR_NONE)
+ ret =_lplayer_convert_error_code(mm_ret, (char *)__FUNCTION__);
+
+ERROR_WITH_RETURN_VALUE:
+ /* callback user_data will be free at player_disp_prepare_async() */
+ __lplayer_unset_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE, false);
__lplayer_update_state(handle, PLAYER_INTERNAL_STATE_IDLE);
- LOGE("LEAVE 0x%X", ret);
- return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+ LPLAYER_FLEAVE();
+ return ret;
}
int legacy_player_prepare(legacy_player_h player)
handle->is_shutdown = true;
/* Initialize the setting regardless of error return */
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
- }
+ __lplayer_unset_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_SEEK, false);
- if (!_lplayer_state_validate(handle, PLAYER_STATE_READY) && !handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
+ if (!_lplayer_state_validate(handle, PLAYER_STATE_READY) && !handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE]) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
return PLAYER_ERROR_INVALID_STATE;
}
-
- L_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
- LOGW("Need to check. prepare cb have to be reset before");
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- g_free(handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE]);
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_PREPARE] = NULL;
- }
- L_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
+ __lplayer_unset_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE, true);
/* stop the pause state trasition to release prepare thread */
if (handle->internal_state == PLAYER_INTERNAL_STATE_PRE_READY)
return PLAYER_ERROR_NONE;
}
-int legacy_player_set_sound_stream_info(legacy_player_h player, sound_stream_info_h stream_info)
-{
- legacy_player_t *handle = (legacy_player_t *)player;
- int ret = MM_ERROR_NONE;
- bool is_available = false;
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
-
- /* check if stream_info is valid */
- ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_PLAYER, &is_available);
- if (ret != MM_ERROR_NONE)
- return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
-
- if (is_available) {
- 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)
- ret = mm_player_set_sound_stream_info(handle->mm_handle, stream_type, stream_index);
- else
- ret = MM_ERROR_PLAYER_INTERNAL;
- } else {
- ret = MM_ERROR_NOT_SUPPORT_API;
- }
-
- if (ret != MM_ERROR_NONE)
- return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
-
- return PLAYER_ERROR_NONE;
-}
-
int legacy_player_set_audio_latency_mode(legacy_player_h player, audio_latency_mode_e latency_mode)
{
legacy_player_t *handle = (legacy_player_t *)player;
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
}
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
- }
-
+ __lplayer_unset_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_SEEK, false);
__lplayer_update_state(handle, PLAYER_INTERNAL_STATE_STOPPED);
LPLAYER_FLEAVE();
return PLAYER_ERROR_INVALID_STATE;
}
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] && !handle->is_media_stream) {
+ if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_SEEK] && !handle->is_media_stream) {
LOGE("previous seeking request is in processing.");
return PLAYER_ERROR_SEEK_FAILED;
}
- LOGI("Event type : %d, pos : %"PRId64, MUSE_PLAYER_EVENT_TYPE_SEEK, nanoseconds);
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data;
+ LOGI("Event type : %d, pos : %"PRId64, LEGACY_PLAYER_CALLBACK_TYPE_SEEK, nanoseconds);
+ handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_SEEK] = callback;
+ handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_SEEK] = user_data;
ret = mm_player_set_attribute(handle->mm_handle, NULL, "accurate_seek", accurated, (char *)NULL);
if (ret != MM_ERROR_NONE)
ret = mm_player_set_position(handle->mm_handle, nanoseconds);
if (ret != MM_ERROR_NONE) {
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
+ handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_SEEK] = NULL;
+ handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_SEEK] = NULL;
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
}
LPLAYER_FENTER();
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(callback);
- if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
+
+ if (!_lplayer_state_validate(handle, PLAYER_STATE_PLAYING)) {
+ LOGE("invalid state error, current state - %d", handle->state);
+ return PLAYER_ERROR_INVALID_STATE;
+ }
+
+ if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE]) {
LOGE("previous capturing request is in processing.");
return PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
}
- LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_CAPTURE);
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = callback;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = user_data;
+ LOGI("Event type : %d ", LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE);
+ handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE] = callback;
+ handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE] = user_data;
- if (handle->state >= PLAYER_STATE_READY) {
- ret = mm_player_do_video_capture(handle->mm_handle);
- if (ret == MM_ERROR_PLAYER_NO_OP) {
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
- LOGE("PLAYER_ERROR_INVALID_OPERATION : video display must be set : %d", handle->display_type);
- return PLAYER_ERROR_INVALID_OPERATION;
- }
- if (ret != MM_ERROR_NONE) {
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
- return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
- }
- return PLAYER_ERROR_NONE;
+ ret = mm_player_do_video_capture(handle->mm_handle);
+ if (ret != MM_ERROR_NONE) {
+ LOGE("failed to capture video 0x%X", ret);
+ __lplayer_unset_callback(handle, LEGACY_PLAYER_CALLBACK_TYPE_CAPTURE, false);
+ return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
}
- LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
- handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
- handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
-
LPLAYER_FLEAVE();
- return PLAYER_ERROR_INVALID_STATE;
+ return PLAYER_ERROR_NONE;
}
int legacy_player_set_streaming_cookie(legacy_player_h player, const char *cookie, int size)
return PLAYER_ERROR_NONE;
}
-int legacy_player_set_callback(legacy_player_h player, muse_player_event_e type, void *callback, void *user_data)
+int legacy_player_set_callback(legacy_player_h player, legacy_player_callback_type_e type, void *callback, void *user_data)
{
int ret = PLAYER_ERROR_NONE;
legacy_player_t *handle = (legacy_player_t *)player;
return PLAYER_ERROR_NONE;
}
-int legacy_player_unset_callback(legacy_player_h player, muse_player_event_e type)
+int legacy_player_unset_callback(legacy_player_h player, legacy_player_callback_type_e type)
{
- int ret = MM_ERROR_NONE;
+ int ret = PLAYER_ERROR_NONE;
legacy_player_t *handle = (legacy_player_t *)player;
PLAYER_INSTANCE_CHECK(player);
return PLAYER_ERROR_NONE;
}
-int legacy_player_set_sound_stream_info_for_mused(legacy_player_h player, char *stream_type, int stream_index)
+int legacy_player_set_sound_stream_info(legacy_player_h player, char *stream_type, int stream_index)
{
legacy_player_t *handle = (legacy_player_t *)player;
int ret = MM_ERROR_NONE;