Improving Debugging in GStreamer Validate

Debugging GStreamer is often a hard and time-consuming task; because of this, the community has been working to enhance debugging tools and make it simpler in the gst-devtools official module and its gst-validate component (you can find more information about this in my previous post).

Lately, we’ve decided to take a step forward and enhance the GStreamer validate reports for specific and very common GStreamer issues. We started with the classic Not Negotiated Error which basically happens when the elements in the pipeline are not able to agree on a data format (Caps) in which to do the processing. This can happen for many reasons, and until recently, the only way to figure out what went wrong was to read verbose and sometimes hard to read GStreamer debug logs; this is time consuming, particularly for people who are not very familiar with GStreamer. Starting from the next 1.10 release, GstValidate will attempt to explain the precise reason and place in the pipeline where the negotiation could not properly occur. Basically, we started caching information about negotiation events in the pipeline (query caps queries and accept caps events) in the GstValidateMonitor-s so that we can figure out what led to the error and report it.

Examples of New Debugging Helpers

For example, for the following pipeline that can’t be negotiated:

gst-validate-1.0 audiotestsrc ! input-selector ! capsfilter name=capsfilter caps=video/x-raw ! fakesink

GstValidate will output the following report:

critical : a NOT NEGOTIATED message has been posted on the bus.
 Detected on pipeline0
 Details : Error message posted by: audiotestsrc0
 Caps negotiation failed starting from pad 'capsfilter:sink' as the QUERY_CAPS returned EMPTY caps for the following possible reasons:
 - Downstream caps struct 0 name 'video/x-raw' differs from filter caps struct 0 name 'audio/x-raw'

Which explains in ‘plain English’ that the data coming inside capsfilter is an audio stream, but we’re trying to force a video stream using the capsfilter, which is simply not possible and thus, produces the Not Negotiated Error.

Here’s another example where the problem happens later in the negotiation (during the ACCEPT_CAPS event):

gst-validate-1.0 audiotestsrc ! audio/x-raw,channels=2 ! audioconvert ! capsfilter caps=audio/x-raw,channels=6,channel-mask='(bitmask)0x32'  name=capsfilter ! fakesink

GStreamer validate will report the following issue:

 critical : a NOT NEGOTIATED message has been posted on the bus.
 Detected on pipeline0
 Details : Error message posted by: audiotestsrc0
 Caps negotiation failed at pad 'capsfilter:sink' as it refused caps: audio/x-raw, layout=(string)interleaved, rate=(int)44100, format=(string)S16LE, channels=(int)6, channel-mask=(bitmask)0x000000000000003f
 - Field 'channel-mask' downstream value from structure 0 '(GstBitmask)0x000000000000003f' can't intersect with filter value from structure number 0 '(GstBitmask)0x0000000000000032'

This informs us there is incompatibility in the ‘channel-mask’ field of the caps proposed by the audioconvert element and the caps we are forcing to be used in the capsfilter (this seems to be a bug in audioconvert as it does not take into account the value returned during QUERY_CAPS).

GstValidate is now also able to add backtraces to its reports if the user explicitly asks for them by setting the GST_VALIDATE_REPORTING_DETAILS variable to all for the wanted messages. The backtraces will contain the stack leading to the message report with the source files names and line numbers.

We are planning to add more of these detailed reports as we have a good idea of  how to do it. Finally, if you have any ideas to contribute to this, please let us know either in the comments here or on the gstreamer-devel mailing list.

Author: Thibault Saunier

Thibault Saunier is a open source Multimedia engineer mostly developing and maintaining the GStreamer framework and the Pitivi Video editor.