Accessing the bus of an element in the pipeline

Srinath, Kamaldeep kasrinat at akamai.com
Fri Nov 7 09:25:27 PST 2014


The approach I finally took was to access the bus of the filter's parent from within itself and register a bus callback on it.

GstBus* bus = gst_element_get_bus(GST_ELEMENT_PARENT(GST_ELEMENT_CAST(myFilterObject)));
watchID = gst_bus_add_watch(bus, bus_call, NULL);

This enables handling GstMessages from within the filter. However, if an app creating this filter also has a bus handler method, both don't co-exist. In other words, once the first bus handler (say the app's) gets registered the other fails saying the first one still exists.

So the bus instance we got inside the filter using the above statement, actually seems to be the same instance as the pipeline's? How can this be avoided? It is definitely better to do this from inside a filter since it gives greater control. Removing GST_ELEMENT_PARENT from that above call returns a null/invalid bus.

Thanks
Kamal

From: Srinath, Kamaldeep [mailto:kasrinat at akamai.com]
Sent: Monday, November 03, 2014 8:19 PM
To: gstreamer-devel at lists.freedesktop.org
Subject: Accessing the bus of an element in the pipeline

Hello,

I have a gstreamer application and have added a bus watch to the GstBus of the pipeline. In  the call back method for this bus watch, I am detecting the message type GST_MESSAGE_BUFFERING. The goal is to "post" this message to the bus of a particular GstElement in the running pipeline.

My questions:
- Is this possible?
- Is it possible instead to access the bus of the running pipeline from inside a gstreamer filter and post a message to the pipeline's bus directly from the filter?
- Why do gst_bus_post(element's bus, msg) AND gst_element_post_message(element, message) not work?

Here's my sample code:

Inside the app:

        case GST_MESSAGE_BUFFERING:
        {
            gint percent;
            GstElement* filter = NULL;
            GstBus* mybus = NULL;

            gst_message_parse_buffering(msg, &percent);
            if (pipeline != NULL)
            {
                filter = gst_bin_get_by_name(GST_BIN(pipeline), gst_element_get_name(myfilter));
                mybus = gst_element_get_bus(filter);

                gst_bus_post(mybus, msg);  // Wont work.
                gst_element_post_message(filter, msg); //Wont work either.
                gst_object_unref(mabus);
                g_free(filter);
            }
        }



Thanks for pointing out what's not right here.

Kamal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20141107/de984b93/attachment.html>


More information about the gstreamer-devel mailing list