1 --- a/tools/gst-inspect.c 17 Nov 2008 15:48:14 -0000 1.144
2 +++ b/tools/gst-inspect.c 20 Jan 2009 16:11:05 -0000
3 @@ -1262,9 +1262,219 @@ print_element_info (GstElementFactory *
8 +print_gst_structure_append_field (GList *strings, const char *field)
12 + //g_message ("adding '%s' to the string", field);
14 + for (s = strings; s != NULL; s = s->next) {
15 + g_string_append (s->data, field);
20 +print_gst_structure_append_field_index (GList *strings, const char *field, guint num_items, guint offset)
25 + //g_message ("adding '%s' to the string (num: %d offset: %d)", field, num_items, offset);
27 + for (s = strings, i = 0; s != NULL; s = s->next, i++) {
29 + //g_message ("adding '%s' at '%d'", field, i);
30 + g_string_append (s->data, field);
39 +print_gst_structure_dup_fields (GList *strings, guint num_items)
46 + //g_message ("creating %d new items", num_items);
48 + new_items = g_list_length (strings) * (num_items - 1);
49 + for (i = 0; i < new_items; i++) {
52 + first = strings->data;
53 + s = g_string_new_len (first->str, first->len);
54 + strings = g_list_prepend (strings, s);
68 +field_get_type (const char *field_name)
70 + if (strstr (field_name, "version") != NULL)
71 + return FIELD_VERSION;
72 + if (strcmp (field_name, "layer") == 0)
74 + if (strcmp (field_name, "systemstream") == 0)
75 + return FIELD_SYSTEMSTREAM;
76 + if (strcmp (field_name, "variant") == 0)
77 + return FIELD_VARIANT;
83 +fields_type_compare (const char *a, const char *b)
85 + gint a_type, b_type;
87 + a_type = field_get_type (a);
88 + b_type = field_get_type (b);
89 + if (a_type < b_type)
91 + if (b_type < a_type)
97 +print_gst_structure_for_rpm (const char *type_name, GstStructure *s)
99 + guint i, num_fields;
101 + GList *fields, *l, *strings;
104 + name = gst_structure_get_name (s);
106 + num_fields = gst_structure_n_fields (s);
109 + for (i = 0; i < num_fields; i++) {
110 + const char *field_name;
112 + field_name = gst_structure_nth_field_name (s, i);
113 + if (field_get_type (field_name) < 0) {
114 + //g_message ("ignoring field named %s", field_name);
118 + fields = g_list_insert_sorted (fields, g_strdup (field_name), (GCompareFunc) fields_type_compare);
122 + * gstreamer0.10(decoder-video/mpeg)(mpegversion=1)()(64bit) */
123 + string = g_string_new ("gstreamer0.10");
124 + g_string_append_c (string, '(');
125 + g_string_append (string, type_name);
126 + g_string_append_c (string, '-');
127 + g_string_append (string, name);
128 + g_string_append_c (string, ')');
130 + strings = g_list_append (strings, string);
132 + for (l = fields; l != NULL; l = l->next) {
136 + field_name = l->data;
138 + type = gst_structure_get_field_type (s, field_name);
139 + //g_message ("field is: %s, type: %s", field_name, g_type_name (type));
141 + if (type == G_TYPE_INT) {
145 + gst_structure_get_int (s, field_name, &value);
146 + field = g_strdup_printf ("(%s=%d)", field_name, value);
147 + print_gst_structure_append_field (strings, field);
149 + } else if (type == G_TYPE_BOOLEAN) {
153 + gst_structure_get_boolean (s, field_name, &value);
154 + field = g_strdup_printf ("(%s=%s)", field_name, value ? "true" : "false");
155 + print_gst_structure_append_field (strings, field);
157 + } else if (type == GST_TYPE_INT_RANGE) {
158 + const GValue *value;
161 + value = gst_structure_get_value (s, field_name);
162 + min = gst_value_get_int_range_min (value);
163 + max = gst_value_get_int_range_max (value);
165 + strings = print_gst_structure_dup_fields (strings, max - min + 1);
167 + for (i = min; i <= max; i++) {
170 + field = g_strdup_printf ("(%s=%d)", field_name, i);
171 + print_gst_structure_append_field_index (strings, field, max - min + 1, i - min);
174 + } else if (type == GST_TYPE_LIST) {
175 + const GValue *value;
178 + value = gst_structure_get_value (s, field_name);
179 + num_items = gst_value_list_get_size (value);
181 + strings = print_gst_structure_dup_fields (strings, num_items);
183 + for (i = 0; i < num_items; i++) {
185 + const GValue *item_value;
187 + item_value = gst_value_list_get_value (value, i);
188 + field = g_strdup_printf ("(%s=%d)", field_name,
189 + g_value_get_int (item_value));
190 + print_gst_structure_append_field_index (strings, field, num_items, i);
193 + } else if (type == G_TYPE_STRING) {
197 + value = gst_structure_get_string (s, field_name);
198 + field = g_strdup_printf ("(%s=%s)", field_name, value);
199 + print_gst_structure_append_field (strings, field);
202 + g_warning ("unhandled type! %s", g_type_name (type));
205 + g_free (field_name);
208 + g_list_free (fields);
210 + for (l = strings; l != NULL; l = l->next) {
212 + g_print ("%s\n", string->str);
213 + g_string_free (string, TRUE);
215 + g_list_free (strings);
219 -print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
220 +print_plugin_automatic_install_info_codecs (GstElementFactory * factory, gboolean rpm_format)
222 GstPadDirection direction;
223 const gchar *type_name;
224 @@ -1325,15 +1535,19 @@ print_plugin_automatic_install_info_code
225 gst_structure_remove_field (s, "rate");
226 gst_structure_remove_field (s, "depth");
227 gst_structure_remove_field (s, "clock-rate");
228 - s_str = gst_structure_to_string (s);
229 - g_print ("%s-%s\n", type_name, s_str);
232 + s_str = gst_structure_to_string (s);
233 + g_print ("%s-%s\n", type_name, s_str);
236 + print_gst_structure_for_rpm (type_name, s);
239 gst_caps_unref (caps);
243 -print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
244 +print_plugin_automatic_install_info_protocols (GstElementFactory * factory, gboolean rpm_format)
246 gchar **protocols, **p;
248 @@ -1342,11 +1556,17 @@ print_plugin_automatic_install_info_prot
249 switch (gst_element_factory_get_uri_type (factory)) {
251 for (p = protocols; *p != NULL; ++p)
252 - g_print ("urisink-%s\n", *p);
254 + g_print ("urisink-%s\n", *p);
256 + g_print ("gstreamer0.10(urisink-%s)\n", *p);
259 for (p = protocols; *p != NULL; ++p)
260 - g_print ("urisource-%s\n", *p);
262 + g_print ("urisource-%s\n", *p);
264 + g_print ("gstreamer0.10(urisource-%s)\n", *p);
268 @@ -1356,7 +1576,7 @@ print_plugin_automatic_install_info_prot
272 -print_plugin_automatic_install_info (GstPlugin * plugin)
273 +print_plugin_automatic_install_info (GstPlugin * plugin, gboolean rpm_format)
275 const gchar *plugin_name;
277 @@ -1376,11 +1596,12 @@ print_plugin_automatic_install_info (Gst
278 if (g_str_equal (plugin_name, feature->plugin_name)) {
279 GstElementFactory *factory;
281 - g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
283 + g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
285 factory = GST_ELEMENT_FACTORY (feature);
286 - print_plugin_automatic_install_info_protocols (factory);
287 - print_plugin_automatic_install_info_codecs (factory);
288 + print_plugin_automatic_install_info_protocols (factory, rpm_format);
289 + print_plugin_automatic_install_info_codecs (factory, rpm_format);
293 @@ -1394,6 +1615,7 @@ main (int argc, char *argv[])
294 gboolean print_all = FALSE;
295 gboolean plugin_name = FALSE;
296 gboolean print_aii = FALSE;
297 + gboolean print_aii_rpm = FALSE;
298 gboolean uri_handlers = FALSE;
299 GOptionEntry options[] = {
300 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
301 @@ -1403,6 +1625,9 @@ main (int argc, char *argv[])
303 "Useful in connection with external automatic plugin "
304 "installation mechanisms"), NULL},
305 + {"rpm", '\0', 0, G_OPTION_ARG_NONE, &print_aii_rpm,
306 + N_("Print the machine-parsable list of features of a plugin in RPM "
307 + "Provides compatible-format"), NULL},
308 {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name,
309 N_("List the plugin contents"), NULL},
310 {"uri-handlers", 'u', 0, G_OPTION_ARG_NONE, &uri_handlers,
311 @@ -1478,7 +1703,7 @@ main (int argc, char *argv[])
312 /* if there is such a plugin, print out info */
315 - print_plugin_automatic_install_info (plugin);
316 + print_plugin_automatic_install_info (plugin, print_aii_rpm);
318 print_plugin_info (plugin);
319 print_plugin_features (plugin);
320 @@ -1491,13 +1716,16 @@ main (int argc, char *argv[])
324 - print_plugin_automatic_install_info (plugin);
325 + print_plugin_automatic_install_info (plugin, print_aii_rpm);
327 print_plugin_info (plugin);
328 print_plugin_features (plugin);
331 - g_print (_("Could not load plugin file: %s\n"), error->message);
332 + if (!print_aii_rpm)
333 + g_print (_("Could not load plugin file: %s\n"), error->message);
335 + g_printerr (_("Could not load plugin file: %s\n"), error->message);
336 g_error_free (error);