Header file fix (these ## are needed for multi-arguments) and a fix for gst_props_get...
[platform/upstream/gstreamer.git] / gst / gstcaps.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstcaps.h: Header for caps subsystem
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23
24 #ifndef __GST_CAPS_H__
25 #define __GST_CAPS_H__
26
27 #include <gst/gstconfig.h>
28
29 #include <gst/gstprops.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34
35 typedef struct _GstCaps GstCaps;
36
37 extern GType _gst_caps_type;
38
39 #define GST_TYPE_CAPS  (_get_caps_type)
40
41
42 #define GST_CAPS(caps) \
43   ((GstCaps *)(caps))
44
45 #define GST_CAPS_IS_FIXED(caps)         ((caps)->fixed)
46 #define GST_CAPS_IS_CHAINED(caps)       ((caps)->next)
47
48 /* CR1: id is an int corresponding to the quark for the mime type because
49  * it's really fast when doing a first-pass check for caps compatibility */
50 struct _GstCaps {
51   gchar         *name;                  /* the name of this caps */
52   guint16       id;                     /* type id (major type) representing 
53                                            the mime type */
54
55   guint         refcount;               
56   gboolean      fixed;                  /* this caps doesn't contain variable properties */
57
58   GstProps      *properties;            /* properties for this capability */
59
60   GstCaps       *next;                  /* not with a GList for efficiency */
61 };
62
63 /* factory macros which make it easier for plugins to instantiate */
64
65 #define GST_CAPS_NEW(name, type, a...)          \
66 gst_caps_new (                                  \
67   name,                                         \
68   type,                                         \
69   gst_props_new (                               \
70     a,                                          \
71     NULL))
72
73 #define GST_CAPS_FACTORY(factoryname, a...)     \
74 static GstCaps*                                 \
75 factoryname (void)                              \
76 {                                               \
77   static GstCaps *caps = NULL;                  \
78   if (!caps) {                                  \
79     caps = gst_caps_chain (a, NULL);            \
80   }                                             \
81   return caps;                                  \
82 }
83
84 #define GST_CAPS_GET(fact) (fact)()
85
86
87 /* initialize the subsystem */
88 void            _gst_caps_initialize                    (void);
89
90 GstCaps*        gst_caps_new                            (const gchar *name, const gchar *mime, GstProps *props);
91 GstCaps*        gst_caps_new_id                         (const gchar *name, const guint16 id, GstProps *props);
92
93 GstCaps*        gst_caps_unref                          (GstCaps *caps);
94 GstCaps*        gst_caps_ref                            (GstCaps *caps);
95 void            gst_caps_destroy                        (GstCaps *caps);
96
97 void            gst_caps_debug                          (GstCaps *caps, const gchar *label);
98
99 GstCaps*        gst_caps_copy                           (GstCaps *caps);
100 GstCaps*        gst_caps_copy_first                     (GstCaps *caps);
101 GstCaps*        gst_caps_copy_on_write                  (GstCaps *caps);
102
103 const gchar*    gst_caps_get_name                       (GstCaps *caps);
104 void            gst_caps_set_name                       (GstCaps *caps, const gchar *name);
105
106 const gchar*    gst_caps_get_mime                       (GstCaps *caps);
107 void            gst_caps_set_mime                       (GstCaps *caps, const gchar *mime);
108
109 guint16         gst_caps_get_type_id                    (GstCaps *caps);
110 void            gst_caps_set_type_id                    (GstCaps *caps, guint16 type_id);
111
112 GstCaps*        gst_caps_set_props                      (GstCaps *caps, GstProps *props);
113 GstProps*       gst_caps_get_props                      (GstCaps *caps);
114
115 #define         gst_caps_set(caps, name, args...)       gst_props_set ((caps)->properties, name, ##args)
116 #define         gst_caps_get(caps, name, args...)       gst_props_get ((caps)->properties, name, ##args)
117
118 #define         gst_caps_get_int(caps,name,res)         gst_props_entry_get_int(gst_props_get_entry((caps)->properties,name),res)
119 #define         gst_caps_get_float(caps,name,res)       gst_props_entry_get_float(gst_props_get_entry((caps)->properties,name),res)
120 #define         gst_caps_get_fourcc_int(caps,name,res)  gst_props_entry_get_fourcc_int(gst_props_get_entry((caps)->properties,name),res)
121 #define         gst_caps_get_boolean(caps,name,res)     gst_props_entry_get_boolean(gst_props_get_entry((caps)->properties,name),res)
122 #define         gst_caps_get_string(caps,name,res)      gst_props_entry_get_string(gst_props_get_entry((caps)->properties,name),res)
123
124 #define         gst_caps_has_property(caps, name)       gst_props_has_property ((caps)->properties, name)
125 #define         gst_caps_has_property_typed(caps, name) gst_props_has_property_typed ((caps)->properties, name)
126 #define         gst_caps_has_fixed_property(caps, name) gst_props_has_fixed_property ((caps)->properties, name)
127
128 GstCaps*        gst_caps_get_by_name                    (GstCaps *caps, const gchar *name);
129
130 GstCaps*        gst_caps_chain                          (GstCaps *caps, ...); 
131 GstCaps*        gst_caps_append                         (GstCaps *caps, GstCaps *capstoadd); 
132 GstCaps*        gst_caps_prepend                        (GstCaps *caps, GstCaps *capstoadd); 
133
134 gboolean        gst_caps_check_compatibility            (GstCaps *fromcaps, GstCaps *tocaps);
135 GstCaps*        gst_caps_intersect                      (GstCaps *caps1, GstCaps *caps2);
136 GstCaps*        gst_caps_normalize                      (GstCaps *caps);
137
138 #ifndef GST_DISABLE_LOADSAVE
139 xmlNodePtr      gst_caps_save_thyself                   (GstCaps *caps, xmlNodePtr parent);
140 GstCaps*        gst_caps_load_thyself                   (xmlNodePtr parent);
141 #endif
142
143 #ifdef __cplusplus
144 }
145 #endif /* __cplusplus */
146
147 #endif /* __GST_CAPS_H__ */