Class FdkAACLibFacade


  • public final class FdkAACLibFacade
    extends java.lang.Object
    • Method Detail

      • openEncoder

        public static AACEncoder openEncoder​(int modules,
                                             int maxChannels)
        Open (create) an AACEncoder.
        Parameters:
        modules - fdk-aac encoder modules bitmask
        maxChannels - the maximum number of expected audio channels
        Returns:
        an AACEncoder instance, populated by fdk-aac library.
        See Also:
        fdk-aac/libAACenc/src/aacenc_lib.cpp
      • closeEncoder

        public static void closeEncoder​(@Nonnull
                                        AACEncoder encoder)
        Close a previously opened AACEncoder.
        Parameters:
        encoder - an AACEncoder instance, previously opened by the fdk-aac library
      • initEncoder

        public static void initEncoder​(@Nonnull
                                       AACEncoder encoder)
        Initialize a previously opened AACEncoder.
        Parameters:
        encoder - an AACEncoder instance, previously opened by the fdk-aac library
      • encode

        public static java.util.Optional<byte[]> encode​(@Nonnull
                                                        AACEncoder encoder,
                                                        @Nonnull
                                                        AACEncBufDesc inBufferDescriptor,
                                                        @Nonnull
                                                        AACEncBufDesc outBufferDescriptor,
                                                        @Nonnull
                                                        AACEncInArgs inArgs,
                                                        @Nonnull
                                                        AACEncOutArgs outArgs,
                                                        int size)
        Encode raw (WAV) bytes to AAC.

        Most of the passed arguments are reused/pre-allocated outside of this function to mitigate memory-pressure effects.

        Parameters:
        encoder - an AACEncoder instance, previously opened and initialized by the fdk-aac library
        inBufferDescriptor - pre instantiated in-buffer descriptor used to hold input raw bytes
        outBufferDescriptor - pre instantiated out-buffer descriptor used to hold output encoded bytes
        inArgs - input encoder data structure
        outArgs - output encoder data structure
        size - input data size indicator
        Returns:
        the encoded AAC bytes, if any are present
      • getEncoderInfo

        public static AACEncInfo getEncoderInfo​(@Nonnull
                                                AACEncoder encoder)
        Get library information on a previously opened AACEncoder.
        Parameters:
        encoder - an AACEncoder instance, previously opened by the fdk-aac library
        Returns:
        the give encoder's information payload
      • outBufferDescriptor

        public static AACEncBufDesc outBufferDescriptor​(@Nonnull
                                                        com.sun.jna.Memory buffer)
        A utility function construct an out-buffer descriptor according to the fdk-aac library specifications.
        Parameters:
        buffer - a pre-allocated native memory region to be used by this descriptor
        Returns:
        an out-buffer descriptor structure
      • inBufferDescriptor

        public static AACEncBufDesc inBufferDescriptor​(@Nonnull
                                                       com.sun.jna.Memory buffer)
        A utility function construct an in-buffer descriptor according to the fdk-aac library specifications.
        Parameters:
        buffer - a pre-allocated native memory region to be used by this descriptor
        Returns:
        an in-buffer descriptor structure