Class ICodec


  • public class ICodec
    extends RefCounted
    A "key" to an {IStreamCoder} that tells it how to encode or decode data.

    Use these objects to tell a IStreamCoder you want to use MP3 or NellyMoser
    for example.
    • Constructor Detail

      • ICodec

        protected ICodec​(long cPtr,
                         boolean cMemoryOwn)
        Internal Only.
      • ICodec

        protected ICodec​(long cPtr,
                         boolean cMemoryOwn,
                         java.util.concurrent.atomic.AtomicLong ref)
        Internal Only.
    • Method Detail

      • getCPtr

        public static long getCPtr​(ICodec obj)
        Internal Only. Not part of public API. Get the raw value of the native object that obj is proxying for.
        Parameters:
        obj - The java proxy object for a native object.
        Returns:
        The raw pointer obj is proxying for.
      • getMyCPtr

        public long getMyCPtr()
        Internal Only. Not part of public API. Get the raw value of the native object that we're proxying for.
        Overrides:
        getMyCPtr in class RefCounted
        Returns:
        The raw pointer we're proxying for.
      • copyReference

        public ICodec copyReference()
        Create a new ICodec object that is actually referring to the exact same underlying native object.
        Overrides:
        copyReference in class RefCounted
        Returns:
        the new Java object.
      • equals

        public boolean equals​(java.lang.Object obj)
        Compares two values, returning true if the underlying objects in native code are the same object. That means you can have two different Java objects, but when you do a comparison, you'll find out they are the EXACT same object.
        Overrides:
        equals in class java.lang.Object
        Returns:
        True if the underlying native object is the same. False otherwise.
      • hashCode

        public int hashCode()
        Get a hashable value for this object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashable value.
      • toString

        public java.lang.String toString()
        Prints the type and id of this codec
        Overrides:
        toString in class java.lang.Object
        Returns:
        the type and id
      • getInstalledCodecs

        public static java.util.Collection<ICodecgetInstalledCodecs()
        Gets a collection of ALL codecs installed on this system.
        Returns:
        A collection of all installed codecs.
      • getSupportedVideoFrameRates

        public java.util.List<IRationalgetSupportedVideoFrameRates()
        Returns a list of supported frame-rates this codec can encode video to.

        Not all codecs support reporting this, in which case the returned list will be empty.

        Returns:
        a list
      • getSupportedVideoPixelFormats

        public java.util.List<IPixelFormat.TypegetSupportedVideoPixelFormats()
        Returns a list of supported pixel formats this codec can encode video in.

        Not all codecs support reporting this, in which case the returned list will be empty.

        Returns:
        a list
      • getSupportedAudioSampleRates

        public java.util.List<java.lang.Integer> getSupportedAudioSampleRates()
        Returns a list of supported audio sample rates this codec can encode audio in.

        Not all codecs support reporting this, in which case the returned list will be empty.

        Returns:
        a list
      • getSupportedAudioSampleFormats

        public java.util.List<IAudioSamples.FormatgetSupportedAudioSampleFormats()
        Returns a list of supported audio sample formats this codec can encode audio in.

        Not all codecs support reporting this, in which case the returned list will be empty.

        Returns:
        a list
      • getSupportedAudioChannelLayouts

        public java.util.List<java.lang.Long> getSupportedAudioChannelLayouts()
        Returns a list of supported audio channel layouts this codec can encode audio in.

        Not all codecs support reporting this, in which case the returned list will be empty.

        Returns:
        a list
      • getName

        public java.lang.String getName()
        Get the name of the codec.
        Returns:
        The name of this Codec.
      • getIDAsInt

        public int getIDAsInt()
        Get the ID of this codec, as an integer.
        Returns:
        the ID of this codec, as an integer.
      • getID

        public ICodec.ID getID()
        Get the ID of this codec as an enumeration.
        Returns:
        the ID of this codec, an enum ID
      • getType

        public ICodec.Type getType()
        Get the type of this codec.
        Returns:
        The type of this Codec, as a enum Type
      • canDecode

        public boolean canDecode()
        Can this codec be used for decoding?
        Returns:
        Can this Codec decode?
      • canEncode

        public boolean canEncode()
        Can this codec be used for encoding?
        Returns:
        Can this Codec encode?
      • findEncodingCodec

        public static ICodec findEncodingCodec​(ICodec.ID id,
                                               IPixelFormat.Type arg1)
        Find a codec that can be used for encoding or
        find a HW codec that can be used for encoding.
        Parameters:
        id - The id of the codec

        Returns:
        the codec, or null if we can't find it.
      • findEncodingCodec

        public static ICodec findEncodingCodec​(ICodec.ID id)
        Find a codec that can be used for encoding or
        find a HW codec that can be used for encoding.
        Parameters:
        id - The id of the codec

        Returns:
        the codec, or null if we can't find it.
      • findEncodingCodecByIntID

        public static ICodec findEncodingCodecByIntID​(int id)
        Find a codec that can be used for encoding.
        Parameters:
        id - The id of the codec, as an integer.
        Returns:
        the codec, or null if we can't find it.
      • findEncodingCodecByName

        public static ICodec findEncodingCodecByName​(java.lang.String id)
        Find a codec that can be used for encoding.
        Parameters:
        id - The id of the codec, as a FFMPEG short-name string
        (for example, "mpeg4").
        Returns:
        the codec, or null if we can't find it.
      • findDecodingCodec

        public static ICodec findDecodingCodec​(ICodec.ID id,
                                               IPixelFormat.Type arg1)
        Find a codec that can be used for decoding or
        find a HW codec that can be used for decoding.
        Parameters:
        id - The id of the codec

        Returns:
        the codec, or null if we can't find it.
      • findDecodingCodec

        public static ICodec findDecodingCodec​(ICodec.ID id)
        Find a codec that can be used for decoding or
        find a HW codec that can be used for decoding.
        Parameters:
        id - The id of the codec

        Returns:
        the codec, or null if we can't find it.
      • findDecodingCodecByIntID

        public static ICodec findDecodingCodecByIntID​(int id)
        Find a codec that can be used for decoding.
        Parameters:
        id - The id of the codec, as an integer
        Returns:
        the codec, or null if we can't find it.
      • findDecodingCodecByName

        public static ICodec findDecodingCodecByName​(java.lang.String id)
        Find a codec that can be used for decoding.
        Parameters:
        id - The id of the codec, as a FFMPEG short-name string
        (for example, "mpeg4")
        Returns:
        the codec, or null if we can't find it.
      • guessEncodingCodec

        public static ICodec guessEncodingCodec​(IContainerFormat fmt,
                                                java.lang.String shortName,
                                                java.lang.String url,
                                                java.lang.String mimeType,
                                                ICodec.Type type)
        Ask us to guess an encoding codec based on the inputs
        passed in.


        You must pass in at least one non null fmt, shortName,
        url or mime_type.


        Parameters:
        fmt - An IContainerFormat for the container you'll want to encode into.
        shortName - The FFMPEG short name of the codec (e.g. "mpeg4").
        url - The URL you'll be writing packets to.
        mimeType - The mime type of the container.
        type - The codec type.
        Returns:
        the codec, or null if we can't find it.
      • getLongName

        public java.lang.String getLongName()
        Get the long name for this codec.

        Returns:
        the long name.
      • getCapabilities

        public int getCapabilities()
        Get the capabilites flag from the codec

        Returns:
        the capabilities flag
      • hasCapability

        public boolean hasCapability​(ICodec.Capabilities capability)
        Convenience method to check individual capability flags.

        Parameters:
        capability - the capability

        Returns:
        true if flag is set; false otherwise.
      • getNumInstalledCodecs

        public static int getNumInstalledCodecs()
        Get the number of installed codecs on this system.
        Returns:
        the number of installed codecs.
      • getInstalledCodec

        public static ICodec getInstalledCodec​(int index)
        Get the {ICodec} at the given index.

        Parameters:
        index - the index in our list

        Returns:
        the codec, or null if index < 0 or index >=
        {#getNumInstalledCodecs()}
      • getNumSupportedVideoFrameRates

        public int getNumSupportedVideoFrameRates()
        Get the number of frame rates this codec supports for encoding.
        Not all codecs will report this number.
        Returns:
        the number or 0 if we don't know.
      • getSupportedVideoFrameRate

        public IRational getSupportedVideoFrameRate​(int index)
        Return the supported frame rate at the given index.

        Parameters:
        index - the index in our list.

        Returns:
        the frame rate, or null if unknown, if index <0 or
        if index >= {#getNumSupportedVideoFrameRates()}
      • getNumSupportedVideoPixelFormats

        public int getNumSupportedVideoPixelFormats()
        Get the number of supported video pixel formats this codec supports
        for encoding. Not all codecs will report this.

        Returns:
        the number or 0 if we don't know.
      • getSupportedVideoPixelFormat

        public IPixelFormat.Type getSupportedVideoPixelFormat​(int index)
        Return the supported video pixel format at the given index.

        Parameters:
        index - the index in our list.

        Returns:
        the pixel format, or {IPixelFormat.Type#NONE} if unknown,
        if index <0 or
        if index >= {#getNumSupportedVideoPixelFormats()}
      • getNumSupportedAudioSampleRates

        public int getNumSupportedAudioSampleRates()
        Get the number of different audio sample rates this codec supports
        for encoding. Not all codecs will report this.

        Returns:
        the number or 0 if we don't know.
      • getSupportedAudioSampleRate

        public int getSupportedAudioSampleRate​(int index)
        Return the support audio sample rate at the given index.

        Parameters:
        index - the index in our list.

        Returns:
        the sample rate, or 0 if unknown, index < 0 or
        index >= {#getNumSupportedAudioSampleRates()}
      • getNumSupportedAudioSampleFormats

        public int getNumSupportedAudioSampleFormats()
        Get the number of different audio sample formats this codec supports
        for encoding. Not all codecs will report this.

        Returns:
        the number or 0 if we don't know.
      • getSupportedAudioSampleFormat

        public IAudioSamples.Format getSupportedAudioSampleFormat​(int index)
        Get the supported sample format at this index.

        Parameters:
        index - the index in our list.

        Returns:
        the format, or {IAudioSamples.Format.FMT_NONE} if
        unknown, index < 0 or index >=
        {#getNumSupportedAudioSampleFormats()}.
      • getNumSupportedAudioChannelLayouts

        public int getNumSupportedAudioChannelLayouts()
        Get the number of different audio channel layouts this codec supports
        for encoding. Not all codecs will report this.


        Returns:
        the number or 0 if we don't know.
      • getSupportedAudioChannelLayout

        public long getSupportedAudioChannelLayout​(int index)
        Get the supported audio channel layout at this index.

        The value returned is a bit flag representing the different
        types of audio layout this codec can support. Test the values
        by bit-comparing them to the {IAudioSamples.ChannelLayout}
        enum types.

        Parameters:
        index - the index

        Returns:
        the channel layout, or 0 if unknown, index < 0 or
        index >= {#getNumSupportedAudioChannelLayouts}.