Next: GstChildProxy, Previous: GstBus, Up: Top
Structure describing sets of media formats
Caps (capabilities) are lighweight refcounted objects describing media types.
They are composed of an array of <gst-structure>
.
Caps are exposed on <gst-pad-template>
to describe all possible types a
given pad can handle. They are also stored in the <gst-registry>
along
with a description of the <gst-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
<gst-buffer>
allow for format negotiation upstream and downstream.
A <gst-caps>
can be constructed with the following code fragment:
GstCaps *caps; caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'), "framerate", GST_TYPE_FRACTION, 25, 1, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, "width", G_TYPE_INT, 320, "height", G_TYPE_INT, 240, NULL);
A <gst-caps>
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
<gst-pad>
or <gst-buffer>
.
Various methods exist to work with the media types such as subtracting or intersecting.
Last reviewed on 2007-02-13 (0.10.10)
<gst-caps>
)Creates a new
<gst-caps>
that is empty. That is, the returned<gst-caps>
contains no media formats. Caller is responsible for unreffing the returned caps.
- ret
- the new
<gst-caps>
<gst-caps>
)Creates a new
<gst-caps>
that indicates that it is compatible with any media format.
- ret
- the new
<gst-caps>
<gst-caps>
) (nth unsigned-int
) (ret <gst-caps>
)Creates a new
<gst-caps>
and appends a copy of the nth structure contained in caps.
- caps
- the
<gst-caps>
to copy- nth
- the nth structure to copy
- ret
- the new
<gst-caps>
<gst-static-caps*>
) (ret <gst-caps>
)Converts a
<gst-static-caps>
to a<gst-caps>
.
- static-caps
- the
<gst-static-caps>
to convert- ret
- A pointer to the
<gst-caps>
. Unref after usage. Since the core holds an additional ref to the returned caps, usegst-caps-make-writable
on the returned caps to modify it.
<gst-caps>
) (caps2 <gst-caps>
)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.
- caps1
- the
<gst-caps>
that will be appended to- caps2
- the
<gst-caps>
to append
<gst-caps>
) (caps2 <gst-caps>
)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
- the
<gst-caps>
that will take the new entries- caps2
- the
<gst-caps>
to merge inSince 0.10.10
<gst-caps>
) (structure <gst-structure>
)Appends structure to caps. The structure is not copied; caps becomes the owner of structure.
- caps
- the
<gst-caps>
that will be appended to- structure
- the
<gst-structure>
to append
<gst-caps>
) (idx unsigned-int
)removes the stucture with the given index from the list of structures contained in caps.
- caps
- the
<gst-caps>
to remove from- idx
- Index of the structure to remove
<gst-caps>
) (structure <gst-structure>
)Appends structure to caps if its not already expressed by caps. The structure is not copied; caps becomes the owner of structure.
- caps
- the
<gst-caps>
that will the the new structure- structure
- the
<gst-structure>
to merge
<gst-caps>
) (ret unsigned-int
)Gets the number of structures contained in caps.
- caps
- a
<gst-caps>
- ret
- the number of structures that caps contains
<gst-caps>
) (index unsigned-int
) (ret <gst-structure>
)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
<gst-caps>
should not be modified.
- caps
- a
<gst-caps>
- index
- the index of the structure
- ret
- a pointer to the
<gst-structure>
corresponding to index
<gst-caps>
) (ret bool
)Determines if caps represents any media format.
- caps
- the
<gst-caps>
to test- ret
- TRUE if caps represents any format.
<gst-caps>
) (ret bool
)Determines if caps represents no media formats.
- caps
- the
<gst-caps>
to test- ret
- TRUE if caps represents no formats.
<gst-caps>
) (ret bool
)Fixed
<gst-caps>
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.
- caps
- the
<gst-caps>
to test- ret
- TRUE if caps is fixed
<gst-caps>
) (caps2 <gst-caps>
) (ret bool
)Checks if the given caps represent the same set of caps.
This function does not work reliably if optional properties for caps are included on one caps and omitted on the other. This function deals correctly with passing NULL for any of the caps.
- caps1
- a
<gst-caps>
- caps2
- another
<gst-caps>
- ret
- TRUE if both caps are equal.
<gst-caps>
) (caps2 <gst-caps>
) (ret bool
)Tests if two
<gst-caps>
are equal. This function only works on fixed<gst-caps>
.
- caps1
- the
<gst-caps>
to test- caps2
- the
<gst-caps>
to test- ret
- TRUE if the arguments represent the same format
<gst-caps>
) (caps2 <gst-caps>
) (ret bool
)A given
<gst-caps>
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
- the
<gst-caps>
to test- caps2
- the
<gst-caps>
to test- ret
- TRUE if caps1 is a subset of caps2.
<gst-caps>
) (superset <gst-caps>
) (ret bool
)Checks if all caps represented by subset are also represented by superset.
This function does not work reliably if optional properties for caps are included on one caps and omitted on the other.
- subset
- a
<gst-caps>
- superset
- a potentially greater
<gst-caps>
- ret
- ‘
#t
’ if subset is a subset of superset
<gst-caps>
) (caps2 <gst-caps>
) (ret <gst-caps>
)Creates a new
<gst-caps>
that contains all the formats that are common to both caps1 and caps2.
- caps1
- a
<gst-caps>
to intersect- caps2
- a
<gst-caps>
to intersect- ret
- the new
<gst-caps>
<gst-caps>
) (caps2 <gst-caps>
) (ret <gst-caps>
)Creates a new
<gst-caps>
that contains all the formats that are in either caps1 and caps2.
- caps1
- a
<gst-caps>
to union- caps2
- a
<gst-caps>
to union- ret
- the new
<gst-caps>
<gst-caps>
) (ret <gst-caps>
)Creates a new
<gst-caps>
that represents the same set of formats as caps, but contains no lists. Each list is expanded into separate gst-structures.
- caps
- a
<gst-caps>
to normalize- ret
- the new
<gst-caps>
<gst-caps>
) (ret bool
)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.
- caps
- a
<gst-caps>
to simplify- ret
- TRUE, if the caps could be simplified
<gst-caps>
) (parent <xml-node-ptr>
) (ret <xml-node-ptr>
)Serializes a
<gst-caps>
to XML and adds it as a child node of parent.
- caps
- a
<gst-caps>
structure- parent
- a XML parent node
- ret
- a XML node pointer
<xml-node-ptr>
) (ret <gst-caps>
)Creates a
<gst-caps>
from its XML serialization.
- parent
- a XML node
- ret
- a new
<gst-caps>
structure
<gst-caps**>
) (newcaps <gst-caps>
)Replaces *caps with newcaps. Unrefs the
<gst-caps>
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.
- caps
- a pointer to
<gst-caps>
- newcaps
- a
<gst-caps>
to replace *caps
<gst-caps>
) (ret mchars
)Converts caps to a string representation. This string representation can be converted back to a
<gst-caps>
bygst-caps-from-string
.For debugging purposes its easier to do something like this: This prints the caps in human readble form.
GST_LOG ("caps are %" GST_PTR_FORMAT, caps);
- caps
- a
<gst-caps>
- ret
- a newly allocated string representing caps.
mchars
) (ret <gst-caps>
)Converts caps from a string representation.
- string
- a string to convert to
<gst-caps>
- ret
- a newly allocated
<gst-caps>
<gst-caps>
) (subtrahend <gst-caps>
) (ret <gst-caps>
)Subtracts the subtrahend from the minuend.
This function does not work reliably if optional properties for caps are included on one caps and omitted on the other.
- minuend
<gst-caps>
to substract from- subtrahend
<gst-caps>
to substract- ret
- the resulting caps
<gst-caps>
) (ret <gst-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
.
- caps
- the
<gst-caps>
to make writable- ret
- the same
<gst-caps>
object.