switchbin is a helper element which chooses between a set of processing chains (paths) based on input caps, and changes if new caps arrive. Paths are child objects, which are accessed by the GstChildProxy interface.

Whenever new input caps are encountered at the switchbin's sinkpad, the * first path with matching caps is picked. The paths are looked at in order: path #0's caps are looked at first, checked against the new input caps with gst_caps_can_intersect, and if its return value is TRUE, path #0 is picked. Otherwise, path #1's caps are looked at etc. If no path matches, an error is reported.

Example launch line

In this example, if the data is raw PCM audio with 44.1 kHz, a volume element is used for reducing the audio volume to 10%. Otherwise, it is just passed through. So, a 44.1 kHz MP3 will sound quiet, a 48 kHz MP3 will be at full volume.

   gst-launch-1.0 uridecodebin uri=<URI> ! switchbin num-paths=2 \
     path0::element="audioconvert ! volume volume=0.1" path0::caps="audio/x-raw, rate=44100" \
     path1::element="identity" path1::caps="ANY" ! \

This example's path #1 is a fallback "catch-all" path. Its caps are "ANY" caps, so any input caps will match against this. A catch-all path with an identity element is useful for cases where certain kinds of processing should only be done for specific formats, like the example above (it applies volume only to 44.1 kHz PCM audio).



Implemented interfaces

Factory details

Authors: – Carlos Rafael Giani


Rank – none

Plugin – switchbin

Package – GStreamer Bad Plug-ins

Pad Templates





Object typeGstPad





Object typeGstPad



“current-path” guint

Returns the currently selected path number. If there is no current path (due to no caps, or unsupported caps), the value is G_MAXUINT. Read-only.

Flags : Read

Default value : -1


“num-paths” guint

Configure how many paths the switchbin will be choosing between. Attempting to configure a path outside the range 0..(n-1) will fail. Reducing the number of paths will release any paths outside the new range, which might trigger activation of a new path by re-assessing the current caps.

Flags : Read / Write

Default value : 0

The results of the search are