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