*/
typedef void (*player_audio_pcm_extraction_cb)(player_audio_raw_data_s *audio_raw_frame, void *user_data);
+/**
+ * @brief Called when the buffer level drops below the min size or exceeds the max size.
+ * @since_tizen 3.0
+ * @remarks This API is used for media stream playback only.
+ * @param[in] status The buffer status
+ * @param[in] bytes The current buffer level bytes
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see player_set_media_stream_buffer_status_cb_ex()
+ * @see player_set_media_stream_buffer_max_size()
+ * @see player_set_media_stream_buffer_min_threshold()
+ */
+typedef void (*player_media_stream_buffer_status_cb_ex) (player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data);
/**
* @brief Registers a callback function to be invoked when audio frame is decoded. Audio only contents is possible. If included video, error happens.
*/
int player_set_streaming_playback_rate(player_h player, float rate);
+/**
+ * @brief Registers a callback function to be invoked when buffer underrun or overflow is occurred.
+ * @since_tizen 3.0
+ * @remarks This API is used for media stream playback only.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[in] callback The buffer status 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_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare().
+ * @post player_media_stream_buffer_status_cb_ex() will be invoked.
+ * @see player_unset_media_stream_buffer_status_cb_ex()
+ * @see player_media_stream_buffer_status_cb_ex()
+ */
+int player_set_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb_ex callback, void *user_data);
+
+/**
+ * @brief Unregisters the buffer status callback function.
+ * @since_tizen 3.0
+ * @remarks This API is used for media stream playback only.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see player_set_media_stream_buffer_status_cb()
+ */
+int player_unset_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type);
/**
* @}
#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,
*/
typedef void (*player_audio_pcm_extraction_cb)(player_audio_raw_data_s *audio_raw_frame, void *user_data);
+/**
+ * @brief Called when the buffer level drops below the min size or exceeds the max size.
+ * @since_tizen 3.0
+ * @remarks This API is used for media stream playback only.
+ * @param[in] status The buffer status
+ * @param[in] bytes The current buffer level bytes
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see player_set_media_stream_buffer_status_cb_ex()
+ * @see player_set_media_stream_buffer_max_size()
+ * @see player_set_media_stream_buffer_min_threshold()
+ */
+typedef void (*player_media_stream_buffer_status_cb_ex) (player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data);
/**
* @brief Registers a callback function to be invoked when audio frame is decoded. Audio only contents is possible. If included video, error happens.
*/
int player_set_streaming_playback_rate(player_h player, float rate);
+/**
+ * @brief Registers a callback function to be invoked when buffer underrun or overflow is occurred.
+ * @since_tizen 3.0
+ * @remarks This API is used for media stream playback only.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[in] callback The buffer status 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_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling player_create() or player_unprepare().
+ * @post player_media_stream_buffer_status_cb_ex() will be invoked.
+ * @see player_unset_media_stream_buffer_status_cb_ex()
+ * @see player_media_stream_buffer_status_cb_ex()
+ */
+int player_set_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb_ex callback, void *user_data);
+
+/**
+ * @brief Unregisters the buffer status callback function.
+ * @since_tizen 3.0
+ * @remarks This API is used for media stream playback only.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see player_set_media_stream_buffer_status_cb()
+ */
+int player_unset_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type);
/**
* @}
return PLAYER_ERROR_NONE;
}
-static bool __media_stream_buffer_status_callback(player_stream_type_e type, player_media_stream_buffer_status_e status, void *user_data)
+static bool __media_stream_buffer_status_callback(player_stream_type_e type, player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
{
player_s *handle = (player_s *)user_data;
_player_event_e event_type;
}
return ret;
}
+
+static bool __media_stream_buffer_status_callback_ex(player_stream_type_e type, player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ _player_event_e event_type;
+
+ if (type == PLAYER_STREAM_TYPE_AUDIO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+ else if (type == PLAYER_STREAM_TYPE_VIDEO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+ else
+ return FALSE;
+
+ LOGE("[%s] event type %d, status %d, bytes %llu", __FUNCTION__, event_type, status, bytes);
+
+ if (handle->user_cb[event_type]) {
+ ((player_media_stream_buffer_status_cb_ex)handle->user_cb[event_type])(status, bytes, handle->user_data[event_type]);
+ } else {
+ LOGE("[%s][type:%d] buffer status cb was not set.", __FUNCTION__, type);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+int player_set_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb_ex callback, void *user_data)
+{
+ int ret;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(callback);
+ player_s *handle = (player_s *)player;
+ _player_event_e event_type;
+
+ if (handle->state != PLAYER_STATE_IDLE) {
+ LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state);
+ return PLAYER_ERROR_INVALID_STATE;
+ }
+ /* the type can be expaned with default and text. */
+ if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
+ LOGE("[%s] PLAYER_ERROR_INVALID_PARAMETER(type : %d)", __FUNCTION__, type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, (mm_player_media_stream_buffer_status_callback)__media_stream_buffer_status_callback_ex, (void *)handle);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ if (type == PLAYER_STREAM_TYPE_VIDEO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+ else
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+
+ LOGI("[%s] Event type : %d ", __FUNCTION__, type);
+
+ handle->user_cb[event_type] = callback;
+ handle->user_data[event_type] = user_data;
+
+ return PLAYER_ERROR_NONE;
+}
+
+int player_unset_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type)
+{
+ int ret;
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ _player_event_e event_type;
+
+ if (type == PLAYER_STREAM_TYPE_VIDEO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+ else if (type == PLAYER_STREAM_TYPE_AUDIO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+ else
+ return PLAYER_ERROR_INVALID_PARAMETER;
+
+ handle->user_cb[event_type] = NULL;
+ handle->user_data[event_type] = NULL;
+
+ LOGI("[%s] Event type : %d ", __FUNCTION__, type);
+
+ ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, NULL, NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
#include <tbm_surface.h>
#include <dlog.h>
#include <player.h>
+#include <player_internal.h>
#include <glib.h>
#include <appcore-efl.h>
#ifdef HAVE_WAYLAND
}
if (ad->player_handle == NULL) {
- printf("player_handle is NULL");
+ LOGE("player_handle is NULL");
return -1;
}
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);
ret = player_unprepare(ad->player_handle);
if (ret != PLAYER_ERROR_NONE) {
- printf("player_unprepare failed : 0x%x", ret);
+ LOGE("player_unprepare failed : 0x%x", ret);
return false;
}
/* destroy player handle */
ret = player_destroy(ad->player_handle);
if (ret != PLAYER_ERROR_NONE) {
- printf("player_destroy failed : 0x%x", ret);
+ LOGE("player_destroy failed : 0x%x", ret);
return false;
}
}
}
-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)
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;