element: Enforce that elements created by gst_element_factory_create/make() are floating
[platform/upstream/gstreamer.git] / gst / parse / types.h
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 _graph_t graph_t;
28 struct _graph_t {
29   chain_t *chain; /* links are supposed to be done now */
30   GSList *links;
31   GError **error;
32   GstParseContext *ctx; /* may be NULL */
33   GstParseFlags flags;
34 };
35
36
37 /*
38  * Memory checking. Should probably be done with gsttrace stuff, but that
39  * doesn't really work.
40  * This is not safe from reentrance issues, but that doesn't matter as long as
41  * we lock a mutex before parsing anyway.
42  *
43  * FIXME: Disable this for now for the above reasons
44  */
45 #if 0
46 #ifdef GST_DEBUG_ENABLED
47 #  define __GST_PARSE_TRACE
48 #endif
49 #endif
50
51 #ifdef __GST_PARSE_TRACE
52 G_GNUC_INTERNAL  gchar  *__gst_parse_strdup (gchar *org);
53 G_GNUC_INTERNAL  void   __gst_parse_strfree (gchar *str);
54 G_GNUC_INTERNAL  link_t *__gst_parse_link_new (void);
55 G_GNUC_INTERNAL  void   __gst_parse_link_free (link_t *data);
56 G_GNUC_INTERNAL  chain_t *__gst_parse_chain_new (void);
57 G_GNUC_INTERNAL  void   __gst_parse_chain_free (chain_t *data);
58 #  define gst_parse_strdup __gst_parse_strdup
59 #  define gst_parse_strfree __gst_parse_strfree
60 #  define gst_parse_link_new __gst_parse_link_new
61 #  define gst_parse_link_free __gst_parse_link_free
62 #  define gst_parse_chain_new __gst_parse_chain_new
63 #  define gst_parse_chain_free __gst_parse_chain_free
64 #else /* __GST_PARSE_TRACE */
65 #  define gst_parse_strdup g_strdup
66 #  define gst_parse_strfree g_free
67 #  define gst_parse_link_new() g_slice_new0 (link_t)
68 #  define gst_parse_link_free(l) g_slice_free (link_t, l)
69 #  define gst_parse_chain_new() g_slice_new0 (chain_t)
70 #  define gst_parse_chain_free(c) g_slice_free (chain_t, c)
71 #endif /* __GST_PARSE_TRACE */
72
73 static inline void
74 gst_parse_unescape (gchar *str)
75 {
76   gchar *walk;
77   gboolean in_quotes;
78
79   g_return_if_fail (str != NULL);
80
81   walk = str;
82   in_quotes = FALSE;
83
84   GST_DEBUG ("unescaping %s", str);
85
86   while (*walk) {
87     if (*walk == '\\' && !in_quotes) {
88       walk++;
89       /* make sure we don't read beyond the end of the string */
90       if (*walk == '\0')
91         break;
92     } else if (*walk == '"' && (!in_quotes || *(walk - 1) != '\\')) {
93       /* don't unescape inside quotes and don't switch
94        * state with escaped quoted inside quotes */
95       in_quotes = !in_quotes;
96     }
97     *str = *walk;
98     str++;
99     walk++;
100   }
101   *str = '\0';
102 }
103
104 G_GNUC_INTERNAL GstElement *priv_gst_parse_launch (const gchar      * str,
105                                                    GError          ** err,
106                                                    GstParseContext  * ctx,
107                                                    GstParseFlags      flags);
108
109 #endif /* __GST_PARSE_TYPES_H__ */