Class AudioDecoderFactory

java.lang.Object
ej.audio.decoders.AudioDecoderFactory

public class AudioDecoderFactory extends Object
Factory class used to create AudioDecoder instances.

Decoders must be instantiated through create(InputStream, String, int[]). This factory provides several built-in AudioDecoder implementations, including PCM, G711, MP3, and Ogg Vorbis.

Additional decoders can be provided using the Java ServiceLoader mechanism. Such decoders must implement the AudioDecoder interface and be properly registered as services.

For non-built-in decoders, the concrete implementation is selected and instantiated based on its declared decoder name.

  • Method Details

    • create

      public static com.microej.audiomockdecoder.AudioDecoder create(InputStream inputStream, String formatEncoding, int[] formatParameters) throws ej.sni.NativeIOException
      Returns an instance of AudioDecoder depending on the formatEncoding.

      Provides dynamic loading of audio decoders using the Java ServiceLoader mechanism.

      This class loads implementations of AudioDecoder declared as services.

      The fully qualified name of each AudioDecoder implementation must be declared in META-INF/services/com.microej.audiomockdecoder.AudioDecoder.

      Parameters:
      inputStream - the InputStream required by the AudioDecoder
      formatEncoding - the String representing the encoding format (PCM, G711, MP3, Ogg Vorbis, ...)
      formatParameters - the int[] representing the format parameters; not used if the parameters are defined in the inputStream (MP3, Ogg Vorbis, ...)
      Returns:
      an instance of AudioDecoder
      Throws:
      ej.sni.NativeIOException - if the format parameters are incorrect or if the formatEncoding is unsupported