public class SampleBuffer extends Object
| Modifier and Type | Method and Description |
|---|---|
static SampleBuffer |
allocate(int capacity,
int sampleType,
ByteOrder byteOrder,
long presentationTimeUs)
Allocates a new sample buffer.
|
static SampleBuffer |
allocate(int capacity,
int sampleType,
int channelCount,
ByteOrder byteOrder,
long presentationTimeUs)
Allocates a new sample buffer.
|
int |
capacity()
Returns the capacity of the buffer per channel.
|
double |
get()
Returns the sample of the current position and then increments the position.
|
double |
get(int index)
Returns the sample from the given index in the buffer.
|
ByteBuffer |
getByteBuffer()
Returns the raw byte buffer managed by this sample buffer.
|
byte[] |
getBytes()
Returns a copy of the bytes from position 0 to the current limit.
|
long |
getPresentationTimeUs()
The presentation time of this sample buffer.
|
int |
limit()
Returns the number of samples in the buffer per channel.
|
void |
limit(int newLimit)
Sets the number of samples in the buffer to the new limit.
|
int |
position()
Returns the current position in the buffer per channel.
|
void |
position(int newPosition)
Sets the position of the sample buffer to the new index.
|
void |
put(double sample)
Puts a sample to the current position and increments the position.
|
void |
put(int index,
double sample)
Puts a sample to the given index in the buffer.
|
static SampleBuffer |
wrap(ByteBuffer buffer,
int sampleType,
int channelCount,
long presentationTimeUs)
Wraps a raw byte buffer to a new sample buffer.
|
static SampleBuffer |
wrap(ByteBuffer buffer,
int sampleType,
long presentationTimeUs)
Wraps a raw (mono) byte buffer to a new sample buffer.
|
public static SampleBuffer wrap(ByteBuffer buffer, int sampleType, long presentationTimeUs)
buffer - The raw buffer to be wrapped.sampleType - The sample type of the samples in the raw buffer.presentationTimeUs - The presentation time of the buffer.public static SampleBuffer wrap(ByteBuffer buffer, int sampleType, int channelCount, long presentationTimeUs)
buffer - The raw buffer to be wrapped.sampleType - The sample type of the samples in the raw buffer.channelCount - The number of channels (1 = mono, 2 = stereo).presentationTimeUs - The presentation time of the buffer.public static SampleBuffer allocate(int capacity, int sampleType, ByteOrder byteOrder, long presentationTimeUs)
capacity - The specified sample capacity of the sample buffer.sampleType - The sample type of the samples the buffer should store.byteOrder - The byte order for the samples (little or big endian).presentationTimeUs - The presentation time for the buffer.public static SampleBuffer allocate(int capacity, int sampleType, int channelCount, ByteOrder byteOrder, long presentationTimeUs)
capacity - The specified sample capacity of the sample buffer.sampleType - The sample type of the samples the buffer should store.channelCount - The number of channels (1 = mono, 2 = stereo).byteOrder - The byte order for the samples (little or big endian).presentationTimeUs - The presentation time for the buffer.public int capacity()
public int limit()
public void limit(int newLimit)
newLimit - The new limit of the sample buffer.public int position()
public void position(int newPosition)
newPosition - The new position of the sample buffer.public double get()
public double get(int index)
index - The index of the sample requested.public void put(double sample)
sample - The sample to put into the buffer.public void put(int index,
double sample)
index - The index to put the sample.sample - The sample to store in the buffer.public ByteBuffer getByteBuffer()
public byte[] getBytes()
public long getPresentationTimeUs()