GstCaps
Capabilities of pads
GstCaps is used to attach capabilities to a pad. Capabilities are made of
a mime-type and a set of properties. GstCaps can be named and chained into
a list, which is then a GstCaps on its own.
GstCaps are created with gst_caps_new_simpl(), which takes a mime type and
a list of arguments in sets of 3, terminated with NULL. Each set of 3
arguments is the name of a field, the GType of the field, and the value
of the field. The following example shows how to create a GstCaps.
GstCaps *caps;
caps = gst_caps_new (
"audio/x-raw-int", /* mime type */
"channels", G_TYPE_INT, 5,
NULL);
The following code example is equivalent to the above example:
GstCaps *caps;
caps = gst_caps_from_string ("audio/x-raw-int, channels = (int) 5");
GstCaps are refcounted with gst_caps_ref() and gst_caps_unref().
GstCaps can be chained with the gst_caps_append(), gst_caps_prepend() and
gst_caps_chain() functions. Use gst_caps_get_by_name() to get a named caps
structure from a chained list.
To get the properties of a caps structure the functions
gst_caps_get_boolean(), gst_caps_get_fourcc_int(), gst_caps_get_int(),
gst_caps_get_string(), gst_caps_get_float(), which all take a property name as an argument.
The fields of the caps structure can be modified with gst_caps_set_simple,
which takes the caps structure to be modified, a list of arguments in
sets of 3, terminated by NULL. The format of these arguments is the
same as above.
GstCaps *caps;
....
gst_caps_set_simple (caps, "channels", G_TYPE_INT, 20, NULL);
before modifying a GstCaps, it is a good idea to make a copy if it first with
gst_caps_copy_on_write(). This will copy the GstCaps if the refcount is >1.
If you need a unique instance of a GstCaps you can use the convenient
GST_CAPS_FACTORY() macro as shown below.
GstStaticCaps my_caps = GST_STATIC_CAPS (
"audio/x-raw-float, "
"channels = (int) 5; "
"audio/x-raw-int, "
"channels = (int) 5"
)
)
void
some_function (void)
{
GstCaps *caps = gst_caps_copy (gst_static_caps_get (&my_caps));
...
}
If you want to check if a link between source and destination caps
is always possible, use gst_caps_is_always_compatible(), which returns
a boolean.
If you want to check if a link between source and destination caps
might be possible, use gst_caps_intersect(), which returns an intersection
of the capabilities.
#GstStructure, #GstPad
The GType of the caps boxed type, for use in GValues.
The gstcaps structure
@type:
@flags:
@structs:
@caps:
@Returns:
@caps:
@Returns:
@caps1:
@caps2:
@caps:
@capstoadd:
@Returns:
@caps:
@newcaps:
@oldcaps:
@caps1:
@caps2:
@Returns:
@fromcaps:
@tocaps:
@caps:
@Returns:
@caps1:
@caps2:
@Returns:
@caps:
@parent:
@Returns:
@parent:
@Returns:
@caps1:
@caps2:
@Returns: