slomo pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=79d5172f0a7bbc30c90130e854133976b0377c96
commit 79d5172f0a7bbc30c90130e854133976b0377c96 Author: Sebastian Dröge <[email protected]> Date: Sun Jan 12 20:28:50 2014 +0100 emotion gstreamer1: Add support for buffering and clock-lost handling --- src/modules/emotion/gstreamer1/emotion_gstreamer.c | 36 ++++++++++++++++++++-- src/modules/emotion/gstreamer1/emotion_gstreamer.h | 2 ++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/modules/emotion/gstreamer1/emotion_gstreamer.c b/src/modules/emotion/gstreamer1/emotion_gstreamer.c index 5e59e62..b620577 100644 --- a/src/modules/emotion/gstreamer1/emotion_gstreamer.c +++ b/src/modules/emotion/gstreamer1/emotion_gstreamer.c @@ -103,6 +103,8 @@ em_file_open(void *video, ev->shutdown = EINA_FALSE; ev->ready = EINA_FALSE; + ev->live = EINA_FALSE; + ev->buffering = EINA_FALSE; DBG("setting file to '%s'", uri); ev->pipeline = _create_pipeline(ev, ev->obj, uri); @@ -174,7 +176,7 @@ em_play(void *video, if (!ev->pipeline) return; - if (ev->ready) + if (ev->ready && !ev->buffering) gst_element_set_state(ev->pipeline, GST_STATE_PLAYING); ev->play = EINA_TRUE; } @@ -1398,6 +1400,35 @@ _bus_main_handler(void *data) break; } + case GST_MESSAGE_BUFFERING: + { + gint percent = 0; + + /* If the stream is live, we do not care about buffering. */ + if (ev->live) + { + ev->buffering = FALSE; + break; + } + + gst_message_parse_buffering (msg, &percent); + + /* Wait until buffering is complete before start/resume playing */ + if (percent < 100) + gst_element_set_state (ev->pipeline, GST_STATE_PAUSED); + else if (ev->play) + gst_element_set_state (ev->pipeline, GST_STATE_PLAYING); + + ev->buffering = (percent < 100); + + break; + } + case GST_MESSAGE_CLOCK_LOST: + { + gst_element_set_state (ev->pipeline, GST_STATE_PAUSED); + gst_element_set_state (ev->pipeline, GST_STATE_PLAYING); + break; + } default: break; } @@ -1441,6 +1472,7 @@ _emotion_gstreamer_pause(void *data, Ecore_Thread *thread) res = gst_element_get_state(ev->pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); if (res == GST_STATE_CHANGE_NO_PREROLL) { + ev->live = EINA_TRUE; gst_element_set_state(ev->pipeline, GST_STATE_PLAYING); gst_element_get_state(ev->pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); } @@ -1470,7 +1502,7 @@ _emotion_gstreamer_end(void *data, Ecore_Thread *thread) ev->threads = eina_list_remove(ev->threads, thread); - if (ev->play) + if (ev->play && !ev->buffering) { gst_element_set_state(ev->pipeline, GST_STATE_PLAYING); } diff --git a/src/modules/emotion/gstreamer1/emotion_gstreamer.h b/src/modules/emotion/gstreamer1/emotion_gstreamer.h index c549d55..7fa1c2d 100644 --- a/src/modules/emotion/gstreamer1/emotion_gstreamer.h +++ b/src/modules/emotion/gstreamer1/emotion_gstreamer.h @@ -72,6 +72,8 @@ struct _Emotion_Gstreamer Eina_Bool video_mute : 1; Eina_Bool audio_mute : 1; Eina_Bool ready : 1; + Eina_Bool live : 1; + Eina_Bool buffering : 1; Eina_Bool shutdown : 1; }; --
