From 3278d28e30d223dca343e80102a9092b7cf2715a Mon Sep 17 00:00:00 2001 From: Eunhye Choi Date: Mon, 22 Apr 2019 20:26:08 +0900 Subject: [PATCH] [0.3.114] cleanup pcm extraction path - cleanup pcm extraction path to use it with public api which will be added soon. - add pcm mime type at player_audio_raw_data_s temporarily to use unified interface with public api. Change-Id: Iab03a2ccb2e5119e2949dec20508f7828010cdc7 --- include/player_internal.h | 1 + packaging/capi-media-player.spec | 2 +- src/player.c | 40 +++++++++++++++++++++++++++++----------- src/player_internal.c | 2 ++ 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/include/player_internal.h b/include/player_internal.h index adcfb74..d3ad1bd 100644 --- a/include/player_internal.h +++ b/include/player_internal.h @@ -67,6 +67,7 @@ typedef struct { int depth; /**< Depth */ bool little_endian; /**< Endianness */ unsigned long long channel_mask; /**< channel_mask */ + media_format_mimetype_e pcm_format; } player_audio_raw_data_s; /** diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index e963281..27fde17 100644 --- a/packaging/capi-media-player.spec +++ b/packaging/capi-media-player.spec @@ -1,6 +1,6 @@ Name: capi-media-player Summary: A Media Player API -Version: 0.3.113 +Version: 0.3.114 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/player.c b/src/player.c index a87e57d..6e86fa9 100644 --- a/src/player.c +++ b/src/player.c @@ -968,12 +968,12 @@ ERROR: 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) { tbm_bo bo = NULL; tbm_bo_handle thandle; int key = INVALID_DEFAULT_VALUE; - player_audio_raw_data_s audio; + player_audio_raw_data_s audio; /* DEPRECATED_PLAYER_INTERNAL_API */ if (!player_msg_get(key, recv_data->buffer)) { LOGE("failed to get key value from msg."); @@ -999,21 +999,35 @@ static void __audio_frame_cb_handler(callback_cb_info_s *cb_info, _player_recv_d memcpy(&audio, thandle.ptr, sizeof(player_audio_raw_data_s)); audio.data = thandle.ptr + sizeof(player_audio_raw_data_s); + 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_AUDIO_FRAME]) { /* DEPRECATED_PLAYER_INTERNAL_API, will be removed */ + ((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]); + } +/* FIXME: Will be implemented with public api + else if (cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME]) { + ((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]); memset(recv_data->tfd, INVALID_DEFAULT_VALUE, sizeof(recv_data->tfd)); - if (bo) - tbm_bo_unref(bo); + /* return buffer directly, DEPRECATED_PLAYER_INTERNAL_API */ + if ((cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME] == NULL) && + (key > INVALID_DEFAULT_VALUE)) { + + if (bo) tbm_bo_unref(bo); - /* return buffer */ - if (key > INVALID_DEFAULT_VALUE) { /* LOGD("send msg to release buffer. key:%d", key); */ PLAYER_SEND_MSG_ASYNC_WITH_NO_RETURN(MUSE_PLAYER_API_RETURN_BUFFER, cb_info->fd, MUSE_TYPE_INT, "key", key); } @@ -1150,7 +1164,7 @@ static void (*_user_callbacks[MUSE_PLAYER_EVENT_TYPE_NUM])(callback_cb_info_s *c __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 */ __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 */ @@ -1170,6 +1184,7 @@ static void (*_user_callbacks[MUSE_PLAYER_EVENT_TYPE_NUM])(callback_cb_info_s *c #ifdef TIZEN_FEATURE_EVAS_RENDERER __retrieve_buffer_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER */ #endif + __media_packet_audio_frame_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME, DEPRECATED_PLAYER_INTERNAL_API */ __disconnected_error_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED */ }; @@ -1202,7 +1217,8 @@ gboolean _player_event_job_function(void *user_data) } g_mutex_unlock(&data->cb_info->event_queue.idle_ev_mutex); - if ((data->cb_info->user_cb[ev] || (ev == MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED)) && + if ((data->cb_info->user_cb[ev] || ev == MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED || + (data->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME] && ev == MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME)) && (_user_callbacks[ev])) _user_callbacks[ev](data->cb_info, data->recv_data); else @@ -1481,7 +1497,9 @@ static bool _user_callback_handler(callback_cb_info_s *cb_info, muse_player_even /* LOGD("get event %d", event); */ if (event < MUSE_PLAYER_EVENT_TYPE_NUM) { - if (cb_info->user_cb[event] && _user_callbacks[event]) { + if ((cb_info->user_cb[event] && _user_callbacks[event]) || + (event == MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME && /* DEPRECATED_PLAYER_INTERNAL_API */ + cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME] && _user_callbacks[event])){ _player_cb_data *data = NULL; data = g_new(_player_cb_data, 1); if (!data) { diff --git a/src/player_internal.c b/src/player_internal.c index 5f2ef00..0e08614 100644 --- a/src/player_internal.c +++ b/src/player_internal.c @@ -26,6 +26,7 @@ #include "player_msg.h" #include "player_internal.h" +/* DEPRECATED_PLAYER_INTERNAL_API */ int player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data) { PLAYER_INSTANCE_CHECK(player); @@ -50,6 +51,7 @@ int player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_ return ret; } +/* DEPRECATED_PLAYER_INTERNAL_API */ int player_set_pcm_spec(player_h player, const char *format, int samplerate, int channel) { PLAYER_INSTANCE_CHECK(player); -- 2.7.4