*
* 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.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstelementfactory
+ * @title: GstElementFactory
* @short_description: Create GstElements from a factory
* @see_also: #GstElement, #GstPlugin, #GstPluginFeature, #GstPadTemplate.
*
* #GstElementFactory is used to create instances of elements. A
- * GstElementfactory can be added to a #GstPlugin as it is also a
+ * GstElementFactory can be added to a #GstPlugin as it is also a
* #GstPluginFeature.
*
* Use the gst_element_factory_find() and gst_element_factory_create()
*
* The following code example shows you how to create a GstFileSrc element.
*
- * <example>
- * <title>Using an element factory</title>
- * <programlisting language="c">
+ * ## Using an element factory
+ * |[<!-- language="C" -->
* #include <gst/gst.h>
*
* GstElement *src;
* src = gst_element_factory_create (srcfactory, "src");
* g_return_if_fail (src != NULL);
* ...
- * </programlisting>
- * </example>
- *
- * Last reviewed on 2005-11-23 (0.9.5)
+ * ]|
*/
#include "gst_private.h"
* Search for an element factory of the given name. Refs the returned
* element factory; caller is responsible for unreffing.
*
- * Returns: (transfer full): #GstElementFactory if found, NULL otherwise
+ * Returns: (transfer full) (nullable): #GstElementFactory if found,
+ * %NULL otherwise
*/
GstElementFactory *
gst_element_factory_find (const gchar * name)
/**
* gst_element_register:
- * @plugin: (allow-none): #GstPlugin to register the element with, or NULL for
+ * @plugin: (allow-none): #GstPlugin to register the element with, or %NULL for
* a static element.
* @name: name of elements of this type
* @rank: rank of element (higher rank means more importance when autoplugging)
* Create a new elementfactory capable of instantiating objects of the
* @type and add the factory to @plugin.
*
- * Returns: TRUE, if the registering succeeded, FALSE on error
+ * Returns: %TRUE, if the registering succeeded, %FALSE on error
*/
gboolean
gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
return TRUE;
}
- factory =
- GST_ELEMENT_FACTORY_CAST (g_object_newv (GST_TYPE_ELEMENT_FACTORY, 0,
- NULL));
+ factory = g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL);
gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name);
GST_LOG_OBJECT (factory, "Created new elementfactory for type %s",
g_type_name (type));
/**
* gst_element_factory_create:
* @factory: factory to instantiate
- * @name: (allow-none): name of new element, or NULL to automatically create
+ * @name: (allow-none): name of new element, or %NULL to automatically create
* a unique name
*
* Create a new element of the type defined by the given elementfactory.
* It will be given the name supplied, since all elements require a name as
* their first argument.
*
- * Returns: (transfer floating): new #GstElement or NULL if the element couldn't
- * be created
+ * Returns: (transfer floating) (nullable): new #GstElement or %NULL
+ * if the element couldn't be created
*/
GstElement *
gst_element_factory_create (GstElementFactory * factory, const gchar * name)
* also set name as early as we can
*/
if (name)
- element =
- GST_ELEMENT_CAST (g_object_new (factory->type, "name", name, NULL));
+ element = g_object_new (factory->type, "name", name, NULL);
else
- element = GST_ELEMENT_CAST (g_object_newv (factory->type, 0, NULL));
+ element = g_object_new (factory->type, NULL);
if (G_UNLIKELY (element == NULL))
goto no_element;
if (!g_atomic_pointer_compare_and_exchange (&oclass->elementfactory, NULL,
factory))
gst_object_unref (factory);
+ else
+ /* This ref will never be dropped as the class is never destroyed */
+ GST_OBJECT_FLAG_SET (factory, GST_OBJECT_FLAG_MAY_BE_LEAKED);
GST_DEBUG ("created element \"%s\"", GST_OBJECT_NAME (factory));
/**
* gst_element_factory_make:
* @factoryname: a named factory to instantiate
- * @name: (allow-none): name of new element, or NULL to automatically create
+ * @name: (allow-none): name of new element, or %NULL to automatically create
* a unique name
*
* 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,
+ * 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.
*
- * Returns: (transfer floating): new #GstElement or NULL if unable to create element
+ * Returns: (transfer floating) (nullable): new #GstElement or %NULL
+ * if unable to create element
*/
GstElement *
gst_element_factory_make (const gchar * factoryname, const gchar * name)
goto create_failed;
gst_object_unref (factory);
+
return element;
/* ERRORS */
no_factory:
{
- GST_INFO ("no such element factory \"%s\"!", factoryname);
+ GST_WARNING ("no such element factory \"%s\"!", factoryname);
return NULL;
}
create_failed:
*
* Get the metadata on @factory with @key.
*
- * Returns: the metadata with @key on @factory or %NULL when there was no
- * metadata with the given @key.
+ * Returns: (nullable): the metadata with @key on @factory or %NULL
+ * when there was no metadata with the given @key.
*/
const gchar *
gst_element_factory_get_metadata (GstElementFactory * factory,
*
* Get the available keys for the metadata on @factory.
*
- * Returns: (transfer full) (element-type utf8) (array zero-terminated=1):
+ * Returns: (transfer full) (element-type utf8) (array zero-terminated=1) (nullable):
* a %NULL-terminated array of key strings, or %NULL when there is no
* metadata. Free with g_strfreev() when no longer needed.
*/
* gst_element_factory_get_uri_protocols:
* @factory: a #GstElementFactory
*
- * Gets a NULL-terminated array of protocols this element supports or NULL if
+ * Gets a %NULL-terminated array of protocols this element supports or %NULL if
* no protocols are supported. You may not change the contents of the returned
* 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.
*
* Returns: (transfer none) (array zero-terminated=1): the supported protocols
- * or NULL
+ * or %NULL
*/
const gchar *const *
gst_element_factory_get_uri_protocols (GstElementFactory * factory)
*
* Check if @factory implements the interface with name @interfacename.
*
- * Returns: #TRUE when @factory implement the interface.
+ * Returns: %TRUE when @factory implement the interface.
*/
gboolean
gst_element_factory_has_interface (GstElementFactory * factory,
if (!res && (type & GST_ELEMENT_FACTORY_TYPE_FORMATTER))
res = (strstr (klass, "Formatter") != NULL);
+ if (!res && (type & GST_ELEMENT_FACTORY_TYPE_DECRYPTOR))
+ res = (strstr (klass, "Decryptor") != NULL);
+
+ if (!res && (type & GST_ELEMENT_FACTORY_TYPE_ENCRYPTOR))
+ res = (strstr (klass, "Encryptor") != NULL);
+
/* Filter by media type now, we only test if it
- * matched any of the types above. */
- if (res
+ * matched any of the types above or only checking the media
+ * type was requested. */
+ if ((res || !(type & (GST_ELEMENT_FACTORY_TYPE_MAX_ELEMENTS - 1)))
&& (type & (GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO |
GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO |
- GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)))
+ GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE |
+ GST_ELEMENT_FACTORY_TYPE_MEDIA_SUBTITLE |
+ GST_ELEMENT_FACTORY_TYPE_MEDIA_METADATA)))
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));
+ && (strstr (klass, "Image") != NULL)) ||
+ ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_SUBTITLE)
+ && (strstr (klass, "Subtitle") != NULL)) ||
+ ((type & GST_ELEMENT_FACTORY_TYPE_MEDIA_METADATA)
+ && (strstr (klass, "Metadata") != NULL));
return res;
}
* whose pad templates caps can intersect with @caps will be returned.
*
* Returns: (transfer full) (element-type Gst.ElementFactory): a #GList of
- * #GstElementFactory elements that match the given requisits.
+ * #GstElementFactory elements that match the given requisites.
* Use #gst_plugin_feature_list_free after usage.
*/
GList *