Class AacDecoder
- java.lang.Object
-
- com.sedmelluq.lava.common.natives.NativeResourceHolder
-
- com.sedmelluq.discord.lavaplayer.natives.aac.AacDecoder
-
public class AacDecoder extends com.sedmelluq.lava.common.natives.NativeResourceHolderA wrapper around the native methods of AacDecoder, which uses fdk-aac native library. Supports data with no transport layer. The only AAC type verified to work with this is AAC_LC.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAacDecoder.StreamInfoAAC stream information.
-
Constructor Summary
Constructors Constructor Description AacDecoder()Create a new decoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intconfigure(byte[] config)Configure the decoder.intconfigure(int objectType, int frequency, int channels)Configure the decoder.booleandecode(java.nio.ShortBuffer buffer, boolean flush)Decode a frame of audio into the given buffer.intfill(java.nio.ByteBuffer buffer)Fill the internal decoding buffer with the bytes from the buffer.protected voidfreeResources()AacDecoder.StreamInforesolveStreamInfo()
-
-
-
Field Detail
-
AAC_LC
public static final int AAC_LC
- See Also:
- Constant Field Values
-
SBR
public static final int SBR
- See Also:
- Constant Field Values
-
PS
public static final int PS
- See Also:
- Constant Field Values
-
-
Method Detail
-
configure
public int configure(int objectType, int frequency, int channels)Configure the decoder. Must be called before the first decoding.- Parameters:
objectType- Audio object type as defined for Audio Specific Config: https://wiki.multimedia.cx/index.php?title=MPEG-4_Audiofrequency- Frequency of samples in Hzchannels- Number of channels.- Throws:
java.lang.IllegalStateException- If the decoder has already been closed.
-
configure
public int configure(byte[] config)
Configure the decoder. Must be called before the first decoding.- Parameters:
config- Raw ASC format configuration- Throws:
java.lang.IllegalStateException- If the decoder has already been closed.
-
fill
public int fill(java.nio.ByteBuffer buffer)
Fill the internal decoding buffer with the bytes from the buffer. May consume less bytes than the buffer provides.- Parameters:
buffer- DirectBuffer which contains the bytes to be added. Position and limit are respected and position is updated as a result of this operation.- Returns:
- The number of bytes consumed from the provided buffer.
- Throws:
java.lang.IllegalArgumentException- If the buffer is not a DirectBuffer.java.lang.IllegalStateException- If the decoder has already been closed.
-
decode
public boolean decode(java.nio.ShortBuffer buffer, boolean flush)Decode a frame of audio into the given buffer.- Parameters:
buffer- DirectBuffer of signed PCM samples where the decoded frame will be stored. The buffer size must be at least of sizeframeSize * channels * 2. Buffer position and limit are ignored and not updated.flush- Whether all the buffered data should be flushed, set to true if no more input is expected.- Returns:
- True if the frame buffer was filled, false if there was not enough input for decoding a full frame.
- Throws:
java.lang.IllegalArgumentException- If the buffer is not a DirectBuffer.java.lang.IllegalStateException- If the decoding library returns an error other than running out of input data.java.lang.IllegalStateException- If the decoder has already been closed.
-
resolveStreamInfo
public AacDecoder.StreamInfo resolveStreamInfo()
- Returns:
- Correct stream info. The values passed to configure method do not account for SBR and PS and detecting these is a part of the decoding process. If there was not enough input for decoding a full frame, null is returned.
- Throws:
java.lang.IllegalStateException- If the decoder result produced an unexpected error.
-
freeResources
protected void freeResources()
- Specified by:
freeResourcesin classcom.sedmelluq.lava.common.natives.NativeResourceHolder
-
-