[0.3.115] get sync return of callback api 04/205904/1
authorEunhye Choi <eunhae1.choi@samsung.com>
Fri, 10 May 2019 07:56:07 +0000 (16:56 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Fri, 10 May 2019 08:02:26 +0000 (17:02 +0900)
- Use the same form to set/unset the callback info
  to simplify the callback handling path.

Change-Id: I54116d315d5560b9560ba54bf10fb2e80b1c7f49

packaging/capi-media-player.spec
src/player.c

index 27fde17633d19d5f3ecae883c98be44e7dc110db..d57fd01fad1f233c06ed0e8470159e11fd6cacba 100644 (file)
@@ -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
index 6e86fa92894fc653f674d28dc0d477f4c3b1625d..44e328f78629244a8d7339ff60066d381a9c8a96 100644 (file)
@@ -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 */