"Request" pads are similar to sometimes pads, except that
request are created on demand of something outside of the element rather
than something inside the element. This concept is often used in muxers,
where - for each elementary stream that is to be placed in the output
system stream - one sink pad will be requested. It can also be used in
elements with a variable number of input or outputs pads, such as the
tee
(multi-output), switch
or aggregator
(both multi-input) elements. At the
time of writing this, it is unclear to me who is responsible for cleaning
up the created pad and how or when that should be done. Below is a simple
example of an aggregator based on request pads.
static GstPad * gst_my_filter_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name); static void gst_my_filter_base_init (GstMyFilterClass *klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ( "sink_%d", GST_PAD_SINK, GST_PAD_REQUEST, GST_STATIC_CAPS ("ANY") ); [..] gst_element_class_add_pad_template (klass, gst_static_pad_template_get (&sink_factory)); } static void gst_my_filter_class_init (GstMyFilterClass *klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); [..] element_class->request_new_pad = gst_my_filter_request_new_pad; } static GstPad * gst_my_filter_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name) { GstPad *pad; GstMyFilterInputContext *context; context = g_new0 (GstMyFilterInputContext, 1); pad = gst_pad_new_from_template (templ, name); gst_element_set_private_data (pad, context); /* normally, you would set _link () and _getcaps () functions here */ gst_element_add_pad (element, pad); return pad; }