Loop player for GStreamer
Thomas Scheuermann
scheuermann at barco.com
Mon May 4 01:20:03 PDT 2015
Am 04.05.2015 um 09:27 schrieb Sebastian Dröge:
On Mo, 2015-05-04 at 09:15 +0200, Thomas Scheuermann wrote:
Hi all,
I need to write a player that loops over a file and plays it
continuously. I found in some mails that I should use gst_element_seek
with GST_SEEK_FLAG_SEGMENT. But it doesn't work. Here is the event loop
I use:
[...]
What kind of file are you using, which container format? And which
GStreamer version? Until recently there were some bugs related to this.
The procedure in general is to a) first to a FLUSHING|SEGMENT seek to
your start position, then b) whenever you receive the segment-done
message you would do a SEGMENT (non-flushing!) see to the loop start and
c) in the very end for the last loop you do a non-segment, non-flushing
seek for the last loop (so that you get EOS in the end instead of
segment-done).
I'm now working with GStreamer 1.4.4 on Debian Jessie.
I've changed my event loop now in the following way:
bus = gst_pipeline_get_bus(GST_PIPELINE(bin));
while(!done)
{
message = gst_bus_timed_pop(bus, GST_CLOCK_TIME_NONE);
switch(GST_MESSAGE_TYPE(message))
{
case GST_MESSAGE_ERROR:
g_print("Error occured\n");
g_print("%s :\n", GST_MESSAGE_SRC_NAME(message));
break;
case GST_MESSAGE_STATE_CHANGED:
gst_element_get_state(GST_ELEMENT(GST_MESSAGE_SRC(message)), &state, NULL, 0);
g_print("Element %s changed state to %d\n", GST_MESSAGE_SRC_NAME(message), state);
if(GST_ELEMENT(message->src) == bin) {
if(state == GST_STATE_PLAYING) {
if(!once) {
once = TRUE;
g_print("gst_element_seek_simple (GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH)\n");
if(!gst_element_seek_simple(bin, GST_FORMAT_TIME, GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH, 0)) {
g_print("gst_element_seek_simple failed\n");
}
}
}
}
break;
case GST_MESSAGE_EOS:
g_print("End Of Stream\n");
done = TRUE;
break;
case GST_MESSAGE_SEGMENT_DONE:
g_print("segment done\n");
g_print("gst_element_seek_simple (GST_SEEK_FLAG_SEGMENT)\n");
if(!gst_element_seek_simple(bin, GST_FORMAT_TIME, GST_SEEK_FLAG_SEGMENT, 0)) {
g_print("gst_element_seek failed\n");
}
break;
default:
g_print("Messgae %s\n", GST_MESSAGE_TYPE_NAME(message));
break;
}
gst_message_unref(message);
}
gst_object_unref(bus);
Now the first time the file plays normal. At the end the file starts playing again from the beginning but in high speed, not in normal speed. So the player loops over the file but only the first time in normal speed.
How can this be fixed?
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org<mailto:gstreamer-devel at lists.freedesktop.org>
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
This message is subject to the following terms and conditions: MAIL DISCLAIMER<http://www.barco.com/en/maildisclaimer>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150504/bc31a359/attachment-0001.html>
More information about the gstreamer-devel
mailing list