#include "gst_private.h"
#include "gstelement.h"
-#include "gstregistry.h"
+#include "gstregistrypool.h"
#include "gstlog.h"
static void gst_element_factory_class_init (GstElementFactoryClass *klass);
static void
gst_element_details_free (GstElementDetails *dp)
{
- g_return_if_fail (dp);
-
- if (dp->longname)
- g_free (dp->longname);
- if (dp->klass)
- g_free (dp->klass);
- if (dp->description)
- g_free (dp->description);
- if (dp->version)
- g_free (dp->version);
- if (dp->author)
- g_free (dp->author);
- if (dp->copyright)
- g_free (dp->copyright);
+ g_free (dp->longname);
+ g_free (dp->klass);
+ g_free (dp->license);
+ g_free (dp->description);
+ g_free (dp->version);
+ g_free (dp->author);
+ g_free (dp->copyright);
g_free (dp);
}
+static void
+gst_element_factory_cleanup (GstElementFactory *factory)
+{
+ GList *padtemplates;
+
+ if (factory->details_dynamic) {
+ gst_element_details_free (factory->details);
+ factory->details_dynamic = FALSE;
+ }
+
+ padtemplates = factory->padtemplates;
+
+ while (padtemplates) {
+ GstPadTemplate *oldtempl = GST_PAD_TEMPLATE (padtemplates->data);
+
+ gst_object_unref (GST_OBJECT (oldtempl));
+
+ padtemplates = g_list_next (padtemplates);
+ }
+ g_list_free (factory->padtemplates);
+
+ factory->padtemplates = NULL;
+ factory->numpadtemplates = 0;
+
+ g_free (GST_PLUGIN_FEATURE (factory)->name);
+}
+
/**
* gst_element_factory_new:
* @name: name of new elementfactory
if (!factory)
factory = GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL));
-
- if (factory->details_dynamic) {
- gst_element_details_free (factory->details);
- factory->details_dynamic = FALSE;
+ else {
+ gst_element_factory_cleanup (factory);
}
factory->details = details;
+ factory->details_dynamic = FALSE;
if (!factory->type)
factory->type = type;
*
* Returns: new #GstElement
*/
-GstElement *
+GstElement*
gst_element_factory_create (GstElementFactory *factory,
const gchar *name)
{
GST_DEBUG (GST_CAT_ELEMENT_FACTORY,
"creating element from factory \"%s\" (name \"%s\", type %d)",
- GST_OBJECT_NAME (factory), name, (gint) factory->type);
+ GST_PLUGIN_FEATURE_NAME (factory), GST_STR_NULL (name), (gint) factory->type);
if (factory->type == 0) {
g_critical ("Factory for `%s' has no type",
/* attempt to set the elemenfactory class pointer if necessary */
oclass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
if (oclass->elementfactory == NULL) {
- GST_DEBUG (GST_CAT_ELEMENT_FACTORY, "class %s", GST_OBJECT_NAME (factory));
+ GST_DEBUG (GST_CAT_ELEMENT_FACTORY, "class %s", GST_PLUGIN_FEATURE_NAME (factory));
oclass->elementfactory = factory;
/* copy pad template pointers to the element class,
g_return_val_if_fail (factoryname != NULL, NULL);
GST_DEBUG (GST_CAT_ELEMENT_FACTORY, "gstelementfactory: make \"%s\" \"%s\"",
- factoryname, name);
+ factoryname, GST_STR_NULL (name));
/* gst_plugin_load_element_factory (factoryname); */
factory = gst_element_factory_find (factoryname);
GstElement*
gst_element_factory_make_or_warn (const gchar *factoryname, const gchar *name)
{
- GstElement *element = gst_element_factory_make (factoryname, name);
+ GstElement *element;
+
+ element = gst_element_factory_make (factoryname, name);
if (element == NULL)
g_warning ("Could not create element from factory %s !\n", factoryname);
*/
void
gst_element_factory_add_pad_template (GstElementFactory *factory,
- GstPadTemplate *templ)
+ GstPadTemplate *templ)
{
- GList *padtemplates;
-
- g_return_if_fail(factory != NULL);
- g_return_if_fail(templ != NULL);
-
- padtemplates = factory->padtemplates;
+ g_return_if_fail (factory != NULL);
+ g_return_if_fail (templ != NULL);
gst_object_ref (GST_OBJECT (templ));
+ gst_object_sink (GST_OBJECT (templ));
- while (padtemplates) {
- GstPadTemplate *oldtempl = GST_PAD_TEMPLATE (padtemplates->data);
-
- if (!strcmp (oldtempl->name_template, templ->name_template)) {
- gst_object_unref (GST_OBJECT (oldtempl));
- padtemplates->data = templ;
- return;
- }
-
- padtemplates = g_list_next (padtemplates);
- }
factory->padtemplates = g_list_append (factory->padtemplates, templ);
factory->numpadtemplates++;
}
GstPadTemplate *template = (GstPadTemplate *)templates->data;
if (template->direction == GST_PAD_SRC) {
- if (gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (template), caps))
+ if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template), caps))
return TRUE;
}
templates = g_list_next (templates);
GstPadTemplate *template = (GstPadTemplate *)templates->data;
if (template->direction == GST_PAD_SINK) {
- if (gst_caps_check_compatibility (caps, GST_PAD_TEMPLATE_CAPS (template)))
+ if (gst_caps_is_always_compatible (caps, GST_PAD_TEMPLATE_CAPS (template)))
return TRUE;
}
templates = g_list_next (templates);
void
gst_element_factory_set_rank (GstElementFactory *factory, guint16 rank)
{
- g_return_if_fail(factory != NULL);
+ g_return_if_fail (factory != NULL);
factory->rank = rank;
}