Class Mp3Decoder


  • public class Mp3Decoder
    extends com.sedmelluq.lava.common.natives.NativeResourceHolder
    A wrapper around the native methods of OpusDecoderLibrary.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Mp3Decoder.MpegVersion  
    • 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
      int decode​(java.nio.ByteBuffer directInput, java.nio.ShortBuffer directOutput)
      Encode the input buffer to output.
      protected void freeResources()  
      static double getAverageFrameSize​(byte[] buffer, int offset)
      Get the average frame size based on this frame
      static int getFrameChannelCount​(byte[] buffer, int offset)
      Get the number of channels in the current frame
      static int getFrameSampleRate​(byte[] buffer, int offset)
      Get the sample rate for the current frame
      static int getFrameSize​(byte[] buffer, int offset)
      Get the frame size of the specified 4 bytes
      static int getMaximumFrameSize()  
      static long getSamplesPerFrame​(byte[] buffer, int offset)  
      static boolean hasFrameSync​(byte[] buffer, int offset)  
      static boolean isUnsupportedVersion​(byte[] buffer, int offset)  
      static boolean isValidFrame​(byte[] buffer, int offset)  
      • Methods inherited from class com.sedmelluq.lava.common.natives.NativeResourceHolder

        checkNotReleased, close, finalize
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Mp3Decoder

        public Mp3Decoder()
        Create a new instance of mp3 decoder
    • Method Detail

      • decode

        public int decode​(java.nio.ByteBuffer directInput,
                          java.nio.ShortBuffer directOutput)
        Encode the input buffer to output.
        Parameters:
        directInput - Input byte buffer
        directOutput - Output sample buffer
        Returns:
        Number of samples written to the output
      • freeResources

        protected void freeResources()
        Specified by:
        freeResources in class com.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 header
        offset - 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 header
        offset - 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 header
        offset - 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 header
        offset - 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 header
        offset - Offset to the frame header
        Returns:
        Number of samples per frame.
      • getMaximumFrameSize

        public static int getMaximumFrameSize()