mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gst-inspect: simplify the code for printing feature info
Rename print_element_features() to print_feature_info() and move the code that handles the ElementFactory there. This simplifies the calling code and improves readability. Also don't leak the features for other factories.
This commit is contained in:
parent
4c8058272e
commit
2354c5b152
1 changed files with 18 additions and 20 deletions
|
@ -1269,21 +1269,31 @@ print_plugin_features (GstPlugin * plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
print_element_features (const gchar * element_name)
|
print_feature_info (const gchar * feature_name, gboolean print_all)
|
||||||
{
|
{
|
||||||
GstPluginFeature *feature;
|
GstPluginFeature *feature;
|
||||||
|
GstRegistry *registry = gst_registry_get ();
|
||||||
|
|
||||||
|
feature = gst_registry_find_feature (registry, feature_name,
|
||||||
|
GST_TYPE_ELEMENT_FACTORY);
|
||||||
|
if (feature) {
|
||||||
|
int ret = print_element_info (GST_ELEMENT_FACTORY (feature), print_all);
|
||||||
|
gst_object_unref (feature);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
/* FIXME implement other pretty print function for these */
|
/* FIXME implement other pretty print function for these */
|
||||||
feature = gst_registry_find_feature (gst_registry_get (), element_name,
|
feature = gst_registry_find_feature (registry, feature_name,
|
||||||
GST_TYPE_TYPE_FIND_FACTORY);
|
GST_TYPE_TYPE_FIND_FACTORY);
|
||||||
if (feature) {
|
if (feature) {
|
||||||
n_print ("%s: a typefind function\n", element_name);
|
n_print ("%s: a typefind function\n", feature_name);
|
||||||
|
gst_object_unref (feature);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
feature = gst_registry_find_feature (gst_registry_get (), element_name,
|
feature = gst_registry_find_feature (registry, feature_name,
|
||||||
GST_TYPE_TRACER_FACTORY);
|
GST_TYPE_TRACER_FACTORY);
|
||||||
if (feature) {
|
if (feature) {
|
||||||
n_print ("%s: a tracer module\n", element_name);
|
n_print ("%s: a tracer module\n", feature_name);
|
||||||
|
gst_object_unref (feature);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1636,28 +1646,16 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* else we try to get a factory */
|
/* else we try to get a factory */
|
||||||
GstElementFactory *factory;
|
|
||||||
GstPlugin *plugin;
|
|
||||||
const char *arg = argv[argc - 1];
|
const char *arg = argv[argc - 1];
|
||||||
int retval;
|
int retval = -1;
|
||||||
|
|
||||||
if (!plugin_name) {
|
if (!plugin_name) {
|
||||||
factory = gst_element_factory_find (arg);
|
retval = print_feature_info (arg, print_all);
|
||||||
|
|
||||||
/* if there's a factory, print out the info */
|
|
||||||
if (factory) {
|
|
||||||
retval = print_element_info (factory, print_all);
|
|
||||||
gst_object_unref (factory);
|
|
||||||
} else {
|
|
||||||
retval = print_element_features (arg);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
retval = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* otherwise check if it's a plugin */
|
/* otherwise check if it's a plugin */
|
||||||
if (retval) {
|
if (retval) {
|
||||||
plugin = gst_registry_find_plugin (gst_registry_get (), arg);
|
GstPlugin *plugin = gst_registry_find_plugin (gst_registry_get (), arg);
|
||||||
|
|
||||||
/* if there is such a plugin, print out info */
|
/* if there is such a plugin, print out info */
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
|
|
Loading…
Reference in a new issue