How can I tell if all elements received the EOS?

yoyosuper8 yoyosuper8 at yahoo.com
Thu Jul 24 19:38:09 PDT 2014


Hey Tim,

I do not have a bus watch, but I'm assuming it should be a simple
implementation right?
Do you think this will suffice? Is this the proper way to terminate a
pipeline if an EOS event is sent thru the pipeline by using a bus watch as
shown below?

static GMainLoop *loop;

gint main ()
{
       GstElement *pipeline; 
       pipeline = gs_parse_launch ("v4l2src ! videoconvert ! eglglessink
name=videosink"); 

       GstBus *bus;
       guint bus_watch_id;

       bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       bus_watch_id = gst_bus_add_watch (bus, my_bus_callback, NULL);

       loop = g_main_loop_new (NULL, FALSE);
       g_main_loop_run (loop);

       // clean up
       gst_element_set_state (pipeline, GST_STATE_NULL);
       gst_object_unref (pipeline);
       g_source_remove (bus_watch_id);
       g_main_loop_unref (loop);
       return 0;
}

static gboolean my_bus_callback (GstBus *bus, GstMessage *message, gpointer
data)
{
       g_print ("Got %s message\n", GST_MESSAGE_TYPE_NAME (message));

       switch (GST_MESSAGE_TYPE (message)) {
              case GST_MESSAGE_ERROR:
                     GError *err;
                     gchar *debug;

                     gst_message_parse_error (message, &err, &debug);
                     g_print ("Error: %s\n", err->message);
                     g_error_free (err);
                     g_free (debug);

                     g_main_loop_quit (loop);
                     break;

               case GST_MESSAGE_EOS:
                     // end-of-stream
                     g_main_loop_quit (loop);
                     break;

               default:
                     break;
      }

      return TRUE;
}

Thanks!



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-can-I-tell-if-all-elements-received-the-EOS-tp4668055p4668059.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list