public final class SampleHolder extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_REPLACEMENT_MODE_DIRECT
Allows buffer replacement using
ByteBuffer.allocateDirect(int) . |
static int |
BUFFER_REPLACEMENT_MODE_DISABLED
Disallows buffer replacement.
|
static int |
BUFFER_REPLACEMENT_MODE_NORMAL
Allows buffer replacement using
ByteBuffer.allocate(int) . |
CryptoInfo |
cryptoInfo |
ByteBuffer |
data
A buffer holding the sample data.
|
int |
flags
Flags that accompany the sample.
|
int |
size
The size of the sample in bytes.
|
long |
timeUs
The time at which the sample should be presented.
|
Constructor and Description |
---|
SampleHolder(int bufferReplacementMode) |
Modifier and Type | Method and Description |
---|---|
void |
clearData()
Clears
data . |
void |
ensureSpaceForWrite(int length)
Ensures that
data is large enough to accommodate a write of a given length at its
current position. |
boolean |
isDecodeOnly()
Returns whether
flags has C.SAMPLE_FLAG_DECODE_ONLY set. |
boolean |
isEncrypted()
Returns whether
flags has C.SAMPLE_FLAG_ENCRYPTED set. |
boolean |
isSyncFrame()
Returns whether
flags has C.SAMPLE_FLAG_SYNC set. |
public static final int BUFFER_REPLACEMENT_MODE_DISABLED
public static final int BUFFER_REPLACEMENT_MODE_NORMAL
ByteBuffer.allocate(int)
.public static final int BUFFER_REPLACEMENT_MODE_DIRECT
ByteBuffer.allocateDirect(int)
.public final CryptoInfo cryptoInfo
public ByteBuffer data
public int size
public int flags
C.SAMPLE_FLAG_SYNC
,
C.SAMPLE_FLAG_ENCRYPTED
and C.SAMPLE_FLAG_DECODE_ONLY
.public long timeUs
public SampleHolder(int bufferReplacementMode)
bufferReplacementMode
- Determines the behavior of ensureSpaceForWrite(int)
. One
of BUFFER_REPLACEMENT_MODE_DISABLED
, BUFFER_REPLACEMENT_MODE_NORMAL
and
BUFFER_REPLACEMENT_MODE_DIRECT
.public void ensureSpaceForWrite(int length) throws IllegalStateException
data
is large enough to accommodate a write of a given length at its
current position.
If the capacity of data
is sufficient this method does nothing. If the capacity is
insufficient then an attempt is made to replace data
with a new ByteBuffer
whose capacity is sufficient. Data up to the current position is copied to the new buffer.
length
- The length of the write that must be accommodated, in bytes.IllegalStateException
- If there is insufficient capacity to accommodate the write and
the buffer replacement mode of the holder is BUFFER_REPLACEMENT_MODE_DISABLED
.public boolean isEncrypted()
flags
has C.SAMPLE_FLAG_ENCRYPTED
set.public boolean isDecodeOnly()
flags
has C.SAMPLE_FLAG_DECODE_ONLY
set.public boolean isSyncFrame()
flags
has C.SAMPLE_FLAG_SYNC
set.public void clearData()