2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstelementfactory.c: GstElementFactory object, support routines
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* #define DEBUG_ENABLED */
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstelement.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
static void gst_elementfactory_class_init (GstElementFactoryClass *klass);
|
|
|
|
static void gst_elementfactory_init (GstElementFactory *factory);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2001-09-10 19:46:01 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2001-12-04 22:12:50 +00:00
|
|
|
static void gst_elementfactory_restore_thyself (GstObject *object, xmlNodePtr parent);
|
|
|
|
static xmlNodePtr gst_elementfactory_save_thyself (GstObject *object, xmlNodePtr parent);
|
2001-10-17 10:21:27 +00:00
|
|
|
#endif
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
static void gst_elementfactory_unload_thyself (GstPluginFeature *feature);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* global list of registered elementfactories */
|
2001-08-21 20:16:48 +00:00
|
|
|
static GList* _gst_elementfactories;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static GstPluginFeatureClass *parent_class = NULL;
|
2001-12-14 22:59:21 +00:00
|
|
|
/* static guint gst_elementfactory_signals[LAST_SIGNAL] = { 0 }; */
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
gst_elementfactory_get_type (void)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
2001-08-21 20:16:48 +00:00
|
|
|
static GType elementfactory_type = 0;
|
|
|
|
|
|
|
|
if (!elementfactory_type) {
|
|
|
|
static const GTypeInfo elementfactory_info = {
|
|
|
|
sizeof (GstElementFactoryClass),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_elementfactory_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(GstElementFactory),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_elementfactory_init,
|
2001-09-14 22:16:47 +00:00
|
|
|
NULL
|
2001-08-21 20:16:48 +00:00
|
|
|
};
|
|
|
|
elementfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
|
|
|
|
"GstElementFactory", &elementfactory_info, 0);
|
|
|
|
}
|
|
|
|
return elementfactory_type;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static void
|
|
|
|
gst_elementfactory_class_init (GstElementFactoryClass *klass)
|
2000-12-11 00:04:25 +00:00
|
|
|
{
|
2001-08-21 20:16:48 +00:00
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstObjectClass *gstobject_class;
|
|
|
|
GstPluginFeatureClass *gstpluginfeature_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass*)klass;
|
|
|
|
gstobject_class = (GstObjectClass*)klass;
|
|
|
|
gstpluginfeature_class = (GstPluginFeatureClass*) klass;
|
|
|
|
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE);
|
|
|
|
|
2001-09-10 19:46:01 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2001-08-21 20:16:48 +00:00
|
|
|
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_elementfactory_save_thyself);
|
|
|
|
gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_elementfactory_restore_thyself);
|
2001-10-17 10:21:27 +00:00
|
|
|
#endif
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
gstpluginfeature_class->unload_thyself = GST_DEBUG_FUNCPTR (gst_elementfactory_unload_thyself);
|
|
|
|
|
|
|
|
_gst_elementfactories = NULL;
|
|
|
|
}
|
2000-12-11 00:04:25 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static void
|
|
|
|
gst_elementfactory_init (GstElementFactory *factory)
|
|
|
|
{
|
|
|
|
factory->padtemplates = NULL;
|
|
|
|
factory->numpadtemplates = 0;
|
2000-12-11 00:04:25 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
_gst_elementfactories = g_list_prepend (_gst_elementfactories, factory);
|
2000-12-11 00:04:25 +00:00
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_elementfactory_find:
|
|
|
|
* @name: name of factory to find
|
|
|
|
*
|
|
|
|
* Search for an elementfactory of the given name.
|
|
|
|
*
|
|
|
|
* Returns: #GstElementFactory if found, NULL otherwise
|
|
|
|
*/
|
2000-12-12 19:29:43 +00:00
|
|
|
GstElementFactory*
|
2001-03-07 21:52:56 +00:00
|
|
|
gst_elementfactory_find (const gchar *name)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
2000-09-14 22:18:43 +00:00
|
|
|
GList *walk;
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElementFactory *factory;
|
|
|
|
|
2000-12-23 03:17:52 +00:00
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
|
|
|
|
2000-09-14 22:18:43 +00:00
|
|
|
walk = _gst_elementfactories;
|
2000-01-30 09:03:00 +00:00
|
|
|
while (walk) {
|
|
|
|
factory = (GstElementFactory *)(walk->data);
|
2001-08-21 20:16:48 +00:00
|
|
|
if (!strcmp(name, GST_OBJECT_NAME (factory)))
|
2000-01-30 09:03:00 +00:00
|
|
|
return factory;
|
|
|
|
walk = g_list_next(walk);
|
|
|
|
}
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* this should be an ERROR */
|
2001-08-21 20:16:48 +00:00
|
|
|
GST_DEBUG (GST_CAT_ELEMENTFACTORY,"no such elementfactory \"%s\"\n", name);
|
2000-01-30 09:03:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_elementfactory_get_list:
|
|
|
|
*
|
|
|
|
* Get the global list of elementfactories.
|
|
|
|
*
|
2000-10-25 19:09:53 +00:00
|
|
|
* Returns: GList of type #GstElementFactory
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2001-08-21 20:16:48 +00:00
|
|
|
const GList*
|
2001-03-07 21:52:56 +00:00
|
|
|
gst_elementfactory_get_list (void)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
return _gst_elementfactories;
|
|
|
|
}
|
|
|
|
|
2001-09-13 20:12:17 +00:00
|
|
|
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);
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_elementfactory_new:
|
|
|
|
* @name: name of new elementfactory
|
2001-06-25 01:20:11 +00:00
|
|
|
* @type: GType of new element
|
2000-01-30 09:03:00 +00:00
|
|
|
* @details: #GstElementDetails structure with element details
|
|
|
|
*
|
|
|
|
* Create a new elementfactory capable of insantiating objects of the
|
|
|
|
* given type.
|
|
|
|
*
|
|
|
|
* Returns: new elementfactory
|
|
|
|
*/
|
2000-12-12 19:29:43 +00:00
|
|
|
GstElementFactory*
|
2001-06-25 01:20:11 +00:00
|
|
|
gst_elementfactory_new (const gchar *name, GType type,
|
2001-03-07 21:52:56 +00:00
|
|
|
GstElementDetails *details)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
2001-03-07 21:52:56 +00:00
|
|
|
GstElementFactory *factory;
|
2000-12-19 13:41:55 +00:00
|
|
|
|
2000-12-23 03:17:52 +00:00
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
2001-09-14 22:16:47 +00:00
|
|
|
g_return_val_if_fail (type, NULL);
|
2001-09-13 20:12:17 +00:00
|
|
|
g_return_val_if_fail (details, NULL);
|
2000-12-23 03:17:52 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
factory = gst_elementfactory_find (name);
|
2001-09-13 01:15:25 +00:00
|
|
|
|
2001-09-13 20:12:17 +00:00
|
|
|
if (!factory)
|
|
|
|
factory = GST_ELEMENTFACTORY (g_object_new (GST_TYPE_ELEMENTFACTORY, NULL));
|
2001-09-13 01:15:25 +00:00
|
|
|
|
2001-09-13 20:12:17 +00:00
|
|
|
if (factory->details_dynamic)
|
|
|
|
{
|
|
|
|
gst_element_details_free (factory->details);
|
|
|
|
factory->details_dynamic = FALSE;
|
2001-09-13 01:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-09-13 20:12:17 +00:00
|
|
|
factory->details = details;
|
|
|
|
|
|
|
|
if (!factory->type)
|
|
|
|
factory->type = type;
|
|
|
|
else if (factory->type != type)
|
|
|
|
g_critical ("`%s' requested type change (!)", name);
|
2002-02-20 21:31:16 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
gst_object_set_name (GST_OBJECT (factory), name);
|
2000-12-19 13:41:55 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_elementfactory_create:
|
|
|
|
* @factory: factory to instantiate
|
|
|
|
* @name: name of new element
|
|
|
|
*
|
|
|
|
* Create a new element of the type defined by the given elementfactory.
|
|
|
|
* It wll be given the name supplied, since all elements require a name as
|
|
|
|
* their first argument.
|
|
|
|
*
|
|
|
|
* Returns: new #GstElement
|
|
|
|
*/
|
2000-12-12 19:29:43 +00:00
|
|
|
GstElement *
|
|
|
|
gst_elementfactory_create (GstElementFactory *factory,
|
2001-03-07 21:52:56 +00:00
|
|
|
const gchar *name)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElement *element;
|
|
|
|
GstElementClass *oclass;
|
|
|
|
|
2000-03-13 22:13:11 +00:00
|
|
|
g_return_val_if_fail(factory != NULL, NULL);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-09-28 19:16:02 +00:00
|
|
|
GST_DEBUG (GST_CAT_ELEMENTFACTORY,"creating element from factory \"%s\" with name \"%s\" and type %d\n",
|
2002-03-04 22:01:42 +00:00
|
|
|
GST_OBJECT_NAME (factory), name, (gint) factory->type);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
if (!gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory)))
|
|
|
|
return NULL;
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
if (factory->type == 0) {
|
2001-09-13 01:15:25 +00:00
|
|
|
g_critical ("Factory for `%s' has no type",
|
|
|
|
gst_object_get_name (GST_OBJECT (factory)));
|
|
|
|
return NULL;
|
2001-10-21 18:00:31 +00:00
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* create an instance of the element */
|
2001-06-25 01:20:11 +00:00
|
|
|
element = GST_ELEMENT(g_object_new(factory->type,NULL));
|
2000-01-30 09:03:00 +00:00
|
|
|
g_assert(element != NULL);
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* attempt to set the elemenfactory class pointer if necessary */
|
2001-06-25 01:20:11 +00:00
|
|
|
oclass = GST_ELEMENT_CLASS(G_OBJECT_GET_CLASS(element));
|
2000-12-22 23:23:10 +00:00
|
|
|
if (oclass->elementfactory == NULL) {
|
2001-08-21 20:16:48 +00:00
|
|
|
GST_DEBUG (GST_CAT_ELEMENTFACTORY,"class %s\n", GST_OBJECT_NAME (factory));
|
2000-01-30 09:03:00 +00:00
|
|
|
oclass->elementfactory = factory;
|
2001-12-15 22:37:35 +00:00
|
|
|
|
2002-02-18 00:40:56 +00:00
|
|
|
/* copy pad template pointers to the element class, allow for custom padtemplates */
|
|
|
|
oclass->padtemplates = g_list_concat (oclass->padtemplates, factory->padtemplates);
|
|
|
|
oclass->numpadtemplates += factory->numpadtemplates;
|
2000-12-22 23:23:10 +00:00
|
|
|
}
|
2001-07-11 12:33:17 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_object_set_name (GST_OBJECT (element),name);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
|
2000-09-14 20:31:03 +00:00
|
|
|
/**
|
|
|
|
* gst_elementfactory_make:
|
|
|
|
* @factoryname: a named factory to instantiate
|
|
|
|
* @name: name of new element
|
|
|
|
*
|
|
|
|
* Create a new element of the type defined by the given elementfactory.
|
|
|
|
* It wll be given the name supplied, since all elements require a name as
|
|
|
|
* their first argument.
|
|
|
|
*
|
2002-02-19 16:08:23 +00:00
|
|
|
* Returns: new #GstElement (or NULL if unable to create element)
|
2000-09-14 20:31:03 +00:00
|
|
|
*/
|
2000-12-12 19:29:43 +00:00
|
|
|
GstElement*
|
2001-03-07 21:52:56 +00:00
|
|
|
gst_elementfactory_make (const gchar *factoryname, const gchar *name)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElementFactory *factory;
|
|
|
|
GstElement *element;
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
g_return_val_if_fail (factoryname != NULL, NULL);
|
2000-12-23 03:17:52 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
GST_DEBUG (GST_CAT_ELEMENTFACTORY, "gstelementfactory: make \"%s\" \"%s\"\n", factoryname, name);
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* gst_plugin_load_elementfactory(factoryname); */
|
2000-01-30 09:03:00 +00:00
|
|
|
factory = gst_elementfactory_find(factoryname);
|
2001-08-21 19:30:45 +00:00
|
|
|
if (factory == NULL) {
|
|
|
|
GST_INFO (GST_CAT_ELEMENTFACTORY,"no such elementfactory \"%s\"!",factoryname);
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
element = gst_elementfactory_create(factory,name);
|
2001-08-21 19:30:45 +00:00
|
|
|
if (element == NULL) {
|
|
|
|
GST_INFO (GST_CAT_ELEMENTFACTORY,"couldn't create instance of elementfactory \"%s\"!",factoryname);
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
return element;
|
|
|
|
}
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-09-14 20:31:03 +00:00
|
|
|
/**
|
2000-12-13 19:29:35 +00:00
|
|
|
* gst_elementfactory_add_padtemplate :
|
2000-09-14 20:31:03 +00:00
|
|
|
* @elementfactory: factory to add the src id to
|
2001-01-19 22:15:21 +00:00
|
|
|
* @templ: the padtemplate to add
|
2000-09-14 20:31:03 +00:00
|
|
|
*
|
2001-01-19 22:15:21 +00:00
|
|
|
* Add the given padtemplate to this elementfactory.
|
2000-09-14 20:31:03 +00:00
|
|
|
*/
|
2001-01-19 22:15:21 +00:00
|
|
|
void
|
|
|
|
gst_elementfactory_add_padtemplate (GstElementFactory *factory,
|
|
|
|
GstPadTemplate *templ)
|
2000-12-11 00:04:25 +00:00
|
|
|
{
|
2001-08-21 20:16:48 +00:00
|
|
|
GList *padtemplates;
|
|
|
|
|
2000-12-11 00:04:25 +00:00
|
|
|
g_return_if_fail(factory != NULL);
|
2001-01-19 22:15:21 +00:00
|
|
|
g_return_if_fail(templ != NULL);
|
2000-12-11 00:04:25 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
padtemplates = factory->padtemplates;
|
2001-09-29 09:53:07 +00:00
|
|
|
|
|
|
|
gst_object_ref (GST_OBJECT (templ));
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
while (padtemplates) {
|
|
|
|
GstPadTemplate *oldtempl = GST_PADTEMPLATE (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);
|
|
|
|
}
|
2001-01-19 22:15:21 +00:00
|
|
|
factory->padtemplates = g_list_append (factory->padtemplates, templ);
|
2001-01-03 20:44:28 +00:00
|
|
|
factory->numpadtemplates++;
|
2000-12-19 13:41:55 +00:00
|
|
|
}
|
2000-08-21 21:20:38 +00:00
|
|
|
|
2000-12-28 21:42:23 +00:00
|
|
|
/**
|
2001-03-12 21:02:12 +00:00
|
|
|
* gst_elementfactory_can_src_caps :
|
2000-12-28 21:42:23 +00:00
|
|
|
* @factory: factory to query
|
2001-03-12 21:02:12 +00:00
|
|
|
* @caps: the caps to check
|
2000-12-28 21:42:23 +00:00
|
|
|
*
|
2001-03-12 21:02:12 +00:00
|
|
|
* Checks if the factory can source the given capability.
|
2000-12-28 21:42:23 +00:00
|
|
|
*
|
2000-12-31 16:12:48 +00:00
|
|
|
* Returns: true if it can src the capabilities
|
2000-12-28 21:42:23 +00:00
|
|
|
*/
|
2000-12-19 13:41:55 +00:00
|
|
|
gboolean
|
2001-03-12 21:02:12 +00:00
|
|
|
gst_elementfactory_can_src_caps (GstElementFactory *factory,
|
|
|
|
GstCaps *caps)
|
2000-12-19 13:41:55 +00:00
|
|
|
{
|
|
|
|
GList *templates;
|
|
|
|
|
|
|
|
g_return_val_if_fail(factory != NULL, FALSE);
|
|
|
|
g_return_val_if_fail(caps != NULL, FALSE);
|
|
|
|
|
|
|
|
templates = factory->padtemplates;
|
|
|
|
|
|
|
|
while (templates) {
|
|
|
|
GstPadTemplate *template = (GstPadTemplate *)templates->data;
|
|
|
|
|
|
|
|
if (template->direction == GST_PAD_SRC) {
|
2001-03-12 21:02:12 +00:00
|
|
|
if (gst_caps_check_compatibility (GST_PADTEMPLATE_CAPS (template), caps))
|
2000-12-19 13:41:55 +00:00
|
|
|
return TRUE;
|
2000-12-12 19:29:43 +00:00
|
|
|
}
|
2000-12-19 13:41:55 +00:00
|
|
|
templates = g_list_next (templates);
|
2000-12-11 00:04:25 +00:00
|
|
|
}
|
2000-12-19 13:41:55 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-12-28 21:42:23 +00:00
|
|
|
/**
|
2001-03-12 21:02:12 +00:00
|
|
|
* gst_elementfactory_can_sink_caps :
|
2000-12-28 21:42:23 +00:00
|
|
|
* @factory: factory to query
|
2001-03-12 21:02:12 +00:00
|
|
|
* @caps: the caps to check
|
2000-12-28 21:42:23 +00:00
|
|
|
*
|
2001-03-12 21:02:12 +00:00
|
|
|
* Checks if the factory can sink the given capability.
|
2000-12-28 21:42:23 +00:00
|
|
|
*
|
2000-12-31 16:12:48 +00:00
|
|
|
* Returns: true if it can sink the capabilities
|
2000-12-28 21:42:23 +00:00
|
|
|
*/
|
2000-12-19 13:41:55 +00:00
|
|
|
gboolean
|
2001-03-12 21:02:12 +00:00
|
|
|
gst_elementfactory_can_sink_caps (GstElementFactory *factory,
|
|
|
|
GstCaps *caps)
|
2000-12-19 13:41:55 +00:00
|
|
|
{
|
|
|
|
GList *templates;
|
|
|
|
|
|
|
|
g_return_val_if_fail(factory != NULL, FALSE);
|
|
|
|
g_return_val_if_fail(caps != NULL, FALSE);
|
|
|
|
|
|
|
|
templates = factory->padtemplates;
|
|
|
|
|
|
|
|
while (templates) {
|
|
|
|
GstPadTemplate *template = (GstPadTemplate *)templates->data;
|
|
|
|
|
|
|
|
if (template->direction == GST_PAD_SINK) {
|
2001-03-12 21:02:12 +00:00
|
|
|
if (gst_caps_check_compatibility (caps, GST_PADTEMPLATE_CAPS (template)))
|
2000-12-19 13:41:55 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
templates = g_list_next (templates);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2000-08-21 21:20:38 +00:00
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static void
|
|
|
|
gst_elementfactory_unload_thyself (GstPluginFeature *feature)
|
|
|
|
{
|
|
|
|
GstElementFactory *factory;
|
|
|
|
|
|
|
|
factory = GST_ELEMENTFACTORY (feature);
|
|
|
|
|
|
|
|
factory->type = 0;
|
|
|
|
}
|
|
|
|
|
2001-09-10 19:46:01 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2001-08-21 20:16:48 +00:00
|
|
|
static xmlNodePtr
|
|
|
|
gst_elementfactory_save_thyself (GstObject *object,
|
2001-03-07 21:52:56 +00:00
|
|
|
xmlNodePtr parent)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
|
|
|
GList *pads;
|
2001-08-21 20:16:48 +00:00
|
|
|
GstElementFactory *factory;
|
|
|
|
|
|
|
|
factory = GST_ELEMENTFACTORY (object);
|
|
|
|
|
|
|
|
if (GST_OBJECT_CLASS (parent_class)->save_thyself) {
|
|
|
|
GST_OBJECT_CLASS (parent_class)->save_thyself (object, parent);
|
|
|
|
}
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2000-12-23 03:17:52 +00:00
|
|
|
g_return_val_if_fail(factory != NULL, NULL);
|
|
|
|
|
2001-09-13 20:12:17 +00:00
|
|
|
if (factory->details)
|
|
|
|
{
|
|
|
|
xmlNewChild(parent,NULL,"longname", factory->details->longname);
|
|
|
|
xmlNewChild(parent,NULL,"class", factory->details->klass);
|
|
|
|
xmlNewChild(parent,NULL,"description", factory->details->description);
|
|
|
|
xmlNewChild(parent,NULL,"version", factory->details->version);
|
|
|
|
xmlNewChild(parent,NULL,"author", factory->details->author);
|
|
|
|
xmlNewChild(parent,NULL,"copyright", factory->details->copyright);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_warning ("elementfactory `%s' is missing details",
|
|
|
|
object->name);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2000-12-13 19:29:35 +00:00
|
|
|
pads = factory->padtemplates;
|
2000-12-12 19:29:43 +00:00
|
|
|
if (pads) {
|
|
|
|
while (pads) {
|
|
|
|
xmlNodePtr subtree;
|
2000-12-13 19:29:35 +00:00
|
|
|
GstPadTemplate *padtemplate = (GstPadTemplate *)pads->data;
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2000-12-13 19:29:35 +00:00
|
|
|
subtree = xmlNewChild(parent, NULL, "padtemplate", NULL);
|
|
|
|
gst_padtemplate_save_thyself(padtemplate, subtree);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2000-12-12 19:29:43 +00:00
|
|
|
pads = g_list_next (pads);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static void
|
|
|
|
gst_elementfactory_restore_thyself (GstObject *object, xmlNodePtr parent)
|
2000-12-11 00:04:25 +00:00
|
|
|
{
|
2001-08-21 20:16:48 +00:00
|
|
|
GstElementFactory *factory = GST_ELEMENTFACTORY (object);
|
2001-01-18 11:16:53 +00:00
|
|
|
xmlNodePtr children = parent->xmlChildrenNode;
|
2001-09-13 20:12:17 +00:00
|
|
|
|
|
|
|
factory->details_dynamic = TRUE;
|
2000-08-28 20:20:55 +00:00
|
|
|
factory->details = g_new0(GstElementDetails, 1);
|
2000-12-13 19:29:35 +00:00
|
|
|
factory->padtemplates = NULL;
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
if (GST_OBJECT_CLASS (parent_class)->restore_thyself) {
|
|
|
|
GST_OBJECT_CLASS (parent_class)->restore_thyself (object, parent);
|
|
|
|
}
|
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
while (children) {
|
|
|
|
if (!strcmp(children->name, "longname")) {
|
2001-01-07 07:45:54 +00:00
|
|
|
factory->details->longname = xmlNodeGetContent(children);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
if (!strcmp(children->name, "class")) {
|
2001-01-07 07:45:54 +00:00
|
|
|
factory->details->klass = xmlNodeGetContent(children);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
if (!strcmp(children->name, "description")) {
|
2001-01-07 07:45:54 +00:00
|
|
|
factory->details->description = xmlNodeGetContent(children);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
if (!strcmp(children->name, "version")) {
|
2001-01-07 07:45:54 +00:00
|
|
|
factory->details->version = xmlNodeGetContent(children);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
if (!strcmp(children->name, "author")) {
|
2001-01-07 07:45:54 +00:00
|
|
|
factory->details->author = xmlNodeGetContent(children);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
if (!strcmp(children->name, "copyright")) {
|
2001-01-07 07:45:54 +00:00
|
|
|
factory->details->copyright = xmlNodeGetContent(children);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2000-12-13 19:29:35 +00:00
|
|
|
if (!strcmp(children->name, "padtemplate")) {
|
|
|
|
GstPadTemplate *template;
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2000-12-13 19:29:35 +00:00
|
|
|
template = gst_padtemplate_load_thyself (children);
|
2000-12-12 19:29:43 +00:00
|
|
|
|
2000-12-13 19:29:35 +00:00
|
|
|
gst_elementfactory_add_padtemplate (factory, template);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
children = children->next;
|
|
|
|
}
|
|
|
|
}
|
2001-09-10 19:46:01 +00:00
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|