[gst-devel] graceful exit/shutdown of a pipeline

Tim-Philipp Müller t.i.m at zen.co.uk
Thu Mar 4 12:21:28 CET 2010


On Thu, 2010-03-04 at 16:18 +0530, Sitanshu Nanavati wrote:

Hi,

> Can someone please let me know what is the right way (or the set of
> APIs) to call for a greaceful shutwon of a gst-launch pipeline?  For
> instance, if there is an error in my own lib if a variable does not
> have correct value, I want to stop the execution.

It depends what you mean by 'graceful'. If you just want to make it stop
in an orderly fashion as soon as possible, a

 gst_element_set_state (pipeline, GST_STATE_NULL);

should be enough.

If you are creating content, e.g. recording audio or video and writing
it to file and you want to make sure that files are all properly
finalised (headers written etc.), then you should do something like
this:

  gst_element_send_event (pipeline, gst_event_new_eos ());
  /* wait for EOS message on the pipeline bus */
  msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipeline),
      GST_MESSAGE_EOS | GST_MESSAGE_ERROR, GST_CLOCK_TIME_NONE);
  /* should check if we got an error message here or an eos */
  gst_element_set_state (pipeline, GST_STATE_NULL);

which is more or less what gst-launch is doing if you pass the -e
option.

Cheers
 -Tim





More information about the gstreamer-devel mailing list