]>
Commit | Line | Data |
---|---|---|
205d484a BS |
1 | --- gstreamer-1.16.0/tools/gst-inspect.c.orig 2019-04-12 00:58:09.000000000 +0200 |
2 | +++ gstreamer-1.16.0/tools/gst-inspect.c 2019-05-20 09:39:11.295876148 +0200 | |
3 | @@ -1726,11 +1726,228 @@ print_tracer_info (GstPluginFeature * fe | |
5ab189e4 PZ |
4 | return 0; |
5 | } | |
6 | ||
7 | +static void | |
92400a1b | 8 | +print_gst_structure_append_field (GList * strings, const char *field) |
5ab189e4 | 9 | +{ |
92400a1b | 10 | + GList *s; |
5ab189e4 | 11 | + |
92400a1b | 12 | + //g_message ("adding '%s' to the string", field); |
5ab189e4 | 13 | + |
92400a1b MB |
14 | + for (s = strings; s != NULL; s = s->next) { |
15 | + g_string_append (s->data, field); | |
16 | + } | |
5ab189e4 | 17 | +} |
555f3e2e MB |
18 | + |
19 | +static void | |
92400a1b MB |
20 | +print_gst_structure_append_field_index (GList * strings, const char *field, |
21 | + guint num_items, guint offset) | |
5ab189e4 | 22 | +{ |
92400a1b MB |
23 | + GList *s; |
24 | + guint i; | |
5ab189e4 | 25 | + |
92400a1b | 26 | + //g_message ("adding '%s' to the string (num: %d offset: %d)", field, num_items, offset); |
5ab189e4 | 27 | + |
92400a1b MB |
28 | + for (s = strings, i = 0; s != NULL; s = s->next, i++) { |
29 | + if (i == offset) { | |
30 | + //g_message ("adding '%s' at '%d'", field, i); | |
31 | + g_string_append (s->data, field); | |
32 | + } | |
33 | + if (i == num_items) | |
34 | + i = 0; | |
35 | + } | |
5ab189e4 PZ |
36 | + |
37 | +} | |
38 | + | |
39 | +static GList * | |
92400a1b | 40 | +print_gst_structure_dup_fields (GList * strings, guint num_items) |
5ab189e4 | 41 | +{ |
92400a1b | 42 | + guint new_items, i; |
5ab189e4 | 43 | + |
92400a1b MB |
44 | + if (num_items == 1) |
45 | + return strings; | |
5ab189e4 | 46 | + |
92400a1b | 47 | + //g_message ("creating %d new items", num_items); |
5ab189e4 | 48 | + |
92400a1b MB |
49 | + new_items = g_list_length (strings) * (num_items - 1); |
50 | + for (i = 0; i < new_items; i++) { | |
51 | + GString *s, *first; | |
5ab189e4 | 52 | + |
92400a1b MB |
53 | + first = strings->data; |
54 | + s = g_string_new_len (first->str, first->len); | |
55 | + strings = g_list_prepend (strings, s); | |
56 | + } | |
5ab189e4 | 57 | + |
92400a1b | 58 | + return strings; |
5ab189e4 PZ |
59 | +} |
60 | + | |
92400a1b MB |
61 | +enum |
62 | +{ | |
63 | + FIELD_VERSION = 0, | |
64 | + FIELD_LAYER, | |
65 | + FIELD_VARIANT, | |
66 | + FIELD_SYSTEMSTREAM | |
5ab189e4 PZ |
67 | +}; |
68 | + | |
69 | +static int | |
70 | +field_get_type (const char *field_name) | |
71 | +{ | |
92400a1b MB |
72 | + if (strstr (field_name, "version") != NULL) |
73 | + return FIELD_VERSION; | |
74 | + if (strcmp (field_name, "layer") == 0) | |
75 | + return FIELD_LAYER; | |
76 | + if (strcmp (field_name, "systemstream") == 0) | |
77 | + return FIELD_SYSTEMSTREAM; | |
78 | + if (strcmp (field_name, "variant") == 0) | |
79 | + return FIELD_VARIANT; | |
80 | + | |
81 | + return -1; | |
5ab189e4 PZ |
82 | +} |
83 | + | |
84 | +static gint | |
85 | +fields_type_compare (const char *a, const char *b) | |
86 | +{ | |
92400a1b MB |
87 | + gint a_type, b_type; |
88 | + | |
89 | + a_type = field_get_type (a); | |
90 | + b_type = field_get_type (b); | |
91 | + if (a_type < b_type) | |
92 | + return -1; | |
93 | + if (b_type < a_type) | |
94 | + return 1; | |
95 | + return 0; | |
5ab189e4 | 96 | +} |
c44ba6d0 ŁK |
97 | + |
98 | +static void | |
92400a1b | 99 | +print_gst_structure_for_rpm (const char *type_name, GstStructure * s) |
5ab189e4 PZ |
100 | +{ |
101 | + guint i, num_fields; | |
102 | + const char *name; | |
103 | + GList *fields, *l, *strings; | |
104 | + GString *string; | |
105 | + | |
106 | + name = gst_structure_get_name (s); | |
107 | + strings = NULL; | |
108 | + num_fields = gst_structure_n_fields (s); | |
109 | + fields = NULL; | |
110 | + | |
111 | + for (i = 0; i < num_fields; i++) { | |
112 | + const char *field_name; | |
113 | + | |
114 | + field_name = gst_structure_nth_field_name (s, i); | |
115 | + if (field_get_type (field_name) < 0) { | |
92400a1b MB |
116 | + //g_message ("ignoring field named %s", field_name); |
117 | + continue; | |
5ab189e4 PZ |
118 | + } |
119 | + | |
92400a1b MB |
120 | + fields = |
121 | + g_list_insert_sorted (fields, g_strdup (field_name), | |
122 | + (GCompareFunc) fields_type_compare); | |
5ab189e4 PZ |
123 | + } |
124 | + | |
125 | + /* Example: | |
555f3e2e MB |
126 | + * gstreamer1(decoder-video/mpeg)(mpegversion=1)()(64bit) */ |
127 | + string = g_string_new ("gstreamer1"); | |
5ab189e4 PZ |
128 | + g_string_append_c (string, '('); |
129 | + g_string_append (string, type_name); | |
130 | + g_string_append_c (string, '-'); | |
131 | + g_string_append (string, name); | |
132 | + g_string_append_c (string, ')'); | |
133 | + | |
134 | + strings = g_list_append (strings, string); | |
135 | + | |
136 | + for (l = fields; l != NULL; l = l->next) { | |
137 | + char *field_name; | |
138 | + GType type; | |
139 | + | |
140 | + field_name = l->data; | |
141 | + | |
142 | + type = gst_structure_get_field_type (s, field_name); | |
143 | + //g_message ("field is: %s, type: %s", field_name, g_type_name (type)); | |
144 | + | |
145 | + if (type == G_TYPE_INT) { | |
146 | + char *field; | |
147 | + int value; | |
148 | + | |
149 | + gst_structure_get_int (s, field_name, &value); | |
150 | + field = g_strdup_printf ("(%s=%d)", field_name, value); | |
151 | + print_gst_structure_append_field (strings, field); | |
152 | + g_free (field); | |
153 | + } else if (type == G_TYPE_BOOLEAN) { | |
154 | + char *field; | |
155 | + int value; | |
156 | + | |
157 | + gst_structure_get_boolean (s, field_name, &value); | |
158 | + field = g_strdup_printf ("(%s=%s)", field_name, value ? "true" : "false"); | |
159 | + print_gst_structure_append_field (strings, field); | |
160 | + g_free (field); | |
161 | + } else if (type == GST_TYPE_INT_RANGE) { | |
162 | + const GValue *value; | |
163 | + int min, max; | |
164 | + | |
165 | + value = gst_structure_get_value (s, field_name); | |
166 | + min = gst_value_get_int_range_min (value); | |
167 | + max = gst_value_get_int_range_max (value); | |
168 | + | |
169 | + strings = print_gst_structure_dup_fields (strings, max - min + 1); | |
170 | + | |
171 | + for (i = min; i <= max; i++) { | |
172 | + char *field; | |
173 | + | |
174 | + field = g_strdup_printf ("(%s=%d)", field_name, i); | |
92400a1b MB |
175 | + print_gst_structure_append_field_index (strings, field, max - min + 1, |
176 | + i - min); | |
5ab189e4 PZ |
177 | + g_free (field); |
178 | + } | |
179 | + } else if (type == GST_TYPE_LIST) { | |
180 | + const GValue *value; | |
181 | + int num_items; | |
182 | + | |
183 | + value = gst_structure_get_value (s, field_name); | |
184 | + num_items = gst_value_list_get_size (value); | |
185 | + | |
186 | + strings = print_gst_structure_dup_fields (strings, num_items); | |
187 | + | |
188 | + for (i = 0; i < num_items; i++) { | |
189 | + char *field; | |
190 | + const GValue *item_value; | |
191 | + | |
92400a1b | 192 | + item_value = gst_value_list_get_value (value, i); |
5ab189e4 | 193 | + field = g_strdup_printf ("(%s=%d)", field_name, |
92400a1b | 194 | + g_value_get_int (item_value)); |
5ab189e4 PZ |
195 | + print_gst_structure_append_field_index (strings, field, num_items, i); |
196 | + g_free (field); | |
197 | + } | |
198 | + } else if (type == G_TYPE_STRING) { | |
199 | + char *field; | |
200 | + const char *value; | |
201 | + | |
202 | + value = gst_structure_get_string (s, field_name); | |
203 | + field = g_strdup_printf ("(%s=%s)", field_name, value); | |
204 | + print_gst_structure_append_field (strings, field); | |
205 | + g_free (field); | |
206 | + } else { | |
207 | + g_warning ("unhandled type! %s", g_type_name (type)); | |
208 | + } | |
209 | + | |
210 | + g_free (field_name); | |
211 | + } | |
212 | + | |
213 | + g_list_free (fields); | |
214 | + | |
215 | + for (l = strings; l != NULL; l = l->next) { | |
216 | + string = l->data; | |
217 | + g_print ("%s\n", string->str); | |
218 | + g_string_free (string, TRUE); | |
219 | + } | |
220 | + g_list_free (strings); | |
221 | +} | |
b7b90bc5 | 222 | + |
205d484a BS |
223 | /* NOTE: Not coloring output from automatic install functions, as their output |
224 | * is meant for machines, not humans. | |
225 | */ | |
555f3e2e MB |
226 | static void |
227 | -print_plugin_automatic_install_info_codecs (GstElementFactory * factory) | |
92400a1b MB |
228 | +print_plugin_automatic_install_info_codecs (GstElementFactory * factory, |
229 | + gboolean rpm_format) | |
5ab189e4 PZ |
230 | { |
231 | GstPadDirection direction; | |
232 | const gchar *type_name; | |
205d484a | 233 | @@ -1756,6 +1973,12 @@ print_plugin_automatic_install_info_code |
92400a1b MB |
234 | return; |
235 | } | |
236 | ||
237 | + if (rpm_format) { | |
238 | + /* Ignore NONE ranked plugins */ | |
555f3e2e | 239 | + if ((gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory))) == GST_RANK_NONE) |
92400a1b MB |
240 | + return; |
241 | + } | |
242 | + | |
243 | /* decoder/demuxer sink pads should always be static and there should only | |
244 | * be one, the same applies to encoders/muxers and source pads */ | |
245 | static_templates = gst_element_factory_get_static_pad_templates (factory); | |
205d484a | 246 | @@ -1792,15 +2015,20 @@ print_plugin_automatic_install_info_code |
5ab189e4 PZ |
247 | gst_structure_remove_field (s, "rate"); |
248 | gst_structure_remove_field (s, "depth"); | |
249 | gst_structure_remove_field (s, "clock-rate"); | |
250 | - s_str = gst_structure_to_string (s); | |
251 | - g_print ("%s-%s\n", type_name, s_str); | |
252 | - g_free (s_str); | |
253 | + if (!rpm_format) { | |
254 | + s_str = gst_structure_to_string (s); | |
255 | + g_print ("%s-%s\n", type_name, s_str); | |
256 | + g_free (s_str); | |
257 | + } else { | |
258 | + print_gst_structure_for_rpm (type_name, s); | |
259 | + } | |
260 | } | |
261 | gst_caps_unref (caps); | |
262 | } | |
263 | ||
264 | static void | |
265 | -print_plugin_automatic_install_info_protocols (GstElementFactory * factory) | |
92400a1b MB |
266 | +print_plugin_automatic_install_info_protocols (GstElementFactory * factory, |
267 | + gboolean rpm_format) | |
5ab189e4 | 268 | { |
c44ba6d0 | 269 | const gchar *const *protocols; |
5ab189e4 | 270 | |
205d484a | 271 | @@ -1809,13 +2037,19 @@ print_plugin_automatic_install_info_prot |
5ab189e4 PZ |
272 | switch (gst_element_factory_get_uri_type (factory)) { |
273 | case GST_URI_SINK: | |
c44ba6d0 ŁK |
274 | while (*protocols != NULL) { |
275 | - g_print ("urisink-%s\n", *protocols); | |
5ab189e4 | 276 | + if (!rpm_format) |
c44ba6d0 | 277 | + g_print ("urisink-%s\n", *protocols); |
5ab189e4 | 278 | + else |
555f3e2e | 279 | + g_print ("gstreamer1(urisink-%s)\n", *protocols); |
c44ba6d0 ŁK |
280 | ++protocols; |
281 | } | |
5ab189e4 PZ |
282 | break; |
283 | case GST_URI_SRC: | |
c44ba6d0 ŁK |
284 | while (*protocols != NULL) { |
285 | - g_print ("urisource-%s\n", *protocols); | |
5ab189e4 | 286 | + if (!rpm_format) |
c44ba6d0 | 287 | + g_print ("urisource-%s\n", *protocols); |
5ab189e4 | 288 | + else |
555f3e2e | 289 | + g_print ("gstreamer1(urisource-%s)\n", *protocols); |
c44ba6d0 ŁK |
290 | ++protocols; |
291 | } | |
5ab189e4 | 292 | break; |
205d484a | 293 | @@ -1826,7 +2060,7 @@ print_plugin_automatic_install_info_prot |
5ab189e4 PZ |
294 | } |
295 | ||
296 | static void | |
297 | -print_plugin_automatic_install_info (GstPlugin * plugin) | |
298 | +print_plugin_automatic_install_info (GstPlugin * plugin, gboolean rpm_format) | |
299 | { | |
5ab189e4 | 300 | GList *features, *l; |
c44ba6d0 | 301 | |
205d484a | 302 | @@ -1845,11 +2079,15 @@ print_plugin_automatic_install_info (Gst |
c44ba6d0 | 303 | if (feature_plugin == plugin) { |
5ab189e4 PZ |
304 | GstElementFactory *factory; |
305 | ||
306 | - g_print ("element-%s\n", gst_plugin_feature_get_name (feature)); | |
307 | + if (!rpm_format) | |
308 | + g_print ("element-%s\n", gst_plugin_feature_get_name (feature)); | |
7ac0ad7d | 309 | + else |
555f3e2e | 310 | + g_print ("gstreamer1(element-%s)\n", |
7ac0ad7d | 311 | + gst_plugin_feature_get_name (feature)); |
5ab189e4 PZ |
312 | |
313 | factory = GST_ELEMENT_FACTORY (feature); | |
314 | - print_plugin_automatic_install_info_protocols (factory); | |
315 | - print_plugin_automatic_install_info_codecs (factory); | |
316 | + print_plugin_automatic_install_info_protocols (factory, rpm_format); | |
317 | + print_plugin_automatic_install_info_codecs (factory, rpm_format); | |
318 | } | |
c44ba6d0 ŁK |
319 | if (feature_plugin) |
320 | gst_object_unref (feature_plugin); | |
205d484a | 321 | @@ -1871,7 +2109,7 @@ print_all_plugin_automatic_install_info |
92400a1b MB |
322 | plugin = (GstPlugin *) (plugins->data); |
323 | plugins = g_list_next (plugins); | |
324 | ||
325 | - print_plugin_automatic_install_info (plugin); | |
326 | + print_plugin_automatic_install_info (plugin, FALSE); | |
327 | } | |
328 | gst_plugin_list_free (orig_plugins); | |
329 | } | |
205d484a | 330 | @@ -1938,6 +2176,7 @@ main (int argc, char *argv[]) |
92400a1b | 331 | gboolean do_print_blacklist = FALSE; |
41357b36 | 332 | gboolean plugin_name = FALSE; |
5ab189e4 PZ |
333 | gboolean print_aii = FALSE; |
334 | + gboolean print_aii_rpm = FALSE; | |
41357b36 | 335 | gboolean uri_handlers = FALSE; |
555f3e2e MB |
336 | gboolean check_exists = FALSE; |
337 | gchar *min_version = NULL; | |
205d484a | 338 | @@ -1958,6 +2197,9 @@ main (int argc, char *argv[]) |
92400a1b | 339 | "or all plugins provide.\n " |
5ab189e4 PZ |
340 | "Useful in connection with external automatic plugin " |
341 | "installation mechanisms"), NULL}, | |
342 | + {"rpm", '\0', 0, G_OPTION_ARG_NONE, &print_aii_rpm, | |
92400a1b MB |
343 | + N_("Print the machine-parsable list of features of a plugin in RPM " |
344 | + "Provides compatible-format"), NULL}, | |
41357b36 MB |
345 | {"plugin", '\0', 0, G_OPTION_ARG_NONE, &plugin_name, |
346 | N_("List the plugin contents"), NULL}, | |
205d484a BS |
347 | {"types", 't', 0, G_OPTION_ARG_STRING, &types, |
348 | @@ -2113,7 +2355,7 @@ main (int argc, char *argv[]) | |
5ab189e4 PZ |
349 | /* if there is such a plugin, print out info */ |
350 | if (plugin) { | |
351 | if (print_aii) { | |
352 | - print_plugin_automatic_install_info (plugin); | |
353 | + print_plugin_automatic_install_info (plugin, print_aii_rpm); | |
354 | } else { | |
355 | print_plugin_info (plugin); | |
356 | print_plugin_features (plugin); | |
205d484a | 357 | @@ -2126,13 +2368,17 @@ main (int argc, char *argv[]) |
5ab189e4 PZ |
358 | |
359 | if (plugin) { | |
360 | if (print_aii) { | |
361 | - print_plugin_automatic_install_info (plugin); | |
362 | + print_plugin_automatic_install_info (plugin, print_aii_rpm); | |
363 | } else { | |
364 | print_plugin_info (plugin); | |
365 | print_plugin_features (plugin); | |
366 | } | |
367 | } else { | |
555f3e2e | 368 | - g_printerr (_("Could not load plugin file: %s\n"), error->message); |
5ab189e4 PZ |
369 | + if (!print_aii_rpm) |
370 | + g_print (_("Could not load plugin file: %s\n"), error->message); | |
92400a1b MB |
371 | + else |
372 | + g_printerr (_("Could not load plugin file: %s\n"), | |
373 | + error->message); | |
3dcbbc36 | 374 | g_clear_error (&error); |
205d484a BS |
375 | exit_code = -1; |
376 | goto done; |