[gst-devel] Seek event problem

Raoul raoul.hecky at gmail.com
Thu Jan 27 07:28:41 CET 2005


Hi all,

I'm working on a project and I want to use Gstreamer. But I'm having trouble 
to get the seek event working. I've made a little test program :

#include <gst/gst.h>

int main (int   argc,  char *argv[])
{
        GstElement *pipeline, *source, *sink;

        /* initialize GStreamer */
        gst_init (&argc, &argv);

        /* check input arguments */
        if (argc != 2)
        {
            g_print ("Usage: %s <wave filename>\n", argv[0]);
            return -1;
        }

        /* create elements */
        pipeline = gst_pipeline_new ("pipeline");
        source = gst_element_factory_make ("filesrc", "src");
        sink = gst_element_factory_make ("esdsink", "sink");

        /* set filename property on the file source */
        g_object_set (G_OBJECT (source), "location", argv[1], NULL);

        gst_bin_add_many (GST_BIN (pipeline), source, sink , NULL);

        gst_element_link_many (source, sink, NULL);
        gst_element_set_state (pipeline, GST_STATE_PAUSED);
        gst_bin_sync_children_state (GST_BIN (pipeline));

        gboolean res;
        GstEvent *event;

        event = gst_event_new_seek (
            GST_FORMAT_TIME |           /* seek on time */
            GST_SEEK_METHOD_SET |       /* set the absolute position */
            GST_SEEK_FLAG_FLUSH,        /* flush any pending data */
            60 * GST_SECOND);           /* the seek offset (1 second) */

        res = gst_element_send_event (sink, event);
        if (!res)
        {
                g_warning ("seek failed");
        }
        gst_element_set_state (pipeline, GST_STATE_PLAYING);

        while (gst_bin_iterate (GST_BIN (pipeline))) ; //iterate

        gst_element_set_state (pipeline, GST_STATE_NULL);
        gst_object_unref (GST_OBJECT (pipeline));

        return 0;
}

But I can't get the seek event working. The gst_element_send_event() always 
return NULL! Am I doing something wrong?

Help appreciated.

Raoul





More information about the gstreamer-devel mailing list