Class OpusDecoder


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

      Constructors 
      Constructor Description
      OpusDecoder​(int sampleRate, int channels)  
    • 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 int getPacketFrameSize​(int sampleRate, byte[] buffer, int offset, int length)
      Get the frame size from an opus packet
      • 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

      • OpusDecoder

        public OpusDecoder​(int sampleRate,
                           int channels)
        Parameters:
        sampleRate - Input sample rate
        channels - Channel count
    • 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 bytes written to the output
      • freeResources

        protected void freeResources()
        Specified by:
        freeResources in class com.sedmelluq.lava.common.natives.NativeResourceHolder
      • getPacketFrameSize

        public static int getPacketFrameSize​(int sampleRate,
                                             byte[] buffer,
                                             int offset,
                                             int length)
        Get the frame size from an opus packet
        Parameters:
        sampleRate - The sample rate of the packet
        buffer - The buffer containing the packet
        offset - Packet offset in the buffer
        length - Packet length in the buffer
        Returns:
        Frame size