public class Caps extends MiniObject
Caps (capabilities) are lightweight objects describing media types. They are
composed of an array of Structure
.
See upstream documentation at https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstCaps.html
Caps are exposed on PadTemplate
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 Pad#getCaps
method.
This method describes the possible types that the pad can handle or produce
at runtime.
Caps are also attached to buffers to describe the content of the data pointed
to by the buffer with Buffer#setCaps
. Caps attached to a
Buffer
allow for format negotiation upstream and downstream.
A Caps can be constructed with the following code fragment:
Caps caps = Caps.fromString("video/x-raw-rgb, bpp=32, depth=24, width=640, height=480");
A Caps is fixed when it has no properties with ranges or lists. Use
isFixed()
to test for fixed caps. Only fixed caps can be set on a
Pad
or Buffer
.
Various methods exist to work with the media types such as subtracting or intersecting.
Structure
NativeObject.Initializer, NativeObject.TypeProvider, NativeObject.TypeRegistration<T extends NativeObject>
Modifier and Type | Field and Description |
---|---|
static String |
GTYPE_NAME |
Constructor and Description |
---|
Caps()
Creates a new Caps that is empty.
|
Caps(Caps caps)
Create a caps that is a copy of another caps.
|
Caps(String caps)
Construct a new Caps from a string representation.
|
Modifier and Type | Method and Description |
---|---|
static Caps |
anyCaps()
Creates a new Caps that indicates that it is compatible with any media
format.
|
void |
append(Caps caps)
Append the structures contained in caps to this caps object.
|
void |
append(Structure struct)
Append structure to this caps.
|
Caps |
copy()
Create a new Caps as a copy of the this caps.
|
static Caps |
emptyCaps()
Creates a new Caps that is empty.
|
boolean |
equals(Object other) |
static Caps |
fromString(String caps)
Construct a new Caps from a string representation.
|
Structure |
getStructure(int index)
Get a
Structure contained in this caps. |
Caps |
intersect(Caps other)
Creates a new
Caps that contains all the formats that are common
to both this Caps and the other Caps. |
boolean |
isAlwaysCompatible(Caps other)
Check if this caps is always compatible with another caps.
|
boolean |
isAny()
Determine if this caps represents any media format.
|
boolean |
isEmpty()
Determine if this caps represents no media formats.
|
boolean |
isEqual(Caps other)
Checks if the given caps represent the same set of caps.
|
boolean |
isEqualFixed(Caps other)
Tests if two Caps are equal.
|
boolean |
isFixed()
Determine if this caps is fixed.
|
boolean |
isSubset(Caps superset)
Checks if all caps represented by this caps are also represented by
superset.
|
Caps |
makeWritable()
Returns a writable copy of this caps.
|
static Caps |
merge(Caps caps1,
Caps caps2)
Merge two
Caps together. |
Caps |
normalize()
Normalize the Caps.
|
void |
removeStructure(int index)
Remove a structure from the caps.
|
void |
setInteger(String field,
Integer value) |
Caps |
simplify()
Modifies this caps inplace into a representation that represents the same
set of formats, but in a simpler form.
|
int |
size()
Get the number of structures contained in this caps.
|
Caps |
subtract(Caps subtrahend)
Subtracts the subtrahend Caps from this Caps.
|
String |
toString() |
Caps |
truncate()
Destructively discard all but the first structure from this caps.
|
getRefCount, isWritable
close, disown, dispose, getPointer, getRawPointer, hashCode, invalidate
public static final String GTYPE_NAME
public Caps()
emptyCaps()
public Caps(String caps)
caps
- The string representation of the caps.fromString(java.lang.String)
public void append(Caps caps)
If either caps is ANY, the resulting caps will be ANY.
caps
- The Caps to appendpublic void append(Structure struct)
struct
- The structure to append.public Caps copy()
copy
in class MiniObject
public boolean equals(Object other)
equals
in class NativeObject
public Structure getStructure(int index)
Structure
contained in this caps.
Finds the structure in @caps that has the index @index, and returns it.index
- The index of the structure to get.public Caps intersect(Caps other)
Caps
that contains all the formats that are common
to both this Caps and the other Caps.public boolean isAlwaysCompatible(Caps other)
A given Caps structure is always compatible with another if every media format that is in the first is also contained in the second. That is, this caps1 is a subset of other.
other
- The caps to test against.public boolean isAny()
public boolean isEmpty()
public boolean isEqual(Caps other)
This function does not work reliably if optional properties for caps are included on one caps and omitted on the other.
other
- The caps to compare this caps to.public boolean isEqualFixed(Caps other)
other
- The other caps to test against.public boolean isFixed()
Fixed 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.
public boolean isSubset(Caps superset)
This function does not work reliably if optional properties for caps are included on one caps and omitted on the other.
superset
- The potentially greater Capspublic Caps makeWritable()
This method will invalidate the native side of this caps object, so it should not be used after calling this method, and only the returned Caps object should be used.
makeWritable
in class MiniObject
public Caps normalize()
public void removeStructure(int index)
index
- Index of the structure to remove.public Caps simplify()
Caps
public int size()
public Caps subtract(Caps subtrahend)
subtrahend
- The Caps
to subtract.public String toString()
toString
in class NativeObject
public Caps truncate()
public static Caps anyCaps()
public static Caps emptyCaps()
public static Caps fromString(String caps)
Caps caps = Caps.fromString("video/x-raw, format=RGB, bpp=32, depth=24, width=640, height=480");
caps
- The string representation of the caps.public static Caps merge(Caps caps1, Caps caps2)
Caps
together.
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.
Copyright © 2019 gstreamer-java. All rights reserved.