Package com.avpkit.core
Class ICodec
- java.lang.Object
-
- com.avpkit.ferry.RefCounted
-
- com.avpkit.core.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classICodec.CapabilitiesCapability flagsstatic classICodec.IDThese are the codecs this library currently supports.
These are based on FFMPEG Git versions with this HEAD:
6a97ba521558ce131fe839eed2d51ff745280e1dstatic classICodec.TypeThe different types of Codecs that can exist in the system.
-
Field Summary
-
Fields inherited from class com.avpkit.ferry.RefCounted
swigCMemOwn
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanDecode()Can this codec be used for decoding?booleancanEncode()Can this codec be used for encoding?ICodeccopyReference()Create a new ICodec object that is actually referring to the exact same underlying native object.booleanequals(java.lang.Object obj)Compares two values, returning true if the underlying objects in native code are the same object.static ICodecfindDecodingCodec(ICodec.ID id)Find a codec that can be used for decoding or
find a HW codec that can be used for decoding.static ICodecfindDecodingCodec(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.static ICodecfindDecodingCodecByIntID(int id)Find a codec that can be used for decoding.static ICodecfindDecodingCodecByName(java.lang.String id)Find a codec that can be used for decoding.static ICodecfindEncodingCodec(ICodec.ID id)Find a codec that can be used for encoding or
find a HW codec that can be used for encoding.static ICodecfindEncodingCodec(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.static ICodecfindEncodingCodecByIntID(int id)Find a codec that can be used for encoding.static ICodecfindEncodingCodecByName(java.lang.String id)Find a codec that can be used for encoding.intgetCapabilities()Get the capabilites flag from the codec
static longgetCPtr(ICodec obj)Internal Only.ICodec.IDgetID()Get the ID of this codec as an enumeration.intgetIDAsInt()Get the ID of this codec, as an integer.static ICodecgetInstalledCodec(int index)Get the {ICodec} at the given index.
static java.util.Collection<ICodec>getInstalledCodecs()Gets a collection of ALL codecs installed on this system.java.lang.StringgetLongName()Get the long name for this codec.
longgetMyCPtr()Internal Only.java.lang.StringgetName()Get the name of the codec.static intgetNumInstalledCodecs()Get the number of installed codecs on this system.intgetNumSupportedAudioChannelLayouts()Get the number of different audio channel layouts this codec supports
for encoding.intgetNumSupportedAudioSampleFormats()Get the number of different audio sample formats this codec supports
for encoding.intgetNumSupportedAudioSampleRates()Get the number of different audio sample rates this codec supports
for encoding.intgetNumSupportedVideoFrameRates()Get the number of frame rates this codec supports for encoding.
Not all codecs will report this number.intgetNumSupportedVideoPixelFormats()Get the number of supported video pixel formats this codec supports
for encoding.longgetSupportedAudioChannelLayout(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.java.util.List<java.lang.Long>getSupportedAudioChannelLayouts()Returns a list of supported audio channel layouts this codec can encode audio in.IAudioSamples.FormatgetSupportedAudioSampleFormat(int index)Get the supported sample format at this index.
java.util.List<IAudioSamples.Format>getSupportedAudioSampleFormats()Returns a list of supported audio sample formats this codec can encode audio in.intgetSupportedAudioSampleRate(int index)Return the support audio sample rate at the given index.
java.util.List<java.lang.Integer>getSupportedAudioSampleRates()Returns a list of supported audio sample rates this codec can encode audio in.IRationalgetSupportedVideoFrameRate(int index)Return the supported frame rate at the given index.
java.util.List<IRational>getSupportedVideoFrameRates()Returns a list of supported frame-rates this codec can encode video to.IPixelFormat.TypegetSupportedVideoPixelFormat(int index)Return the supported video pixel format at the given index.
java.util.List<IPixelFormat.Type>getSupportedVideoPixelFormats()Returns a list of supported pixel formats this codec can encode video in.ICodec.TypegetType()Get the type of this codec.static ICodecguessEncodingCodec(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.booleanhasCapability(ICodec.Capabilities capability)Convenience method to check individual capability flags.
inthashCode()Get a hashable value for this object.java.lang.StringtoString()Prints the type and id of this codec-
Methods inherited from class com.avpkit.ferry.RefCounted
acquire, delete, getCPtr, getCurrentRefCount, getJavaRefCount, release
-
-
-
-
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:
getMyCPtrin classRefCounted- 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:
copyReferencein classRefCounted- 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:
equalsin classjava.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:
hashCodein classjava.lang.Object- Returns:
- the hashable value.
-
toString
public java.lang.String toString()
Prints the type and id of this codec- Overrides:
toStringin classjava.lang.Object- Returns:
- the type and id
-
getInstalledCodecs
public static java.util.Collection<ICodec> getInstalledCodecs()
Gets a collection of ALL codecs installed on this system.- Returns:
- A collection of all installed codecs.
-
getSupportedVideoFrameRates
public java.util.List<IRational> getSupportedVideoFrameRates()
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.Type> getSupportedVideoPixelFormats()
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.Format> getSupportedAudioSampleFormats()
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}.
-
-