2 * Copyright (C) 2003 David A. Schleef <ds@schleef.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __GST_CAPS_H__
21 #define __GST_CAPS_H__
23 #include <gst/gstconfig.h>
24 #include <gst/gststructure.h>
25 #include <gst/glib-compat.h>
29 #define GST_TYPE_CAPS (gst_caps_get_type())
30 #define GST_CAPS(object) ((GstCaps*)object)
31 #define GST_IS_CAPS(object) ((object) && (GST_CAPS(object)->type == GST_TYPE_CAPS))
33 #define GST_TYPE_STATIC_CAPS (gst_static_caps_get_type())
37 * @GST_CAPS_FLAGS_ANY: Caps has no specific content, but can contain
40 * Extra flags for a caps.
43 GST_CAPS_FLAGS_ANY = (1 << 0)
47 * GstCapsIntersectMode:
48 * @GST_CAPS_INTERSECT_ZIG_ZAG : Zig-zags over both caps.
49 * @GST_CAPS_INTERSECT_FIRST : Keeps the first caps order.
51 * Modes of caps intersection
53 * #GST_CAPS_INTERSECT_ZIG_ZAG tries to preserve overall order of both caps
54 * by iterating on the caps' structures as the following matrix shows:
61 * Used when there is no explicit precedence of one caps over the other. e.g.
62 * tee's sink pad getcaps function, it will probe its src pad peers' for their
63 * caps and intersect them with this mode.
65 * #GST_CAPS_INTERSECT_FIRST is useful when an element wants to preserve
66 * another element's caps priority order when intersecting with its own caps.
67 * Example: If caps1 is [A, B, C] and caps2 is [E, B, D, A], the result
68 * would be [A, B], maintaining the first caps priority on the intersection.
73 GST_CAPS_INTERSECT_ZIG_ZAG = 0,
74 GST_CAPS_INTERSECT_FIRST = 1
75 } GstCapsIntersectMode;
80 * Means that the element/pad can output 'anything'. Useful for elements
81 * that output unknown media, such as filesrc.
83 #define GST_CAPS_ANY gst_caps_new_any()
87 * The opposite of %GST_CAPS_ANY: it means that the pad/element outputs an
88 * undefined media type that can not be detected.
90 #define GST_CAPS_NONE gst_caps_new_empty()
93 * GST_STATIC_CAPS_ANY:
95 * Creates a new #GstCaps static caps that matches anything.
96 * This can be used in pad templates.
98 #define GST_STATIC_CAPS_ANY GST_STATIC_CAPS("ANY")
100 * GST_STATIC_CAPS_NONE:
102 * Creates a new #GstCaps static caps that matches nothing.
103 * This can be used in pad templates.
105 #define GST_STATIC_CAPS_NONE GST_STATIC_CAPS("NONE")
108 * GST_CAPS_IS_SIMPLE:
109 * @caps: the #GstCaps instance to check
111 * Convenience macro that checks if the number of structures in the given caps
114 #define GST_CAPS_IS_SIMPLE(caps) (gst_caps_get_size(caps) == 1)
116 #ifndef GST_DISABLE_DEPRECATED
119 * @string: a string that should be prepended to the caps data.
120 * @caps: the #GstCaps instance to print
122 * Convenience macro for printing out the contents of caps with GST_DEBUG().
124 * Deprecated: do not use anymore
126 #define GST_DEBUG_CAPS(string, caps) \
127 GST_DEBUG ( string "%s: " GST_PTR_FORMAT, caps)
129 #endif /* GST_DISABLE_DEPRECATED */
133 * @string: the string describing the caps
135 * Creates a new #GstCaps static caps from an input string.
136 * This can be used in pad templates.
138 #define GST_STATIC_CAPS(string) \
140 /* caps */ { 0, 0, (GstCapsFlags) 0, NULL, GST_PADDING_INIT }, \
141 /* string */ string, \
145 typedef struct _GstCaps GstCaps;
146 typedef struct _GstStaticCaps GstStaticCaps;
153 * Get access to the reference count field of the caps
155 #define GST_CAPS_REFCOUNT(caps) ((GST_CAPS(caps))->refcount)
157 * GST_CAPS_REFCOUNT_VALUE:
160 * Get the reference count value of the caps.
162 #define GST_CAPS_REFCOUNT_VALUE(caps) (g_atomic_int_get (&(GST_CAPS(caps))->refcount))
166 * @type: GType of the caps
167 * @refcount: the atomic refcount value
168 * @flags: extra flags for the caps, read only.
170 * Object describing media types.
175 /*< public >*/ /* with COW */
179 /*< public >*/ /* read only */
186 gpointer _gst_reserved[GST_PADDING];
191 * @caps: the cached #GstCaps
192 * @string: a string describing a caps
194 * Datastructure to initialize #GstCaps from a string description usually
195 * used in conjunction with GST_STATIC_CAPS() and gst_static_caps_get() to
196 * instantiate a #GstCaps.
198 struct _GstStaticCaps {
204 gpointer _gst_reserved[GST_PADDING];
207 GType gst_caps_get_type (void);
208 GstCaps * gst_caps_new_empty (void);
209 GstCaps * gst_caps_new_any (void);
210 GstCaps * gst_caps_new_simple (const char *media_type,
211 const char *fieldname,
213 GstCaps * gst_caps_new_full (GstStructure *struct1, ...);
214 GstCaps * gst_caps_new_full_valist (GstStructure *structure,
217 /* reference counting */
218 GstCaps * gst_caps_ref (GstCaps *caps);
219 GstCaps * gst_caps_copy (const GstCaps *caps);
220 GstCaps * gst_caps_make_writable (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT;
221 void gst_caps_unref (GstCaps *caps);
223 GType gst_static_caps_get_type (void);
224 GstCaps * gst_static_caps_get (GstStaticCaps *static_caps);
227 void gst_caps_append (GstCaps *caps1,
229 void gst_caps_merge (GstCaps *caps1,
231 void gst_caps_append_structure (GstCaps *caps,
232 GstStructure *structure);
233 void gst_caps_remove_structure (GstCaps *caps, guint idx);
234 void gst_caps_merge_structure (GstCaps *caps,
235 GstStructure *structure);
236 guint gst_caps_get_size (const GstCaps *caps);
237 GstStructure * gst_caps_get_structure (const GstCaps *caps,
239 GstStructure * gst_caps_steal_structure (GstCaps *caps,
241 GstCaps * gst_caps_copy_nth (const GstCaps *caps, guint nth);
242 void gst_caps_truncate (GstCaps *caps);
243 void gst_caps_set_value (GstCaps *caps,
245 const GValue *value);
246 void gst_caps_set_simple (GstCaps *caps,
247 const char *field, ...) G_GNUC_NULL_TERMINATED;
248 void gst_caps_set_simple_valist (GstCaps *caps,
253 gboolean gst_caps_is_any (const GstCaps *caps);
254 gboolean gst_caps_is_empty (const GstCaps *caps);
255 gboolean gst_caps_is_fixed (const GstCaps *caps);
256 gboolean gst_caps_is_always_compatible (const GstCaps *caps1,
257 const GstCaps *caps2);
258 gboolean gst_caps_is_subset (const GstCaps *subset,
259 const GstCaps *superset);
260 gboolean gst_caps_is_equal (const GstCaps *caps1,
261 const GstCaps *caps2);
262 gboolean gst_caps_is_equal_fixed (const GstCaps *caps1,
263 const GstCaps *caps2);
264 gboolean gst_caps_can_intersect (const GstCaps * caps1,
265 const GstCaps * caps2);
269 GstCaps * gst_caps_intersect (const GstCaps *caps1,
270 const GstCaps *caps2);
271 GstCaps * gst_caps_intersect_full (const GstCaps *caps1,
272 const GstCaps *caps2,
273 GstCapsIntersectMode mode);
274 GstCaps * gst_caps_subtract (const GstCaps *minuend,
275 const GstCaps *subtrahend);
276 GstCaps * gst_caps_union (const GstCaps *caps1,
277 const GstCaps *caps2);
278 GstCaps * gst_caps_normalize (const GstCaps *caps);
279 gboolean gst_caps_do_simplify (GstCaps *caps);
281 #if !defined(GST_DISABLE_LOADSAVE) && !defined(GST_DISABLE_DEPRECATED)
282 xmlNodePtr gst_caps_save_thyself (const GstCaps *caps,
284 GstCaps * gst_caps_load_thyself (xmlNodePtr parent);
288 void gst_caps_replace (GstCaps **caps,
290 gchar * gst_caps_to_string (const GstCaps *caps);
291 GstCaps * gst_caps_from_string (const gchar *string);
295 #endif /* __GST_CAPS_H__ */