add internal api about buffer status cb with bytes info 79/56379/1 accepted/tizen/mobile/20160108.005420 accepted/tizen/tv/20160108.005439 accepted/tizen/wearable/20160108.005512 submit/tizen/20160107.071246
authorEunhae Choi <eunhae1.choi@samsung.com>
Thu, 7 Jan 2016 06:47:50 +0000 (15:47 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Thu, 7 Jan 2016 06:47:58 +0000 (15:47 +0900)
Change-Id: Ibdc936248b993e290fcaf65e8e4af852016ef89c

client/src/player2.c
client/src/player2_internal.c
client/test/player_es_push_test.c
include/player2_private.h
src/player_msg_dispatcher.c

index 8846b7a..781f182 100644 (file)
@@ -633,6 +633,33 @@ static void __media_stream_audio_buffer_cb_handler(callback_cb_info_s *cb_info,
 
 }
 
+static void __media_stream_video_buffer_cb_handler_ex(callback_cb_info_s *cb_info, char *recvMsg)
+{
+       /* player_media_stream_buffer_status_e status; */
+       int status;
+       unsigned long long bytes;
+
+       if (player_msg_get(status, recvMsg) && player_msg_get_type(bytes, recvMsg, INT64)) {
+               ((player_media_stream_buffer_status_cb_ex)
+                       cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO])
+                       ((player_media_stream_buffer_status_e)status, bytes, cb_info->user_data[_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, char *recvMsg)
+{
+       /* player_media_stream_buffer_status_e status; */
+       int status;
+       unsigned long long bytes;
+
+       if (player_msg_get(status, recvMsg) && player_msg_get_type(bytes, recvMsg, INT64)) {
+               ((player_media_stream_buffer_status_cb_ex)
+                       cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO])
+                       ((player_media_stream_buffer_status_e)status, bytes, cb_info->user_data[_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO]);
+       }
+
+}
+
 static void __media_stream_video_seek_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
 {
        unsigned long long offset;
@@ -704,6 +731,8 @@ static void (*_user_callbacks[_PLAYER_EVENT_TYPE_NUM])(callback_cb_info_s *cb_in
 #endif
        __media_stream_video_buffer_cb_handler, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS*/
        __media_stream_audio_buffer_cb_handler, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS*/
+       __media_stream_video_buffer_cb_handler_ex,      /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO*/
+       __media_stream_audio_buffer_cb_handler_ex,      /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO*/
        __media_stream_video_seek_cb_handler,   /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK*/
        __media_stream_audio_seek_cb_handler,   /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK*/
        NULL,   /*_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED*/
index c8cabf4..e7329b5 100644 (file)
@@ -81,3 +81,87 @@ int player_set_streaming_playback_rate(player_h player, float rate)
        g_free(ret_buf);
        return ret;
 }
+
+int player_set_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e stream_type, player_media_stream_buffer_status_cb_ex 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;
+       _player_event_e type;
+       int set = 1;
+
+       LOGD("ENTER");
+
+       if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
+               type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+       else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
+               type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+       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;
+}
+
+static void set_null_user_cb(callback_cb_info_s *cb_info, _player_event_e event)
+{
+       if (cb_info && event < _PLAYER_EVENT_TYPE_NUM) {
+               cb_info->user_cb[event] = NULL;
+               cb_info->user_data[event] = NULL;
+       }
+}
+
+static void set_null_user_cb_lock(callback_cb_info_s *cb_info, _player_event_e event)
+{
+       bool lock = g_thread_self() != cb_info->event_queue.thread;
+
+       if (lock)
+               g_mutex_lock(&cb_info->event_queue.mutex);
+
+       set_null_user_cb(cb_info, event);
+
+       if (lock)
+               g_mutex_unlock(&cb_info->event_queue.mutex);
+}
+
+int player_unset_media_stream_buffer_status_cb_ex(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;
+       _player_event_e type;
+       int set = 0;
+
+       LOGD("ENTER");
+
+       if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
+               type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+       else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
+               type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+       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;
+}
index fea74c1..3872f37 100644 (file)
@@ -18,6 +18,7 @@
 #include <tbm_surface.h>
 #include <dlog.h>
 #include <player.h>
+#include <player_internal.h>
 #include <glib.h>
 #include <appcore-efl.h>
 #ifdef HAVE_WAYLAND
@@ -209,8 +210,8 @@ static int app_pause(void *data)
                ad->feeding_thread_id = 0;
        }
 
-       player_unset_media_stream_buffer_status_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO);
-       player_unset_media_stream_buffer_status_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO);
+       player_unset_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO);
+       player_unset_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO);
        player_unset_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO);
        player_unset_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO);
 
@@ -441,7 +442,6 @@ static void feed_video_data_thread_func(void *data)
 
        while (TRUE) {
                static int frame_count = 0;
-
                if (frame_count < ES_DEFAULT_NUMBER_OF_FEED) {
                        if (!feed_video_data(ad))
                                break;
@@ -453,20 +453,24 @@ static void feed_video_data_thread_func(void *data)
        }
 }
 
-void _video_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
+void _video_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
 {
-       if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN)
-               LOGE("video buffer is underrun state");
-       else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW)
-               LOGE("video buffer is overrun state");
+       if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) {
+               LOGE("video buffer is underrun state, current level byte = %llu", bytes);
+       }
+       else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) {
+               LOGE("video buffer is overrun state, current level byte = %llu", bytes);
+       }
 }
 
-void _audio_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
+void _audio_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
 {
-       if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN)
-               LOGE("audio buffer is underrun state");
-       else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW)
-               LOGE("audio buffer is overrun state");
+       if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) {
+               LOGE("audio buffer is underrun state, current level byte = %llu", bytes);
+       }
+       else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) {
+               LOGE("audio buffer is overrun state, current level byte = %llu", bytes);
+       }
 }
 
 void _video_seek_data_cb(unsigned long long offset, void *user_data)
@@ -516,12 +520,15 @@ static int app_reset(bundle *b, void *data)
        media_format_set_video_width(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_WIDTH);
        media_format_set_video_height(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_HEIGHT);
 
-       ret = player_set_media_stream_buffer_status_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, _video_buffer_status_cb, (void *)ad);
+       player_set_media_stream_buffer_max_size(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, (unsigned long long)800*1024);
+       player_set_media_stream_buffer_min_threshold(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, 50);
+
+       ret = player_set_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, _video_buffer_status_cb_ex, (void *)ad);
        if (ret != PLAYER_ERROR_NONE) {
                LOGE("player set video buffer status cb failed : 0x%x", ret);
                goto FAILED;
        }
-       ret = player_set_media_stream_buffer_status_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO, _audio_buffer_status_cb, (void *)ad);
+       ret = player_set_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO, _audio_buffer_status_cb_ex, (void *)ad);
        if (ret != PLAYER_ERROR_NONE) {
                LOGE("player set audio buffer status cb failed : 0x%x", ret);
                goto FAILED;
index b4579b0..1843c9c 100644 (file)
@@ -152,6 +152,8 @@ typedef enum {
 #endif
        _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS,
        _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS,
+       _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO,
+       _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO,
        _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK,
        _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK,
        _PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED,
index c6f7e14..35d2a66 100644 (file)
@@ -368,6 +368,24 @@ static void _media_stream_video_buffer_status_cb(player_media_stream_buffer_stat
        player_msg_event1(api, ev, module, INT, status);
 }
 
+static void _media_stream_audio_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+{
+       muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+       _player_event_e ev = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+       muse_module_h module = (muse_module_h)user_data;
+
+       player_msg_event2(api, ev, module, INT, status, INT64, bytes);
+}
+
+static void _media_stream_video_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+{
+       muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+       _player_event_e ev = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+       muse_module_h module = (muse_module_h)user_data;
+
+       player_msg_event2(api, ev, module, INT, status, INT64, bytes);
+}
+
 static void _media_stream_audio_seek_cb(unsigned long long offset, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
@@ -523,6 +541,34 @@ static void _set_media_stream_video_buffer_cb(player_h player, void *data, bool
        player_msg_return(api, ret, module);
 }
 
+static void _set_media_stream_audio_buffer_cb_ex(player_h player, void *data, bool set)
+{
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+       muse_module_h module = (muse_module_h)data;
+
+       if (set)
+               ret = player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_buffer_status_cb_ex, module);
+       else
+               ret = player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO);
+
+       player_msg_return(api, ret, module);
+}
+
+static void _set_media_stream_video_buffer_cb_ex(player_h player, void *data, bool set)
+{
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+       muse_module_h module = (muse_module_h)data;
+
+       if (set)
+               ret = player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_buffer_status_cb_ex, module);
+       else
+               ret = player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO);
+
+       player_msg_return(api, ret, module);
+}
+
 static void (*set_callback_func[_PLAYER_EVENT_TYPE_NUM])(player_h player, void *user_data, bool set) = {
        NULL,                                   /* _PLAYER_EVENT_TYPE_PREPARE */
        _set_completed_cb,              /* _PLAYER_EVENT_TYPE_COMPLETE */
@@ -545,6 +591,8 @@ static void (*set_callback_func[_PLAYER_EVENT_TYPE_NUM])(player_h player, void *
 #endif
        _set_media_stream_video_buffer_cb,      /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS*/
        _set_media_stream_audio_buffer_cb,      /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS*/
+       _set_media_stream_video_buffer_cb_ex,   /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO*/
+       _set_media_stream_audio_buffer_cb_ex,   /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO*/
        _set_media_stream_video_seek_cb,        /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK*/
        _set_media_stream_audio_seek_cb,        /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK*/
        NULL,                                                           /*_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED*/