Captue "critical" messages

Kyrylo V Polezhaiev polezhaiev at ukr.net
Wed Feb 27 05:53:03 PST 2013


> Occasionally as I develop a new pipeline I will make an error that causes the
> pipeline to emit critical warnings and/or critical errors.  These messages
> just pop-up on my screen and, since I already have a bunch of program debug
> print statements sending stuff to the screen, I don't always see them and
> they aren't captured into my logs (program logs, not gst ones).
> 
> So, how do I capture these messages?  I assume there is a callback routine
> to capture them.
> 
> Or, how do I programatically turn on gsgtreamer logging.  I'd prefer not to
> use command line switches nor environment variables as this particular
> project is a dll/so where I'd like to be able to let the main program
> control the gst logging by a library call.  Of course, I'd also like to be
> able to restrict the class/type of the logged information.
> 
> Thanks,
> 
> Wes
> 
Hello, Wes!

You can create a bus watch function like this and put your handlers inside:

static gboolean bus_cb(GstBus *bus, GstMessage *message, gpointer data)
{
    switch (GST_MESSAGE_TYPE(message))
    {
    case GST_MESSAGE_BUFFERING:
        break;

    case GST_MESSAGE_EOS:
        break;

    case GST_MESSAGE_CLOCK_LOST:
        break;

    case GST_MESSAGE_INFO:
        break;

    case GST_MESSAGE_WARNING:
        break;

    case GST_MESSAGE_ERROR:
        break;

    default:
        break;
    }

    return TRUE;
}

And than attach it to your pipeline:

GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
gst_bus_add_watch(bus, bus_cb, data);
gst_object_unref(bus);

Sincerely,
Kyrylo.


More information about the gstreamer-devel mailing list