mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
aggregator: Add create_new_pad() vfunc to allow subclasses to override the default behaviour
Not all aggregator subclasses will have a single pad template called sink_%u and might do something special depending on what the application requests. https://bugzilla.gnome.org/show_bug.cgi?id=757018
This commit is contained in:
parent
41b4a78b6b
commit
bbd11aea40
2 changed files with 32 additions and 10 deletions
|
@ -1308,23 +1308,19 @@ gst_aggregator_release_pad (GstElement * element, GstPad * pad)
|
|||
SRC_UNLOCK (self);
|
||||
}
|
||||
|
||||
static GstPad *
|
||||
gst_aggregator_request_new_pad (GstElement * element,
|
||||
static GstAggregatorPad *
|
||||
gst_aggregator_default_create_new_pad (GstAggregator * self,
|
||||
GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps)
|
||||
{
|
||||
GstAggregator *self;
|
||||
GstAggregatorPad *agg_pad;
|
||||
|
||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
|
||||
GstAggregatorPrivate *priv = GST_AGGREGATOR (element)->priv;
|
||||
|
||||
self = GST_AGGREGATOR (element);
|
||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS (self);
|
||||
GstAggregatorPrivate *priv = self->priv;
|
||||
|
||||
if (templ == gst_element_class_get_pad_template (klass, "sink_%u")) {
|
||||
gint serial = 0;
|
||||
gchar *name = NULL;
|
||||
|
||||
GST_OBJECT_LOCK (element);
|
||||
GST_OBJECT_LOCK (self);
|
||||
if (req_name == NULL || strlen (req_name) < 6
|
||||
|| !g_str_has_prefix (req_name, "sink_")) {
|
||||
/* no name given when requesting the pad, use next available int */
|
||||
|
@ -1341,11 +1337,30 @@ gst_aggregator_request_new_pad (GstElement * element,
|
|||
"name", name, "direction", GST_PAD_SINK, "template", templ, NULL);
|
||||
g_free (name);
|
||||
|
||||
GST_OBJECT_UNLOCK (element);
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
return agg_pad;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static GstPad *
|
||||
gst_aggregator_request_new_pad (GstElement * element,
|
||||
GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps)
|
||||
{
|
||||
GstAggregator *self;
|
||||
GstAggregatorPad *agg_pad;
|
||||
GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (element);
|
||||
GstAggregatorPrivate *priv = GST_AGGREGATOR (element)->priv;
|
||||
|
||||
self = GST_AGGREGATOR (element);
|
||||
|
||||
agg_pad = klass->create_new_pad (self, templ, req_name, caps);
|
||||
if (!agg_pad) {
|
||||
GST_ERROR_OBJECT (element, "Couldn't create new pad");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (element, "Adding pad %s", GST_PAD_NAME (agg_pad));
|
||||
self->priv->has_peer_latency = FALSE;
|
||||
|
@ -1949,6 +1964,8 @@ gst_aggregator_class_init (GstAggregatorClass * klass)
|
|||
klass->src_event = gst_aggregator_default_src_event;
|
||||
klass->src_query = gst_aggregator_default_src_query;
|
||||
|
||||
klass->create_new_pad = gst_aggregator_default_create_new_pad;
|
||||
|
||||
gstelement_class->request_new_pad =
|
||||
GST_DEBUG_FUNCPTR (gst_aggregator_request_new_pad);
|
||||
gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_aggregator_send_event);
|
||||
|
|
|
@ -245,6 +245,11 @@ struct _GstAggregatorClass {
|
|||
|
||||
GstClockTime (*get_next_time) (GstAggregator * aggregator);
|
||||
|
||||
GstAggregatorPad * (*create_new_pad) (GstAggregator * self,
|
||||
GstPadTemplate * templ,
|
||||
const gchar * req_name,
|
||||
const GstCaps * caps);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue