
public class MediaAudio extends MediaSampled
The data described by the sample format is always in native-endian order.
The floating-point formats are based on full volume being in the range
[-1.0, 1.0]. Any values outside this range are beyond full volume level.
The data layout is as follows:
For planar sample formats, each audio channel is in a separate data plane,
and MediaAudio#getDataLineSize(int) is the buffer size, in bytes, for a single plane. All data
planes must be the same size. For packed sample formats, only the first data
plane is used, and samples for each channel are interleaved. In this case,
MediaAudio#getDataLineSize(int) is the buffer size, in bytes, for the 1 plane.
DEFAULT_TIME_STAMP_FORMAT| Modifier and Type | Method and Description |
|---|---|
MediaAudio |
copyReference()
Create a new MediaAudio object that is actually referring to the
exact same underlying native object.
|
boolean |
equals(Object obj)
Compares two values, returning true if the underlying objects in native code are the same object.
|
int |
getBytesPerSample()
Number of bytes in one sample of one channel of audio in this object.
|
AudioChannel.Layout |
getChannelLayout()
What is the channel layout of the audio in this buffer?
|
int |
getChannels()
Number of channels of audio in this object.
|
Buffer |
getData(int plane)
Get any underlying raw data available for this object.
|
int |
getDataPlaneSize(int plane)
The total number of bytes in #getData() that represent valid audio data.
If #isComplete() returns true, this returns the total number of bytes returned by #getData(int) that are readable from. |
AudioFormat.Type |
getFormat()
Format of audio in this object.
|
int |
getMaxNumSamples() |
int |
getNumDataPlanes()
Returns the number of data planes in this object.
|
int |
getNumSamples()
The number of samples in this frame of sampled data.
|
int |
getSampleRate()
Sample rate of audio, or 0 if unknown.
|
int |
hashCode()
Get a hashable value for this object.
|
boolean |
isComplete()
Does this object have complete data? If not, other methods may return unknown.
|
boolean |
isKey()
Was this audio decoded from a key packet?
|
boolean |
isPlanar()
Is audio laid out in a planar format?
|
static MediaAudio |
make(Buffer buffer,
int numSamples,
int sampleRate,
int channels,
AudioChannel.Layout channelLayout,
AudioFormat.Type format)
Create a MediaAudio using the given buffer.
Note: that the Buffer.getBufferSize() constraints the max number of samples we can place in here, and HumbleVideo needs to reserve some of the buffer for, um, stuff (assume at least 64 bytes). |
static MediaAudio |
make(int numSamples,
int sampleRate,
int channels,
AudioChannel.Layout channelLayout,
AudioFormat.Type format)
Create a MediaAudio and the underlying data.
|
static MediaAudio |
make(MediaAudio src,
boolean copy)
Create a MediaAudio by either referencing or copying another MediaAudio.
|
void |
setComplete(boolean complete)
Call this if you modify the samples and are now done.
|
void |
setNumSamples(int numSamples)
Set the number of samples in the buffer.
|
String |
toString() |
getBestEffortTimeStamp, getMetaData, getPacketDts, getPacketDuration, getPacketPts, getPacketSize, getPts, getTimeBase, getTimeStamp, setTimeBase, setTimeStampgetFormattedTimeStamp, getFormattedTimeStampdelete, getCurrentRefCountpublic MediaAudio copyReference()
copyReference in class MediaSampledpublic boolean equals(Object obj)
equals in class MediaSampledpublic int hashCode()
hashCode in class MediaSampledpublic static MediaAudio make(int numSamples, int sampleRate, int channels, AudioChannel.Layout channelLayout, AudioFormat.Type format)
numSamples - The number of samples of audio that will be placed in this MediaAudio object.sampleRate - The sample rate (per second) of this audio.channels - The number of channels of audio that will be placed in this MediaAudio object.format - The format of the audio placed in this MediaAudio object.public static MediaAudio make(Buffer buffer, int numSamples, int sampleRate, int channels, AudioChannel.Layout channelLayout, AudioFormat.Type format)
buffer - A buffer to back the audio with. If not large enough to hold all the samples (with alignment on 32-bit boundaries if planar),numSamples - The number of samples of audio that will be placed in this MediaAudio object.sampleRate - The sample rate (per second) of this audio.channels - The number of channels of audio that will be placed in this MediaAudio object.format - The format of the audio placed in this MediaAudio object.public static MediaAudio make(MediaAudio src, boolean copy)
This method is very useful when you want to change some meta-data about MediaAudio (such as
changing a timestamp) without effecting other users of the same underlying data.
It can also be useful to create a copy of the raw audio data in the buffers in the
event you are doing audio manipulation and do not want to effect other people
using the audio.
src - MediaAudio to referencecopy - true if we should copy all data. false if we should just gain a reference to the same underlying data in src.public Buffer getData(int plane)
plane - The plane number if getFormat() is Planar (rather than packed) audio. Pass zero for packed data.public int getDataPlaneSize(int plane)
public int getNumDataPlanes()
public int getMaxNumSamples()
public int getNumSamples()
MediaSampledgetNumSamples in class MediaSampledpublic void setNumSamples(int numSamples)
public int getBytesPerSample()
public void setComplete(boolean complete)
setComplete in class MediaRawcomplete - true if complete; false if not.Media.isComplete()public int getSampleRate()
public int getChannels()
public AudioFormat.Type getFormat()
public boolean isComplete()
isComplete in class Mediapublic boolean isKey()
public boolean isPlanar()
public AudioChannel.Layout getChannelLayout()
Copyright © 2018 Humble Software. All rights reserved.