2001-08-21 20:16:48 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstpluginfeature.c: Abstract base class for all plugin features
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2001-08-21 20:16:48 +00:00
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
more docs inlined, splitted gstindex.{c,h}
Original commit message from CVS:
* docs/gst/gstreamer-docs.sgml:
* docs/gst/gstreamer-sections.txt:
* docs/gst/tmpl/.cvsignore:
* gst/Makefile.am:
* gst/gst.h:
* gst/gstbin.c:
* gst/gstelement.h:
* gst/gstindex.c: (gst_index_class_init):
* gst/gstindex.h:
* gst/gstindexfactory.c: (gst_index_factory_get_type),
(gst_index_factory_class_init), (gst_index_factory_init),
(gst_index_factory_finalize), (gst_index_factory_new),
(gst_index_factory_destroy), (gst_index_factory_find),
(gst_index_factory_create), (gst_index_factory_make):
* gst/gstindexfactory.h:
* gst/gstpluginfeature.c:
* gst/gstpluginfeature.h:
* libs/gst/controller/gstcontroller.c: (gst_controller_new_valist):
more docs inlined, splitted gstindex.{c,h}
2005-09-20 20:40:00 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstpluginfeature
|
2017-01-16 14:26:16 +00:00
|
|
|
* @title: GstPluginfeature
|
more docs inlined, splitted gstindex.{c,h}
Original commit message from CVS:
* docs/gst/gstreamer-docs.sgml:
* docs/gst/gstreamer-sections.txt:
* docs/gst/tmpl/.cvsignore:
* gst/Makefile.am:
* gst/gst.h:
* gst/gstbin.c:
* gst/gstelement.h:
* gst/gstindex.c: (gst_index_class_init):
* gst/gstindex.h:
* gst/gstindexfactory.c: (gst_index_factory_get_type),
(gst_index_factory_class_init), (gst_index_factory_init),
(gst_index_factory_finalize), (gst_index_factory_new),
(gst_index_factory_destroy), (gst_index_factory_find),
(gst_index_factory_create), (gst_index_factory_make):
* gst/gstindexfactory.h:
* gst/gstpluginfeature.c:
* gst/gstpluginfeature.h:
* libs/gst/controller/gstcontroller.c: (gst_controller_new_valist):
more docs inlined, splitted gstindex.{c,h}
2005-09-20 20:40:00 +00:00
|
|
|
* @short_description: Base class for contents of a GstPlugin
|
|
|
|
* @see_also: #GstPlugin
|
|
|
|
*
|
|
|
|
* This is a base class for anything that can be added to a #GstPlugin.
|
|
|
|
*/
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
#include "gst_private.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
#include "gstpluginfeature.h"
|
|
|
|
#include "gstplugin.h"
|
2002-05-08 20:40:48 +00:00
|
|
|
#include "gstregistry.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gstinfo.h"
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2009-10-07 07:00:05 +00:00
|
|
|
#include <stdio.h>
|
2003-10-28 20:25:30 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2005-10-06 09:49:42 +00:00
|
|
|
#define GST_CAT_DEFAULT GST_CAT_PLUGIN_LOADING
|
|
|
|
|
2005-09-18 21:24:55 +00:00
|
|
|
static void gst_plugin_feature_finalize (GObject * object);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, GST_TYPE_OBJECT);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_class_init (GstPluginFeatureClass * klass)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
2009-10-28 00:29:30 +00:00
|
|
|
G_OBJECT_CLASS (klass)->finalize = gst_plugin_feature_finalize;
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_init (GstPluginFeature * feature)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
2007-06-27 10:12:14 +00:00
|
|
|
/* do nothing, needed because of G_DEFINE_TYPE */
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
static void
|
2005-09-18 21:24:55 +00:00
|
|
|
gst_plugin_feature_finalize (GObject * object)
|
2005-09-18 06:59:25 +00:00
|
|
|
{
|
gst/: Use _CAST macros to avoid unneeded type checking.
Original commit message from CVS:
* gst/gst.c: (gst_debug_help):
* gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_list_free):
* gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
(gst_plugin_feature_list_free):
* gst/gstregistry.c: (gst_registry_add_plugin),
(gst_registry_add_feature), (gst_registry_plugin_filter),
(gst_registry_feature_filter), (gst_registry_find_plugin),
(gst_registry_find_feature), (gst_registry_get_plugin_list),
(gst_registry_lookup_feature_locked), (gst_registry_lookup_locked):
* gst/gstregistryxml.c: (load_feature),
(gst_registry_xml_read_cache), (gst_registry_xml_write_cache):
* gst/gstminiobject.c: (gst_mini_object_unref),
(gst_mini_object_replace), (gst_value_mini_object_free),
(gst_value_mini_object_copy):
Use _CAST macros to avoid unneeded type checking.
Added some more G_UNLIKELY.
2006-06-12 09:17:44 +00:00
|
|
|
GstPluginFeature *feature = GST_PLUGIN_FEATURE_CAST (object);
|
2005-09-18 21:24:55 +00:00
|
|
|
|
2011-05-24 16:17:24 +00:00
|
|
|
GST_DEBUG ("finalizing feature %p: '%s'", feature, GST_OBJECT_NAME (feature));
|
2005-09-18 21:24:55 +00:00
|
|
|
|
2011-04-24 08:53:39 +00:00
|
|
|
if (feature->plugin != NULL) {
|
|
|
|
g_object_remove_weak_pointer ((GObject *) feature->plugin,
|
|
|
|
(gpointer *) & feature->plugin);
|
|
|
|
}
|
|
|
|
|
2010-10-18 11:45:16 +00:00
|
|
|
G_OBJECT_CLASS (gst_plugin_feature_parent_class)->finalize (object);
|
2005-09-18 06:59:25 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2005-09-15 00:13:26 +00:00
|
|
|
* gst_plugin_feature_load:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @feature: (transfer none): the plugin feature to check
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2005-09-22 12:05:05 +00:00
|
|
|
* Loads the plugin containing @feature if it's not already loaded. @feature is
|
|
|
|
* unaffected; use the return value instead.
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2005-09-22 12:05:05 +00:00
|
|
|
* Normally this function is used like this:
|
2014-06-05 20:27:28 +00:00
|
|
|
* |[<!-- language="C" -->
|
2005-09-22 12:05:05 +00:00
|
|
|
* GstPluginFeature *loaded_feature;
|
2011-04-28 08:34:39 +00:00
|
|
|
*
|
2005-09-22 12:05:05 +00:00
|
|
|
* loaded_feature = gst_plugin_feature_load (feature);
|
|
|
|
* // presumably, we're no longer interested in the potentially-unloaded feature
|
|
|
|
* gst_object_unref (feature);
|
|
|
|
* feature = loaded_feature;
|
2009-02-15 14:37:17 +00:00
|
|
|
* ]|
|
2005-09-22 12:05:05 +00:00
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (transfer full) (nullable): a reference to the loaded
|
|
|
|
* feature, or %NULL on error
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2005-09-15 00:13:26 +00:00
|
|
|
GstPluginFeature *
|
|
|
|
gst_plugin_feature_load (GstPluginFeature * feature)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
2003-01-27 21:37:13 +00:00
|
|
|
GstPlugin *plugin;
|
2005-09-15 00:13:26 +00:00
|
|
|
GstPluginFeature *real_feature;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-01-27 21:37:13 +00:00
|
|
|
g_return_val_if_fail (feature != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
|
|
|
|
|
2005-12-12 18:12:13 +00:00
|
|
|
GST_DEBUG ("loading plugin for feature %p; '%s'", feature,
|
2011-05-24 16:17:24 +00:00
|
|
|
GST_OBJECT_NAME (feature));
|
2005-09-18 06:59:25 +00:00
|
|
|
if (feature->loaded)
|
2006-12-07 12:11:14 +00:00
|
|
|
return gst_object_ref (feature);
|
2005-09-18 06:59:25 +00:00
|
|
|
|
2005-09-19 14:09:54 +00:00
|
|
|
GST_DEBUG ("loading plugin %s", feature->plugin_name);
|
2005-09-18 06:59:25 +00:00
|
|
|
plugin = gst_plugin_load_by_name (feature->plugin_name);
|
2006-04-11 11:47:39 +00:00
|
|
|
if (!plugin)
|
|
|
|
goto load_failed;
|
|
|
|
|
2005-09-19 14:09:54 +00:00
|
|
|
GST_DEBUG ("loaded plugin %s", feature->plugin_name);
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_object_unref (plugin);
|
2005-01-09 01:35:01 +00:00
|
|
|
|
2012-01-02 02:22:51 +00:00
|
|
|
real_feature = gst_registry_lookup_feature (gst_registry_get (),
|
2011-05-24 16:17:24 +00:00
|
|
|
GST_OBJECT_NAME (feature));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2006-04-11 11:47:39 +00:00
|
|
|
if (real_feature == NULL)
|
|
|
|
goto disappeared;
|
|
|
|
else if (!real_feature->loaded)
|
|
|
|
goto not_found;
|
|
|
|
|
|
|
|
return real_feature;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
load_failed:
|
|
|
|
{
|
|
|
|
GST_WARNING ("Failed to load plugin containing feature '%s'.",
|
2011-05-24 16:17:24 +00:00
|
|
|
GST_OBJECT_NAME (feature));
|
2006-04-11 11:47:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
disappeared:
|
|
|
|
{
|
2005-10-04 11:10:04 +00:00
|
|
|
GST_INFO
|
2005-09-15 00:13:26 +00:00
|
|
|
("Loaded plugin containing feature '%s', but feature disappeared.",
|
2011-05-24 16:17:24 +00:00
|
|
|
GST_OBJECT_NAME (feature));
|
2006-04-11 11:47:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
not_found:
|
|
|
|
{
|
2005-10-04 11:10:04 +00:00
|
|
|
GST_INFO ("Tried to load plugin containing feature '%s', but feature was "
|
2011-05-24 16:17:24 +00:00
|
|
|
"not found.", GST_OBJECT_NAME (real_feature));
|
2005-10-04 11:10:04 +00:00
|
|
|
return NULL;
|
2005-09-15 00:13:26 +00:00
|
|
|
}
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
2005-03-07 18:27:42 +00:00
|
|
|
* gst_plugin_feature_set_rank:
|
|
|
|
* @feature: feature to rank
|
|
|
|
* @rank: rank value - higher number means more priority rank
|
|
|
|
*
|
|
|
|
* Specifies a rank for a plugin feature, so that autoplugging uses
|
|
|
|
* the most appropriate feature.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank)
|
|
|
|
{
|
|
|
|
g_return_if_fail (feature != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
|
|
|
|
|
|
|
|
feature->rank = rank;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-10-14 11:09:29 +00:00
|
|
|
* gst_plugin_feature_get_rank:
|
2003-11-24 03:21:54 +00:00
|
|
|
* @feature: a feature
|
|
|
|
*
|
2005-03-07 18:27:42 +00:00
|
|
|
* Gets the rank of a plugin feature.
|
2003-11-24 03:21:54 +00:00
|
|
|
*
|
2005-03-07 18:27:42 +00:00
|
|
|
* Returns: The rank of the feature
|
2003-11-24 03:21:54 +00:00
|
|
|
*/
|
2005-03-07 18:27:42 +00:00
|
|
|
guint
|
|
|
|
gst_plugin_feature_get_rank (GstPluginFeature * feature)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), GST_RANK_NONE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
return feature->rank;
|
2003-11-24 03:21:54 +00:00
|
|
|
}
|
2005-09-15 20:56:30 +00:00
|
|
|
|
2012-05-19 16:16:35 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_get_plugin:
|
|
|
|
* @feature: a feature
|
|
|
|
*
|
|
|
|
* Get the plugin that provides this feature.
|
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (transfer full) (nullable): the plugin that provides this
|
|
|
|
* feature, or %NULL. Unref with gst_object_unref() when no
|
|
|
|
* longer needed.
|
2012-05-19 16:16:35 +00:00
|
|
|
*/
|
|
|
|
GstPlugin *
|
|
|
|
gst_plugin_feature_get_plugin (GstPluginFeature * feature)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
|
|
|
|
|
|
|
|
if (feature->plugin == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (GstPlugin *) gst_object_ref (feature->plugin);
|
|
|
|
}
|
|
|
|
|
2012-10-28 15:53:19 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_get_plugin_name:
|
|
|
|
* @feature: a feature
|
|
|
|
*
|
|
|
|
* Get the name of the plugin that provides this feature.
|
|
|
|
*
|
2014-06-11 22:21:34 +00:00
|
|
|
* Returns: (nullable): the name of the plugin that provides this
|
|
|
|
* feature, or %NULL if the feature is not associated with a
|
|
|
|
* plugin.
|
2012-10-28 15:53:19 +00:00
|
|
|
*
|
2013-11-16 12:24:56 +00:00
|
|
|
* Since: 1.2
|
2012-10-28 15:53:19 +00:00
|
|
|
*/
|
|
|
|
const gchar *
|
|
|
|
gst_plugin_feature_get_plugin_name (GstPluginFeature * feature)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
|
|
|
|
|
|
|
|
if (feature->plugin == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return gst_plugin_get_name (feature->plugin);
|
|
|
|
}
|
|
|
|
|
2005-09-22 12:05:05 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_list_free:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @list: (transfer full) (element-type Gst.PluginFeature): list
|
|
|
|
* of #GstPluginFeature
|
2005-09-22 12:05:05 +00:00
|
|
|
*
|
|
|
|
* Unrefs each member of @list, then frees the list.
|
|
|
|
*/
|
2005-09-15 20:56:30 +00:00
|
|
|
void
|
|
|
|
gst_plugin_feature_list_free (GList * list)
|
|
|
|
{
|
|
|
|
GList *g;
|
|
|
|
|
|
|
|
for (g = list; g; g = g->next) {
|
gst/: Use _CAST macros to avoid unneeded type checking.
Original commit message from CVS:
* gst/gst.c: (gst_debug_help):
* gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_list_free):
* gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
(gst_plugin_feature_list_free):
* gst/gstregistry.c: (gst_registry_add_plugin),
(gst_registry_add_feature), (gst_registry_plugin_filter),
(gst_registry_feature_filter), (gst_registry_find_plugin),
(gst_registry_find_feature), (gst_registry_get_plugin_list),
(gst_registry_lookup_feature_locked), (gst_registry_lookup_locked):
* gst/gstregistryxml.c: (load_feature),
(gst_registry_xml_read_cache), (gst_registry_xml_write_cache):
* gst/gstminiobject.c: (gst_mini_object_unref),
(gst_mini_object_replace), (gst_value_mini_object_free),
(gst_value_mini_object_copy):
Use _CAST macros to avoid unneeded type checking.
Added some more G_UNLIKELY.
2006-06-12 09:17:44 +00:00
|
|
|
GstPluginFeature *feature = GST_PLUGIN_FEATURE_CAST (g->data);
|
2005-09-15 20:56:30 +00:00
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_object_unref (feature);
|
2005-09-15 20:56:30 +00:00
|
|
|
}
|
|
|
|
g_list_free (list);
|
|
|
|
}
|
2005-10-14 11:09:29 +00:00
|
|
|
|
2009-10-21 07:40:49 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_list_copy:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @list: (transfer none) (element-type Gst.PluginFeature): list
|
|
|
|
* of #GstPluginFeature
|
2009-10-21 07:40:49 +00:00
|
|
|
*
|
|
|
|
* Copies the list of features. Caller should call @gst_plugin_feature_list_free
|
|
|
|
* when done with the list.
|
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer full) (element-type Gst.PluginFeature): a copy of @list,
|
|
|
|
* with each feature's reference count incremented.
|
2009-10-21 07:40:49 +00:00
|
|
|
*/
|
|
|
|
GList *
|
|
|
|
gst_plugin_feature_list_copy (GList * list)
|
|
|
|
{
|
|
|
|
GList *new_list = NULL;
|
|
|
|
|
|
|
|
if (G_LIKELY (list)) {
|
|
|
|
GList *last;
|
|
|
|
|
|
|
|
new_list = g_list_alloc ();
|
2012-04-12 12:58:47 +00:00
|
|
|
new_list->data = gst_object_ref (list->data);
|
2009-10-21 07:40:49 +00:00
|
|
|
new_list->prev = NULL;
|
|
|
|
last = new_list;
|
|
|
|
list = list->next;
|
|
|
|
while (list) {
|
|
|
|
last->next = g_list_alloc ();
|
|
|
|
last->next->prev = last;
|
|
|
|
last = last->next;
|
2012-04-12 12:58:47 +00:00
|
|
|
last->data = gst_object_ref (list->data);
|
2009-10-21 07:40:49 +00:00
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
last->next = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_list;
|
|
|
|
}
|
|
|
|
|
2010-08-16 17:01:15 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_list_debug:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @list: (transfer none) (element-type Gst.PluginFeature): a #GList of
|
|
|
|
* plugin features
|
2010-08-16 17:01:15 +00:00
|
|
|
*
|
|
|
|
* Debug the plugin feature names in @list.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_plugin_feature_list_debug (GList * list)
|
|
|
|
{
|
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
|
|
|
while (list) {
|
|
|
|
GST_DEBUG ("%s",
|
|
|
|
gst_plugin_feature_get_name ((GstPluginFeature *) list->data));
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-10-14 11:09:29 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_check_version:
|
|
|
|
* @feature: a feature
|
|
|
|
* @min_major: minimum required major version
|
|
|
|
* @min_minor: minimum required minor version
|
|
|
|
* @min_micro: minimum required micro version
|
|
|
|
*
|
|
|
|
* Checks whether the given plugin feature is at least
|
|
|
|
* the required version
|
|
|
|
*
|
2014-05-29 21:54:34 +00:00
|
|
|
* Returns: %TRUE if the plugin feature has at least
|
|
|
|
* the required version, otherwise %FALSE.
|
2005-10-14 11:09:29 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_plugin_feature_check_version (GstPluginFeature * feature,
|
|
|
|
guint min_major, guint min_minor, guint min_micro)
|
|
|
|
{
|
|
|
|
GstRegistry *registry;
|
|
|
|
GstPlugin *plugin;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (feature != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
|
|
|
|
|
|
|
|
GST_DEBUG ("Looking up plugin '%s' containing plugin feature '%s'",
|
2011-05-24 16:17:24 +00:00
|
|
|
feature->plugin_name, GST_OBJECT_NAME (feature));
|
2005-10-14 11:09:29 +00:00
|
|
|
|
2012-01-02 02:22:51 +00:00
|
|
|
registry = gst_registry_get ();
|
2005-10-14 11:09:29 +00:00
|
|
|
plugin = gst_registry_find_plugin (registry, feature->plugin_name);
|
|
|
|
|
|
|
|
if (plugin) {
|
|
|
|
const gchar *ver_str;
|
2009-09-10 09:41:56 +00:00
|
|
|
guint major, minor, micro, nano;
|
|
|
|
gint nscan;
|
2005-10-14 11:09:29 +00:00
|
|
|
|
|
|
|
ver_str = gst_plugin_get_version (plugin);
|
|
|
|
g_return_val_if_fail (ver_str != NULL, FALSE);
|
|
|
|
|
2009-09-10 09:41:56 +00:00
|
|
|
nscan = sscanf (ver_str, "%u.%u.%u.%u", &major, &minor, µ, &nano);
|
|
|
|
GST_DEBUG ("version string '%s' parsed to %d values", ver_str, nscan);
|
|
|
|
|
|
|
|
if (nscan >= 3) {
|
2005-10-14 11:09:29 +00:00
|
|
|
if (major > min_major)
|
|
|
|
ret = TRUE;
|
|
|
|
else if (major < min_major)
|
|
|
|
ret = FALSE;
|
|
|
|
else if (minor > min_minor)
|
|
|
|
ret = TRUE;
|
|
|
|
else if (minor < min_minor)
|
|
|
|
ret = FALSE;
|
|
|
|
else if (micro > min_micro)
|
|
|
|
ret = TRUE;
|
2011-09-07 11:14:38 +00:00
|
|
|
/* micro is 1 smaller but we have a nano version, this is the upcoming
|
2009-09-10 09:41:56 +00:00
|
|
|
* release of the requested version and we're ok then */
|
|
|
|
else if (nscan == 4 && nano > 0 && (micro + 1 == min_micro))
|
|
|
|
ret = TRUE;
|
2005-10-14 11:09:29 +00:00
|
|
|
else
|
|
|
|
ret = (micro == min_micro);
|
|
|
|
|
|
|
|
GST_DEBUG ("Checking whether %u.%u.%u >= %u.%u.%u? %s", major, minor,
|
|
|
|
micro, min_major, min_minor, min_micro, (ret) ? "yes" : "no");
|
|
|
|
} else {
|
|
|
|
GST_WARNING ("Could not parse version string '%s' of plugin '%s'",
|
|
|
|
ver_str, feature->plugin_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (plugin);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG ("Could not find plugin '%s'", feature->plugin_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2010-08-16 17:01:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_feature_rank_compare_func:
|
|
|
|
* @p1: a #GstPluginFeature
|
|
|
|
* @p2: a #GstPluginFeature
|
|
|
|
*
|
|
|
|
* Compares the two given #GstPluginFeature instances. This function can be
|
|
|
|
* used as a #GCompareFunc when sorting by rank and then by name.
|
|
|
|
*
|
|
|
|
* Returns: negative value if the rank of p1 > the rank of p2 or the ranks are
|
|
|
|
* equal but the name of p1 comes before the name of p2; zero if the rank
|
|
|
|
* and names are equal; positive value if the rank of p1 < the rank of p2 or the
|
2013-04-13 16:43:10 +00:00
|
|
|
* ranks are equal but the name of p2 comes before the name of p1
|
2010-08-16 17:01:15 +00:00
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gst_plugin_feature_rank_compare_func (gconstpointer p1, gconstpointer p2)
|
|
|
|
{
|
|
|
|
GstPluginFeature *f1, *f2;
|
|
|
|
gint diff;
|
|
|
|
|
|
|
|
f1 = (GstPluginFeature *) p1;
|
|
|
|
f2 = (GstPluginFeature *) p2;
|
|
|
|
|
|
|
|
diff = f2->rank - f1->rank;
|
|
|
|
if (diff != 0)
|
|
|
|
return diff;
|
|
|
|
|
2013-04-13 16:43:10 +00:00
|
|
|
diff = strcmp (GST_OBJECT_NAME (f1), GST_OBJECT_NAME (f2));
|
2010-08-16 17:01:15 +00:00
|
|
|
|
|
|
|
return diff;
|
|
|
|
}
|
pluginfeature: Allow updating initial rank of plugin feature
Introducing "GST_PLUGIN_FEATURE_RANK" environment variable in order for users
to adjust rank of plugin(s) via environment.
A "feature" and "rank" key-value pair should be separable by ":",
and each key-value pair is recognized per "," delimiters. The rank
can be a numerical value or one of pre-defined rank values
such as "NONE", "MARGINAL", "SECONDARY", and "PRIMARY" in case-insensitive manner.
In addition to pre-defined { NONE, MARGINAL, SECONDARY, PRIMARY },
"MAX" can be passed to key value used to ensure having a higher rank
than other plugin features.
Example)
- GST_PLUGIN_FEATURE_RANK=qtdemux:256,h264parse:NONE
Set rank of qtdemux plugin to 256 (primary) and 0 (none) for h264parse.
2019-08-15 11:56:40 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_feature_name (gchar * str, const gchar ** feature)
|
|
|
|
{
|
|
|
|
if (!str)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* works in place */
|
|
|
|
g_strstrip (str);
|
|
|
|
|
|
|
|
if (str[0] != '\0') {
|
|
|
|
*feature = str;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_feature_rank (gchar * str, GstRank * rank)
|
|
|
|
{
|
|
|
|
if (!str)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* works in place */
|
|
|
|
g_strstrip (str);
|
|
|
|
|
|
|
|
if (g_ascii_isdigit (str[0])) {
|
|
|
|
unsigned long l;
|
|
|
|
char *endptr;
|
|
|
|
l = strtoul (str, &endptr, 10);
|
|
|
|
if (endptr > str && endptr[0] == 0) {
|
|
|
|
*rank = (GstRank) l;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else if (g_ascii_strcasecmp (str, "NONE") == 0) {
|
|
|
|
*rank = GST_RANK_NONE;
|
|
|
|
} else if (g_ascii_strcasecmp (str, "MARGINAL") == 0) {
|
|
|
|
*rank = GST_RANK_MARGINAL;
|
|
|
|
} else if (g_ascii_strcasecmp (str, "SECONDARY") == 0) {
|
|
|
|
*rank = GST_RANK_SECONDARY;
|
|
|
|
} else if (g_ascii_strcasecmp (str, "PRIMARY") == 0) {
|
|
|
|
*rank = GST_RANK_PRIMARY;
|
|
|
|
} else if (g_ascii_strcasecmp (str, "MAX") == 0) {
|
|
|
|
*rank = (GstRank) G_MAXINT;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_priv_gst_plugin_feature_rank_initialize (void)
|
|
|
|
{
|
|
|
|
const gchar *env;
|
|
|
|
gchar **split;
|
|
|
|
gchar **walk;
|
|
|
|
|
|
|
|
env = g_getenv ("GST_PLUGIN_FEATURE_RANK");
|
|
|
|
|
|
|
|
if (!env)
|
|
|
|
return;
|
|
|
|
|
|
|
|
split = g_strsplit (env, ",", 0);
|
|
|
|
|
|
|
|
for (walk = split; *walk; walk++) {
|
|
|
|
if (strchr (*walk, ':')) {
|
|
|
|
gchar **values = g_strsplit (*walk, ":", 2);
|
|
|
|
|
|
|
|
if (values[0] && values[1]) {
|
|
|
|
GstRank rank;
|
|
|
|
const gchar *str;
|
|
|
|
|
|
|
|
if (parse_feature_name (values[0], &str)
|
|
|
|
&& parse_feature_rank (values[1], &rank)) {
|
|
|
|
GstPluginFeature *feature;
|
|
|
|
|
|
|
|
feature = gst_registry_find_feature (gst_registry_get (), str,
|
|
|
|
GST_TYPE_ELEMENT_FACTORY);
|
|
|
|
if (feature) {
|
|
|
|
gst_plugin_feature_set_rank (feature, rank);
|
|
|
|
GST_DEBUG ("Update rank of plugin feature \"%s\" to %d", str, rank);
|
2022-01-13 19:45:08 +00:00
|
|
|
gst_object_unref (feature);
|
pluginfeature: Allow updating initial rank of plugin feature
Introducing "GST_PLUGIN_FEATURE_RANK" environment variable in order for users
to adjust rank of plugin(s) via environment.
A "feature" and "rank" key-value pair should be separable by ":",
and each key-value pair is recognized per "," delimiters. The rank
can be a numerical value or one of pre-defined rank values
such as "NONE", "MARGINAL", "SECONDARY", and "PRIMARY" in case-insensitive manner.
In addition to pre-defined { NONE, MARGINAL, SECONDARY, PRIMARY },
"MAX" can be passed to key value used to ensure having a higher rank
than other plugin features.
Example)
- GST_PLUGIN_FEATURE_RANK=qtdemux:256,h264parse:NONE
Set rank of qtdemux plugin to 256 (primary) and 0 (none) for h264parse.
2019-08-15 11:56:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (values);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (split);
|
|
|
|
}
|