* GST_PAD_TEMPLATE_DIRECTION().
*
* The GST_PAD_TEMPLATE_NAME_TEMPLATE () is important for GST_PAD_REQUEST pads
- * because it has to be used as the name in the gst_element_get_request_pad()
+ * because it has to be used as the name in the gst_element_request_pad_simple()
* call to instantiate a pad from this template.
*
* Padtemplates can be created with gst_pad_template_new() or with
PROP_NAME_TEMPLATE = 1,
PROP_DIRECTION,
PROP_PRESENCE,
- PROP_CAPS
+ PROP_CAPS,
+ PROP_GTYPE,
};
enum
gst_pad_template_signals[TEMPL_PAD_CREATED] =
g_signal_new ("pad-created", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstPadTemplateClass, pad_created),
- NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GST_TYPE_PAD);
+ NULL, NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_PAD);
gobject_class->dispose = gst_pad_template_dispose;
GST_TYPE_CAPS,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ /**
+ * GstPadTemplate:gtype:
+ *
+ * The type of the pad described by the pad template.
+ *
+ * Since: 1.14
+ */
+ g_object_class_install_property (gobject_class, PROP_GTYPE,
+ g_param_spec_gtype ("gtype", "GType",
+ "The GType of the pad described by the pad template",
+ G_TYPE_NONE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
gstobject_class->path_string_separator = "*";
}
{
/* GstPadTemplate objects are usually leaked */
GST_OBJECT_FLAG_SET (templ, GST_OBJECT_FLAG_MAY_BE_LEAKED);
+ GST_PAD_TEMPLATE_GTYPE (templ) = G_TYPE_NONE;
}
static void
gst_caps_unref (GST_PAD_TEMPLATE_CAPS (templ));
}
+ gst_caps_replace (&templ->ABI.abi.documentation_caps, NULL);
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
underscore = strchr (str, '_');
str = strchr (str + 1, '%');
- if (str && (!underscore || (underscore && str < underscore))) {
+ if (str && (!underscore || str < underscore)) {
g_warning
("invalid name template %s: each of conversion specifications "
"must be separated by an underscore", name);
*
* Converts a #GstStaticPadTemplate into a #GstPadTemplate.
*
- * Returns: (transfer full): a new #GstPadTemplate.
+ * Returns: (transfer floating) (nullable): a new #GstPadTemplate.
*/
/* FIXME0.11: rename to gst_pad_template_new_from_static_pad_template() */
GstPadTemplate *
}
/**
+ * gst_pad_template_new_from_static_pad_template_with_gtype:
+ * @pad_template: the static pad template
+ * @pad_type: The #GType of the pad to create
+ *
+ * Converts a #GstStaticPadTemplate into a #GstPadTemplate with a type.
+ *
+ * Returns: (transfer floating) (nullable): a new #GstPadTemplate.
+ *
+ * Since: 1.14
+ */
+GstPadTemplate *
+gst_pad_template_new_from_static_pad_template_with_gtype (GstStaticPadTemplate *
+ pad_template, GType pad_type)
+{
+ GstPadTemplate *new;
+ GstCaps *caps;
+
+ g_return_val_if_fail (g_type_is_a (pad_type, GST_TYPE_PAD), NULL);
+
+ if (!name_is_valid (pad_template->name_template, pad_template->presence))
+ return NULL;
+
+ caps = gst_static_caps_get (&pad_template->static_caps);
+
+ new = g_object_new (gst_pad_template_get_type (),
+ "name", pad_template->name_template,
+ "name-template", pad_template->name_template,
+ "direction", pad_template->direction,
+ "presence", pad_template->presence, "caps", caps, "gtype", pad_type,
+ NULL);
+
+ gst_caps_unref (caps);
+
+ return new;
+}
+
+/**
* gst_pad_template_new:
* @name_template: the name template.
* @direction: the #GstPadDirection of the template.
* Creates a new pad template with a name according to the given template
* and with the given arguments.
*
- * Returns: (transfer floating): a new #GstPadTemplate.
+ * Returns: (transfer floating) (nullable): a new #GstPadTemplate.
*/
GstPadTemplate *
gst_pad_template_new (const gchar * name_template,
}
/**
+ * gst_pad_template_new_with_gtype:
+ * @name_template: the name template.
+ * @direction: the #GstPadDirection of the template.
+ * @presence: the #GstPadPresence of the pad.
+ * @caps: (transfer none): a #GstCaps set for the template.
+ * @pad_type: The #GType of the pad to create
+ *
+ * Creates a new pad template with a name according to the given template
+ * and with the given arguments.
+ *
+ * Returns: (transfer floating) (nullable): a new #GstPadTemplate.
+ *
+ * Since: 1.14
+ */
+GstPadTemplate *
+gst_pad_template_new_with_gtype (const gchar * name_template,
+ GstPadDirection direction, GstPadPresence presence, GstCaps * caps,
+ GType pad_type)
+{
+ GstPadTemplate *new;
+
+ g_return_val_if_fail (name_template != NULL, NULL);
+ g_return_val_if_fail (caps != NULL, NULL);
+ g_return_val_if_fail (direction == GST_PAD_SRC
+ || direction == GST_PAD_SINK, NULL);
+ g_return_val_if_fail (presence == GST_PAD_ALWAYS
+ || presence == GST_PAD_SOMETIMES || presence == GST_PAD_REQUEST, NULL);
+ g_return_val_if_fail (g_type_is_a (pad_type, GST_TYPE_PAD), NULL);
+
+ if (!name_is_valid (name_template, presence)) {
+ return NULL;
+ }
+
+ new = g_object_new (gst_pad_template_get_type (),
+ "name", name_template, "name-template", name_template,
+ "direction", direction, "presence", presence, "caps", caps,
+ "gtype", pad_type, NULL);
+
+ return new;
+}
+
+/**
* gst_static_pad_template_get_caps:
* @templ: a #GstStaticPadTemplate to get capabilities of.
*
}
/**
+ * gst_pad_template_set_documentation_caps:
+ * @templ: the pad template to set documented capabilities on
+ * @caps: (transfer full): the documented capabilities
+ *
+ * Certain elements will dynamically construct the caps of their
+ * pad templates. In order not to let environment-specific information
+ * into the documentation, element authors should use this method to
+ * expose "stable" caps to the reader.
+ *
+ * Since: 1.18
+ */
+void
+gst_pad_template_set_documentation_caps (GstPadTemplate * templ, GstCaps * caps)
+{
+ g_return_if_fail (GST_IS_PAD_TEMPLATE (templ));
+ g_return_if_fail (GST_IS_CAPS (caps));
+
+ if (caps)
+ GST_MINI_OBJECT_FLAG_SET (caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
+ gst_caps_replace (&(((GstPadTemplate *) (templ))->ABI.abi.documentation_caps),
+ caps);
+}
+
+/**
+ * gst_pad_template_get_documentation_caps:
+ * @templ: the pad template to get documented capabilities on
+ *
+ * See gst_pad_template_set_documentation_caps().
+ *
+ * Returns: The caps to document. For convenience, this will return
+ * gst_pad_template_get_caps() when no documentation caps were set.
+ * Since: 1.18
+ */
+GstCaps *
+gst_pad_template_get_documentation_caps (GstPadTemplate * templ)
+{
+ g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL);
+
+ if (((GstPadTemplate *) (templ))->ABI.abi.documentation_caps)
+ return gst_caps_ref (((GstPadTemplate *) (templ))->ABI.abi.
+ documentation_caps);
+ else
+ return gst_pad_template_get_caps (templ);
+}
+
+/**
* gst_pad_template_pad_created:
* @templ: a #GstPadTemplate that has been created
* @pad: the #GstPad that created it
GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
}
break;
+ case PROP_GTYPE:
+ GST_PAD_TEMPLATE_GTYPE (object) = g_value_get_gtype (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_CAPS:
g_value_set_boxed (value, GST_PAD_TEMPLATE_CAPS (object));
break;
+ case PROP_GTYPE:
+ g_value_set_gtype (value, GST_PAD_TEMPLATE_GTYPE (object));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;