Class Mp3Decoder
- java.lang.Object
-
- com.sedmelluq.lava.common.natives.NativeResourceHolder
-
- com.sedmelluq.discord.lavaplayer.natives.mp3.Mp3Decoder
-
public class Mp3Decoder extends com.sedmelluq.lava.common.natives.NativeResourceHolderA wrapper around the native methods of OpusDecoderLibrary.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMp3Decoder.MpegVersion
-
Field Summary
Fields Modifier and Type Field Description static intHEADER_SIZEstatic longMPEG1_SAMPLES_PER_FRAMEstatic longMPEG2_SAMPLES_PER_FRAME
-
Constructor Summary
Constructors Constructor Description Mp3Decoder()Create a new instance of mp3 decoder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intdecode(java.nio.ByteBuffer directInput, java.nio.ShortBuffer directOutput)Encode the input buffer to output.protected voidfreeResources()static doublegetAverageFrameSize(byte[] buffer, int offset)Get the average frame size based on this framestatic intgetFrameChannelCount(byte[] buffer, int offset)Get the number of channels in the current framestatic intgetFrameSampleRate(byte[] buffer, int offset)Get the sample rate for the current framestatic intgetFrameSize(byte[] buffer, int offset)Get the frame size of the specified 4 bytesstatic intgetMaximumFrameSize()static longgetSamplesPerFrame(byte[] buffer, int offset)static booleanhasFrameSync(byte[] buffer, int offset)static booleanisUnsupportedVersion(byte[] buffer, int offset)static booleanisValidFrame(byte[] buffer, int offset)
-
-
-
Field Detail
-
MPEG1_SAMPLES_PER_FRAME
public static final long MPEG1_SAMPLES_PER_FRAME
- See Also:
- Constant Field Values
-
MPEG2_SAMPLES_PER_FRAME
public static final long MPEG2_SAMPLES_PER_FRAME
- See Also:
- Constant Field Values
-
HEADER_SIZE
public static final int HEADER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
decode
public int decode(java.nio.ByteBuffer directInput, java.nio.ShortBuffer directOutput)Encode the input buffer to output.- Parameters:
directInput- Input byte bufferdirectOutput- Output sample buffer- Returns:
- Number of samples written to the output
-
freeResources
protected void freeResources()
- Specified by:
freeResourcesin classcom.sedmelluq.lava.common.natives.NativeResourceHolder
-
getFrameSampleRate
public static int getFrameSampleRate(byte[] buffer, int offset)Get the sample rate for the current frame- Parameters:
buffer- Buffer which contains the frame headeroffset- Offset to the frame header- Returns:
- Sample rate
-
getFrameChannelCount
public static int getFrameChannelCount(byte[] buffer, int offset)Get the number of channels in the current frame- Parameters:
buffer- Buffer which contains the frame headeroffset- Offset to the frame header- Returns:
- Number of channels
-
hasFrameSync
public static boolean hasFrameSync(byte[] buffer, int offset)
-
isUnsupportedVersion
public static boolean isUnsupportedVersion(byte[] buffer, int offset)
-
isValidFrame
public static boolean isValidFrame(byte[] buffer, int offset)
-
getFrameSize
public static int getFrameSize(byte[] buffer, int offset)Get the frame size of the specified 4 bytes- Parameters:
buffer- Buffer which contains the frame headeroffset- Offset to the frame header- Returns:
- Frame size, or zero if not a valid frame header
-
getAverageFrameSize
public static double getAverageFrameSize(byte[] buffer, int offset)Get the average frame size based on this frame- Parameters:
buffer- Buffer which contains the frame headeroffset- Offset to the frame header- Returns:
- Average frame size, assuming CBR
-
getSamplesPerFrame
public static long getSamplesPerFrame(byte[] buffer, int offset)- Parameters:
buffer- Buffer which contains the frame headeroffset- Offset to the frame header- Returns:
- Number of samples per frame.
-
getMaximumFrameSize
public static int getMaximumFrameSize()
-
-