[gst-devel] Seek howto ?

Giuliano Pochini pochini at shiny.it
Fri Jun 25 13:52:02 CEST 2004


On Fri, 25 Jun 2004 12:44:44 +0200 (CEST)

> > For a pipeline filesrc ! spider ! audiosink, do:
> >
> > static gboolean
> > seek (guint64 ns)
> > {
> >   GstEvent *event;
> >   GstElement *audiosink = ..;
> >
> >   event = gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_TIME,
> >       ns);
> >   return gst_element_send_event (audiosink, event);
> > }
> 
> 
> Are you sure ?  I cannot test it now, but I couldn't seek
> at all when the spider is in the chain. I tried to send
> the event to all the elements without success.


Nope, it doesn't seek when I use the spider. When I use mad, it doesn't seek
if I specify GST_SEEK_FLAG_FLUSH. Furthermore, it seeks only if the stream
has been started AND gst_bin_iterate() has been called at least once.

This is the code:


int main (int argc, char *argv[]) {
  GstElement *mainpl, *filesrc, *decoder, *audiosink;
  gboolean res;
  GstEvent *event;

  gst_init (&argc, &argv);

  mainpl = gst_pipeline_new("pipeline");
  filesrc = gst_element_factory_make("filesrc", "disk_source");
  g_object_set(G_OBJECT(filesrc), "location", argv[1], NULL);
  decoder = gst_element_factory_make("spider", 0);
  audiosink = gst_element_factory_make("alsasink", "play_audio");
  gst_bin_add_many(GST_BIN(mainpl), filesrc, decoder, audiosink, NULL);
  gst_element_link_many(filesrc, decoder, audiosink, NULL);

  gst_element_set_state(mainpl, GST_STATE_PLAYING);
  gst_bin_iterate(GST_BIN(mainpl));

  gst_element_seek(audiosink, GST_FORMAT_TIME|GST_SEEK_METHOD_SET, 10 * GST_SECOND);
  gst_element_set_state(mainpl, GST_STATE_PLAYING);

  while (gst_bin_iterate(GST_BIN(mainpl)));
  gst_element_set_state(mainpl, GST_STATE_NULL);
  exit(0);
}




--
Giuliano.




More information about the gstreamer-devel mailing list