Working with a GStreamer pipeline will often involve the use of pad probes. Pad probes are callbacks that GStreamer pads call at various stages of sending and receiving buffers and events. They allow GStreamer applications to monitor and control the flow of data between elements. Pad probes are created by calling ‘gst_pad_add_probe’ which takes parameters for the pad, probe type and probe callback function. The return value is a unique ID for the pad probe. This value can be passed to ‘gst_pad_remove_probe’ when the probe is no longer needed.
Pad probes can be blocking or non-blocking. A blocking probe will prevent any buffers from flowing through a pad as long as the probe is installed. These can be configured to run on the next buffer, or after the next buffer when the pad is idle. Blocking pad probes ca be used to dynamically re-configure a pipeline while it is playing.
Another common use of pad probes is to monitor buffers as they flow through the pipeline. Pad probes can be configured to run every time a buffer is passed through the pad. In this case a pointer to the buffer is provided so that information about the buffer can be read, including the buffer’s data format and timestamp. If needed, the buffer’s data can be mapped to a region of memory and copied or even modified.