linking "urisourcebin" element with "tee" element programatically

Guy Flax guyflax1234 at
Sat Nov 21 12:01:21 UTC 2020

This is a simplified version of the pipeline that I'm building:
gst-launch-1.0 urisourcebin uri=rtsp:// ! tee name=t !
queue ! decodebin ! videoconvert ! autovideosink

As gst-inspect-1.0 says:
* urisourcebin has multiple "sometimes" pads (called src_%d).
* tee has single sink (called sink)

How can I link both video and audio source pads to this single tee sink?
Do I have a special pad "ANY"?  If yes, how to do that?

this is the pad_added callback:

void urisourcebin_pad_added_handler(GstElement* src, GstPad* new_pad,
CustomData* data) {
GstPad* sink_pad = gst_element_get_static_pad(data->urisource_tee, "sink");
GstCaps* new_pad_caps = NULL;
GstStructure* new_pad_struct = NULL;
const gchar* new_pad_type = NULL;
GstPadLinkReturn ret;

g_print("Received new pad '%s' from '%s':\n", GST_PAD_NAME(new_pad),

/* Check the new pad's type */
new_pad_caps = gst_pad_get_current_caps(new_pad);
new_pad_struct = gst_caps_get_structure(new_pad_caps, 0);
new_pad_type = gst_structure_get_name(new_pad_struct);

if (!g_str_has_prefix(new_pad_type, "ANY")) {
g_print("It has type '%s' which is not 'any'. Ignoring.\n", new_pad_type);
goto exit;

/* If our tee is already linked, we have nothing to do here */
if (gst_pad_is_linked(sink_pad)) {
g_print("We are already linked. Ignoring.\n");
goto exit;

/* Attempt the link */
ret = gst_pad_link(new_pad, sink_pad);
g_print("Linking urisourcebin to tee sink was failed.\n");

/* Unreference the new pad's caps, if we got them */
if (new_pad_caps != NULL)

/* Unreference the sink pad */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list