Class AbstractFFmpegAudioCodec

  • All Implemented Interfaces:
    javax.media.Codec, javax.media.Controls, javax.media.PlugIn
    Direct Known Subclasses:
    FFmpegAudioDecoder, FFmpegAudioEncoder

    public abstract class AbstractFFmpegAudioCodec
    extends AbstractCodec2
    Implements an audio Codec using the FFmpeg library.
    Author:
    Lyubomir Marinov
    • Field Detail

      • avctx

        protected long avctx
        The AVCodecContext which performs the actual encoding/decoding and which is the native counterpart of this open AbstractFFmpegAudioCodec.
      • codecID

        protected final int codecID
        The AVCodecID of avctx.
      • frameSizeInBytes

        protected int frameSizeInBytes
        The number of bytes of audio data to be encoded with a single call to FFmpeg.avcodec_encode_audio(long, byte[], int, int, byte[], int) based on the frame_size of avctx.
    • Constructor Detail

      • AbstractFFmpegAudioCodec

        protected AbstractFFmpegAudioCodec​(String name,
                                           int codecID,
                                           javax.media.Format[] supportedOutputFormats)
        Initializes a new AbstractFFmpegAudioCodec instance with a specific PlugIn name, a specific AVCodecID, and a specific list of Formats supported as output.
        Parameters:
        name - the PlugIn name of the new instance
        codecID - the AVCodecID of the FFmpeg codec to be represented by the new instance
        supportedOutputFormats - the list of Formats supported by the new instance as output
    • Method Detail

      • codecIDToString

        public static String codecIDToString​(int codecID)
        Returns a String representation of a specific AVCodecID.
        Parameters:
        codecID - the AVCodecID to represent as a String
        Returns:
        a String representation of the specified codecID
      • configureAVCodecContext

        protected void configureAVCodecContext​(long avctx,
                                               javax.media.format.AudioFormat format)
        Configures the AVCodecContext initialized in doOpen() prior to invoking one of the FFmpeg functions in the avcodec_open family. Allows extenders to override and provide additional, optional configuration.
        Parameters:
        avctx - the AVCodecContext to configure
        format - the AudioFormat with which avctx is being configured
      • doOpen

        protected void doOpen()
                       throws javax.media.ResourceUnavailableException
        Opens this Codec and acquires the resources that it needs to operate. A call to PlugIn.open() on this instance will result in a call to doOpen only if AbstractCodec.opened is false. All required input and/or output formats are assumed to have been set on this Codec before doOpen is called.
        Specified by:
        doOpen in class AbstractCodec2
        Throws:
        javax.media.ResourceUnavailableException - if any of the resources that this Codec needs to operate cannot be acquired
      • findAVCodec

        protected abstract long findAVCodec​(int codecID)
        Finds an AVCodec with a specific AVCodecID. The method is invoked by doOpen() in order to (eventually) open a new AVCodecContext.
        Parameters:
        codecID - the AVCodecID of the AVCodec to find
        Returns:
        an AVCodec with the specified codecID or 0
      • getAVCodecContextFormat

        protected abstract javax.media.format.AudioFormat getAVCodecContextFormat()
        Gets the AudioFormat with which avctx is to be configured and opened by doOpen().
        Returns:
        the AudioFormat with which avctx is to be configured and opened by doOpen()