From: Eunhye Choi Date: Fri, 10 May 2019 07:56:07 +0000 (+0900) Subject: [0.3.115] get sync return of callback api X-Git-Tag: submit/tizen/20190513.085714~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d02255ee45d66a63f347b3b4f585567523574c0;p=platform%2Fcore%2Fapi%2Fplayer.git [0.3.115] get sync return of callback api - Use the same form to set/unset the callback info to simplify the callback handling path. Change-Id: I54116d315d5560b9560ba54bf10fb2e80b1c7f49 --- diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index 27fde17..d57fd01 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.114 +Version: 0.3.115 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/player.c b/src/player.c index 6e86fa9..44e328f 100644 --- a/src/player.c +++ b/src/player.c @@ -457,6 +457,7 @@ static int __set_callback(muse_player_event_e type, player_h player, void *callb 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; int set = 1; if (MUSE_PLAYER_EVENT_TYPE_BUFFERING == type) { @@ -468,12 +469,16 @@ static int __set_callback(muse_player_event_e type, player_h player, void *callb return PLAYER_ERROR_INVALID_OPERATION; LOGI("Event type : %d ", type); - PLAYER_SEND_MSG_ASYNC(api, MSG_FD(pc), ret, MUSE_TYPE_INT, "type", type, MUSE_TYPE_INT, "set", 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; } @@ -483,6 +488,7 @@ static int __unset_callback(muse_player_event_e type, player_h 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; int set = 0; LOGI("Event type : %d ", type); @@ -490,8 +496,11 @@ static int __unset_callback(muse_player_event_e type, player_h player) PLAYER_NULL_ARG_CHECK(CALLBACK_INFO(pc)); set_null_user_cb_lock(CALLBACK_INFO(pc), type); - PLAYER_SEND_MSG_ASYNC(api, MSG_FD(pc), ret, MUSE_TYPE_INT, "type", type, MUSE_TYPE_INT, "set", set); + PLAYER_SEND_MSG(api, pc, ret_buf, ret, + MUSE_TYPE_INT, "type", type, + MUSE_TYPE_INT, "set", set); + g_free(ret_buf); return ret; } @@ -4028,112 +4037,29 @@ int player_unset_subtitle_updated_cb(player_h player) 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("ENTER"); - - 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[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); - } - - g_free(ret_buf); - return ret; + 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) { - 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_SEND_MSG(api, pc, ret_buf, ret, - MUSE_TYPE_INT, "type", type, - MUSE_TYPE_INT, "set", set); - - g_free(ret_buf); - return ret; + return __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_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_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; - 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_SEND_MSG(api, pc, ret_buf, ret, - MUSE_TYPE_INT, "type", type, - MUSE_TYPE_INT, "set", 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) { 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"); @@ -4146,29 +4072,13 @@ int player_set_media_stream_buffer_status_cb(player_h player, player_stream_type return PLAYER_ERROR_INVALID_PARAMETER; } - 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; - 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; LOGD("ENTER"); @@ -4181,26 +4091,14 @@ int player_unset_media_stream_buffer_status_cb(player_h player, player_stream_ty return PLAYER_ERROR_INVALID_PARAMETER; } - set_null_user_cb_lock(pc->cb_info, type); - - PLAYER_SEND_MSG(api, pc, ret_buf, ret, - MUSE_TYPE_INT, "type", type, - MUSE_TYPE_INT, "set", 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) { 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"); @@ -4213,29 +4111,13 @@ int player_set_media_stream_seek_cb(player_h player, player_stream_type_e stream return PLAYER_ERROR_INVALID_PARAMETER; } - 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; - 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; LOGD("ENTER"); @@ -4248,14 +4130,7 @@ int player_unset_media_stream_seek_cb(player_h player, player_stream_type_e stre return PLAYER_ERROR_INVALID_PARAMETER; } - set_null_user_cb_lock(pc->cb_info, type); - - PLAYER_SEND_MSG(api, pc, ret_buf, ret, - MUSE_TYPE_INT, "type", type, - MUSE_TYPE_INT, "set", set); - - g_free(ret_buf); - return ret; + return __unset_callback(type, player); } /* TODO Implement raw data socket channel */