gstreamer/gst/gstcaps.h

249 lines
8.2 KiB
C
Raw Normal View History

/* GStreamer
* Copyright (C) 2003 David A. Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_CAPS_H__
#define __GST_CAPS_H__
#include <gst/gstconfig.h>
#include <gst/gststructure.h>
#include <gst/glib-compat.h>
G_BEGIN_DECLS
#define GST_TYPE_CAPS (gst_caps_get_type())
#define GST_CAPS(object) ((GstCaps*)object)
#define GST_IS_CAPS(object) ((object) && (GST_CAPS(object)->type == GST_TYPE_CAPS))
#define GST_TYPE_STATIC_CAPS (gst_static_caps_get_type())
/**
* GstCapsFlags:
* @GST_CAPS_FLAGS_ANY: Caps has no specific content, but can contain
* anything.
*
* Extra flags for a caps.
*/
typedef enum {
GST_CAPS_FLAGS_ANY = (1 << 0)
} GstCapsFlags;
/**
* GST_CAPS_ANY:
*
* Means that the element/pad can output 'anything'. Useful for elements
* that output unknown media, such as filesrc.
*/
#define GST_CAPS_ANY gst_caps_new_any()
/**
* GST_CAPS_NONE:
*
* The opposite of %GST_CAPS_ANY: it means that the pad/element outputs an
* undefined media type that can not be detected.
*/
#define GST_CAPS_NONE gst_caps_new_empty()
/**
* GST_STATIC_CAPS_ANY:
*
* Creates a new #GstCaps static caps that matches anything.
* This can be used in pad templates.
*/
#define GST_STATIC_CAPS_ANY GST_STATIC_CAPS("ANY")
/**
* GST_STATIC_CAPS_NONE:
*
* Creates a new #GstCaps static caps that matches nothing.
* This can be used in pad templates.
*/
#define GST_STATIC_CAPS_NONE GST_STATIC_CAPS("NONE")
/**
* GST_CAPS_IS_SIMPLE:
* @caps: the #GstCaps instance to check
*
* Convenience macro that checks if the number of structures in the given caps
* is exactly one.
*/
#define GST_CAPS_IS_SIMPLE(caps) (gst_caps_get_size(caps) == 1)
#ifndef GST_DISABLE_DEPRECATED
/**
* GST_DEBUG_CAPS:
* @string: a string that should be prepended to the caps data.
* @caps: the #GstCaps instance to print
*
* Convenience macro for printing out the contents of caps with GST_DEBUG().
*
* Deprecated: do not use anymore
*/
#define GST_DEBUG_CAPS(string, caps) \
GST_DEBUG ( string "%s: " GST_PTR_FORMAT, caps)
#endif
/**
* GST_STATIC_CAPS:
* @string: the string describing the caps
*
* Creates a new #GstCaps static caps from an input string.
* This can be used in pad templates.
*/
#define GST_STATIC_CAPS(string) \
{ \
/* caps */ { 0 }, \
/* string */ string, \
}
typedef struct _GstCaps GstCaps;
typedef struct _GstStaticCaps GstStaticCaps;
/* refcount */
/**
* GST_CAPS_REFCOUNT:
* @caps: a #GstCaps
*
* Get access to the reference count field of the caps
*/
#define GST_CAPS_REFCOUNT(caps) ((GST_CAPS(caps))->refcount)
/**
* GST_CAPS_REFCOUNT_VALUE:
* @caps: a #GstCaps
*
* Get the reference count value of the caps.
*/
#define GST_CAPS_REFCOUNT_VALUE(caps) (g_atomic_int_get (&(GST_CAPS(caps))->refcount))
/**
* GstCaps:
* @type: GType of the caps
* @refcount: the atomic refcount value
* @flags: extra flags for the caps, read only.
*
* Object describing media types.
*/
struct _GstCaps {
GType type;
/*< public >*/ /* with COW */
/* refcounting */
gint refcount;
/*< public >*/ /* read only */
GstCapsFlags flags;
/*< private >*/
GPtrArray *structs;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
/**
* GstStaticCaps:
* @caps: the cached #GstCaps
* @string: a string describing a caps
*
* Datastructure to initialize #GstCaps from a string description usually
* used in conjunction with GST_STATIC_CAPS() and gst_static_caps_get() to
* instantiate a #GstCaps.
*/
struct _GstStaticCaps {
/*< public >*/
GstCaps caps;
const char *string;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_caps_get_type (void);
GstCaps * gst_caps_new_empty (void);
GstCaps * gst_caps_new_any (void);
GstCaps * gst_caps_new_simple (const char *media_type,
const char *fieldname,
...);
GstCaps * gst_caps_new_full (GstStructure *struct1,
...);
GstCaps * gst_caps_new_full_valist (GstStructure *structure,
va_list var_args);
/* reference counting */
GstCaps * gst_caps_ref (GstCaps* caps);
GstCaps * gst_caps_copy (const GstCaps * caps);
GstCaps * gst_caps_make_writable (GstCaps *caps);
void gst_caps_unref (GstCaps* caps);
GType gst_static_caps_get_type (void);
tests/network-clock.scm: Commentary update. Original commit message from CVS: 2005-07-01 Andy Wingo <wingo@pobox.com> * tests/network-clock.scm: Commentary update. * gst/elements/gstidentity.c (PROP_DUPLICATE): Gone daddy gone. Didn't really make sense, not implementable with basetransform, etc. (gst_identity_transform): Unref inbuf via make_writable. Feeble attempt at implementing the sync property, needs an unlock method. * gst/base/gstbasetransform.c (gst_base_transform_transform_caps): New func, by default returns the same caps (the identity transformation). (gst_base_transform_getcaps): Uses transform_caps to return something sensible. (gst_base_transform_setcaps): Complicated logic to get caps on both pads, even if they are different, and to call set_caps once for every time both pads get their caps set. (gst_base_transform_handle_buffer): Give the ref to the transform function. Allows in-place modification of the buffer. * gst/base/gstbasetransform.h (transform_caps): New class method. Given caps on one side, what can I do on the other. (set_caps): Take two caps, one for each side of the element. * gst/gstpad.h: * gst/gstpad.c (gst_pad_fixate_caps): Change prototype to modify caps in place. This is safe because we can check the mutability of the caps, and a good idea because fixate functions are just called as a matter of last resort. (Not actually implemented.) (gst_pad_set_caps): If the caps we're setting is actually the same as the existing pad caps, just update the pointer without calling setcaps. Assert that caps is either NULL or fixed, as per the docs. * gst/gstghostpad.c: Update for fixate changes.
2005-07-01 16:46:59 +00:00
GstCaps * gst_static_caps_get (GstStaticCaps *static_caps);
/* manipulation */
void gst_caps_append (GstCaps *caps1,
GstCaps *caps2);
void gst_caps_append_structure (GstCaps *caps,
GstStructure *structure);
guint gst_caps_get_size (const GstCaps *caps);
GstStructure * gst_caps_get_structure (const GstCaps *caps,
guint index);
GstCaps * gst_caps_copy_nth (const GstCaps * caps, guint nth);
void gst_caps_truncate (GstCaps * caps);
void gst_caps_set_simple (GstCaps *caps,
char *field, ...) G_GNUC_NULL_TERMINATED;
void gst_caps_set_simple_valist (GstCaps *caps,
char *field,
va_list varargs);
/* tests */
gboolean gst_caps_is_any (const GstCaps *caps);
gboolean gst_caps_is_empty (const GstCaps *caps);
gst/gstcaps.c: check for ANY caps before appending/unioning Original commit message from CVS: * gst/gstcaps.c: (gst_caps_append), (gst_caps_union): check for ANY caps before appending/unioning * gst/gstcaps.c: (gst_caps_is_subset), (gst_caps_is_equal), (gst_caps_structure_subtract_field), (gst_caps_structure_subtract), (gst_caps_subtract): * gst/gstcaps.h: add gst_caps_is_equal, gst_caps_is_subset and gst_caps_subtract to the API. deprecate gst_caps_is_equal_fixed * gst/gstpad.c: (gst_pad_try_set_caps): * gst/gstqueue.c: (gst_queue_link): s/gst_caps_is_equal_fixed/gst_caps_is_equal/ * gst/gststructure.c: (gst_structure_get_name_id): * gst/gststructure.h: add function gst_structure_get_name_id * gst/gstvalue.c: (gst_value_subtract_int_int_range), (gst_value_create_new_range), (gst_value_subtract_int_range_int), (gst_value_subtract_int_range_int_range), (gst_value_subtract_double_double_range), (gst_value_subtract_double_range_double), (gst_value_subtract_double_range_double_range), (gst_value_subtract_from_list), (gst_value_subtract_list), (gst_value_can_intersect), (gst_value_subtract), (gst_value_can_subtract), (gst_value_register_subtract_func), (_gst_value_initialize): * gst/gstvalue.h: add support for subtracting values from each other. Note that subtracting means subtracting as in set theory. Required for caps stuff above. * testsuite/caps/.cvsignore: * testsuite/caps/Makefile.am: * testsuite/caps/erathostenes.c: (erathostenes), (main): * testsuite/caps/sets.c: (check_caps), (main): * testsuite/caps/subtract.c: (check_caps), (main): add tests for subtraction and equality code.
2004-04-21 03:25:13 +00:00
gboolean gst_caps_is_fixed (const GstCaps *caps);
gboolean gst_caps_is_always_compatible (const GstCaps *caps1,
const GstCaps *caps2);
gst/gstcaps.c: check for ANY caps before appending/unioning Original commit message from CVS: * gst/gstcaps.c: (gst_caps_append), (gst_caps_union): check for ANY caps before appending/unioning * gst/gstcaps.c: (gst_caps_is_subset), (gst_caps_is_equal), (gst_caps_structure_subtract_field), (gst_caps_structure_subtract), (gst_caps_subtract): * gst/gstcaps.h: add gst_caps_is_equal, gst_caps_is_subset and gst_caps_subtract to the API. deprecate gst_caps_is_equal_fixed * gst/gstpad.c: (gst_pad_try_set_caps): * gst/gstqueue.c: (gst_queue_link): s/gst_caps_is_equal_fixed/gst_caps_is_equal/ * gst/gststructure.c: (gst_structure_get_name_id): * gst/gststructure.h: add function gst_structure_get_name_id * gst/gstvalue.c: (gst_value_subtract_int_int_range), (gst_value_create_new_range), (gst_value_subtract_int_range_int), (gst_value_subtract_int_range_int_range), (gst_value_subtract_double_double_range), (gst_value_subtract_double_range_double), (gst_value_subtract_double_range_double_range), (gst_value_subtract_from_list), (gst_value_subtract_list), (gst_value_can_intersect), (gst_value_subtract), (gst_value_can_subtract), (gst_value_register_subtract_func), (_gst_value_initialize): * gst/gstvalue.h: add support for subtracting values from each other. Note that subtracting means subtracting as in set theory. Required for caps stuff above. * testsuite/caps/.cvsignore: * testsuite/caps/Makefile.am: * testsuite/caps/erathostenes.c: (erathostenes), (main): * testsuite/caps/sets.c: (check_caps), (main): * testsuite/caps/subtract.c: (check_caps), (main): add tests for subtraction and equality code.
2004-04-21 03:25:13 +00:00
gboolean gst_caps_is_subset (const GstCaps *subset,
const GstCaps *superset);
gboolean gst_caps_is_equal (const GstCaps *caps1,
const GstCaps *caps2);
gboolean gst_caps_is_equal_fixed (const GstCaps * caps1,
const GstCaps * caps2);
/* operations */
GstCaps * gst_caps_intersect (const GstCaps *caps1,
const GstCaps *caps2);
gst/gstcaps.c: check for ANY caps before appending/unioning Original commit message from CVS: * gst/gstcaps.c: (gst_caps_append), (gst_caps_union): check for ANY caps before appending/unioning * gst/gstcaps.c: (gst_caps_is_subset), (gst_caps_is_equal), (gst_caps_structure_subtract_field), (gst_caps_structure_subtract), (gst_caps_subtract): * gst/gstcaps.h: add gst_caps_is_equal, gst_caps_is_subset and gst_caps_subtract to the API. deprecate gst_caps_is_equal_fixed * gst/gstpad.c: (gst_pad_try_set_caps): * gst/gstqueue.c: (gst_queue_link): s/gst_caps_is_equal_fixed/gst_caps_is_equal/ * gst/gststructure.c: (gst_structure_get_name_id): * gst/gststructure.h: add function gst_structure_get_name_id * gst/gstvalue.c: (gst_value_subtract_int_int_range), (gst_value_create_new_range), (gst_value_subtract_int_range_int), (gst_value_subtract_int_range_int_range), (gst_value_subtract_double_double_range), (gst_value_subtract_double_range_double), (gst_value_subtract_double_range_double_range), (gst_value_subtract_from_list), (gst_value_subtract_list), (gst_value_can_intersect), (gst_value_subtract), (gst_value_can_subtract), (gst_value_register_subtract_func), (_gst_value_initialize): * gst/gstvalue.h: add support for subtracting values from each other. Note that subtracting means subtracting as in set theory. Required for caps stuff above. * testsuite/caps/.cvsignore: * testsuite/caps/Makefile.am: * testsuite/caps/erathostenes.c: (erathostenes), (main): * testsuite/caps/sets.c: (check_caps), (main): * testsuite/caps/subtract.c: (check_caps), (main): add tests for subtraction and equality code.
2004-04-21 03:25:13 +00:00
GstCaps * gst_caps_subtract (const GstCaps *minuend,
const GstCaps *subtrahend);
GstCaps * gst_caps_union (const GstCaps *caps1,
const GstCaps *caps2);
GstCaps * gst_caps_normalize (const GstCaps *caps);
gboolean gst_caps_do_simplify (GstCaps *caps);
#ifndef GST_DISABLE_LOADSAVE
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps,
xmlNodePtr parent);
GstCaps * gst_caps_load_thyself (xmlNodePtr parent);
#endif
/* utility */
void gst_caps_replace (GstCaps **caps,
GstCaps *newcaps);
gchar * gst_caps_to_string (const GstCaps *caps);
GstCaps * gst_caps_from_string (const gchar *string);
G_END_DECLS
#endif /* __GST_CAPS_H__ */