Debian Codegraph @

gst/parse/types.h

raw
1 #ifndef __GST_PARSE_TYPES_H__
2 #define __GST_PARSE_TYPES_H__
3
4 #include <glib-object.h>
5 #include "../gstelement.h"
6 #include "../gstparse.h"
7
8 typedef struct {
9 GstElement *element;
10 gchar *name;
11 GSList *pads;
12 } reference_t;
13
14 typedef struct {
15 reference_t src;
16 reference_t sink;
17 GstCaps *caps;
18 gboolean all_pads;
19 } link_t;
20
21 typedef struct {
22 GSList *elements;
23 reference_t first;
24 reference_t last;
25 } chain_t;
26
27 typedef struct {
28 gchar *factory_name;
29 GSList *values;
30 GSList *presets;
31 } element_t;
32
33 /* Filled from a bus sync handler if a error message is posted during the
34 * construction of the chain.
35 * The mutex is necessary as the bus could -- at least in principle -- have
36 * messages posted from several threads simultaneously. */
37 typedef struct {
38 GMutex mutex;
39 gchar *reason; /* owned by the struct */
40 } reason_receiver_t;
41
42
43 typedef struct _graph_t graph_t;
44 struct _graph_t {
45 chain_t *chain; /* links are supposed to be done now */
46 GSList *links;
47 GError **error;
48 reason_receiver_t *error_probable_reason_receiver;
49 GstParseContext *ctx; /* may be NULL */
50 GstParseFlags flags;
51 };
52
53
54 /*
55 * Memory checking. Should probably be done with gsttrace stuff, but that
56 * doesn't really work.
57 * This is not safe from reentrance issues, but that doesn't matter as long as
58 * we lock a mutex before parsing anyway.
59 *
60 * FIXME: Disable this for now for the above reasons
61 */
62 #if 0
63 #ifdef GST_DEBUG_ENABLED
64 # define __GST_PARSE_TRACE
65 #endif
66 #endif
67
68 #ifdef __GST_PARSE_TRACE
69 G_GNUC_INTERNAL gchar *__gst_parse_strdup (gchar *org);
70 G_GNUC_INTERNAL void __gst_parse_strfree (gchar *str);
71 G_GNUC_INTERNAL link_t *__gst_parse_link_new (void);
72 G_GNUC_INTERNAL void __gst_parse_link_free (link_t *data);
73 G_GNUC_INTERNAL chain_t *__gst_parse_chain_new (void);
74 G_GNUC_INTERNAL void __gst_parse_chain_free (chain_t *data);
75 G_GNUC_INTERNAL element_t *__gst_parse_element_new (void);
76 G_GNUC_INTERNAL void __gst_parse_element_free (element_t *data);
77 # define gst_parse_strdup __gst_parse_strdup
78 # define gst_parse_strfree __gst_parse_strfree
79 # define gst_parse_link_new __gst_parse_link_new
80 # define gst_parse_link_free __gst_parse_link_free
81 # define gst_parse_chain_new __gst_parse_chain_new
82 # define gst_parse_chain_free __gst_parse_chain_free
83 # define gst_parse_element_new __gst_parse_element_new
84 # define gst_parse_element_free __gst_parse_element_free
85 #else /* __GST_PARSE_TRACE */
86 # define gst_parse_strdup g_strdup
87 # define gst_parse_strfree g_free
88 # define gst_parse_link_new() g_new0 (link_t, 1)
89 # define gst_parse_link_free(l) g_free (l)
90 # define gst_parse_chain_new() g_new0 (chain_t, 1)
91 # define gst_parse_chain_free(c) g_free (c)
92 # define gst_parse_element_new() g_new0 (element_t, 1)
93 # define gst_parse_element_free(e) g_free (e)
94 #endif /* __GST_PARSE_TRACE */
95
96 static inline void
97 gst_parse_unescape (gchar *str)
98 {
99 gchar *walk;
100 gboolean in_quotes;
101
102 g_return_if_fail (str != NULL);
103
104 walk = str;
105 in_quotes = FALSE;
106
107 GST_DEBUG ("unescaping %s", str);
108
109 while (*walk) {
110 if (*walk == '\\' && !in_quotes) {
111 walk++;
112 /* make sure we don't read beyond the end of the string */
113 if (*walk == '\0')
114 break;
115 } else if (*walk == '"' && (!in_quotes || *(walk - 1) != '\\')) {
116 /* don't unescape inside quotes and don't switch
117 * state with escaped quoted inside quotes */
118 in_quotes = !in_quotes;
119 }
120 *str = *walk;
121 str++;
122 walk++;
123 }
124 *str = '\0';
125 }
126
127 G_GNUC_INTERNAL GstElement *priv_gst_parse_launch (const gchar * str,
128 GError ** err,
129 GstParseContext * ctx,
130 GstParseFlags flags);
131
132 #endif /* __GST_PARSE_TYPES_H__ */