public class Caps extends RefCountedObject
Caps (capabilities) are lightweight objects describing media types.
They are composed of an array of Structure
.
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(org.gstreamer.Caps)
. 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
Modifier and Type | Field and Description |
---|---|
static String |
GTYPE_NAME |
defaultInit, ownsHandle
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(NativeObject.Initializer init) |
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.
|
protected void |
disposeNativeHandle(com.sun.jna.Pointer ptr) |
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. |
protected static NativeObject.Initializer |
initializer(com.sun.jna.Pointer ptr) |
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.
|
void |
merge(Caps other)
Merge another
Caps with this one. |
void |
merge(Structure structure)
Append a structure to this caps.
|
Caps |
normalize()
Normalize the Caps.
|
protected void |
ref() |
void |
removeStructure(int index)
Remove a struture from the caps.
|
void |
setInteger(String field,
Integer value) |
boolean |
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() |
void |
truncate()
Destructively discard all but the first structure from this caps.
|
Caps |
union(Caps other)
Creates a new
Caps that contains all the formats that are in
either this Caps or the other Caps. |
protected void |
unref() |
classFor, disown, dispose, finalize, getNativeAddress, handle, hashCode, initializer, instanceFor, invalidate, isDisposed, nativeValue, objectFor, objectFor, objectFor, objectFor
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 Caps(Caps caps)
caps
- The caps to copy.copy()
public Caps(NativeObject.Initializer init)
public static Caps emptyCaps()
public static Caps anyCaps()
public static Caps fromString(String caps)
Caps caps = Caps.fromString("video/x-raw-rgb, bpp=32, depth=24, width=640, height=480");
caps
- The string representation of the caps.protected static NativeObject.Initializer initializer(com.sun.jna.Pointer ptr)
public int size()
public Caps copy()
public Caps union(Caps other)
Caps
that contains all the formats that are in
either this Caps or the other Caps.public Caps intersect(Caps other)
Caps
that contains all the formats that are common
to both this Caps and the other Caps.public Caps subtract(Caps subtrahend)
subtrahend
- The Caps
to subtract.public Caps normalize()
public boolean simplify()
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 void removeStructure(int index)
index
- Index of the structure to remove.public void merge(Caps other)
Caps
with this one.
Appends the structures contained in the other Caps to this one, if they are not yet expressed by this Caps.
The structures in other are not copied, they are transferred to this Caps, and then other is freed.
If either caps is ANY, the resulting caps will be ANY.
Do not use the argument after calling this method, as the native peer is no longer valid.
other
- The other Caps
to merge.public void merge(Structure structure)
structure
- The structure to merge.public 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.
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 void truncate()
public String toString()
toString
in class NativeObject
public boolean isAny()
public boolean isEmpty()
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 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 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 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 equals(Object other)
equals
in class NativeObject
protected void ref()
ref
in class RefCountedObject
protected void unref()
unref
in class RefCountedObject
protected void disposeNativeHandle(com.sun.jna.Pointer ptr)
disposeNativeHandle
in class NativeObject
Copyright © 2016. All rights reserved.