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>
|
2003-10-31 19:32:47 +00:00
|
|
|
* 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
2000-12-28 22:12:02 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-09-02 17:23:06 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstelementfactory
|
|
|
|
* @short_description: Create GstElements from a factory
|
|
|
|
* @see_also: #GstElement, #GstPlugin, #GstPluginFeature, #GstPadTemplate.
|
|
|
|
*
|
2005-11-24 09:44:07 +00:00
|
|
|
* #GstElementFactory is used to create instances of elements. A
|
2005-10-15 16:01:57 +00:00
|
|
|
* GstElementfactory can be added to a #GstPlugin as it is also a
|
|
|
|
* #GstPluginFeature.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2005-10-15 16:01:57 +00:00
|
|
|
* Use the gst_element_factory_find() and gst_element_factory_create()
|
|
|
|
* functions to create element instances or use gst_element_factory_make() as a
|
|
|
|
* convenient shortcut.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2005-09-02 17:23:06 +00:00
|
|
|
* The following code example shows you how to create a GstFileSrc element.
|
|
|
|
*
|
|
|
|
* <example>
|
|
|
|
* <title>Using an element factory</title>
|
|
|
|
* <programlisting language="c">
|
|
|
|
* #include <gst/gst.h>
|
2009-09-10 09:53:09 +00:00
|
|
|
*
|
2005-09-02 17:23:06 +00:00
|
|
|
* GstElement *src;
|
|
|
|
* GstElementFactory *srcfactory;
|
2009-09-10 09:53:09 +00:00
|
|
|
*
|
2009-02-15 14:37:17 +00:00
|
|
|
* gst_init (&argc, &argv);
|
2009-09-10 09:53:09 +00:00
|
|
|
*
|
2009-02-15 14:37:17 +00:00
|
|
|
* srcfactory = gst_element_factory_find ("filesrc");
|
|
|
|
* g_return_if_fail (srcfactory != NULL);
|
|
|
|
* src = gst_element_factory_create (srcfactory, "src");
|
|
|
|
* g_return_if_fail (src != NULL);
|
2005-09-02 17:23:06 +00:00
|
|
|
* ...
|
|
|
|
* </programlisting>
|
|
|
|
* </example>
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2005-11-24 09:44:07 +00:00
|
|
|
* Last reviewed on 2005-11-23 (0.9.5)
|
2005-09-02 17:23:06 +00:00
|
|
|
*/
|
2000-01-30 09:03:00 +00:00
|
|
|
|
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"
|
2010-03-02 21:58:06 +00:00
|
|
|
#include "gstelementdetails.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gstinfo.h"
|
2003-11-24 03:21:54 +00:00
|
|
|
#include "gsturi.h"
|
2005-09-15 00:13:26 +00:00
|
|
|
#include "gstregistry.h"
|
2010-09-16 18:27:57 +00:00
|
|
|
#include "gst.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2007-09-19 13:28:40 +00:00
|
|
|
#include "glib-compat-private.h"
|
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (element_factory_debug);
|
|
|
|
#define GST_CAT_DEFAULT element_factory_debug
|
2003-07-05 15:05:23 +00:00
|
|
|
|
2005-09-18 21:24:55 +00:00
|
|
|
static void gst_element_factory_finalize (GObject * object);
|
|
|
|
static void gst_element_factory_cleanup (GstElementFactory * factory);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
/* static guint gst_element_factory_signals[LAST_SIGNAL] = { 0 }; */
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2009-06-07 19:09:14 +00:00
|
|
|
/* this is defined in gstelement.c */
|
|
|
|
extern GQuark _gst_elementclass_factory;
|
|
|
|
|
2009-04-04 08:20:36 +00:00
|
|
|
#define _do_init \
|
|
|
|
{ \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY", \
|
|
|
|
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, \
|
|
|
|
"element factories keep information about installed elements"); \
|
|
|
|
}
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2009-04-04 08:20:36 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstElementFactory, gst_element_factory,
|
|
|
|
GST_TYPE_PLUGIN_FEATURE, _do_init);
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_class_init (GstElementFactoryClass * klass)
|
2000-12-11 00:04:25 +00:00
|
|
|
{
|
2009-04-04 08:20:36 +00:00
|
|
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2009-10-28 00:29:30 +00:00
|
|
|
gobject_class->finalize = gst_element_factory_finalize;
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
2005-09-18 21:24:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_init (GstElementFactory * factory)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
factory->staticpadtemplates = NULL;
|
2001-08-21 20:16:48 +00:00
|
|
|
factory->numpadtemplates = 0;
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
factory->uri_type = GST_URI_UNKNOWN;
|
|
|
|
factory->uri_protocols = NULL;
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
factory->interfaces = NULL;
|
2000-12-11 00:04:25 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-09-18 21:24:55 +00:00
|
|
|
static void
|
|
|
|
gst_element_factory_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstElementFactory *factory = GST_ELEMENT_FACTORY (object);
|
|
|
|
|
|
|
|
gst_element_factory_cleanup (factory);
|
2010-09-06 11:33:44 +00:00
|
|
|
G_OBJECT_CLASS (gst_element_factory_parent_class)->finalize (object);
|
2005-09-18 21:24:55 +00:00
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_element_factory_find:
|
2000-01-30 09:03:00 +00:00
|
|
|
* @name: name of factory to find
|
|
|
|
*
|
2005-09-19 14:09:54 +00:00
|
|
|
* Search for an element factory of the given name. Refs the returned
|
|
|
|
* element factory; caller is responsible for unreffing.
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full): #GstElementFactory if found, NULL otherwise
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstElementFactory *
|
|
|
|
gst_element_factory_find (const gchar * name)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
2002-05-08 20:40:48 +00:00
|
|
|
GstPluginFeature *feature;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2000-12-23 03:17:52 +00:00
|
|
|
|
2005-09-15 00:13:26 +00:00
|
|
|
feature = gst_registry_find_feature (gst_registry_get_default (), name,
|
|
|
|
GST_TYPE_ELEMENT_FACTORY);
|
2002-05-08 20:40:48 +00:00
|
|
|
if (feature)
|
|
|
|
return GST_ELEMENT_FACTORY (feature);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-02-20 13:18:32 +00:00
|
|
|
/* this isn't an error, for instance when you query if an element factory is
|
|
|
|
* present */
|
|
|
|
GST_LOG ("no such element factory \"%s\"", name);
|
2000-01-30 09:03:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-11-02 16:24:22 +00:00
|
|
|
|
2003-01-17 18:50:07 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_cleanup (GstElementFactory * factory)
|
2003-01-17 18:50:07 +00:00
|
|
|
{
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
GList *item;
|
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
__gst_element_details_clear (&factory->details);
|
2010-08-10 11:05:22 +00:00
|
|
|
if (factory->meta_data) {
|
|
|
|
gst_structure_free ((GstStructure *) factory->meta_data);
|
|
|
|
factory->meta_data = NULL;
|
|
|
|
}
|
2003-10-31 19:32:47 +00:00
|
|
|
if (factory->type) {
|
2009-06-07 19:09:14 +00:00
|
|
|
factory->type = G_TYPE_INVALID;
|
2003-01-17 18:50:07 +00:00
|
|
|
}
|
|
|
|
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
for (item = factory->staticpadtemplates; item; item = item->next) {
|
|
|
|
GstStaticPadTemplate *templ = item->data;
|
2007-09-19 12:31:16 +00:00
|
|
|
GstCaps *caps = (GstCaps *) & (templ->static_caps);
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
|
2007-09-19 12:31:16 +00:00
|
|
|
/* FIXME: this is not threadsafe */
|
|
|
|
if (caps->refcount == 1) {
|
|
|
|
GstStructure *structure;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < caps->structs->len; i++) {
|
|
|
|
structure = (GstStructure *) gst_caps_get_structure (caps, i);
|
|
|
|
gst_structure_set_parent_refcount (structure, NULL);
|
|
|
|
gst_structure_free (structure);
|
|
|
|
}
|
|
|
|
g_ptr_array_free (caps->structs, TRUE);
|
|
|
|
caps->refcount = 0;
|
|
|
|
}
|
2010-03-28 16:05:36 +00:00
|
|
|
g_slice_free (GstStaticPadTemplate, templ);
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
}
|
|
|
|
g_list_free (factory->staticpadtemplates);
|
|
|
|
factory->staticpadtemplates = NULL;
|
2003-02-02 19:58:11 +00:00
|
|
|
factory->numpadtemplates = 0;
|
2003-11-24 03:21:54 +00:00
|
|
|
factory->uri_type = GST_URI_UNKNOWN;
|
|
|
|
if (factory->uri_protocols) {
|
|
|
|
g_strfreev (factory->uri_protocols);
|
|
|
|
factory->uri_protocols = NULL;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
g_list_free (factory->interfaces);
|
|
|
|
factory->interfaces = NULL;
|
2003-01-17 18:50:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
2003-10-31 19:32:47 +00:00
|
|
|
* gst_element_register:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @plugin: (allow-none): #GstPlugin to register the element with, or NULL for
|
|
|
|
* a static element (note that passing NULL only works in GStreamer 0.10.13
|
|
|
|
* and later)
|
2003-10-31 19:32:47 +00:00
|
|
|
* @name: name of elements of this type
|
|
|
|
* @rank: rank of element (higher rank means more importance when autoplugging)
|
|
|
|
* @type: GType of element to register
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
2004-03-30 09:15:47 +00:00
|
|
|
* Create a new elementfactory capable of instantiating objects of the
|
2006-04-11 11:47:39 +00:00
|
|
|
* @type and add the factory to @plugin.
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
2003-10-31 19:32:47 +00:00
|
|
|
* Returns: TRUE, if the registering succeeded, FALSE on error
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2003-10-31 19:32:47 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
|
|
|
|
GType type)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
2009-06-07 19:09:14 +00:00
|
|
|
GstPluginFeature *existing_feature;
|
|
|
|
GstRegistry *registry;
|
2001-03-07 21:52:56 +00:00
|
|
|
GstElementFactory *factory;
|
2003-11-24 02:09:23 +00:00
|
|
|
GType *interfaces;
|
|
|
|
guint n_interfaces, i;
|
2003-10-31 19:32:47 +00:00
|
|
|
GstElementClass *klass;
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
GList *item;
|
2000-12-19 13:41:55 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
g_return_val_if_fail (name != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (g_type_is_a (type, GST_TYPE_ELEMENT), FALSE);
|
2000-12-23 03:17:52 +00:00
|
|
|
|
2009-06-07 19:09:14 +00:00
|
|
|
registry = gst_registry_get_default ();
|
|
|
|
|
|
|
|
/* check if feature already exists, if it exists there is no need to update it
|
2009-08-20 21:24:19 +00:00
|
|
|
* when the registry is getting updated, outdated plugins and all their
|
|
|
|
* features are removed and readded.
|
2009-06-07 19:09:14 +00:00
|
|
|
*/
|
|
|
|
existing_feature = gst_registry_lookup_feature (registry, name);
|
|
|
|
if (existing_feature) {
|
|
|
|
GST_DEBUG_OBJECT (registry, "update existing feature %p (%s)",
|
|
|
|
existing_feature, name);
|
|
|
|
factory = GST_ELEMENT_FACTORY_CAST (existing_feature);
|
|
|
|
factory->type = type;
|
|
|
|
existing_feature->loaded = TRUE;
|
|
|
|
g_type_set_qdata (type, _gst_elementclass_factory, factory);
|
|
|
|
gst_object_unref (existing_feature);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-05-02 12:43:11 +00:00
|
|
|
factory =
|
2009-10-28 08:26:32 +00:00
|
|
|
GST_ELEMENT_FACTORY_CAST (g_object_newv (GST_TYPE_ELEMENT_FACTORY, 0,
|
|
|
|
NULL));
|
2009-05-02 12:43:11 +00:00
|
|
|
gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name);
|
2005-09-15 00:13:26 +00:00
|
|
|
GST_LOG_OBJECT (factory, "Created new elementfactory for type %s",
|
|
|
|
g_type_name (type));
|
2001-09-13 01:15:25 +00:00
|
|
|
|
2009-08-29 18:44:36 +00:00
|
|
|
/* provide info needed during class structure setup */
|
|
|
|
g_type_set_qdata (type, _gst_elementclass_factory, factory);
|
2004-07-29 15:29:37 +00:00
|
|
|
klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
|
2006-08-14 15:33:17 +00:00
|
|
|
if ((klass->details.longname == NULL) ||
|
|
|
|
(klass->details.klass == NULL) || (klass->details.author == NULL))
|
|
|
|
goto detailserror;
|
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
factory->type = type;
|
|
|
|
__gst_element_details_copy (&factory->details, &klass->details);
|
2010-08-10 11:05:22 +00:00
|
|
|
if (klass->meta_data) {
|
|
|
|
factory->meta_data = gst_structure_copy ((GstStructure *) klass->meta_data);
|
|
|
|
} else {
|
|
|
|
factory->meta_data = NULL;
|
|
|
|
}
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
for (item = klass->padtemplates; item; item = item->next) {
|
|
|
|
GstPadTemplate *templ = item->data;
|
|
|
|
GstStaticPadTemplate *newt;
|
2010-10-18 10:29:53 +00:00
|
|
|
gchar *caps_string = gst_caps_to_string (templ->caps);
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
|
2010-03-28 16:05:36 +00:00
|
|
|
newt = g_slice_new (GstStaticPadTemplate);
|
2007-09-19 13:28:40 +00:00
|
|
|
newt->name_template = g_intern_string (templ->name_template);
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
newt->direction = templ->direction;
|
|
|
|
newt->presence = templ->presence;
|
2010-03-28 16:05:36 +00:00
|
|
|
newt->static_caps.caps.refcount = 0;
|
2010-10-18 10:29:53 +00:00
|
|
|
newt->static_caps.string = g_intern_string (caps_string);
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
factory->staticpadtemplates =
|
|
|
|
g_list_append (factory->staticpadtemplates, newt);
|
2010-10-18 10:29:53 +00:00
|
|
|
|
|
|
|
g_free (caps_string);
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
}
|
2003-10-31 19:32:47 +00:00
|
|
|
factory->numpadtemplates = klass->numpadtemplates;
|
2001-09-13 20:12:17 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/* special stuff for URI handling */
|
|
|
|
if (g_type_is_a (type, GST_TYPE_URI_HANDLER)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
GstURIHandlerInterface *iface = (GstURIHandlerInterface *)
|
2004-03-15 19:27:17 +00:00
|
|
|
g_type_interface_peek (klass, GST_TYPE_URI_HANDLER);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2007-10-25 16:19:05 +00:00
|
|
|
if (!iface || (!iface->get_type && !iface->get_type_full) ||
|
|
|
|
(!iface->get_protocols && !iface->get_protocols_full))
|
2006-08-14 15:33:17 +00:00
|
|
|
goto urierror;
|
2007-10-25 16:19:05 +00:00
|
|
|
if (iface->get_type)
|
|
|
|
factory->uri_type = iface->get_type ();
|
|
|
|
else if (iface->get_type_full)
|
|
|
|
factory->uri_type = iface->get_type_full (factory->type);
|
2003-11-24 03:21:54 +00:00
|
|
|
if (!GST_URI_TYPE_IS_VALID (factory->uri_type))
|
2006-08-14 15:33:17 +00:00
|
|
|
goto urierror;
|
2007-10-25 16:19:05 +00:00
|
|
|
if (iface->get_protocols)
|
|
|
|
factory->uri_protocols = g_strdupv (iface->get_protocols ());
|
|
|
|
else if (iface->get_protocols_full)
|
|
|
|
factory->uri_protocols = iface->get_protocols_full (factory->type);
|
2003-11-24 03:21:54 +00:00
|
|
|
if (!factory->uri_protocols)
|
2006-08-14 15:33:17 +00:00
|
|
|
goto urierror;
|
2003-11-24 03:21:54 +00:00
|
|
|
}
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
interfaces = g_type_interfaces (type, &n_interfaces);
|
|
|
|
for (i = 0; i < n_interfaces; i++) {
|
|
|
|
__gst_element_factory_add_interface (factory, g_type_name (interfaces[i]));
|
|
|
|
}
|
|
|
|
g_free (interfaces);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2007-05-12 23:53:08 +00:00
|
|
|
if (plugin && plugin->desc.name) {
|
2009-05-02 12:43:11 +00:00
|
|
|
GST_PLUGIN_FEATURE_CAST (factory)->plugin_name = plugin->desc.name;
|
2011-04-24 08:53:39 +00:00
|
|
|
GST_PLUGIN_FEATURE_CAST (factory)->plugin = plugin;
|
|
|
|
g_object_add_weak_pointer ((GObject *) plugin,
|
|
|
|
(gpointer *) & GST_PLUGIN_FEATURE_CAST (factory)->plugin);
|
2007-05-12 23:53:08 +00:00
|
|
|
} else {
|
2009-05-02 12:43:11 +00:00
|
|
|
GST_PLUGIN_FEATURE_CAST (factory)->plugin_name = "NULL";
|
2011-04-24 08:53:39 +00:00
|
|
|
GST_PLUGIN_FEATURE_CAST (factory)->plugin = NULL;
|
2007-05-12 23:53:08 +00:00
|
|
|
}
|
2009-05-02 12:43:11 +00:00
|
|
|
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE_CAST (factory), rank);
|
|
|
|
GST_PLUGIN_FEATURE_CAST (factory)->loaded = TRUE;
|
2005-09-18 06:59:25 +00:00
|
|
|
|
2009-06-07 19:09:14 +00:00
|
|
|
gst_registry_add_feature (registry, GST_PLUGIN_FEATURE_CAST (factory));
|
2000-12-19 13:41:55 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
return TRUE;
|
2003-11-24 03:21:54 +00:00
|
|
|
|
2006-04-11 11:47:39 +00:00
|
|
|
/* ERRORS */
|
2006-08-14 15:33:17 +00:00
|
|
|
urierror:
|
2006-04-11 11:47:39 +00:00
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (factory, "error with uri handler!");
|
|
|
|
gst_element_factory_cleanup (factory);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-08-14 15:33:17 +00:00
|
|
|
|
|
|
|
detailserror:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (factory,
|
|
|
|
"The GstElementDetails don't seem to have been set properly");
|
|
|
|
gst_element_factory_cleanup (factory);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_element_factory_create:
|
2000-01-30 09:03:00 +00:00
|
|
|
* @factory: factory to instantiate
|
2011-07-27 09:09:11 +00:00
|
|
|
* @name: (allow-none): name of new element, or NULL to automatically create
|
|
|
|
* a unique name
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* Create a new element of the type defined by the given elementfactory.
|
2002-04-21 14:06:14 +00:00
|
|
|
* It will be given the name supplied, since all elements require a name as
|
2000-01-30 09:03:00 +00:00
|
|
|
* their first argument.
|
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full): new #GstElement or NULL if the element couldn't
|
|
|
|
* be created
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstElement *
|
|
|
|
gst_element_factory_create (GstElementFactory * factory, const gchar * name)
|
2000-12-12 19:29:43 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GstElement *element;
|
2003-11-02 16:46:12 +00:00
|
|
|
GstElementClass *oclass;
|
2005-09-20 11:09:50 +00:00
|
|
|
GstElementFactory *newfactory;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-08-28 10:45:57 +00:00
|
|
|
g_return_val_if_fail (factory != NULL, NULL);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2005-09-20 11:09:50 +00:00
|
|
|
newfactory =
|
2005-09-15 00:13:26 +00:00
|
|
|
GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
|
|
|
|
(factory)));
|
2006-07-31 15:07:30 +00:00
|
|
|
|
2006-04-11 11:47:39 +00:00
|
|
|
if (newfactory == NULL)
|
|
|
|
goto load_failed;
|
|
|
|
|
|
|
|
factory = newfactory;
|
2002-08-28 16:07:34 +00:00
|
|
|
|
2004-02-20 13:18:32 +00:00
|
|
|
if (name)
|
2005-09-27 18:33:48 +00:00
|
|
|
GST_INFO ("creating element \"%s\" named \"%s\"",
|
|
|
|
GST_PLUGIN_FEATURE_NAME (factory), GST_STR_NULL (name));
|
2004-02-20 13:18:32 +00:00
|
|
|
else
|
2005-09-27 18:33:48 +00:00
|
|
|
GST_INFO ("creating element \"%s\"", GST_PLUGIN_FEATURE_NAME (factory));
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2006-04-11 11:47:39 +00:00
|
|
|
if (factory->type == 0)
|
|
|
|
goto no_type;
|
2005-09-15 00:13:26 +00:00
|
|
|
|
2009-12-14 09:05:41 +00:00
|
|
|
/* create an instance of the element, cast so we don't assert on NULL
|
|
|
|
* also set name as early as we can
|
|
|
|
*/
|
|
|
|
if (name)
|
|
|
|
element =
|
|
|
|
GST_ELEMENT_CAST (g_object_new (factory->type, "name", name, NULL));
|
|
|
|
else
|
|
|
|
element = GST_ELEMENT_CAST (g_object_newv (factory->type, 0, NULL));
|
2006-12-07 12:11:14 +00:00
|
|
|
if (G_UNLIKELY (element == NULL))
|
2006-04-11 11:47:39 +00:00
|
|
|
goto no_element;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2006-04-11 11:47:39 +00:00
|
|
|
/* fill in the pointer to the factory in the element class. The
|
2009-09-10 09:53:09 +00:00
|
|
|
* class will not be unreffed currently.
|
2009-06-07 19:09:14 +00:00
|
|
|
* Be thread safe as there might be 2 threads creating the first instance of
|
|
|
|
* an element at the same moment
|
|
|
|
*/
|
2006-04-11 11:47:39 +00:00
|
|
|
oclass = GST_ELEMENT_GET_CLASS (element);
|
2011-06-04 07:30:15 +00:00
|
|
|
if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&oclass->elementfactory, NULL,
|
|
|
|
factory))
|
2006-12-07 12:11:14 +00:00
|
|
|
gst_object_unref (factory);
|
2003-11-02 16:46:12 +00:00
|
|
|
|
2005-09-27 18:33:48 +00:00
|
|
|
GST_DEBUG ("created element \"%s\"", GST_PLUGIN_FEATURE_NAME (factory));
|
2005-09-18 06:59:25 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
return element;
|
2006-04-11 11:47:39 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
load_failed:
|
|
|
|
{
|
2009-06-07 19:09:14 +00:00
|
|
|
GST_WARNING_OBJECT (factory,
|
|
|
|
"loading plugin containing feature %s returned NULL!", name);
|
2006-04-11 11:47:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
no_type:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (factory, "factory has no type");
|
2006-12-07 12:11:14 +00:00
|
|
|
gst_object_unref (factory);
|
2006-04-11 11:47:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
no_element:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (factory, "could not create element");
|
2006-12-07 12:11:14 +00:00
|
|
|
gst_object_unref (factory);
|
2006-04-11 11:47:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2000-09-14 20:31:03 +00:00
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_element_factory_make:
|
2000-09-14 20:31:03 +00:00
|
|
|
* @factoryname: a named factory to instantiate
|
2011-07-27 09:09:11 +00:00
|
|
|
* @name: (allow-none): name of new element, or NULL to automatically create
|
|
|
|
* a unique name
|
2000-09-14 20:31:03 +00:00
|
|
|
*
|
2002-04-21 14:06:14 +00:00
|
|
|
* Create a new element of the type defined by the given element factory.
|
|
|
|
* If name is NULL, then the element will receive a guaranteed unique name,
|
|
|
|
* consisting of the element factory name and a number.
|
|
|
|
* If name is given, it will be given the name supplied.
|
2000-09-14 20:31:03 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full): new #GstElement or NULL if unable to create element
|
2000-09-14 20:31:03 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstElement *
|
|
|
|
gst_element_factory_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);
|
2010-09-16 18:27:57 +00:00
|
|
|
g_return_val_if_fail (gst_is_initialized (), NULL);
|
2000-12-23 03:17:52 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_LOG ("gstelementfactory: make \"%s\" \"%s\"",
|
|
|
|
factoryname, GST_STR_NULL (name));
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2002-08-28 10:45:57 +00:00
|
|
|
factory = gst_element_factory_find (factoryname);
|
2006-04-11 11:47:39 +00:00
|
|
|
if (factory == NULL)
|
|
|
|
goto no_factory;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (factory, "found factory %p", factory);
|
|
|
|
element = gst_element_factory_create (factory, name);
|
|
|
|
if (element == NULL)
|
|
|
|
goto create_failed;
|
|
|
|
|
2008-04-23 14:54:20 +00:00
|
|
|
gst_object_unref (factory);
|
2006-04-11 11:47:39 +00:00
|
|
|
return element;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_factory:
|
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_INFO ("no such element factory \"%s\"!", factoryname);
|
2001-08-21 19:30:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2006-04-11 11:47:39 +00:00
|
|
|
create_failed:
|
|
|
|
{
|
2003-10-31 19:32:47 +00:00
|
|
|
GST_INFO_OBJECT (factory, "couldn't create instance!");
|
2008-04-23 14:54:20 +00:00
|
|
|
gst_object_unref (factory);
|
2001-08-21 19:30:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
void
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
__gst_element_factory_add_static_pad_template (GstElementFactory * factory,
|
|
|
|
GstStaticPadTemplate * templ)
|
2003-10-31 19:32:47 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (factory != NULL);
|
|
|
|
g_return_if_fail (templ != NULL);
|
|
|
|
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
factory->staticpadtemplates =
|
|
|
|
g_list_append (factory->staticpadtemplates, templ);
|
2003-10-31 19:32:47 +00:00
|
|
|
factory->numpadtemplates++;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-06-13 15:08:52 +00:00
|
|
|
/**
|
2003-10-31 19:32:47 +00:00
|
|
|
* gst_element_factory_get_element_type:
|
|
|
|
* @factory: factory to get managed #GType from
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2006-04-11 11:47:39 +00:00
|
|
|
* Get the #GType for elements managed by this factory. The type can
|
|
|
|
* only be retrieved if the element factory is loaded, which can be
|
|
|
|
* assured with gst_plugin_feature_load().
|
2002-06-13 15:08:52 +00:00
|
|
|
*
|
2006-04-11 11:47:39 +00:00
|
|
|
* Returns: the #GType for elements managed by this factory or 0 if
|
|
|
|
* the factory is not loaded.
|
2003-10-31 19:32:47 +00:00
|
|
|
*/
|
|
|
|
GType
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_get_element_type (GstElementFactory * factory)
|
2003-10-31 19:32:47 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), 0);
|
|
|
|
|
|
|
|
return factory->type;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
/**
|
|
|
|
* gst_element_factory_get_longname:
|
|
|
|
* @factory: a #GstElementFactory
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-10-31 19:32:47 +00:00
|
|
|
* Gets the longname for this factory
|
2002-06-13 15:08:52 +00:00
|
|
|
*
|
2003-10-31 19:32:47 +00:00
|
|
|
* Returns: the longname
|
2002-06-13 15:08:52 +00:00
|
|
|
*/
|
2011-06-09 16:13:35 +00:00
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_get_longname (GstElementFactory * factory)
|
2002-06-13 15:08:52 +00:00
|
|
|
{
|
2003-10-31 19:32:47 +00:00
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
|
2002-06-13 15:08:52 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
return factory->details.longname;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
/**
|
2005-10-08 18:07:20 +00:00
|
|
|
* gst_element_factory_get_klass:
|
2003-10-31 19:32:47 +00:00
|
|
|
* @factory: a #GstElementFactory
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-10-31 19:32:47 +00:00
|
|
|
* Gets the class for this factory.
|
|
|
|
*
|
|
|
|
* Returns: the class
|
|
|
|
*/
|
2011-06-09 16:13:35 +00:00
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_get_klass (GstElementFactory * factory)
|
2003-10-31 19:32:47 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
|
2002-06-13 15:08:52 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
return factory->details.klass;
|
2002-06-13 15:08:52 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2000-09-14 20:31:03 +00:00
|
|
|
/**
|
2003-10-31 19:32:47 +00:00
|
|
|
* gst_element_factory_get_description:
|
|
|
|
* @factory: a #GstElementFactory
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-10-31 19:32:47 +00:00
|
|
|
* Gets the description for this factory.
|
2000-09-14 20:31:03 +00:00
|
|
|
*
|
2003-10-31 19:32:47 +00:00
|
|
|
* Returns: the description
|
2000-09-14 20:31:03 +00:00
|
|
|
*/
|
2011-06-09 16:13:35 +00:00
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_get_description (GstElementFactory * factory)
|
2000-12-11 00:04:25 +00:00
|
|
|
{
|
2003-10-31 19:32:47 +00:00
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
|
2000-12-11 00:04:25 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
return factory->details.description;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
/**
|
|
|
|
* gst_element_factory_get_author:
|
|
|
|
* @factory: a #GstElementFactory
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-10-31 19:32:47 +00:00
|
|
|
* Gets the author for this factory.
|
|
|
|
*
|
|
|
|
* Returns: the author
|
|
|
|
*/
|
2011-06-09 16:13:35 +00:00
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_get_author (GstElementFactory * factory)
|
2003-10-31 19:32:47 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
|
2001-09-29 09:53:07 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
return factory->details.author;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2011-06-09 16:13:35 +00:00
|
|
|
static const gchar *
|
2010-08-10 11:05:22 +00:00
|
|
|
gst_element_factory_get_meta_data (GstElementFactory * factory,
|
|
|
|
const gchar * key)
|
|
|
|
{
|
2010-12-02 22:00:09 +00:00
|
|
|
if (!factory->meta_data)
|
|
|
|
return NULL;
|
|
|
|
|
2010-08-10 11:05:22 +00:00
|
|
|
/* FIXME: do we want to support other types? */
|
|
|
|
return gst_structure_get_string ((GstStructure *) factory->meta_data, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_factory_get_documentation_uri:
|
|
|
|
* @factory: a #GstElementFactory
|
|
|
|
*
|
|
|
|
* Gets documentation uri for this factory if set.
|
|
|
|
*
|
|
|
|
* Since: 0.10.31
|
|
|
|
*
|
|
|
|
* Returns: the documentation uri
|
|
|
|
*/
|
2011-06-09 16:13:35 +00:00
|
|
|
const gchar *
|
2010-08-10 11:05:22 +00:00
|
|
|
gst_element_factory_get_documentation_uri (GstElementFactory * factory)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
|
|
|
|
return gst_element_factory_get_meta_data (factory, "doc-uri");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-05-02 13:22:56 +00:00
|
|
|
* gst_element_factory_get_icon_name:
|
2010-08-10 11:05:22 +00:00
|
|
|
* @factory: a #GstElementFactory
|
|
|
|
*
|
|
|
|
* Gets icon name for this factory if set.
|
|
|
|
*
|
|
|
|
* Since: 0.10.31
|
|
|
|
*
|
|
|
|
* Returns: the icon name
|
|
|
|
*/
|
2011-06-09 16:13:35 +00:00
|
|
|
const gchar *
|
2010-08-10 11:05:22 +00:00
|
|
|
gst_element_factory_get_icon_name (GstElementFactory * factory)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
|
|
|
|
return gst_element_factory_get_meta_data (factory, "icon-name");
|
|
|
|
}
|
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
/**
|
2003-11-11 12:34:15 +00:00
|
|
|
* gst_element_factory_get_num_pad_templates:
|
2003-10-31 19:32:47 +00:00
|
|
|
* @factory: a #GstElementFactory
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-11-11 12:34:15 +00:00
|
|
|
* Gets the number of pad_templates in this factory.
|
2003-10-31 19:32:47 +00:00
|
|
|
*
|
2003-11-11 12:34:15 +00:00
|
|
|
* Returns: the number of pad_templates
|
2003-10-31 19:32:47 +00:00
|
|
|
*/
|
|
|
|
guint
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_get_num_pad_templates (GstElementFactory * factory)
|
2003-10-31 19:32:47 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), 0);
|
|
|
|
|
|
|
|
return factory->numpadtemplates;
|
2000-12-19 13:41:55 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* __gst_element_factory_add_interface:
|
|
|
|
* @elementfactory: The elementfactory to add the interface to
|
|
|
|
* @interfacename: Name of the interface
|
|
|
|
*
|
|
|
|
* Adds the given interfacename to the list of implemented interfaces of the
|
|
|
|
* element.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
__gst_element_factory_add_interface (GstElementFactory * elementfactory,
|
|
|
|
const gchar * interfacename)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT_FACTORY (elementfactory));
|
|
|
|
g_return_if_fail (interfacename != NULL);
|
2004-03-15 19:27:17 +00:00
|
|
|
g_return_if_fail (interfacename[0] != '\0'); /* no empty string */
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
elementfactory->interfaces =
|
2010-10-20 11:27:16 +00:00
|
|
|
g_list_prepend (elementfactory->interfaces,
|
|
|
|
(gpointer) g_intern_string (interfacename));
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
/**
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
* gst_element_factory_get_static_pad_templates:
|
2003-10-31 19:32:47 +00:00
|
|
|
* @factory: a #GstElementFactory
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2007-02-11 19:59:12 +00:00
|
|
|
* Gets the #GList of #GstStaticPadTemplate for this factory.
|
2003-10-31 19:32:47 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer none) (element-type Gst.StaticPadTemplate): the
|
|
|
|
* static pad templates
|
2003-10-31 19:32:47 +00:00
|
|
|
*/
|
2011-06-09 16:13:35 +00:00
|
|
|
const GList *
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
gst_element_factory_get_static_pad_templates (GstElementFactory * factory)
|
2003-10-31 19:32:47 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
|
2000-08-21 21:20:38 +00:00
|
|
|
|
Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.
Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 15:00:30 +00:00
|
|
|
return factory->staticpadtemplates;
|
2003-10-31 19:32:47 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
|
|
|
* gst_element_factory_get_uri_type:
|
|
|
|
* @factory: a #GstElementFactory
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2008-05-28 16:46:07 +00:00
|
|
|
* Gets the type of URIs the element supports or #GST_URI_UNKNOWN if none.
|
2003-11-24 03:21:54 +00:00
|
|
|
*
|
|
|
|
* Returns: type of URIs this element supports
|
|
|
|
*/
|
2005-10-15 00:15:43 +00:00
|
|
|
gint
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_get_uri_type (GstElementFactory * factory)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), GST_URI_UNKNOWN);
|
|
|
|
|
|
|
|
return factory->uri_type;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
|
|
|
* gst_element_factory_get_uri_protocols:
|
|
|
|
* @factory: a #GstElementFactory
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2006-09-25 13:08:29 +00:00
|
|
|
* Gets a NULL-terminated array of protocols this element supports or NULL if
|
2003-11-24 03:21:54 +00:00
|
|
|
* no protocols are supported. You may not change the contents of the returned
|
2006-09-25 13:08:29 +00:00
|
|
|
* array, as it is still owned by the element factory. Use g_strdupv() to
|
|
|
|
* make a copy of the protocol string array if you need to.
|
2003-11-24 03:21:54 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer none) (array zero-terminated=1): the supported protocols
|
|
|
|
* or NULL
|
2003-11-24 03:21:54 +00:00
|
|
|
*/
|
|
|
|
gchar **
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_factory_get_uri_protocols (GstElementFactory * factory)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
|
|
|
|
|
|
|
|
return factory->uri_protocols;
|
|
|
|
}
|
2007-07-25 18:37:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_factory_has_interface:
|
|
|
|
* @factory: a #GstElementFactory
|
|
|
|
* @interfacename: an interface name
|
|
|
|
*
|
|
|
|
* Check if @factory implements the interface with name @interfacename.
|
|
|
|
*
|
|
|
|
* Returns: #TRUE when @factory implement the interface.
|
|
|
|
*
|
|
|
|
* Since: 0.10.14
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_element_factory_has_interface (GstElementFactory * factory,
|
|
|
|
const gchar * interfacename)
|
|
|
|
{
|
|
|
|
GList *walk;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), FALSE);
|
|
|
|
|
|
|
|
for (walk = factory->interfaces; walk; walk = g_list_next (walk)) {
|
|
|
|
gchar *iname = (gchar *) walk->data;
|
|
|
|
|
|
|
|
if (!strcmp (iname, interfacename))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-08-16 17:01:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstElementFactoryListType type;
|
|
|
|
GstRank minrank;
|
|
|
|
} FilterData;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_factory_list_is_type:
|
|
|
|
* @factory: a #GstElementFactory
|
|
|
|
* @type: a #GstElementFactoryListType
|
|
|
|
*
|
2011-08-16 16:19:29 +00:00
|
|
|
* Check if @factory is of the given types.
|
2010-08-16 17:01:15 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if @factory is of @type.
|
|
|
|
*
|
|
|
|
* Since: 0.10.31
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_element_factory_list_is_type (GstElementFactory * factory,
|
|
|
|
GstElementFactoryListType type)
|
|
|
|
{
|
|
|
|
gboolean res = FALSE;
|
|
|
|
const gchar *klass;
|
|
|
|
|
|
|
|
klass = gst_element_factory_get_klass (factory);
|
|
|
|
|
|
|
|
/* Filter by element type first, as soon as it matches
|
|
|
|
* one type, we skip all other tests */
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_SINK))
|
|
|
|
res = (strstr (klass, "Sink") != NULL);
|
|
|
|
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_SRC))
|
|
|
|
res = (strstr (klass, "Source") != NULL);
|
|
|
|
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DECODER))
|
|
|
|
res = (strstr (klass, "Decoder") != NULL);
|
|
|
|
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_ENCODER))
|
|
|
|
res = (strstr (klass, "Encoder") != NULL);
|
|
|
|
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_MUXER))
|
|
|
|
res = (strstr (klass, "Muxer") != NULL);
|
|
|
|
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DEMUXER))
|
|
|
|
res = (strstr (klass, "Demux") != NULL);
|
|
|
|
|
|
|
|
/* FIXME : We're actually parsing two Classes here... */
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_PARSER))
|
|
|
|
res = ((strstr (klass, "Parser") != NULL)
|
|
|
|
&& (strstr (klass, "Codec") != NULL));
|
|
|
|
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER))
|
|
|
|
res = (strstr (klass, "Depayloader") != NULL);
|
|
|
|
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_PAYLOADER))
|
|
|
|
res = (strstr (klass, "Payloader") != NULL);
|
|
|
|
|
|
|
|
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_FORMATTER))
|
|
|
|
res = (strstr (klass, "Formatter") != NULL);
|
|
|
|
|
|
|
|
/* Filter by media type now, we only test if it
|
|
|
|
* matched any of the types above. */
|
|
|
|
if (res
|
|
|
|
&& (type & (GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO |
|
|
|
|
GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO |
|
|
|
|
GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)))
|
|
|
|
res = ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO)
|
|
|
|
&& (strstr (klass, "Audio") != NULL))
|
|
|
|
|| ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO)
|
|
|
|
&& (strstr (klass, "Video") != NULL))
|
|
|
|
|| ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)
|
|
|
|
&& (strstr (klass, "Image") != NULL));
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
element_filter (GstPluginFeature * feature, FilterData * data)
|
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
/* we only care about element factories */
|
|
|
|
if (G_UNLIKELY (!GST_IS_ELEMENT_FACTORY (feature)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
res = (gst_plugin_feature_get_rank (feature) >= data->minrank) &&
|
|
|
|
gst_element_factory_list_is_type (GST_ELEMENT_FACTORY_CAST (feature),
|
|
|
|
data->type);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_factory_list_get_elements:
|
|
|
|
* @type: a #GstElementFactoryListType
|
|
|
|
* @minrank: Minimum rank
|
|
|
|
*
|
|
|
|
* Get a list of factories that match the given @type. Only elements
|
|
|
|
* with a rank greater or equal to @minrank will be returned.
|
|
|
|
* The list of factories is returned by decreasing rank.
|
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full) (element-type Gst.ElementFactory): a #GList of
|
|
|
|
* #GstElementFactory elements. Use gst_plugin_feature_list_free() after
|
|
|
|
* usage.
|
2010-08-16 17:01:15 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.31
|
|
|
|
*/
|
|
|
|
GList *
|
|
|
|
gst_element_factory_list_get_elements (GstElementFactoryListType type,
|
|
|
|
GstRank minrank)
|
|
|
|
{
|
|
|
|
GList *result;
|
|
|
|
FilterData data;
|
|
|
|
|
|
|
|
/* prepare type */
|
|
|
|
data.type = type;
|
|
|
|
data.minrank = minrank;
|
|
|
|
|
|
|
|
/* get the feature list using the filter */
|
|
|
|
result = gst_default_registry_feature_filter ((GstPluginFeatureFilter)
|
|
|
|
element_filter, FALSE, &data);
|
|
|
|
|
|
|
|
/* sort on rank and name */
|
|
|
|
result = g_list_sort (result, gst_plugin_feature_rank_compare_func);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_element_factory_list_filter:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @list: (transfer none) (element-type Gst.ElementFactory): a #GList of
|
|
|
|
* #GstElementFactory to filter
|
2010-08-16 17:01:15 +00:00
|
|
|
* @caps: a #GstCaps
|
|
|
|
* @direction: a #GstPadDirection to filter on
|
|
|
|
* @subsetonly: whether to filter on caps subsets or not.
|
|
|
|
*
|
|
|
|
* Filter out all the elementfactories in @list that can handle @caps in
|
|
|
|
* the given direction.
|
|
|
|
*
|
|
|
|
* If @subsetonly is %TRUE, then only the elements whose pads templates
|
|
|
|
* are a complete superset of @caps will be returned. Else any element
|
|
|
|
* whose pad templates caps can intersect with @caps will be returned.
|
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full) (element-type Gst.ElementFactory): a #GList of
|
|
|
|
* #GstElementFactory elements that match the given requisits.
|
|
|
|
* Use #gst_plugin_feature_list_free after usage.
|
2010-08-16 17:01:15 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.31
|
|
|
|
*/
|
|
|
|
GList *
|
|
|
|
gst_element_factory_list_filter (GList * list,
|
|
|
|
const GstCaps * caps, GstPadDirection direction, gboolean subsetonly)
|
|
|
|
{
|
|
|
|
GList *result = NULL;
|
|
|
|
|
|
|
|
GST_DEBUG ("finding factories");
|
|
|
|
|
|
|
|
/* loop over all the factories */
|
|
|
|
for (; list; list = list->next) {
|
|
|
|
GstElementFactory *factory;
|
|
|
|
const GList *templates;
|
|
|
|
GList *walk;
|
|
|
|
|
|
|
|
factory = (GstElementFactory *) list->data;
|
|
|
|
|
|
|
|
GST_DEBUG ("Trying %s",
|
|
|
|
gst_plugin_feature_get_name ((GstPluginFeature *) factory));
|
|
|
|
|
|
|
|
/* get the templates from the element factory */
|
|
|
|
templates = gst_element_factory_get_static_pad_templates (factory);
|
|
|
|
for (walk = (GList *) templates; walk; walk = g_list_next (walk)) {
|
|
|
|
GstStaticPadTemplate *templ = walk->data;
|
|
|
|
|
|
|
|
/* we only care about the sink templates */
|
|
|
|
if (templ->direction == direction) {
|
|
|
|
GstCaps *tmpl_caps;
|
|
|
|
|
|
|
|
/* try to intersect the caps with the caps of the template */
|
|
|
|
tmpl_caps = gst_static_caps_get (&templ->static_caps);
|
|
|
|
|
|
|
|
/* FIXME, intersect is not the right method, we ideally want to check
|
|
|
|
* for a subset here */
|
|
|
|
|
|
|
|
/* check if the intersection is empty */
|
|
|
|
if ((subsetonly && gst_caps_is_subset (caps, tmpl_caps)) ||
|
|
|
|
(!subsetonly && gst_caps_can_intersect (caps, tmpl_caps))) {
|
|
|
|
/* non empty intersection, we can use this element */
|
|
|
|
result = g_list_prepend (result, gst_object_ref (factory));
|
2010-11-18 00:29:19 +00:00
|
|
|
gst_caps_unref (tmpl_caps);
|
2010-08-16 17:01:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_caps_unref (tmpl_caps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return g_list_reverse (result);
|
|
|
|
}
|