How can I tell if all elements received the EOS?

Tim Müller tim at centricular.com
Thu Jul 24 15:50:34 PDT 2014


On Thu, 2014-07-24 at 14:05 -0700, yoyosuper8 wrote:

> Hi, I'm trying to figure out if the EOS event I send thru the pipeline is
> actually accepted by all the elements in the pipeline.
> 
> Here is the pipeline code:
> GstElement *pipeline;
> pipeline = gs_parse_launch ("v4l2src ! videoconvert ! eglglessink
> name=videosink");
> 
> 
> When I close the application, I send an EOS thru the pipeline as such:
> gst_element_send_event(pipeline, gst_event_new_eos());
> sleep(5);
> g_free(pipeline);

g_free() is not how you free a pipeline.

> After the EOS is sent, I execute a sleep(5) to pause for 5 seconds before
> freeing the pipeline resources.
> I know this is not the best way to do it, but it actually works. However,
> I'd like to find a way to detect if v4l2src does get the EOS and stops
> streaming, and if it does, then free the pipeline resources, otherwise wait
> until v4l2src gets the EOS event.
> 
> Any thoughts :)

gst_element_send_event(pipeline, gst_event_new_eos());
wait for EOS message on bus, either asynchronously if you have a bus
watch or (as last resort) like this:

/* wait for EOS (blocks) */
GstClockTime timeout = 10 * GST_SECOND;
GstMessage *msg;

msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipeline),
    timeout, GST_MESSAGE_EOS | GST_MESSAGE_ERROR);

if (msg == NULL) {
  g_warning ("No EOS after 10 seconds!\n");
} else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {
  .. handle error message ...
} else {
  g_print ("EOS.\n");
}

if (msg)
  gst_message_unref (msg);

/* shutdown pipeline and free pipeline */
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);


 Cheers
  -Tim

-- 
Tim Müller, Centricular Ltd - http://www.centricular.com



More information about the gstreamer-devel mailing list