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_NONE: no extra flags (Since 0.10.36)
38 * @GST_CAPS_FLAGS_ANY: Caps has no specific content, but can contain
41 * Extra flags for a caps.
44 GST_CAPS_FLAGS_NONE = 0,
45 GST_CAPS_FLAGS_ANY = (1 << 0)
49 * GstCapsIntersectMode:
50 * @GST_CAPS_INTERSECT_ZIG_ZAG : Zig-zags over both caps.
51 * @GST_CAPS_INTERSECT_FIRST : Keeps the first caps order.
53 * Modes of caps intersection
55 * @GST_CAPS_INTERSECT_ZIG_ZAG tries to preserve overall order of both caps
56 * by iterating on the caps' structures as the following matrix shows:
64 * Used when there is no explicit precedence of one caps over the other. e.g.
65 * tee's sink pad getcaps function, it will probe its src pad peers' for their
66 * caps and intersect them with this mode.
68 * @GST_CAPS_INTERSECT_FIRST is useful when an element wants to preserve
69 * another element's caps priority order when intersecting with its own caps.
70 * Example: If caps1 is [A, B, C] and caps2 is [E, B, D, A], the result
71 * would be [A, B], maintaining the first caps priority on the intersection.
76 GST_CAPS_INTERSECT_ZIG_ZAG = 0,
77 GST_CAPS_INTERSECT_FIRST = 1
78 } GstCapsIntersectMode;
83 * Means that the element/pad can output 'anything'. Useful for elements
84 * that output unknown media, such as filesrc.
86 #define GST_CAPS_ANY gst_caps_new_any()
90 * The opposite of %GST_CAPS_ANY: it means that the pad/element outputs an
91 * undefined media type that can not be detected.
93 #define GST_CAPS_NONE gst_caps_new_empty()
96 * GST_STATIC_CAPS_ANY:
98 * Creates a new #GstCaps static caps that matches anything.
99 * This can be used in pad templates.
101 #define GST_STATIC_CAPS_ANY GST_STATIC_CAPS("ANY")
103 * GST_STATIC_CAPS_NONE:
105 * Creates a new #GstCaps static caps that matches nothing.
106 * This can be used in pad templates.
108 #define GST_STATIC_CAPS_NONE GST_STATIC_CAPS("NONE")
111 * GST_CAPS_IS_SIMPLE:
112 * @caps: the #GstCaps instance to check
114 * Convenience macro that checks if the number of structures in the given caps
117 #define GST_CAPS_IS_SIMPLE(caps) (gst_caps_get_size(caps) == 1)
119 #ifndef GST_DISABLE_DEPRECATED
122 * @string: a string that should be prepended to the caps data.
123 * @caps: the #GstCaps instance to print
125 * Convenience macro for printing out the contents of caps with GST_DEBUG().
127 * Deprecated: do not use anymore
129 #define GST_DEBUG_CAPS(string, caps) \
130 GST_DEBUG ( string "%s: " GST_PTR_FORMAT, caps)
132 #endif /* GST_DISABLE_DEPRECATED */
136 * @string: the string describing the caps
138 * Creates a new #GstCaps static caps from an input string.
139 * This can be used in pad templates.
141 #define GST_STATIC_CAPS(string) \
143 /* caps */ { 0, 0, (GstCapsFlags) 0, NULL, GST_PADDING_INIT }, \
144 /* string */ string, \
148 typedef struct _GstCaps GstCaps;
149 typedef struct _GstStaticCaps GstStaticCaps;
156 * Get access to the reference count field of the caps
158 #define GST_CAPS_REFCOUNT(caps) ((GST_CAPS(caps))->refcount)
160 * GST_CAPS_REFCOUNT_VALUE:
163 * Get the reference count value of the caps.
165 #define GST_CAPS_REFCOUNT_VALUE(caps) (g_atomic_int_get (&(GST_CAPS(caps))->refcount))
169 * @type: GType of the caps
170 * @refcount: the atomic refcount value
171 * @flags: extra flags for the caps, read only.
173 * Object describing media types.
178 /*< public >*/ /* with COW */
182 /*< public >*/ /* read only */
189 gpointer _gst_reserved[GST_PADDING];
194 * @caps: the cached #GstCaps
195 * @string: a string describing a caps
197 * Datastructure to initialize #GstCaps from a string description usually
198 * used in conjunction with GST_STATIC_CAPS() and gst_static_caps_get() to
199 * instantiate a #GstCaps.
201 struct _GstStaticCaps {
207 gpointer _gst_reserved[GST_PADDING];
210 GType gst_caps_get_type (void);
211 GstCaps * gst_caps_new_empty (void) G_GNUC_MALLOC;
212 GstCaps * gst_caps_new_any (void) G_GNUC_MALLOC;
213 GstCaps * gst_caps_new_simple (const char *media_type,
214 const char *fieldname,
216 GstCaps * gst_caps_new_full (GstStructure *struct1, ...) G_GNUC_MALLOC;
217 GstCaps * gst_caps_new_full_valist (GstStructure *structure,
218 va_list var_args) G_GNUC_MALLOC;
220 /* reference counting */
221 GstCaps * gst_caps_ref (GstCaps *caps);
222 GstCaps * gst_caps_copy (const GstCaps *caps) G_GNUC_MALLOC;
223 GstCaps * gst_caps_make_writable (GstCaps *caps) G_GNUC_WARN_UNUSED_RESULT;
224 void gst_caps_unref (GstCaps *caps);
226 GType gst_static_caps_get_type (void);
227 GstCaps * gst_static_caps_get (GstStaticCaps *static_caps);
230 void gst_caps_append (GstCaps *caps1,
232 void gst_caps_merge (GstCaps *caps1,
234 void gst_caps_append_structure (GstCaps *caps,
235 GstStructure *structure);
236 void gst_caps_remove_structure (GstCaps *caps, guint idx);
237 void gst_caps_merge_structure (GstCaps *caps,
238 GstStructure *structure);
239 guint gst_caps_get_size (const GstCaps *caps);
240 GstStructure * gst_caps_get_structure (const GstCaps *caps,
242 GstStructure * gst_caps_steal_structure (GstCaps *caps,
243 guint index) G_GNUC_WARN_UNUSED_RESULT;
244 GstCaps * gst_caps_copy_nth (const GstCaps *caps, guint nth) G_GNUC_MALLOC;
245 void gst_caps_truncate (GstCaps *caps);
246 void gst_caps_set_value (GstCaps *caps,
248 const GValue *value);
249 void gst_caps_set_simple (GstCaps *caps,
250 const char *field, ...) G_GNUC_NULL_TERMINATED;
251 void gst_caps_set_simple_valist (GstCaps *caps,
256 gboolean gst_caps_is_any (const GstCaps *caps);
257 gboolean gst_caps_is_empty (const GstCaps *caps);
258 gboolean gst_caps_is_fixed (const GstCaps *caps);
259 gboolean gst_caps_is_always_compatible (const GstCaps *caps1,
260 const GstCaps *caps2);
261 gboolean gst_caps_is_subset (const GstCaps *subset,
262 const GstCaps *superset);
263 gboolean gst_caps_is_subset_structure (const GstCaps *caps,
264 const GstStructure *structure);
265 gboolean gst_caps_is_equal (const GstCaps *caps1,
266 const GstCaps *caps2);
267 gboolean gst_caps_is_equal_fixed (const GstCaps *caps1,
268 const GstCaps *caps2);
269 gboolean gst_caps_can_intersect (const GstCaps * caps1,
270 const GstCaps * caps2);
271 gboolean gst_caps_is_strictly_equal (const GstCaps *caps1,
272 const GstCaps *caps2);
276 GstCaps * gst_caps_intersect (const GstCaps *caps1,
277 const GstCaps *caps2) G_GNUC_MALLOC;
278 GstCaps * gst_caps_intersect_full (const GstCaps *caps1,
279 const GstCaps *caps2,
280 GstCapsIntersectMode mode) G_GNUC_MALLOC;
281 GstCaps * gst_caps_subtract (const GstCaps *minuend,
282 const GstCaps *subtrahend) G_GNUC_MALLOC;
283 GstCaps * gst_caps_union (const GstCaps *caps1,
284 const GstCaps *caps2) G_GNUC_MALLOC;
285 GstCaps * gst_caps_normalize (const GstCaps *caps) G_GNUC_MALLOC;
286 gboolean gst_caps_do_simplify (GstCaps *caps);
288 #if !defined(GST_DISABLE_LOADSAVE) && !defined(GST_DISABLE_DEPRECATED)
289 xmlNodePtr gst_caps_save_thyself (const GstCaps *caps,
291 GstCaps * gst_caps_load_thyself (xmlNodePtr parent);
295 void gst_caps_replace (GstCaps **caps,
297 gchar * gst_caps_to_string (const GstCaps *caps) G_GNUC_MALLOC;
298 GstCaps * gst_caps_from_string (const gchar *string) G_GNUC_MALLOC;
302 #endif /* __GST_CAPS_H__ */