add callback to retrieve buffer in gapless mode 00/86600/5 accepted/tizen/common/20170206.124409 accepted/tizen/common/20170210.170643 accepted/tizen/ivi/20170214.010749 accepted/tizen/mobile/20170214.010545 accepted/tizen/tv/20170214.010632 accepted/tizen/wearable/20170214.010710 submit/tizen/20170206.043356 submit/tizen/20170210.083202
authorNAMJEONGYOON <just.nam@samsung.com>
Fri, 2 Sep 2016 05:13:48 +0000 (14:13 +0900)
committerNAMJEONGYOON <just.nam@samsung.com>
Mon, 9 Jan 2017 11:39:48 +0000 (20:39 +0900)
Change-Id: I52cf07726b5a17d37f3aa4d7eb7814d6021de664

legacy/include/legacy_player.h
legacy/include/legacy_player_private.h
legacy/src/legacy_player.c
muse/include/muse_player.h
muse/src/muse_player.c

index 4b9468b2ba72deee78a4496b739e6277301a9c66..e91fd1334a30b88b373982dc1b58470d3e2551ea 100644 (file)
@@ -393,6 +393,19 @@ typedef void (*player_media_stream_seek_cb) (unsigned long long offset, void *us
  */
 typedef void (*player_video_stream_changed_cb) (int width, int height, int fps, int bit_rate, void *user_data);
 
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+/**
+ * @brief Called when the buffer needs to be released for gapless.
+ * @since_tizen 4.0
+ * @details It will be invoked when the player is under the construction for gapless.
+ * @param[in]   user_data  The user data passed from the callback registration function
+ * @pre It will be invoked when the playback is completed if you register this callback using legacy_player_set_completed_cb().
+ * @see legacy_player_set_retrieve_buffer_cb()
+ * @see legacy_player_unset_retrieve_buffer_cb()
+ */
+typedef void (*player_retrieve_buffer_cb)(void *user_data);
+#endif
+
 /**
  * @brief Creates a player handle for playing multimedia content.
  * @since_tizen 2.3
@@ -1970,6 +1983,36 @@ int legacy_player_get_track_count(player_h player, player_stream_type_e type, in
  */
 int legacy_player_select_track(player_h player, player_stream_type_e type, int index);
 
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+/**
+ * @brief Registers a callback function that is to be invoked when the buffer needs to be released for gapless.
+ * @since_tizen 4.0
+ * @param[in] player   The handle to the media player
+ * @param[in] callback The callback function to register
+ * @param[in] user_data        The user data to be passed to the callback function
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @post  player_retrieve_buffer_cb() will be invoked.
+ * @see legacy_player_unset_retrieve_buffer_cb()
+ */
+int legacy_player_set_retrieve_buffer_cb(player_h player, player_retrieve_buffer_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 4.0
+ * @param[in] player The handle to the media player
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @see legacy_player_set_retrieve_buffer_cb()
+ */
+int legacy_player_unset_retrieve_buffer_cb(player_h player);
+#endif
 /**
  * @}
  */
index cefba6307f28a2f5fa57496783da47205c1a77a0..5bc2684554d1d5f1590e0fccdd50087195d49e3e 100644 (file)
@@ -83,6 +83,9 @@ typedef enum {
        PLAYER_MESSAGE_SEEK_DONE,
        PLAYER_MESSAGE_EOS,
        PLAYER_MESSAGE_LOOP_EXIT,
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+       PLAYER_MESSAGE_GAPLESS_CONSTRUCTION,
+#endif
        PLAYER_MESSAGE_MAX
 } _player_message_e;
 #endif
index 4130252f5a4b642d3c3ac81d7e7a40d30972d7b8..8bb6edb29d8658bc51b4db0f5680f52d31960df4 100644 (file)
                        g_mutex_unlock(&handle->message_queue_lock); \
                        LOGI("Retrieved  message [%d] from queue", handle->current_message); \
                } else { \
-                       LOGI("Failed to retrive message from queue"); \
+                       LOGI("Failed to retrieve message from queue"); \
                        handle->current_message = PLAYER_MESSAGE_NONE; \
                } \
        } while (0)
@@ -551,6 +551,18 @@ static void __job_eos_cb(void *user_data)
        __REMOVE_ECORE_JOB(handle, __JOB_KEY_EOS);
        LOGI("End");
 }
+
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+static void __job_retrieve_buffer_cb(void *user_data)
+{
+       player_s *handle = (player_s *)user_data;
+       LOGI("Start");
+       handle->is_doing_jobs = TRUE;
+       ((player_retrieve_buffer_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]);
+       __REMOVE_ECORE_JOB(handle, "test");
+       LOGI("End");
+}
+#endif
 #else
 static void __message_cb_loop(void *data)
 {
@@ -612,6 +624,18 @@ static void __message_cb_loop(void *data)
                                        LOGE("null handle in PLAYER_MESSAGE_EOS");
                        }
                        break;
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+               case PLAYER_MESSAGE_GAPLESS_CONSTRUCTION:
+                       {
+                               LOGW("PLAYER_MESSAGE_GAPLESS_CONSTRUCTION");
+                               if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]) {
+                                       ((player_retrieve_buffer_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]);
+                               } else {
+                                       LOGE("null handle in PLAYER_MESSAGE_GAPLESS_CONSTRUCTION");
+                               }
+                       }
+                       break;
+#endif
                case PLAYER_MESSAGE_LOOP_EXIT:
                        {
                                LOGW("PLAYER_MESSAGE_LOOP_EXIT");
@@ -673,6 +697,17 @@ static int __msg_callback(int message, void *param, void *user_data)
 #endif
                }
                break;
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+       case MM_MESSAGE_GAPLESS_CONSTRUCTION:   /* 0x105 */
+               if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]) {
+#ifdef USE_ECORE_FUNCTIONS
+                       __ADD_ECORE_JOB(handle, "test", __job_retrieve_buffer_cb);
+#else
+                       __ADD_MESSAGE(handle, PLAYER_MESSAGE_GAPLESS_CONSTRUCTION);
+#endif
+               }
+               break;
+#endif
        case MM_MESSAGE_BUFFERING:      /* 0x103 */
                if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING])
                        ((player_buffering_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING])(msg->connection.buffering, handle->user_data[MUSE_PLAYER_EVENT_TYPE_BUFFERING]);
@@ -2535,6 +2570,18 @@ int legacy_player_unset_completed_cb(player_h player)
        return __unset_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player);
 }
 
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+int legacy_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);
+}
+
+int legacy_player_unset_retrieve_buffer_cb(player_h player)
+{
+       return __unset_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player);
+}
+#endif
+
 int legacy_player_set_interrupted_cb(player_h player, player_interrupted_cb callback, void *user_data)
 {
        return __set_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player, callback, user_data);
index f265b6b697a78feb1e9456d6915bc9b17fe22b12..26e8722d3578f05438956fde263f24df4cbbd305 100644 (file)
@@ -82,6 +82,9 @@ typedef enum {
        MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK,
        MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED,
        MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED,
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+       MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER,
+#endif
        MUSE_PLAYER_EVENT_TYPE_NUM
 } muse_player_event_e;
 
index a4cc23395801bf5c5994e065ed6bcbb33e85771e..6abe3e155697a4ec30e0b5fc53dcbade6ece6b5d 100644 (file)
@@ -426,6 +426,14 @@ static void _completed_cb(void *user_data)
        __player_callback(ev, (muse_module_h)user_data);
 }
 
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+static void _retrieve_buffer_cb(void *user_data)
+{
+       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER;
+       __player_callback(ev, (muse_module_h)user_data);
+}
+#endif
+
 static void _set_completed_cb(player_h player, void *module, bool set)
 {
        if (set)
@@ -434,6 +442,16 @@ static void _set_completed_cb(player_h player, void *module, bool set)
                legacy_player_unset_completed_cb(player);
 }
 
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+static void _set_retrieve_buffer_cb(player_h player, void *module, bool set)
+{
+       if (set)
+               legacy_player_set_retrieve_buffer_cb(player, _retrieve_buffer_cb, module);
+       else
+               legacy_player_unset_retrieve_buffer_cb(player);
+}
+#endif
+
 static void _capture_video_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
@@ -860,6 +878,9 @@ static void (*set_callback_func[MUSE_PLAYER_EVENT_TYPE_NUM])(player_h player, vo
        _set_media_stream_audio_seek_cb,        /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK */
        NULL,                                                           /* MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED */
        _set_video_stream_changed_cb,           /* MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED */
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+       _set_retrieve_buffer_cb,        /* MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER */
+#endif
 };
 
 static int _push_media_stream(muse_player_handle_s *muse_player, player_push_media_msg_type *push_media, char *buf)