add callback to retrieve buffer in gapless mode 55/109255/2
authorNAMJEONGYOON <just.nam@samsung.com>
Mon, 9 Jan 2017 11:43:03 +0000 (20:43 +0900)
committerNam <just.nam@samsung.com>
Wed, 18 Jan 2017 07:06:55 +0000 (23:06 -0800)
Change-Id: If8a7ab64e2266987b37f44ba16d8d7789354cb78

src/player.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 95bbf82..8dd128f
@@ -78,7 +78,12 @@ typedef struct {
 */
 static int _player_deinit_memory_buffer(player_cli_s * pc);
 static void _player_event_queue_add(player_event_queue * ev, _player_cb_data * data);
-
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+typedef void (*player_retrieve_buffer_cb)(void *user_data);
+static void __retrieve_buffer_cb(void *user_data);
+static int __player_set_retrieve_buffer_cb(player_h player, player_retrieve_buffer_cb callback, void *user_data);
+static int __player_unset_retrieve_buffer_cb(player_h player);
+#endif
 int _player_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
 {
        int ret = MEDIA_PACKET_FINALIZE;
@@ -497,6 +502,15 @@ static void __complete_cb_handler(callback_cb_info_s * cb_info, _player_recv_dat
        ((player_completed_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
 }
 
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+static void __retrieve_buffer_cb_handler(callback_cb_info_s * cb_info, _player_recv_data *recv_data)
+
+{
+       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER;
+       ((player_retrieve_buffer_cb) cb_info->user_cb[ev]) (cb_info->user_data[ev]);
+}
+#endif
+
 static char* _convert_code_to_str(int code)
 {
        switch (code) {
@@ -1095,6 +1109,9 @@ static void (*_user_callbacks[MUSE_PLAYER_EVENT_TYPE_NUM]) (callback_cb_info_s *
        __media_stream_audio_seek_cb_handler,   /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK */
        NULL,   /* MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED */
        __video_stream_changed_cb_handler,              /* MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED */
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+       __retrieve_buffer_cb_handler,           /* MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER */
+#endif
 };
 
 gboolean _player_event_job_function(void *user_data)
@@ -1809,6 +1826,7 @@ int player_destroy(player_h player)
                player_unset_media_packet_video_frame_decoded_cb(player);
                if (mm_evas_renderer_destroy(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
                        LOGW("fail to unset evas client");
+               __player_unset_retrieve_buffer_cb(player);
                g_free(pc->cb_info->evas_info);
        }
 #endif
@@ -1899,6 +1917,7 @@ int player_unprepare(player_h player)
                player_unset_media_packet_video_frame_decoded_cb(player);
                if (mm_evas_renderer_destroy(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
                        LOGW("fail to unset evas client");
+               __player_unset_retrieve_buffer_cb(player);
        }
 #endif
        player_msg_send(api, pc, ret_buf, ret);
@@ -2601,6 +2620,8 @@ int player_set_display(player_h player, player_display_type_e type, player_displ
                                ret = player_set_media_packet_video_frame_decoded_cb(player, mm_evas_renderer_write, (void *)EVAS_HANDLE(pc));
                                if (ret != PLAYER_ERROR_NONE)
                                        LOGW("fail to set decoded callback");
+                               if (__player_set_retrieve_buffer_cb(player, __retrieve_buffer_cb, pc))
+                                       LOGW("fail to set __retrieve_buffer_cb");
                        }
 #endif
                        else
@@ -3460,6 +3481,35 @@ int player_set_completed_cb(player_h player, player_completed_cb callback, void
        return __set_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player, callback, user_data);
 }
 
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+static void __retrieve_buffer_cb(void *user_data)
+{
+       player_cli_s *player = (player_cli_s *)user_data;
+       int ret = PLAYER_ERROR_NONE;
+       bool gapless = false;
+
+       ret = player_is_gapless((player_h)user_data, &gapless);
+       if (ret != PLAYER_ERROR_NONE) {
+               LOGW("player_is_gapless is failed");
+               return;
+       }
+
+       ret = mm_evas_renderer_retrieve_all_packets(EVAS_HANDLE(player), gapless);
+       if (ret != PLAYER_ERROR_NONE)
+               LOGI("mm_evas_renderer_retrieve_all_packets returned error");
+}
+
+static int __player_set_retrieve_buffer_cb(player_h player, player_retrieve_buffer_cb callback, void *user_data)
+{
+       return __set_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player, callback, user_data);
+}
+
+static int __player_unset_retrieve_buffer_cb(player_h player)
+{
+       return __unset_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player);
+}
+#endif
+
 int player_unset_completed_cb(player_h player)
 {
        return __unset_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player);