1 diff -u -p -r1.142 tools/gst-inspect.c
2 --- tools/gst-inspect.c 31 Jul 2008 15:20:31 -0000 1.142
3 +++ tools/gst-inspect.c 11 Sep 2008 23:47:16 -0000
4 @@ -1188,9 +1188,219 @@ print_element_info (GstElementFactory *
9 +print_gst_structure_append_field (GList *strings, const char *field)
13 + //g_message ("adding '%s' to the string", field);
15 + for (s = strings; s != NULL; s = s->next) {
16 + g_string_append (s->data, field);
21 +print_gst_structure_append_field_index (GList *strings, const char *field, guint num_items, guint offset)
26 + //g_message ("adding '%s' to the string (num: %d offset: %d)", field, num_items, offset);
28 + for (s = strings, i = 0; s != NULL; s = s->next, i++) {
30 + //g_message ("adding '%s' at '%d'", field, i);
31 + g_string_append (s->data, field);
40 +print_gst_structure_dup_fields (GList *strings, guint num_items)
47 + //g_message ("creating %d new items", num_items);
49 + new_items = g_list_length (strings) * (num_items - 1);
50 + for (i = 0; i < new_items; i++) {
53 + first = strings->data;
54 + s = g_string_new_len (first->str, first->len);
55 + strings = g_list_prepend (strings, s);
69 +field_get_type (const char *field_name)
71 + if (strstr (field_name, "version") != NULL)
72 + return FIELD_VERSION;
73 + if (strcmp (field_name, "layer") == 0)
75 + if (strcmp (field_name, "systemstream") == 0)
76 + return FIELD_SYSTEMSTREAM;
77 + if (strcmp (field_name, "variant") == 0)
78 + return FIELD_VARIANT;
84 +fields_type_compare (const char *a, const char *b)
86 + gint a_type, b_type;
88 + a_type = field_get_type (a);
89 + b_type = field_get_type (b);
90 + if (a_type < b_type)
92 + if (b_type < a_type)
98 +print_gst_structure_for_rpm (const char *type_name, GstStructure *s)
100 + guint i, num_fields;
102 + GList *fields, *l, *strings;
105 + name = gst_structure_get_name (s);
107 + num_fields = gst_structure_n_fields (s);
110 + for (i = 0; i < num_fields; i++) {
111 + const char *field_name;
113 + field_name = gst_structure_nth_field_name (s, i);
114 + if (field_get_type (field_name) < 0) {
115 + //g_message ("ignoring field named %s", field_name);
119 + fields = g_list_insert_sorted (fields, g_strdup (field_name), (GCompareFunc) fields_type_compare);
123 + * gstreamer0.10(decoder-video/mpeg)(mpegversion=1)()(64bit) */
124 + string = g_string_new ("gstreamer0.10");
125 + g_string_append_c (string, '(');
126 + g_string_append (string, type_name);
127 + g_string_append_c (string, '-');
128 + g_string_append (string, name);
129 + g_string_append_c (string, ')');
131 + strings = g_list_append (strings, string);
133 + for (l = fields; l != NULL; l = l->next) {
137 + field_name = l->data;
139 + type = gst_structure_get_field_type (s, field_name);
140 + //g_message ("field is: %s, type: %s", field_name, g_type_name (type));
142 + if (type == G_TYPE_INT) {
146 + gst_structure_get_int (s, field_name, &value);
147 + field = g_strdup_printf ("(%s=%d)", field_name, value);
148 + print_gst_structure_append_field (strings, field);
150 + } else if (type == G_TYPE_BOOLEAN) {
154 + gst_structure_get_boolean (s, field_name, &value);
155 + field = g_strdup_printf ("(%s=%s)", field_name, value ? "true" : "false");
156 + print_gst_structure_append_field (strings, field);
158 + } else if (type == GST_TYPE_INT_RANGE) {
159 + const GValue *value;
162 + value = gst_structure_get_value (s, field_name);
163 + min = gst_value_get_int_range_min (value);
164 + max = gst_value_get_int_range_max (value);
166 + strings = print_gst_structure_dup_fields (strings, max - min + 1);
168 + for (i = min; i <= max; i++) {
171 + field = g_strdup_printf ("(%s=%d)", field_name, i);
172 + print_gst_structure_append_field_index (strings, field, max - min + 1, i - min);
175 + } else if (type == GST_TYPE_LIST) {
176 + const GValue *value;
179 + value = gst_structure_get_value (s, field_name);
180 + num_items = gst_value_list_get_size (value);
182 + strings = print_gst_structure_dup_fields (strings, num_items);
184 + for (i = 0; i < num_items; i++) {
186 + const GValue *item_value;
188 + item_value = gst_value_list_get_value (value, i);
189 + field = g_strdup_printf ("(%s=%d)", field_name,
190 + g_value_get_int (item_value));
191 + print_gst_structure_append_field_index (strings, field, num_items, i);
194 + } else if (type == G_TYPE_STRING) {
198 + value = gst_structure_get_string (s, field_name);
199 + field = g_strdup_printf ("(%s=%s)", field_name, value);
200 + print_gst_structure_append_field (strings, field);
203 + g_warning ("unhandled type! %s", g_type_name (type));
206 + g_free (field_name);
209 + g_list_free (fields);
211 + for (l = strings; l != NULL; l = l->next) {
213 + g_print ("%s\n", string->str);
214 + g_string_free (string, TRUE);
216 + g_list_free (strings);
220 -print_plugin_automatic_install_info_codecs (GstElementFactory * factory)
221 +print_plugin_automatic_install_info_codecs (GstElementFactory * factory, gboolean rpm_format)
223 GstPadDirection direction;
224 const gchar *type_name;
225 @@ -1251,15 +1461,19 @@ print_plugin_automatic_install_info_code
226 gst_structure_remove_field (s, "rate");
227 gst_structure_remove_field (s, "depth");
228 gst_structure_remove_field (s, "clock-rate");
229 - s_str = gst_structure_to_string (s);
230 - g_print ("%s-%s\n", type_name, s_str);
233 + s_str = gst_structure_to_string (s);
234 + g_print ("%s-%s\n", type_name, s_str);
237 + print_gst_structure_for_rpm (type_name, s);
240 gst_caps_unref (caps);
244 -print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
245 +print_plugin_automatic_install_info_protocols (GstElementFactory * factory, gboolean rpm_format)
247 gchar **protocols, **p;
249 @@ -1268,11 +1482,17 @@ print_plugin_automatic_install_info_prot
250 switch (gst_element_factory_get_uri_type (factory)) {
252 for (p = protocols; *p != NULL; ++p)
253 - g_print ("urisink-%s\n", *p);
255 + g_print ("urisink-%s\n", *p);
257 + g_print ("gstreamer0.10(urisink-%s)\n", *p);
260 for (p = protocols; *p != NULL; ++p)
261 - g_print ("urisource-%s\n", *p);
263 + g_print ("urisource-%s\n", *p);
265 + g_print ("gstreamer0.10(urisource-%s)\n", *p);
269 @@ -1282,7 +1502,7 @@ print_plugin_automatic_install_info_prot
273 -print_plugin_automatic_install_info (GstPlugin * plugin)
274 +print_plugin_automatic_install_info (GstPlugin * plugin, gboolean rpm_format)
276 const gchar *plugin_name;
278 @@ -1302,11 +1522,12 @@ print_plugin_automatic_install_info (Gst
279 if (g_str_equal (plugin_name, feature->plugin_name)) {
280 GstElementFactory *factory;
282 - g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
284 + g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
286 factory = GST_ELEMENT_FACTORY (feature);
287 - print_plugin_automatic_install_info_protocols (factory);
288 - print_plugin_automatic_install_info_codecs (factory);
289 + print_plugin_automatic_install_info_protocols (factory, rpm_format);
290 + print_plugin_automatic_install_info_codecs (factory, rpm_format);
294 @@ -1319,6 +1540,7 @@ main (int argc, char *argv[])
296 gboolean print_all = FALSE;
297 gboolean print_aii = FALSE;
298 + gboolean print_aii_rpm = FALSE;
299 GOptionEntry options[] = {
300 {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
301 N_("Print all elements"), NULL},
302 @@ -1327,6 +1549,9 @@ main (int argc, char *argv[])
304 "Useful in connection with external automatic plugin "
305 "installation mechanisms"), NULL},
306 + {"rpm", '\0', 0, G_OPTION_ARG_NONE, &print_aii_rpm,
307 + N_("Print the machine-parsable list of features of a plugin in RPM "
308 + "Provides compatible-format"), NULL},
309 GST_TOOLS_GOPTION_VERSION,
312 @@ -1384,7 +1609,7 @@ main (int argc, char *argv[])
313 /* if there is such a plugin, print out info */
316 - print_plugin_automatic_install_info (plugin);
317 + print_plugin_automatic_install_info (plugin, print_aii_rpm);
319 print_plugin_info (plugin);
320 print_plugin_features (plugin);
321 @@ -1397,13 +1622,16 @@ main (int argc, char *argv[])
325 - print_plugin_automatic_install_info (plugin);
326 + print_plugin_automatic_install_info (plugin, print_aii_rpm);
328 print_plugin_info (plugin);
329 print_plugin_features (plugin);
332 - g_print (_("Could not load plugin file: %s\n"), error->message);
333 + if (!print_aii_rpm)
334 + g_print (_("Could not load plugin file: %s\n"), error->message);
336 + g_printerr (_("Could not load plugin file: %s\n"), error->message);
337 g_error_free (error);