Class (GI Struct)

Gst-1.0GstCaps

Caps (capabilities) are lightweight refcounted objects describing media types. They are composed of an array of Gst.Structure.

Caps are exposed on Gst.PadTemplate 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_query_caps() pad function. This function describes the possible types that the pad can handle or produce at runtime.

A Gst.Caps can be constructed with the following code fragment:

  GstCaps *caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, "I420",
"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 fields with ranges or lists. Use gst_caps_is_fixed() to test for fixed caps. Fixed caps can be used in a caps event to notify downstream elements of the current media type.

Various methods exist to work with the media types such as subtracting or intersecting.

Be aware that until 1.20 the Gst.Caps / Gst.Structure serialization into string had limited support for nested Gst.Caps / Gst.Structure fields. It could only support one level of nesting. Using more levels would lead to unexpected behavior when using serialization features, such as gst_caps_to_string() or gst_value_serialize() and their counterparts.

Index

Constructors

Properties

$gtype: GType<Gst.Caps>

Methods

  • 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.

    Parameters

    Returns void

  • Tries intersecting caps1 and caps2 and reports whether the result would not be empty

    Parameters

    Returns boolean

    true if intersection would be not empty

  • Creates a new Gst.Caps 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().

    Returns Gst.Caps

    the new Gst.Caps

  • Calls the provided function once for each structure and caps feature in the Gst.Caps. In contrast to gst_caps_foreach(), the function may modify the structure and features. In contrast to gst_caps_map_in_place(), the structure and features are removed from the caps if false is returned from the function. The caps must be mutable.

    Parameters

    Returns void

  • Modifies the given caps into a representation with only fixed values. First the caps will be truncated and then the first structure will be fixated with gst_structure_fixate().

    This function takes ownership of caps and will call gst_caps_make_writable() on it so you must not use caps afterwards unless you keep an additional reference to it with gst_caps_ref().

    Note that it is not guaranteed that the returned caps have exactly one structure. If caps are empty caps then the returned caps will be the empty too and contain no structure at all.

    Calling this function with ANY caps is not allowed.

    Returns Gst.Caps

    the fixated caps

  • Calls the provided function once for each structure and caps feature in the Gst.Caps. The function must not modify the fields. Also see gst_caps_map_in_place() and gst_caps_filter_and_map_in_place().

    Parameters

    Returns boolean

    true if the supplied function returns true for each call, false otherwise.

  • Finds the features in caps at index, and returns it.

    WARNING: This function takes a const GstCaps *, but returns a non-const GstCapsFeatures *. This is for programming convenience -- the caller should be aware that features inside a constant Gst.Caps should not be modified. However, if you know the caps are writable, either because you have just copied them or made them writable with gst_caps_make_writable(), you may modify the features returned in the usual way, e.g. with functions like gst_caps_features_add().

    Parameters

    • index: number

      the index of the structure

    Returns CapsFeatures

    a pointer to the Gst.CapsFeatures corresponding to index

  • Gets the number of structures contained in caps.

    Returns number

    the number of structures that caps contains

  • Finds the structure in caps at 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. However, if you know the caps are writable, either because you have just copied them or made them writable with gst_caps_make_writable(), you may modify the structure returned in the usual way, e.g. with functions like gst_structure_set().

    Parameters

    • index: number

      the index of the structure

    Returns Structure

    a pointer to the Gst.Structure corresponding to index

  • Sets the given field on all structures of caps to the given value. This is a convenience function for calling gst_structure_set_value() on all structures of caps.

    Parameters

    • field: IdStr

      name of the field to set

    • value: any

      value to set the field to

    Returns void

  • 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.

    Parameters

    Returns boolean

    true if caps1 is a subset of caps2.

  • Determines if caps represents any media format.

    Returns boolean

    true if caps represents any format.

  • Determines if caps represents no media formats.

    Returns boolean

    true if caps represents no formats.

  • 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.

    Returns boolean

    true if caps is fixed

  • Checks if all caps represented by subset are also represented by superset.

    Parameters

    Returns boolean

    true if subset is a subset of superset

  • Checks if structure is a subset of caps. See gst_caps_is_subset() for more information.

    Parameters

    Returns boolean

    true if structure is a subset of caps

  • Calls the provided function once for each structure and caps feature in the Gst.Caps. In contrast to gst_caps_foreach(), the function may modify but not delete the structures and features. The caps must be mutable.

    Parameters

    Returns boolean

    true if the supplied function returns true for each call, false otherwise.

  • 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 a writable copy of caps1, and then caps2 is freed. If either caps is ANY, the resulting caps will be ANY.

    Parameters

    Returns Gst.Caps

    the merged caps.

  • Returns a Gst.Caps that represents the same set of formats as caps, but contains no lists. Each list is expanded into separate Gst.Structure.

    This function takes ownership of caps and will call gst_caps_make_writable() on it so you must not use caps afterwards unless you keep an additional reference to it with gst_caps_ref().

    Returns Gst.Caps

    the normalized Gst.Caps

  • Removes the structure with the given index from the list of structures contained in caps.

    Parameters

    • idx: number

      Index of the structure to remove

    Returns void

  • Converts caps to a string representation. This string representation can be converted back to a Gst.Caps by gst_caps_from_string().

    This prints the caps in human readable form.

    This version of the caps serialization function introduces support for nested structures and caps but the resulting strings won't be parsable with GStreamer prior to 1.20 unless #GST_SERIALIZE_FLAG_BACKWARD_COMPAT is passed as flag.

    Returns string

    a newly allocated string representing caps.

  • Sets the given field on all structures of caps to the given value. This is a convenience function for calling gst_structure_set_value() on all structures of caps.

    Parameters

    • field: string

      name of the field to set

    • value: any

      value to set the field to

    Returns void

  • Sets the given field on all structures of caps to the given value. This is a convenience function for calling gst_structure_set_value() on all structures of caps.

    field needs to be valid for the remaining lifetime of the process, e.g. has to be a static string.

    Parameters

    • field: string

      name of the field to set

    • value: any

      value to set the field to

    Returns void

  • Converts the given caps 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.

    This function takes ownership of caps and will call gst_caps_make_writable() on it if necessary, so you must not use caps afterwards unless you keep an additional reference to it with gst_caps_ref().

    This method does not preserve the original order of caps.

    Returns Gst.Caps

    The simplified caps.

  • Retrieves the structure with the given index from the list of structures contained in caps. The caller becomes the owner of the returned structure.

    Parameters

    • index: number

      Index of the structure to retrieve

    Returns Structure

    a pointer to the Gst.Structure corresponding to index.

  • 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.

    Parameters

    Returns Gst.Caps

    the resulting caps

  • Converts caps to a string representation. This string representation can be converted back to a Gst.Caps 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 readable form.

    The implementation of serialization up to 1.20 would lead to unexpected results when there were nested Gst.Caps / Gst.Structure deeper than one level.

    Returns string

    a newly allocated string representing caps.

  • Discards all but the first structure from caps. Useful when fixating.

    This function takes ownership of caps and will call gst_caps_make_writable() on it if necessary, so you must not use caps afterwards unless you keep an additional reference to it with gst_caps_ref().

    Note that it is not guaranteed that the returned caps have exactly one structure. If caps is any or empty caps then the returned caps will be the same and contain no structure at all.

    Returns Gst.Caps

    truncated caps