![]() |
![]() |
![]() |
GStreamer 0.10 Core Reference Manual | ![]() |
---|---|---|---|---|
#include <gst/gst.h> GstCaps; GstStaticCaps; enum GstCapsFlags; #define GST_CAPS_ANY #define GST_CAPS_NONE #define GST_CAPS_REFCOUNT (caps) #define GST_CAPS_REFCOUNT_VALUE (caps) #define GST_STATIC_CAPS_ANY #define GST_STATIC_CAPS_NONE #define GST_CAPS_IS_SIMPLE (caps) #define GST_DEBUG_CAPS (string, caps) #define GST_STATIC_CAPS (string) 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); GstCaps* gst_caps_copy (const GstCaps *caps); GstCaps* gst_caps_copy_nth (const GstCaps *caps, guint nth); GstCaps* gst_static_caps_get (GstStaticCaps *static_caps); void gst_caps_append (GstCaps *caps1, GstCaps *caps2); void gst_caps_merge (GstCaps *caps1, GstCaps *caps2); void gst_caps_append_structure (GstCaps *caps, GstStructure *structure); void gst_caps_remove_structure (GstCaps *caps, guint idx); void gst_caps_merge_structure (GstCaps *caps, GstStructure *structure); guint gst_caps_get_size (const GstCaps *caps); GstStructure* gst_caps_get_structure (const GstCaps *caps, guint index); void gst_caps_set_simple (GstCaps *caps, char *field, ...); void gst_caps_set_simple_valist (GstCaps *caps, char *field, va_list varargs); gboolean gst_caps_is_any (const GstCaps *caps); gboolean gst_caps_is_empty (const GstCaps *caps); gboolean gst_caps_is_fixed (const GstCaps *caps); gboolean gst_caps_is_equal (const GstCaps *caps1, const GstCaps *caps2); gboolean gst_caps_is_equal_fixed (const GstCaps *caps1, const GstCaps *caps2); gboolean gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2); gboolean gst_caps_is_subset (const GstCaps *subset, const GstCaps *superset); GstCaps* gst_caps_intersect (const GstCaps *caps1, const GstCaps *caps2); GstCaps* gst_caps_union (const GstCaps *caps1, const GstCaps *caps2); GstCaps* gst_caps_normalize (const GstCaps *caps); gboolean gst_caps_do_simplify (GstCaps *caps); xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent); GstCaps* gst_caps_load_thyself (xmlNodePtr parent); void gst_caps_replace (GstCaps **caps, GstCaps *newcaps); gchar* gst_caps_to_string (const GstCaps *caps); GstCaps* gst_caps_from_string (const gchar *string); GstCaps* gst_caps_subtract (const GstCaps *minuend, const GstCaps *subtrahend); GstCaps* gst_caps_make_writable (GstCaps *caps); GstCaps* gst_caps_ref (GstCaps *caps); void gst_caps_truncate (GstCaps *caps); void gst_caps_unref (GstCaps *caps);
Caps (capabilities) are lighweight refcounted objects describing media types. They are composed of an array of GstStructure.
Caps are exposed on GstPadTemplate to describe all possible types a given pad can handle. They are also stored in the registry along with a description of the element.
Caps are exposed on the element pads using the gst_pad_get_caps()
pad
function. This function describes the possible types that the pad can
handle or produce at runtime.
Caps are also attached to buffers to describe to content of the data
pointed to by the buffer with gst_buffer_set_caps()
. Caps attached to
a GstBuffer allow for format negotiation upstream and downstream.
A GstCaps can be constructed with the following code fragment:
Example 4. Creating caps
GstCaps *caps; caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'), "framerate", G_TYPE_DOUBLE, 25.0, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, "width", G_TYPE_INT, 320, "height", G_TYPE_INT, 240, NULL);
A GstCaps is fixed when it has no properties with ranges or lists. Use
gst_caps_is_fixed()
to test for fixed caps. Only fixed caps can be
set on a GstPad or GstBuffer.
Various methods exist to work with the media types such as subtracting or intersecting.
Last reviewed on 2005-11-23 (0.9.5)
typedef struct { GType type; /* refcounting */ gint refcount; GstCapsFlags flags; } GstCaps;
Object describing media types.
type
;GTypetype
GType of the caps
GType of the caps
gint refcount
;gintrefcount
the atomic refcount value
the atomic refcount value
GstCapsFlags flags
;GstCapsFlagsflags
extra flags for the caps, read only.
extra flags for the caps, read only.
GType type ; |
GType of the caps |
gint refcount ; |
the atomic refcount value |
GstCapsFlags flags ; |
extra flags for the caps, read only. |
typedef struct { GstCaps caps; const char *string; } GstStaticCaps;
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.
typedef enum { GST_CAPS_FLAGS_ANY = (1 << 0) } GstCapsFlags;
Extra flags for a caps.
#define GST_CAPS_ANY gst_caps_new_any()
Means that the element/pad can output 'anything'. Useful for elements that output unknown media, such as filesrc.
#define GST_CAPS_NONE gst_caps_new_empty()
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_REFCOUNT(caps) ((GST_CAPS(caps))->refcount)
Get access to the reference count field of the caps
#define GST_CAPS_REFCOUNT_VALUE(caps) (g_atomic_int_get (&(GST_CAPS(caps))->refcount))
Get the reference count value of the caps.
#define GST_STATIC_CAPS_ANY GST_STATIC_CAPS("ANY")
Creates a new GstCaps static caps that matches anything. This can be used in pad templates.
#define GST_STATIC_CAPS_NONE GST_STATIC_CAPS("NONE")
Creates a new GstCaps static caps that matches nothing. This can be used in pad templates.
#define GST_CAPS_IS_SIMPLE(caps) (gst_caps_get_size(caps) == 1)
Convenience macro that checks if the number of structures in the given caps is exactly one.
#define GST_DEBUG_CAPS(string, caps)
GST_DEBUG_CAPS
is deprecated and should not be used in newly-written code. do not use anymore
Convenience macro for printing out the contents of caps with GST_DEBUG()
.
string
:string
a string that should be prepended to the caps data.
a string that should be prepended to the caps data.
caps
:caps
the GstCaps instance to print
the GstCaps instance to print
GstCapsGstCaps
string : |
a string that should be prepended to the caps data. |
caps : |
the GstCaps instance to print |
#define GST_STATIC_CAPS(string)
Creates a new GstCaps static caps from an input string. This can be used in pad templates.
string
:string
the string describing the caps
the string describing the caps
string : |
the string describing the caps |
GstCaps* gst_caps_new_empty (void);
Creates a new GstCaps that is empty. That is, the returned GstCaps contains no media formats. Caller is responsible for unreffing the returned caps.
GstCaps* gst_caps_new_any (void);
Creates a new GstCaps that indicates that it is compatible with any media format.
GstCaps* gst_caps_new_simple (const char *media_type, const char *fieldname, ...);
Creates a new GstCaps that contains one GstStructure. The
structure is defined by the arguments, which have the same format
as gst_structure_new()
.
Caller is responsible for unreffing the returned caps.
media_type
:media_type
the media type of the structure
the media type of the structure
fieldname
:fieldname
first field to set
first field to set
...
:...
additional arguments
additional arguments
Returns :Returns the new GstCaps
the new GstCaps
GstCapsGstCaps
media_type : |
the media type of the structure |
fieldname : |
first field to set |
... : |
additional arguments |
Returns : | the new GstCaps |
GstCaps* gst_caps_new_full (GstStructure *struct1, ...);
Creates a new GstCaps and adds all the structures listed as arguments. The list must be NULL-terminated. The structures are not copied; the returned GstCaps owns the structures.
GstCaps* gst_caps_new_full_valist (GstStructure *structure, va_list var_args);
Creates a new GstCaps and adds all the structures listed as arguments. The list must be NULL-terminated. The structures are not copied; the returned GstCaps owns the structures.
structure
:structure
the first structure to add
the first structure to add
var_args
:var_args
additional structures to add
additional structures to add
Returns :Returns the new GstCaps
the new GstCaps
GstCapsGstCaps
structure : |
the first structure to add |
var_args : |
additional structures to add |
Returns : | the new GstCaps |
GstCaps* gst_caps_copy (const GstCaps *caps);
Creates a new GstCaps as a copy of the old caps
. The new caps will have a
refcount of 1, owned by the caller. The structures are copied as well.
Note that this function is the semantic equivalent of a gst_caps_ref()
followed by a gst_caps_make_writable()
. If you only want to hold on to a
reference to the data, you should use gst_caps_ref()
.
When you are finished with the caps, call gst_caps_unref()
on it.
GstCaps* gst_caps_copy_nth (const GstCaps *caps, guint nth);
Creates a new GstCaps and appends a copy of the nth structure
contained in caps
.
GstCaps* gst_static_caps_get (GstStaticCaps *static_caps);
Converts a GstStaticCaps to a GstCaps.
static_caps
:static_caps
the GstStaticCaps to convert
the GstStaticCaps to convert
GstStaticCapsGstStaticCapsReturns :Returns A pointer to the GstCaps. Unref after usage. Since the
core holds an additional ref to the returned caps,
use gst_caps_make_writable()
on the returned caps to modify it.
A pointer to the GstCaps. Unref after usage. Since the
core holds an additional ref to the returned caps,
use gst_caps_make_writable()
on the returned caps to modify it.
GstCapsGstCapsgst_caps_make_writable()
gst_caps_make_writable()
static_caps : |
the GstStaticCaps to convert |
Returns : | A pointer to the GstCaps. Unref after usage. Since the
core holds an additional ref to the returned caps,
use gst_caps_make_writable() on the returned caps to modify it.
|
void gst_caps_append (GstCaps *caps1, GstCaps *caps2);
Appends the structures contained in caps2
to caps1
. The structures in
caps2
are not copied -- they are transferred to caps1
, and then caps2
is
freed. If either caps is ANY, the resulting caps will be ANY.
void gst_caps_merge (GstCaps *caps1, GstCaps *caps2);
Appends the structures contained in caps2
to caps1
if they are not yet
expressed by caps1
. The structures in caps2
are not copied -- they are
transferred to caps1
, and then caps2
is freed.
If either caps is ANY, the resulting caps will be ANY.
caps1
:caps1
the GstCaps that will take the new entries
the GstCaps that will take the new entries
GstCapsGstCapscaps2
:caps2
the GstCaps to merge in
the GstCaps to merge in
GstCapsGstCaps
caps1 : |
the GstCaps that will take the new entries |
caps2 : |
the GstCaps to merge in |
Since 0.10.10
void gst_caps_append_structure (GstCaps *caps, GstStructure *structure);
Appends structure
to caps
. The structure is not copied; caps
becomes the owner of structure
.
caps
:caps
the GstCaps that will be appended to
the GstCaps that will be appended to
GstCapsGstCapsstructure
:structure
the GstStructure to append
the GstStructure to append
GstStructureGstStructure
caps : |
the GstCaps that will be appended to |
structure : |
the GstStructure to append |
void gst_caps_remove_structure (GstCaps *caps, guint idx);
removes the stucture with the given index from the list of structures
contained in caps
.
void gst_caps_merge_structure (GstCaps *caps, GstStructure *structure);
Appends structure
to caps
if its not already expressed by caps
. The
structure is not copied; caps
becomes the owner of structure
.
caps
:caps
the GstCaps that will the the new structure
the GstCaps that will the the new structure
GstCapsGstCapsstructure
:structure
the GstStructure to merge
the GstStructure to merge
GstStructureGstStructure
caps : |
the GstCaps that will the the new structure |
structure : |
the GstStructure to merge |
guint gst_caps_get_size (const GstCaps *caps);
Gets the number of structures contained in caps
.
GstStructure* gst_caps_get_structure (const GstCaps *caps, guint index);
Finds the structure in caps
that has the index index
, and
returns it.
WARNING: This function takes a const GstCaps *, but returns a non-const GstStructure *. This is for programming convenience -- the caller should be aware that structures inside a constant GstCaps should not be modified.
caps
:caps
a GstCaps
a GstCaps
GstCapsGstCapsindex
:index
the index of the structure
the index of the structure
Returns :Returns a pointer to the GstStructure corresponding to index
a pointer to the GstStructure corresponding to index
GstStructureGstStructureindex
caps : |
a GstCaps |
index : |
the index of the structure |
Returns : | a pointer to the GstStructure corresponding to index
|
void gst_caps_set_simple (GstCaps *caps, char *field, ...);
Sets fields in a simple GstCaps. A simple GstCaps is one that
only has one structure. The arguments must be passed in the same
manner as gst_structure_set()
, and be NULL-terminated.
void gst_caps_set_simple_valist (GstCaps *caps, char *field, va_list varargs);
Sets fields in a simple GstCaps. A simple GstCaps is one that
only has one structure. The arguments must be passed in the same
manner as gst_structure_set()
, and be NULL-terminated.
gboolean gst_caps_is_any (const GstCaps *caps);
Determines if caps
represents any media format.
gboolean gst_caps_is_empty (const GstCaps *caps);
Determines if caps
represents no media formats.
gboolean gst_caps_is_fixed (const GstCaps *caps);
Fixed GstCaps describe exactly one format, that is, they have exactly one structure, and each field in the structure describes a fixed type. Examples of non-fixed types are GST_TYPE_INT_RANGE and GST_TYPE_LIST.
gboolean gst_caps_is_equal (const GstCaps *caps1, const GstCaps *caps2);
Checks if the given caps represent the same set of caps.
This function deals correctly with passing NULL for any of the caps.
gboolean gst_caps_is_equal_fixed (const GstCaps *caps1, const GstCaps *caps2);
Tests if two GstCaps are equal. This function only works on fixed GstCaps.
caps1
:caps1
the GstCaps to test
the GstCaps to test
GstCapsGstCapscaps2
:caps2
the GstCaps to test
the GstCaps to test
GstCapsGstCapsReturns :Returns TRUE if the arguments represent the same format
TRUE if the arguments represent the same format
caps1 : |
the GstCaps to test |
caps2 : |
the GstCaps to test |
Returns : | TRUE if the arguments represent the same format |
gboolean gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2);
A given GstCaps structure is always compatible with another if
every media format that is in the first is also contained in the
second. That is, caps1
is a subset of caps2
.
caps1
:caps1
the GstCaps to test
the GstCaps to test
GstCapsGstCapscaps2
:caps2
the GstCaps to test
the GstCaps to test
GstCapsGstCapsReturns :Returns TRUE if caps1
is a subset of caps2
.
TRUE if caps1
is a subset of caps2
.
caps1
caps2
caps1 : |
the GstCaps to test |
caps2 : |
the GstCaps to test |
Returns : | TRUE if caps1 is a subset of caps2 .
|
gboolean gst_caps_is_subset (const GstCaps *subset, const GstCaps *superset);
Checks if all caps represented by subset
are also represented by superset
subset
:subset
a GstCaps
a GstCaps
GstCapsGstCapssuperset
:superset
a potentially greater GstCaps
a potentially greater GstCaps
GstCapsGstCapsReturns :Returns TRUE if subset
is a subset of superset
TRUE if subset
is a subset of superset
subset
superset
subset : |
a GstCaps |
superset : |
a potentially greater GstCaps |
Returns : | TRUE if subset is a subset of superset
|
GstCaps* gst_caps_intersect (const GstCaps *caps1, const GstCaps *caps2);
Creates a new GstCaps that contains all the formats that are common
to both caps1
and caps2
.
GstCaps* gst_caps_union (const GstCaps *caps1, const GstCaps *caps2);
Creates a new GstCaps that contains all the formats that are in
either caps1
and caps2
.
GstCaps* gst_caps_normalize (const GstCaps *caps);
Creates a new GstCaps that represents the same set of formats as
caps
, but contains no lists. Each list is expanded into separate
GstStructures
.
gboolean gst_caps_do_simplify (GstCaps *caps);
Modifies the given caps
inplace into a representation that represents the
same set of formats, but in a simpler form. Component structures that are
identical are merged. Component structures that have values that can be
merged are also merged.
xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, xmlNodePtr parent);
Serializes a GstCaps to XML and adds it as a child node of parent
.
GstCaps* gst_caps_load_thyself (xmlNodePtr parent);
Creates a GstCaps from its XML serialization.
void gst_caps_replace (GstCaps **caps, GstCaps *newcaps);
Replaces *caps with newcaps
. Unrefs the GstCaps in the location
pointed to by caps
, if applicable, then modifies caps
to point to
newcaps
. An additional ref on newcaps
is taken.
This function does not take any locks so you might want to lock
the object owning caps
pointer.
gchar* gst_caps_to_string (const GstCaps *caps);
Converts caps
to a string representation. This string representation
can be converted back to a GstCaps by gst_caps_from_string()
.
For debugging purposes its easier to do something like this:
GST_LOG ("caps are %" GST_PTR_FORMAT, caps);
This prints the caps in human readble form.
GstCaps* gst_caps_from_string (const gchar *string);
Converts caps
from a string representation.
GstCaps* gst_caps_subtract (const GstCaps *minuend, const GstCaps *subtrahend);
Subtracts the subtrahend
from the minuend
.
minuend
:minuend
GstCaps to substract from
GstCaps to substract from
GstCapsGstCapssubtrahend
:subtrahend
GstCaps to substract
GstCaps to substract
GstCapsGstCapsReturns :Returns the resulting caps
the resulting caps
minuend : |
GstCaps to substract from |
subtrahend : |
GstCaps to substract |
Returns : | the resulting caps |
GstCaps* gst_caps_make_writable (GstCaps *caps);
Returns a writable copy of caps
.
If there is only one reference count on caps
, the caller must be the owner,
and so this function will return the caps object unchanged. If on the other
hand there is more than one reference on the object, a new caps object will
be returned. The caller's reference on caps
will be removed, and instead the
caller will own a reference to the returned object.
In short, this function unrefs the caps in the argument and refs the caps
that it returns. Don't access the argument after calling this function. See
also: gst_caps_ref()
.
GstCaps* gst_caps_ref (GstCaps *caps);
Add a reference to a GstCaps object.
From this point on, until the caller calls gst_caps_unref()
or
gst_caps_make_writable()
, it is guaranteed that the caps object will not
change. This means its structures won't change, etc. To use a GstCaps
object, you must always have a refcount on it -- either the one made
implicitly by gst_caps_new()
, or via taking one explicitly with this
function.
void gst_caps_truncate (GstCaps *caps);
Destructively discard all but the first structure from caps
. Useful when
fixating. caps
must be writable.