X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tools%2Fgst-inspect.c;h=3a59ef3c7c60c6148190cc1468e6d742eaeea02e;hb=ad537a2d51cae916bb2bc54d1da97721461c1925;hp=37684cff734b6fd3ec314c5ea95fe6099ce04009;hpb=66d19b65fb6eee8283a6c2ac742be251f66d631c;p=platform%2Fupstream%2Fgstreamer.git diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c index 37684cf..3a59ef3 100644 --- a/tools/gst-inspect.c +++ b/tools/gst-inspect.c @@ -17,14 +17,18 @@ * * 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. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif +/* FIXME 2.0: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include "tools.h" #include @@ -36,6 +40,9 @@ static char *_name = NULL; static int print_element_info (GstElementFactory * factory, gboolean print_names); +/* *INDENT-OFF* */ +G_GNUC_PRINTF (1, 2) +/* *INDENT-ON* */ static void n_print (const char *format, ...) { @@ -77,78 +84,22 @@ print_caps (const GstCaps * caps, const gchar * pfx) for (i = 0; i < gst_caps_get_size (caps); i++) { GstStructure *structure = gst_caps_get_structure (caps, i); + GstCapsFeatures *features = gst_caps_get_features (caps, i); - n_print ("%s%s\n", pfx, gst_structure_get_name (structure)); - gst_structure_foreach (structure, print_field, (gpointer) pfx); - } -} - -#if 0 -static void -print_formats (const GstFormat * formats) -{ - while (formats && *formats) { - const GstFormatDefinition *definition; - - definition = gst_format_get_details (*formats); - if (definition) - n_print ("\t\t(%d):\t%s (%s)\n", *formats, - definition->nick, definition->description); - else - n_print ("\t\t(%d):\tUnknown format\n", *formats); - - formats++; - } -} + if (features && (gst_caps_features_is_any (features) || + !gst_caps_features_is_equal (features, + GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))) { + gchar *features_string = gst_caps_features_to_string (features); -static void -print_event_masks (const GstEventMask * masks) -{ - GType event_type; - GEnumClass *klass; - GType event_flags; - GFlagsClass *flags_class = NULL; - - event_type = gst_event_type_get_type (); - klass = (GEnumClass *) g_type_class_ref (event_type); - - while (masks && masks->type) { - GEnumValue *value; - gint flags = 0, index = 0; - - switch (masks->type) { - case GST_EVENT_SEEK: - flags = masks->flags; - event_flags = gst_seek_type_get_type (); - flags_class = (GFlagsClass *) g_type_class_ref (event_flags); - break; - default: - break; - } - - value = g_enum_get_value (klass, masks->type); - g_print ("\t\t%s ", value->value_nick); - - while (flags) { - GFlagsValue *value; - - if (flags & 1) { - value = g_flags_get_first_value (flags_class, 1 << index); - - if (value) - g_print ("| %s ", value->value_nick); - else - g_print ("| ? "); - } - flags >>= 1; - index++; + n_print ("%s%s(%s)\n", pfx, gst_structure_get_name (structure), + features_string); + g_free (features_string); + } else { + n_print ("%s%s\n", pfx, gst_structure_get_name (structure)); } - g_print ("\n"); - - masks++; + gst_structure_foreach (structure, print_field, (gpointer) pfx); } } -#endif static const char * get_rank_name (char *s, gint rank) @@ -177,31 +128,29 @@ get_rank_name (char *s, gint rank) return s; } -static gboolean -print_factory_details_metadata (GQuark field_id, const GValue * value, - gpointer user_data) -{ - gchar *val = g_strdup_value_contents (value); - gchar *key = g_strdup (g_quark_to_string (field_id)); - - key[0] = g_ascii_toupper (key[0]); - n_print (" %s:\t\t%s\n", key, val); - g_free (val); - g_free (key); - return TRUE; -} - static void print_factory_details_info (GstElementFactory * factory) { + gchar **keys, **k; + GstRank rank; char s[20]; + rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)); n_print ("Factory Details:\n"); - n_print (" Rank:\t\t%s (%d)\n", - get_rank_name (s, GST_PLUGIN_FEATURE (factory)->rank), - GST_PLUGIN_FEATURE (factory)->rank); - gst_structure_foreach ((GstStructure *) factory->metadata, - print_factory_details_metadata, NULL); + n_print (" %-25s%s (%d)\n", "Rank", get_rank_name (s, rank), rank); + + keys = gst_element_factory_get_metadata_keys (factory); + if (keys != NULL) { + for (k = keys; *k != NULL; ++k) { + const gchar *val; + gchar *key = *k; + + val = gst_element_factory_get_metadata (factory, key); + key[0] = g_ascii_toupper (key[0]); + n_print (" %-25s%s\n", key, val); + } + g_strfreev (keys); + } n_print ("\n"); } @@ -296,9 +245,9 @@ flags_to_string (GFlagsValue * vals, guint flags) #define KNOWN_PARAM_FLAGS \ (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY | \ G_PARAM_LAX_VALIDATION | G_PARAM_STATIC_STRINGS | \ - G_PARAM_READABLE | G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE | \ - GST_PARAM_MUTABLE_PLAYING | GST_PARAM_MUTABLE_PAUSED | \ - GST_PARAM_MUTABLE_READY) + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_DEPRECATED | \ + GST_PARAM_CONTROLLABLE | GST_PARAM_MUTABLE_PLAYING | \ + GST_PARAM_MUTABLE_PAUSED | GST_PARAM_MUTABLE_READY) static void print_element_properties_info (GstElement * element) @@ -341,6 +290,10 @@ print_element_properties_info (GstElement * element) g_print ("%s%s", (first_flag) ? "" : ", ", _("writable")); first_flag = FALSE; } + if (param->flags & G_PARAM_DEPRECATED) { + g_print ("%s%s", (first_flag) ? "" : ", ", _("deprecated")); + first_flag = FALSE; + } if (param->flags & GST_PARAM_CONTROLLABLE) { g_print (", %s", _("controllable")); first_flag = FALSE; @@ -388,7 +341,7 @@ print_element_properties_info (GstElement * element) g_print ("Range: %lu - %lu Default: %lu ", pulong->minimum, pulong->maximum, g_value_get_ulong (&value)); - GST_ERROR ("%s: property '%s' of type char: consider changing to " + GST_ERROR ("%s: property '%s' of type ulong: consider changing to " "uint/uint64", GST_OBJECT_NAME (element), g_param_spec_get_name (param)); break; @@ -534,6 +487,12 @@ print_element_properties_info (GstElement * element) } else if (G_IS_PARAM_SPEC_BOXED (param)) { n_print ("%-23.23s Boxed pointer of type \"%s\"", "", g_type_name (param->value_type)); + if (param->value_type == GST_TYPE_STRUCTURE) { + const GstStructure *s = gst_value_get_structure (&value); + if (s) + gst_structure_foreach (s, print_field, + (gpointer) " "); + } } else if (G_IS_PARAM_SPEC_POINTER (param)) { if (param->value_type != G_TYPE_POINTER) { n_print ("%-23.23s Pointer of type \"%s\".", "", @@ -561,8 +520,8 @@ print_element_properties_info (GstElement * element) 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)); + n_print ("%-23.23s Unknown type %ld \"%s\"", "", + (glong) param->value_type, g_type_name (param->value_type)); } break; } @@ -582,19 +541,16 @@ print_element_properties_info (GstElement * element) static void print_pad_templates_info (GstElement * element, GstElementFactory * factory) { - GstElementClass *gstelement_class; const GList *pads; GstStaticPadTemplate *padtemplate; n_print ("Pad Templates:\n"); - if (!factory->numpadtemplates) { + if (gst_element_factory_get_num_pad_templates (factory) == 0) { n_print (" none\n"); return; } - gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element)); - - pads = factory->staticpadtemplates; + pads = gst_element_factory_get_static_pad_templates (factory); while (pads) { padtemplate = (GstStaticPadTemplate *) (pads->data); pads = g_list_next (pads); @@ -612,8 +568,6 @@ print_pad_templates_info (GstElement * element, GstElementFactory * factory) n_print (" Availability: Sometimes\n"); else if (padtemplate->presence == GST_PAD_REQUEST) { n_print (" Availability: On request\n"); - n_print (" Has request_new_pad() function: %s\n", - GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad)); } else n_print (" Availability: UNKNOWN!!!\n"); @@ -671,7 +625,7 @@ print_clocking_info (GstElement * element) if (!requires_clock && !provides_clock) { n_print ("\n"); - n_print ("Element has no clocking capabilities."); + n_print ("Element has no clocking capabilities.\n"); return; } @@ -694,19 +648,6 @@ print_clocking_info (GstElement * element) } static void -print_index_info (GstElement * 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"); - } else { - n_print ("\n"); - n_print ("Element has no indexing capabilities.\n"); - } -} - -static void print_uri_handler_info (GstElement * element) { if (GST_IS_URI_HANDLER (element)) { @@ -761,38 +702,16 @@ print_pad_info (GstElement * element) pad = GST_PAD (pads->data); pads = g_list_next (pads); - n_print (""); - name = gst_pad_get_name (pad); if (gst_pad_get_direction (pad) == GST_PAD_SRC) - g_print (" SRC: '%s'", name); + n_print (" SRC: '%s'\n", name); else if (gst_pad_get_direction (pad) == GST_PAD_SINK) - g_print (" SINK: '%s'", name); + n_print (" SINK: '%s'\n", name); else - g_print (" UNKNOWN!!!: '%s'", name); + n_print (" UNKNOWN!!!: '%s'\n", name); g_free (name); - g_print ("\n"); - - n_print (" Implementation:\n"); - if (pad->chainfunc) - n_print (" Has chainfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (pad->chainfunc)); - if (pad->getrangefunc) - n_print (" Has getrangefunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (pad->getrangefunc)); - if (pad->eventfunc != gst_pad_event_default) - n_print (" Has custom eventfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (pad->eventfunc)); - if (pad->queryfunc != gst_pad_query_default) - n_print (" Has custom queryfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (pad->queryfunc)); - - if (pad->iterintlinkfunc != gst_pad_iterate_internal_links_default) - n_print (" Has custom iterintlinkfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (pad->iterintlinkfunc)); - if (pad->padtemplate) n_print (" Pad Template: '%s'\n", pad->padtemplate->name_template); @@ -819,6 +738,19 @@ has_sometimes_template (GstElement * element) return FALSE; } +static gboolean +gtype_needs_ptr_marker (GType type) +{ + if (type == G_TYPE_POINTER) + return FALSE; + + if (G_TYPE_FUNDAMENTAL (type) == G_TYPE_POINTER || G_TYPE_IS_BOXED (type) + || G_TYPE_IS_OBJECT (type)) + return TRUE; + + return FALSE; +} + static void print_signal_info (GstElement * element) { @@ -882,38 +814,40 @@ print_signal_info (GstElement * element) for (l = found_signals; l; l = l->next) { gchar *indent; + const gchar *pmark; int indent_len; query = (GSignalQuery *) l->data; indent_len = strlen (query->signal_name) + strlen (g_type_name (query->return_type)) + 24; + if (gtype_needs_ptr_marker (query->return_type)) { + pmark = "* "; + indent_len += 2; + } else { + pmark = ""; + } + indent = g_new0 (gchar, indent_len + 1); memset (indent, ' ', indent_len); - n_print (" \"%s\" : %s user_function (%s* object", - query->signal_name, - g_type_name (query->return_type), g_type_name (type)); + n_print (" \"%s\" : %s %suser_function (%s* object", + query->signal_name, g_type_name (query->return_type), pmark, + g_type_name (type)); for (j = 0; j < query->n_params; j++) { - if (_name) - g_print ("%s", _name); - if (G_TYPE_IS_FUNDAMENTAL (query->param_types[j])) { - g_print (",\n%s%s arg%d", indent, - g_type_name (query->param_types[j]), j); - } else if (G_TYPE_IS_ENUM (query->param_types[j])) { - g_print (",\n%s%s arg%d", indent, - g_type_name (query->param_types[j]), j); - } else { - g_print (",\n%s%s* arg%d", indent, - g_type_name (query->param_types[j]), j); - } + const gchar *type_name, *asterisk; + + type_name = g_type_name (query->param_types[j]); + asterisk = gtype_needs_ptr_marker (query->param_types[j]) ? "*" : ""; + + g_print (",\n"); + n_print ("%s%s%s arg%d", indent, type_name, asterisk, j); } if (k == 0) { - if (_name) - g_print ("%s", _name); - g_print (",\n%sgpointer user_data);\n", indent); + g_print (",\n"); + n_print ("%sgpointer user_data);\n", indent); } else g_print (");\n"); @@ -938,7 +872,7 @@ print_children_info (GstElement * element) children = (GList *) GST_BIN (element)->children; if (children) { n_print ("\n"); - g_print ("Children:\n"); + n_print ("Children:\n"); } while (children) { @@ -948,6 +882,25 @@ print_children_info (GstElement * element) } static void +print_preset_list (GstElement * element) +{ + gchar **presets, **preset; + + if (!GST_IS_PRESET (element)) + return; + + presets = gst_preset_get_preset_names (GST_PRESET (element)); + if (presets && *presets) { + n_print ("\n"); + n_print ("Presets:\n"); + for (preset = presets; *preset; preset++) { + n_print (" \"%s\"\n", *preset); + } + g_strfreev (presets); + } +} + +static void print_blacklist (void) { GList *plugins, *cur; @@ -958,8 +911,8 @@ print_blacklist (void) 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) { - g_print (" %s\n", plugin->desc.name); + if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) { + g_print (" %s\n", gst_plugin_get_name (plugin)); count++; } } @@ -987,14 +940,14 @@ print_element_list (gboolean print_all) plugins = g_list_next (plugins); plugincount++; - if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) { + if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) { blacklistcount++; continue; } orig_features = features = gst_registry_get_feature_list_by_plugin (gst_registry_get (), - plugin->desc.name); + gst_plugin_get_name (plugin)); while (features) { GstPluginFeature *feature; @@ -1010,31 +963,26 @@ print_element_list (gboolean print_all) if (print_all) print_element_info (factory, TRUE); else - g_print ("%s: %s: %s\n", plugin->desc.name, + g_print ("%s: %s: %s\n", gst_plugin_get_name (plugin), GST_OBJECT_NAME (factory), - gst_element_factory_get_longname (factory)); -#if 0 - } else if (GST_IS_INDEX_FACTORY (feature)) { - GstIndexFactory *factory; - - factory = GST_INDEX_FACTORY (feature); - if (!print_all) - g_print ("%s: %s: %s\n", plugin->desc.name, - GST_OBJECT_NAME (factory), factory->longdesc); -#endif + gst_element_factory_get_metadata (factory, + GST_ELEMENT_METADATA_LONGNAME)); } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { GstTypeFindFactory *factory; + const gchar *const *extensions; factory = GST_TYPE_FIND_FACTORY (feature); if (!print_all) - g_print ("%s: %s: ", plugin->desc.name, + g_print ("%s: %s: ", gst_plugin_get_name (plugin), gst_plugin_feature_get_name (feature)); - if (factory->extensions) { + + extensions = gst_type_find_factory_get_extensions (factory); + if (extensions != NULL) { guint i = 0; - while (factory->extensions[i]) { + while (extensions[i]) { if (!print_all) - g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); + g_print ("%s%s", i > 0 ? ", " : "", extensions[i]); i++; } if (!print_all) @@ -1045,7 +993,7 @@ print_element_list (gboolean print_all) } } else { if (!print_all) - n_print ("%s: %s (%s)\n", plugin->desc.name, + n_print ("%s: %s (%s)\n", gst_plugin_get_name (plugin), GST_OBJECT_NAME (feature), g_type_name (G_OBJECT_TYPE (feature))); } @@ -1084,7 +1032,7 @@ print_all_uri_handlers (void) features = gst_registry_get_feature_list_by_plugin (gst_registry_get (), - plugin->desc.name); + gst_plugin_get_name (plugin)); for (f = features; f; f = f->next) { GstPluginFeature *feature = GST_PLUGIN_FEATURE (f->data); @@ -1095,7 +1043,8 @@ print_all_uri_handlers (void) factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature)); if (!factory) { - g_print ("element plugin %s couldn't be loaded\n", plugin->desc.name); + g_print ("element plugin %s couldn't be loaded\n", + gst_plugin_get_name (plugin)); continue; } @@ -1150,21 +1099,24 @@ print_all_uri_handlers (void) static void print_plugin_info (GstPlugin * plugin) { + const gchar *release_date = gst_plugin_get_release_date_string (plugin); + const gchar *filename = gst_plugin_get_filename (plugin); + n_print ("Plugin Details:\n"); - n_print (" Name:\t\t\t%s\n", plugin->desc.name); - n_print (" Description:\t\t%s\n", plugin->desc.description); - n_print (" Filename:\t\t%s\n", - plugin->filename ? plugin->filename : "(null)"); - n_print (" Version:\t\t%s\n", plugin->desc.version); - n_print (" License:\t\t%s\n", plugin->desc.license); - n_print (" Source module:\t%s\n", plugin->desc.source); - if (plugin->desc.release_datetime != NULL) { + n_print (" %-25s%s\n", "Name", gst_plugin_get_name (plugin)); + n_print (" %-25s%s\n", "Description", gst_plugin_get_description (plugin)); + n_print (" %-25s%s\n", "Filename", (filename != NULL) ? filename : "(null)"); + n_print (" %-25s%s\n", "Version", gst_plugin_get_version (plugin)); + n_print (" %-25s%s\n", "License", gst_plugin_get_license (plugin)); + n_print (" %-25s%s\n", "Source module", gst_plugin_get_source (plugin)); + + if (release_date != NULL) { const gchar *tz = "(UTC)"; gchar *str, *sep; /* may be: YYYY-MM-DD or YYYY-MM-DDTHH:MMZ */ /* YYYY-MM-DDTHH:MMZ => YYYY-MM-DD HH:MM (UTC) */ - str = g_strdup (plugin->desc.release_datetime); + str = g_strdup (release_date); sep = strstr (str, "T"); if (sep != NULL) { *sep = ' '; @@ -1174,11 +1126,11 @@ print_plugin_info (GstPlugin * plugin) } else { tz = ""; } - n_print (" Source release date:\t%s%s\n", str, tz); + n_print (" %-25s%s%s\n", "Source release date", str, tz); g_free (str); } - n_print (" Binary package:\t%s\n", plugin->desc.package); - n_print (" Origin URL:\t\t%s\n", plugin->desc.origin); + n_print (" %-25s%s\n", "Binary package", gst_plugin_get_package (plugin)); + n_print (" %-25s%s\n", "Origin URL", gst_plugin_get_origin (plugin)); n_print ("\n"); } @@ -1188,13 +1140,14 @@ print_plugin_features (GstPlugin * plugin) GList *features, *origlist; gint num_features = 0; gint num_elements = 0; + gint num_tracers = 0; gint num_typefinders = 0; - gint num_indexes = 0; + gint num_devproviders = 0; gint num_other = 0; origlist = features = gst_registry_get_feature_list_by_plugin (gst_registry_get (), - plugin->desc.name); + gst_plugin_get_name (plugin)); while (features) { GstPluginFeature *feature; @@ -1206,42 +1159,48 @@ print_plugin_features (GstPlugin * plugin) factory = GST_ELEMENT_FACTORY (feature); n_print (" %s: %s\n", GST_OBJECT_NAME (factory), - gst_element_factory_get_longname (factory)); + gst_element_factory_get_metadata (factory, + GST_ELEMENT_METADATA_LONGNAME)); 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; + const gchar *const *extensions; factory = GST_TYPE_FIND_FACTORY (feature); - if (factory->extensions) { + extensions = gst_type_find_factory_get_extensions (factory); + if (extensions) { guint i = 0; - g_print ("%s: %s: ", plugin->desc.name, + g_print (" %s: %s: ", gst_plugin_get_name (plugin), gst_plugin_feature_get_name (feature)); - while (factory->extensions[i]) { - g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); + while (extensions[i]) { + g_print ("%s%s", i > 0 ? ", " : "", extensions[i]); i++; } g_print ("\n"); } else - g_print ("%s: %s: no extensions\n", plugin->desc.name, + g_print (" %s: %s: no extensions\n", gst_plugin_get_name (plugin), gst_plugin_feature_get_name (feature)); num_typefinders++; + } else if (GST_IS_DEVICE_PROVIDER_FACTORY (feature)) { + GstDeviceProviderFactory *factory; + + factory = GST_DEVICE_PROVIDER_FACTORY (feature); + n_print (" %s: %s\n", GST_OBJECT_NAME (factory), + gst_device_provider_factory_get_metadata (factory, + GST_ELEMENT_METADATA_LONGNAME)); + num_devproviders++; + } else if (GST_IS_TRACER_FACTORY (feature)) { + n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)), + g_type_name (G_OBJECT_TYPE (feature))); + num_tracers++; } else if (feature) { n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)), g_type_name (G_OBJECT_TYPE (feature))); num_other++; } num_features++; - gst_object_unref (feature); features = g_list_next (features); } @@ -1253,8 +1212,10 @@ print_plugin_features (GstPlugin * plugin) n_print (" +-- %d elements\n", num_elements); if (num_typefinders > 0) n_print (" +-- %d typefinders\n", num_typefinders); - if (num_indexes > 0) - n_print (" +-- %d indexes\n", num_indexes); + if (num_devproviders > 0) + n_print (" +-- %d device providers\n", num_devproviders); + if (num_tracers > 0) + n_print (" +-- %d tracers\n", num_tracers); if (num_other > 0) n_print (" +-- %d other objects\n", num_other); @@ -1267,18 +1228,16 @@ 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); + feature = gst_registry_find_feature (gst_registry_get (), element_name, + GST_TYPE_TYPE_FIND_FACTORY); if (feature) { - n_print ("%s: an index\n", element_name); + n_print ("%s: a typefind function\n", element_name); return 0; } -#endif feature = gst_registry_find_feature (gst_registry_get (), element_name, - GST_TYPE_TYPE_FIND_FACTORY); + GST_TYPE_TRACER_FACTORY); if (feature) { - n_print ("%s: a typefind function\n", element_name); + n_print ("%s: a tracer module\n", element_name); return 0; } @@ -1289,6 +1248,7 @@ static int print_element_info (GstElementFactory * factory, gboolean print_names) { GstElement *element; + GstPlugin *plugin; gint maxlevel = 0; factory = @@ -1302,6 +1262,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; } @@ -1312,14 +1273,11 @@ print_element_info (GstElementFactory * factory, gboolean print_names) _name = NULL; print_factory_details_info (factory); - if (GST_PLUGIN_FEATURE (factory)->plugin_name) { - GstPlugin *plugin; - plugin = gst_registry_find_plugin (gst_registry_get (), - GST_PLUGIN_FEATURE (factory)->plugin_name); - if (plugin) { - print_plugin_info (plugin); - } + plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory)); + if (plugin) { + print_plugin_info (plugin); + gst_object_unref (plugin); } print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel); @@ -1329,12 +1287,12 @@ print_element_info (GstElementFactory * factory, gboolean print_names) print_element_flag_info (element); print_implementation_info (element); print_clocking_info (element); - print_index_info (element); print_uri_handler_info (element); print_pad_info (element); print_element_properties_info (element); print_signal_info (element); print_children_info (element); + print_preset_list (element); gst_object_unref (element); gst_object_unref (factory); @@ -1354,7 +1312,8 @@ print_plugin_automatic_install_info_codecs (GstElementFactory * factory) GstCaps *caps = NULL; guint i, num; - klass = gst_element_factory_get_klass (factory); + klass = + gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS); g_return_if_fail (klass != NULL); if (strstr (klass, "Demuxer") || @@ -1442,22 +1401,21 @@ print_plugin_automatic_install_info_protocols (GstElementFactory * factory) static void print_plugin_automatic_install_info (GstPlugin * plugin) { - const gchar *plugin_name; GList *features, *l; - plugin_name = gst_plugin_get_name (plugin); - /* not interested in typefind factories, only element factories */ features = gst_registry_get_feature_list (gst_registry_get (), GST_TYPE_ELEMENT_FACTORY); for (l = features; l != NULL; l = l->next) { GstPluginFeature *feature; + GstPlugin *feature_plugin; feature = GST_PLUGIN_FEATURE (l->data); /* only interested in the ones that are in the plugin we just loaded */ - if (g_str_equal (plugin_name, feature->plugin_name)) { + feature_plugin = gst_plugin_feature_get_plugin (feature); + if (feature_plugin == plugin) { GstElementFactory *factory; g_print ("element-%s\n", gst_plugin_feature_get_name (feature)); @@ -1466,6 +1424,8 @@ print_plugin_automatic_install_info (GstPlugin * plugin) print_plugin_automatic_install_info_protocols (factory); print_plugin_automatic_install_info_codecs (factory); } + if (feature_plugin) + gst_object_unref (feature_plugin); } g_list_foreach (features, (GFunc) gst_object_unref, NULL); @@ -1497,6 +1457,11 @@ main (int argc, char *argv[]) gboolean plugin_name = FALSE; gboolean print_aii = FALSE; gboolean uri_handlers = FALSE; + gboolean check_exists = FALSE; + gchar *min_version = NULL; + guint minver_maj = GST_VERSION_MAJOR; + guint minver_min = GST_VERSION_MINOR; + guint minver_micro = 0; #ifndef GST_DISABLE_OPTION_PARSING GOptionEntry options[] = { {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all, @@ -1510,6 +1475,12 @@ main (int argc, char *argv[]) "installation mechanisms"), NULL}, {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name, N_("List the plugin contents"), NULL}, + {"exists", '\0', 0, G_OPTION_ARG_NONE, &check_exists, + N_("Check if the specified element or plugin exists"), NULL}, + {"atleast-version", '\0', 0, G_OPTION_ARG_STRING, &min_version, + N_ + ("When checking if an element or plugin exists, also check that its " + "version is at least the version specified"), NULL}, {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers, N_ ("Print supported URI schemes, with the elements that implement them"), @@ -1521,41 +1492,84 @@ main (int argc, char *argv[]) GError *err = NULL; #endif + setlocale (LC_ALL, ""); + #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif -#if !GLIB_CHECK_VERSION (2, 31, 0) - g_thread_init (NULL); -#endif + /* avoid glib warnings when inspecting deprecated properties */ + g_setenv ("G_ENABLE_DIAGNOSTIC", "0", FALSE); - gst_tools_set_prgname ("gst-inspect"); + g_set_prgname ("gst-inspect-" GST_API_VERSION); #ifndef GST_DISABLE_OPTION_PARSING ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]"); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { - g_print ("Error initializing: %s\n", err->message); - exit (1); + g_printerr ("Error initializing: %s\n", err->message); + g_clear_error (&err); + g_option_context_free (ctx); + return -1; } g_option_context_free (ctx); #else gst_init (&argc, &argv); #endif - gst_tools_print_version ("gst-inspect"); + gst_tools_print_version (); if (print_all && argc > 1) { - g_print ("-a requires no extra arguments\n"); - return 1; + g_printerr ("-a requires no extra arguments\n"); + return -1; } if (uri_handlers && argc > 1) { - g_print ("-u requires no extra arguments\n"); - exit (1); + g_printerr ("-u requires no extra arguments\n"); + return -1; + } + + /* --atleast-version implies --exists */ + if (min_version != NULL) { + if (sscanf (min_version, "%u.%u.%u", &minver_maj, &minver_min, + &minver_micro) < 2) { + g_printerr ("Can't parse version '%s' passed to --atleast-version\n", + min_version); + return -1; + } + check_exists = TRUE; + } + + if (check_exists) { + int exit_code; + + if (argc == 1) { + g_printerr ("--exists requires an extra command line argument\n"); + exit_code = -1; + } else { + if (!plugin_name) { + GstPluginFeature *feature; + + feature = gst_registry_lookup_feature (gst_registry_get (), argv[1]); + if (feature != NULL && gst_plugin_feature_check_version (feature, + minver_maj, minver_min, minver_micro)) { + exit_code = 0; + } else { + exit_code = 1; + } + + if (feature) + gst_object_unref (feature); + } else { + /* FIXME: support checking for plugins too */ + g_printerr ("Checking for plugins is not supported yet\n"); + exit_code = -1; + } + } + return exit_code; } /* if no arguments, print out list of elements */ @@ -1617,12 +1631,12 @@ main (int argc, char *argv[]) print_plugin_features (plugin); } } else { - g_print (_("Could not load plugin file: %s\n"), error->message); - g_error_free (error); + g_printerr (_("Could not load plugin file: %s\n"), error->message); + g_clear_error (&error); return -1; } } else { - g_print (_("No such element or plugin '%s'\n"), arg); + g_printerr (_("No such element or plugin '%s'\n"), arg); return -1; } }