Why are seek events failing with my GStreamer app?
This is my seeking function:
gboolean seek(CustomData* data)
{
gint64 position;
GstFormat format = GST_FORMAT_TIME;
GstEvent *seek_event;
/* Obtain the current position, needed for the seek event */
if (!gst_element_query_position(data->pipeline, &format, &position))
{
g_printerr("Unable to retrieve current position.\n");
return FALSE;
}
/* Create the seek event */
if (data->rate > 0)
{
seek_event = gst_event_new_seek(data->rate, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
position, GST_SEEK_TYPE_NONE, 0);
}
else if (data->rate < 0)
{
seek_event = gst_event_new_seek(data->rate, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
0,
GST_SEEK_TYPE_SET, position);
}
else
{
g_printerr("Rate is set to 0.\n");
return FALSE;
}
/* Check that seek_event was created */
if (seek_event == NULL) {
g_printerr("Could not create seek event.\n");
return FALSE;
}
/* Send the event */
if (!gst_element_send_event(data->autovideosink, seek_event))
{
g_printerr("Could not perform seek event.\n");
return FALSE;
}
g_print("Current rate: %gx\n", data->rate);
return TRUE;
}
But it fails at sending the seek event. This code is pertty much just
slightly modified from the GStreamer tutorials, but I'm playing a .vob
file and I have a custom pipeline instead of playbin2. I'm also using
appsrc so I'm feeding the buffers from a file, but I don't imagine that
would cause any problems with fast forwarding. However, I can't seek
either forward or backward (setting the rate to 2x or .5x fails at the
same spot).
No comments:
Post a Comment