diff options
Diffstat (limited to 'tools/gst-inspect.c')
-rw-r--r-- | tools/gst-inspect.c | 234 |
1 files changed, 98 insertions, 136 deletions
diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c index bf947ed..fe5b98d 100644 --- a/tools/gst-inspect.c +++ b/tools/gst-inspect.c @@ -21,12 +21,14 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include <gst/controller/gstcontroller.h> - #include "tools.h" #include <string.h> @@ -102,27 +104,8 @@ print_formats (const GstFormat * formats) formats++; } } -#endif static void -print_query_types (const GstQueryType * types) -{ - while (types && *types) { - const GstQueryTypeDefinition *definition; - - definition = gst_query_type_get_details (*types); - if (definition) - n_print ("\t\t(%d):\t%s (%s)\n", *types, - definition->nick, definition->description); - else - n_print ("\t\t(%d):\tUnknown query format\n", *types); - - types++; - } -} - -#if 0 -static void print_event_masks (const GstEventMask * masks) { GType event_type; @@ -352,6 +335,11 @@ print_element_properties_info (GstElement * element) readable = TRUE; g_print ("%s%s", (first_flag) ? "" : ", ", _("readable")); first_flag = FALSE; + } else { + /* if we can't read the property value, assume it's set to the default + * (which might not be entirely true for sub-classes, but that's an + * unlikely corner-case anyway) */ + g_param_value_set_default (param, &value); } if (param->flags & G_PARAM_WRITABLE) { g_print ("%s%s", (first_flag) ? "" : ", ", _("writable")); @@ -377,34 +365,23 @@ print_element_properties_info (GstElement * element) switch (G_VALUE_TYPE (&value)) { case G_TYPE_STRING: { - GParamSpecString *pstring = G_PARAM_SPEC_STRING (param); + const char *string_val = g_value_get_string (&value); n_print ("%-23.23s String. ", ""); - if (pstring->default_value == NULL) - g_print ("Default: null "); + if (string_val == NULL) + g_print ("Default: null"); else - g_print ("Default: \"%s\" ", pstring->default_value); - - if (readable) { - const char *string_val = g_value_get_string (&value); - - if (string_val == NULL) - g_print ("Current: null"); - else - g_print ("Current: \"%s\"", string_val); - } + g_print ("Default: \"%s\"", string_val); break; } case G_TYPE_BOOLEAN: { - GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param); + gboolean bool_val = g_value_get_boolean (&value); n_print ("%-23.23s Boolean. ", ""); - g_print ("Default: %s ", (pboolean->default_value ? "true" : "false")); - if (readable) - g_print ("Current: %s", - (g_value_get_boolean (&value) ? "true" : "false")); + + g_print ("Default: %s", bool_val ? "true" : "false"); break; } case G_TYPE_ULONG: @@ -413,9 +390,11 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Unsigned Long. ", ""); g_print ("Range: %lu - %lu Default: %lu ", - pulong->minimum, pulong->maximum, pulong->default_value); - if (readable) - g_print ("Current: %lu", g_value_get_ulong (&value)); + pulong->minimum, pulong->maximum, g_value_get_ulong (&value)); + + GST_ERROR ("%s: property '%s' of type ulong: consider changing to " + "uint/uint64", GST_OBJECT_NAME (element), + g_param_spec_get_name (param)); break; } case G_TYPE_LONG: @@ -424,9 +403,11 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Long. ", ""); g_print ("Range: %ld - %ld Default: %ld ", - plong->minimum, plong->maximum, plong->default_value); - if (readable) - g_print ("Current: %ld", g_value_get_long (&value)); + plong->minimum, plong->maximum, g_value_get_long (&value)); + + GST_ERROR ("%s: property '%s' of type long: consider changing to " + "int/int64", GST_OBJECT_NAME (element), + g_param_spec_get_name (param)); break; } case G_TYPE_UINT: @@ -435,9 +416,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Unsigned Integer. ", ""); g_print ("Range: %u - %u Default: %u ", - puint->minimum, puint->maximum, puint->default_value); - if (readable) - g_print ("Current: %u", g_value_get_uint (&value)); + puint->minimum, puint->maximum, g_value_get_uint (&value)); break; } case G_TYPE_INT: @@ -446,9 +425,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Integer. ", ""); g_print ("Range: %d - %d Default: %d ", - pint->minimum, pint->maximum, pint->default_value); - if (readable) - g_print ("Current: %d", g_value_get_int (&value)); + pint->minimum, pint->maximum, g_value_get_int (&value)); break; } case G_TYPE_UINT64: @@ -458,9 +435,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Unsigned Integer64. ", ""); g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT " Default: %" G_GUINT64_FORMAT " ", - puint64->minimum, puint64->maximum, puint64->default_value); - if (readable) - g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value)); + puint64->minimum, puint64->maximum, g_value_get_uint64 (&value)); break; } case G_TYPE_INT64: @@ -470,9 +445,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Integer64. ", ""); g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT " Default: %" G_GINT64_FORMAT " ", - pint64->minimum, pint64->maximum, pint64->default_value); - if (readable) - g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value)); + pint64->minimum, pint64->maximum, g_value_get_int64 (&value)); break; } case G_TYPE_FLOAT: @@ -481,9 +454,7 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Float. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", - pfloat->minimum, pfloat->maximum, pfloat->default_value); - if (readable) - g_print ("Current: %15.7g", g_value_get_float (&value)); + pfloat->minimum, pfloat->maximum, g_value_get_float (&value)); break; } case G_TYPE_DOUBLE: @@ -492,11 +463,15 @@ print_element_properties_info (GstElement * element) n_print ("%-23.23s Double. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", - pdouble->minimum, pdouble->maximum, pdouble->default_value); - if (readable) - g_print ("Current: %15.7g", g_value_get_double (&value)); + pdouble->minimum, pdouble->maximum, g_value_get_double (&value)); break; } + case G_TYPE_CHAR: + case G_TYPE_UCHAR: + GST_ERROR ("%s: property '%s' of type char: consider changing to " + "int/string", GST_OBJECT_NAME (element), + g_param_spec_get_name (param)); + /* fall through */ default: if (param->value_type == GST_TYPE_CAPS) { const GstCaps *caps = gst_value_get_caps (&value); @@ -507,27 +482,22 @@ print_element_properties_info (GstElement * element) print_caps (caps, " "); } } else if (G_IS_PARAM_SPEC_ENUM (param)) { - GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param); GEnumValue *values; guint j = 0; gint enum_value; - const gchar *def_val_nick = "", *cur_val_nick = ""; + const gchar *value_nick = ""; values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; enum_value = g_value_get_enum (&value); while (values[j].value_name) { if (values[j].value == enum_value) - cur_val_nick = values[j].value_nick; - if (values[j].value == penum->default_value) - def_val_nick = values[j].value_nick; + value_nick = values[j].value_nick; j++; } - n_print - ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"", - "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value, - def_val_nick, enum_value, cur_val_nick); + n_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\"", "", + g_type_name (G_VALUE_TYPE (&value)), enum_value, value_nick); j = 0; while (values[j].value_name) { @@ -542,17 +512,15 @@ print_element_properties_info (GstElement * element) } else if (G_IS_PARAM_SPEC_FLAGS (param)) { GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param); GFlagsValue *vals; - gchar *cur, *def; + gchar *cur; vals = pflags->flags_class->values; cur = flags_to_string (vals, g_value_get_flags (&value)); - def = flags_to_string (vals, pflags->default_value); - n_print - ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"", - "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value, - def, g_value_get_flags (&value), cur); + n_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "", + g_type_name (G_VALUE_TYPE (&value)), + g_value_get_flags (&value), cur); while (vals[0].value_name) { g_print ("\n"); @@ -564,7 +532,6 @@ print_element_properties_info (GstElement * element) } g_free (cur); - g_free (def); } else if (G_IS_PARAM_SPEC_OBJECT (param)) { n_print ("%-23.23s Object of type \"%s\"", "", g_type_name (param->value_type)); @@ -595,12 +562,8 @@ print_element_properties_info (GstElement * element) g_print ("Range: %d/%d - %d/%d Default: %d/%d ", pfraction->min_num, pfraction->min_den, pfraction->max_num, pfraction->max_den, - pfraction->def_num, pfraction->def_den); - if (readable) - g_print ("Current: %d/%d", - gst_value_get_fraction_numerator (&value), - gst_value_get_fraction_denominator (&value)); - + gst_value_get_fraction_numerator (&value), + gst_value_get_fraction_denominator (&value)); } else { n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type, g_type_name (param->value_type)); @@ -703,9 +666,14 @@ print_implementation_info (GstElement * element) static void print_clocking_info (GstElement * element) { - if (!gst_element_requires_clock (element) && - !(gst_element_provides_clock (element) && - gst_element_get_clock (element))) { + gboolean requires_clock, provides_clock; + + requires_clock = + GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_REQUIRE_CLOCK); + provides_clock = + GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_PROVIDE_CLOCK); + + if (!requires_clock && !provides_clock) { n_print ("\n"); n_print ("Element has no clocking capabilities."); return; @@ -713,17 +681,18 @@ print_clocking_info (GstElement * element) n_print ("\n"); n_print ("Clocking Interaction:\n"); - if (gst_element_requires_clock (element)) { + if (requires_clock) { n_print (" element requires a clock\n"); } - if (gst_element_provides_clock (element)) { + if (provides_clock) { GstClock *clock; clock = gst_element_get_clock (element); - if (clock) + if (clock) { n_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock)); - else + gst_object_unref (clock); + } else n_print (" element is supposed to provide a clock but returned NULL\n"); } } @@ -731,7 +700,7 @@ print_clocking_info (GstElement * element) static void print_index_info (GstElement * element) { - if (gst_element_is_indexable (element)) { + if (GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_INDEXABLE)) { n_print ("\n"); n_print ("Indexing capabilities:\n"); n_print (" element can do indexing\n"); @@ -745,8 +714,8 @@ static void print_uri_handler_info (GstElement * element) { if (GST_IS_URI_HANDLER (element)) { + const gchar *const *uri_protocols; const gchar *uri_type; - gchar **uri_protocols; if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) == GST_URI_SRC) uri_type = "source"; @@ -823,30 +792,11 @@ print_pad_info (GstElement * element) if (pad->queryfunc != gst_pad_query_default) n_print (" Has custom queryfunc(): %s\n", GST_DEBUG_FUNCPTR_NAME (pad->queryfunc)); - if (pad->querytypefunc != gst_pad_get_query_types_default) { - const GstQueryType *query_types = gst_pad_get_query_types (pad); - if (query_types) { - n_print (" Provides query types:\n"); - print_query_types (query_types); - } - } if (pad->iterintlinkfunc != gst_pad_iterate_internal_links_default) n_print (" Has custom iterintlinkfunc(): %s\n", GST_DEBUG_FUNCPTR_NAME (pad->iterintlinkfunc)); - if (pad->getcapsfunc) - n_print (" Has getcapsfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (pad->getcapsfunc)); - /* gst_pad_acceptcaps_default is static :/ */ - if (pad->acceptcapsfunc) - n_print (" Has acceptcapsfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (pad->acceptcapsfunc)); - if (pad->fixatecapsfunc) - n_print (" Has fixatecapsfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (pad->fixatecapsfunc)); - - if (pad->padtemplate) n_print (" Pad Template: '%s'\n", pad->padtemplate->name_template); @@ -1009,7 +959,7 @@ print_blacklist (void) g_print ("%s\n", _("Blacklisted files:")); - plugins = gst_default_registry_get_plugin_list (); + plugins = gst_registry_get_plugin_list (gst_registry_get ()); for (cur = plugins; cur != NULL; cur = g_list_next (cur)) { GstPlugin *plugin = (GstPlugin *) (cur->data); if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) { @@ -1032,7 +982,7 @@ print_element_list (gboolean print_all) int plugincount = 0, featurecount = 0, blacklistcount = 0; GList *plugins, *orig_plugins; - orig_plugins = plugins = gst_default_registry_get_plugin_list (); + orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ()); while (plugins) { GList *features, *orig_features; GstPlugin *plugin; @@ -1047,7 +997,7 @@ print_element_list (gboolean print_all) } orig_features = features = - gst_registry_get_feature_list_by_plugin (gst_registry_get_default (), + gst_registry_get_feature_list_by_plugin (gst_registry_get (), plugin->desc.name); while (features) { GstPluginFeature *feature; @@ -1067,6 +1017,7 @@ print_element_list (gboolean print_all) g_print ("%s: %s: %s\n", plugin->desc.name, GST_OBJECT_NAME (factory), gst_element_factory_get_longname (factory)); +#if 0 } else if (GST_IS_INDEX_FACTORY (feature)) { GstIndexFactory *factory; @@ -1074,6 +1025,7 @@ print_element_list (gboolean print_all) if (!print_all) g_print ("%s: %s: %s\n", plugin->desc.name, GST_OBJECT_NAME (factory), factory->longdesc); +#endif } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { GstTypeFindFactory *factory; @@ -1129,13 +1081,13 @@ print_all_uri_handlers (void) { GList *plugins, *p, *features, *f; - plugins = gst_default_registry_get_plugin_list (); + plugins = gst_registry_get_plugin_list (gst_registry_get ()); for (p = plugins; p; p = p->next) { GstPlugin *plugin = (GstPlugin *) (p->data); features = - gst_registry_get_feature_list_by_plugin (gst_registry_get_default (), + gst_registry_get_feature_list_by_plugin (gst_registry_get (), plugin->desc.name); for (f = features; f; f = f->next) { @@ -1160,8 +1112,9 @@ print_all_uri_handlers (void) } if (GST_IS_URI_HANDLER (element)) { + const gchar *const *uri_protocols; const gchar *dir; - gchar **uri_protocols, *joined; + gchar *joined; switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) { case GST_URI_SRC: @@ -1177,7 +1130,7 @@ print_all_uri_handlers (void) uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element)); - joined = g_strjoinv (", ", uri_protocols); + joined = g_strjoinv (", ", (gchar **) uri_protocols); g_print ("%s (%s, rank %u): %s\n", gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), dir, @@ -1236,15 +1189,15 @@ print_plugin_info (GstPlugin * plugin) static void print_plugin_features (GstPlugin * plugin) { - GList *features; + GList *features, *origlist; gint num_features = 0; gint num_elements = 0; gint num_typefinders = 0; gint num_indexes = 0; gint num_other = 0; - features = - gst_registry_get_feature_list_by_plugin (gst_registry_get_default (), + origlist = features = + gst_registry_get_feature_list_by_plugin (gst_registry_get (), plugin->desc.name); while (features) { @@ -1259,12 +1212,14 @@ print_plugin_features (GstPlugin * plugin) n_print (" %s: %s\n", GST_OBJECT_NAME (factory), gst_element_factory_get_longname (factory)); num_elements++; +#if 0 } else if (GST_IS_INDEX_FACTORY (feature)) { GstIndexFactory *factory; factory = GST_INDEX_FACTORY (feature); n_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc); num_indexes++; +#endif } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { GstTypeFindFactory *factory; @@ -1292,6 +1247,9 @@ print_plugin_features (GstPlugin * plugin) num_features++; features = g_list_next (features); } + + gst_plugin_feature_list_free (origlist); + n_print ("\n"); n_print (" %d features:\n", num_features); if (num_elements > 0) @@ -1312,13 +1270,15 @@ print_element_features (const gchar * element_name) GstPluginFeature *feature; /* FIXME implement other pretty print function for these */ +#if 0 feature = gst_default_registry_find_feature (element_name, GST_TYPE_INDEX_FACTORY); if (feature) { n_print ("%s: an index\n", element_name); return 0; } - feature = gst_default_registry_find_feature (element_name, +#endif + feature = gst_registry_find_feature (gst_registry_get (), element_name, GST_TYPE_TYPE_FIND_FACTORY); if (feature) { n_print ("%s: a typefind function\n", element_name); @@ -1345,6 +1305,7 @@ print_element_info (GstElementFactory * factory, gboolean print_names) element = gst_element_factory_create (factory, NULL); if (!element) { + gst_object_unref (factory); g_print ("couldn't construct element for some reason\n"); return -1; } @@ -1358,7 +1319,7 @@ print_element_info (GstElementFactory * factory, gboolean print_names) if (GST_PLUGIN_FEATURE (factory)->plugin_name) { GstPlugin *plugin; - plugin = gst_registry_find_plugin (gst_registry_get_default (), + plugin = gst_registry_find_plugin (gst_registry_get (), GST_PLUGIN_FEATURE (factory)->plugin_name); if (plugin) { print_plugin_info (plugin); @@ -1459,23 +1420,26 @@ print_plugin_automatic_install_info_codecs (GstElementFactory * factory) static void print_plugin_automatic_install_info_protocols (GstElementFactory * factory) { - gchar **protocols, **p; + const gchar *const *protocols; protocols = gst_element_factory_get_uri_protocols (factory); if (protocols != NULL && *protocols != NULL) { switch (gst_element_factory_get_uri_type (factory)) { case GST_URI_SINK: - for (p = protocols; *p != NULL; ++p) - g_print ("urisink-%s\n", *p); + while (*protocols != NULL) { + g_print ("urisink-%s\n", *protocols); + ++protocols; + } break; case GST_URI_SRC: - for (p = protocols; *p != NULL; ++p) - g_print ("urisource-%s\n", *p); + while (*protocols != NULL) { + g_print ("urisource-%s\n", *protocols); + ++protocols; + } break; default: break; } - g_strfreev (protocols); } } @@ -1488,7 +1452,7 @@ print_plugin_automatic_install_info (GstPlugin * plugin) plugin_name = gst_plugin_get_name (plugin); /* not interested in typefind factories, only element factories */ - features = gst_registry_get_feature_list (gst_registry_get_default (), + features = gst_registry_get_feature_list (gst_registry_get (), GST_TYPE_ELEMENT_FACTORY); for (l = features; l != NULL; l = l->next) { @@ -1517,7 +1481,7 @@ print_all_plugin_automatic_install_info (void) { GList *plugins, *orig_plugins; - orig_plugins = plugins = gst_default_registry_get_plugin_list (); + orig_plugins = plugins = gst_registry_get_plugin_list (gst_registry_get ()); while (plugins) { GstPlugin *plugin; @@ -1567,8 +1531,6 @@ main (int argc, char *argv[]) textdomain (GETTEXT_PACKAGE); #endif - g_thread_init (NULL); - gst_tools_set_prgname ("gst-inspect"); #ifndef GST_DISABLE_OPTION_PARSING @@ -1631,7 +1593,7 @@ main (int argc, char *argv[]) /* otherwise check if it's a plugin */ if (retval) { - plugin = gst_default_registry_find_plugin (arg); + plugin = gst_registry_find_plugin (gst_registry_get (), arg); /* if there is such a plugin, print out info */ if (plugin) { |