element: add gst_element_class_add_static_pad_template()

Pretty much every single element does

  gst_element_class_add_pad_template (element_class,
      gst_static_pad_template_get (&some_templ));

which is both confusing and unnecessary. We might just
as well add a function to do that in one step.

https://bugzilla.gnome.org/show_bug.cgi?id=762778
This commit is contained in:
Tim-Philipp Müller 2016-02-27 15:28:49 +00:00
parent 94ec3f8a3e
commit fa12d23a17
4 changed files with 25 additions and 0 deletions

View file

@ -827,6 +827,7 @@ GST_ELEMENT_METADATA_LONGNAME
<SUBSECTION element-construction>
gst_element_class_add_pad_template
gst_element_class_add_static_pad_template
gst_element_class_get_pad_template
gst_element_class_get_pad_template_list
gst_element_class_set_metadata

View file

@ -1229,6 +1229,26 @@ gst_element_class_add_pad_template (GstElementClass * klass,
klass->numpadtemplates++;
}
/**
* gst_element_class_add_static_pad_template:
* @klass: the #GstElementClass to add the pad template to.
* @templ: #GstStaticPadTemplate to add as pad template to the element class.
*
* Adds a pad template to an element class based on the static pad template
* @templ. This is mainly used in the _class_init functions of element
* implementations. If a pad template with the same name already exists,
* the old one is replaced by the new one.
*
* Since: 1.8
*/
void
gst_element_class_add_static_pad_template (GstElementClass * klass,
GstStaticPadTemplate * static_templ)
{
gst_element_class_add_pad_template (klass,
gst_static_pad_template_get (static_templ));
}
/**
* gst_element_class_add_metadata:
* @klass: class to set metadata for

View file

@ -663,6 +663,9 @@ struct _GstElementClass
/* element class pad templates */
void gst_element_class_add_pad_template (GstElementClass *klass, GstPadTemplate *templ);
void gst_element_class_add_static_pad_template (GstElementClass *klass, GstStaticPadTemplate *static_templ);
GstPadTemplate* gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name);
GList* gst_element_class_get_pad_template_list (GstElementClass *element_class);

View file

@ -480,6 +480,7 @@ EXPORTS
gst_element_class_add_metadata
gst_element_class_add_pad_template
gst_element_class_add_static_metadata
gst_element_class_add_static_pad_template
gst_element_class_get_metadata
gst_element_class_get_pad_template
gst_element_class_get_pad_template_list