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