Class DefaultCodec
- java.lang.Object
-
- com.google.android.exoplayer2.transformer.DefaultCodec
-
- All Implemented Interfaces:
Codec
@Deprecated public final class DefaultCodec extends Object implements Codec
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.A defaultCodec
implementation that usesMediaCodec
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.transformer.Codec
Codec.DecoderFactory, Codec.EncoderFactory
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_PCM_ENCODING
Deprecated.
-
Constructor Summary
Constructors Constructor Description DefaultCodec(Context context, Format configurationFormat, MediaFormat configurationMediaFormat, String mediaCodecName, boolean isDecoder, Surface outputSurface)
Deprecated.Creates aDefaultCodec
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Format
getConfigurationFormat()
Deprecated.Returns theFormat
used for configuring theCodec
.Surface
getInputSurface()
Deprecated.Returns the inputSurface
of an underlying video encoder.int
getMaxPendingFrameCount()
Deprecated.Returns the maximum number of frames that may be pending in the outputCodec
at a time, or5
as a default value.String
getName()
Deprecated.Returns the name of the underlying codec.ByteBuffer
getOutputBuffer()
Deprecated.Returns the current outputByteBuffer
, ornull
if unavailable.MediaCodec.BufferInfo
getOutputBufferInfo()
Deprecated.Returns theMediaCodec.BufferInfo
associated with the current output buffer, ornull
if there is no output buffer available.Format
getOutputFormat()
Deprecated.Returns the current output format, ornull
if unavailable.boolean
isEnded()
Deprecated.Returns whether theCodec
's output stream has ended, and no more data can be dequeued.boolean
maybeDequeueInputBuffer(DecoderInputBuffer inputBuffer)
Deprecated.Dequeues a writable input buffer, if available.void
queueInputBuffer(DecoderInputBuffer inputBuffer)
Deprecated.Queues an input buffer to theCodec
.void
release()
Deprecated.Releases theCodec
.void
releaseOutputBuffer(boolean render)
Deprecated.Releases the current output buffer.void
releaseOutputBuffer(long renderPresentationTimeUs)
Deprecated.Renders and releases the current output buffer.void
signalEndOfInputStream()
Deprecated.Signals end-of-stream on input to a video encoder.
-
-
-
Field Detail
-
DEFAULT_PCM_ENCODING
public static final int DEFAULT_PCM_ENCODING
Deprecated.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultCodec
public DefaultCodec(Context context, Format configurationFormat, MediaFormat configurationMediaFormat, String mediaCodecName, boolean isDecoder, @Nullable Surface outputSurface) throws ExportException
Deprecated.Creates aDefaultCodec
.- Parameters:
context
- TheContext
.configurationFormat
- TheFormat
to configure theDefaultCodec
. SeegetConfigurationFormat()
. ThesampleMimeType
must not benull
.configurationMediaFormat
- TheMediaFormat
to configure the underlyingMediaCodec
.mediaCodecName
- The name of a specificMediaCodec
to instantiate.isDecoder
- Whether theDefaultCodec
is intended as a decoder.outputSurface
- The outputSurface
if theMediaCodec
outputs to a surface.- Throws:
ExportException
-
-
Method Detail
-
getConfigurationFormat
public Format getConfigurationFormat()
Deprecated.Description copied from interface:Codec
Returns theFormat
used for configuring theCodec
.The configuration
Format
is the inputFormat
used by theCodec.DecoderFactory
or outputFormat
used by theCodec.EncoderFactory
for selecting and configuring the underlying decoder or encoder.- Specified by:
getConfigurationFormat
in interfaceCodec
-
getInputSurface
public Surface getInputSurface()
Deprecated.Description copied from interface:Codec
Returns the inputSurface
of an underlying video encoder.This method must only be called on video encoders because audio/video decoders and audio encoders don't use a
Surface
as input.- Specified by:
getInputSurface
in interfaceCodec
-
getMaxPendingFrameCount
public int getMaxPendingFrameCount()
Deprecated.Description copied from interface:Codec
Returns the maximum number of frames that may be pending in the outputCodec
at a time, or5
as a default value.- Specified by:
getMaxPendingFrameCount
in interfaceCodec
-
maybeDequeueInputBuffer
@EnsuresNonNullIf(expression="#1.data", result=true) public boolean maybeDequeueInputBuffer(DecoderInputBuffer inputBuffer) throws ExportException
Deprecated.Description copied from interface:Codec
Dequeues a writable input buffer, if available.This method must not be called from video encoders because they must use a
Surface
to receive input.- Specified by:
maybeDequeueInputBuffer
in interfaceCodec
- Parameters:
inputBuffer
- The buffer where the dequeued buffer data is stored, atinputBuffer.data
.- Returns:
- Whether an input buffer is ready to be used.
- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
queueInputBuffer
public void queueInputBuffer(DecoderInputBuffer inputBuffer) throws ExportException
Deprecated.Description copied from interface:Codec
Queues an input buffer to theCodec
. No buffers may be queued after end of stream buffer has been queued.This method must not be called from video encoders because they must use a
Surface
to receive input.- Specified by:
queueInputBuffer
in interfaceCodec
- Parameters:
inputBuffer
- The input buffer.- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
signalEndOfInputStream
public void signalEndOfInputStream() throws ExportException
Deprecated.Description copied from interface:Codec
Signals end-of-stream on input to a video encoder.This method must only be called on video encoders because they must use a
Surface
as input. For audio/video decoders or audio encoders, theC.BUFFER_FLAG_END_OF_STREAM
flag should be set on the last input buffer queued.- Specified by:
signalEndOfInputStream
in interfaceCodec
- Throws:
ExportException
- If the underlying video encoder encounters a problem.
-
getOutputFormat
@Nullable public Format getOutputFormat() throws ExportException
Deprecated.Description copied from interface:Codec
Returns the current output format, ornull
if unavailable.- Specified by:
getOutputFormat
in interfaceCodec
- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
getOutputBuffer
@Nullable public ByteBuffer getOutputBuffer() throws ExportException
Deprecated.Description copied from interface:Codec
Returns the current outputByteBuffer
, ornull
if unavailable.This method must not be called on video decoders because they must output to a
Surface
.- Specified by:
getOutputBuffer
in interfaceCodec
- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
getOutputBufferInfo
@Nullable public MediaCodec.BufferInfo getOutputBufferInfo() throws ExportException
Deprecated.Description copied from interface:Codec
Returns theMediaCodec.BufferInfo
associated with the current output buffer, ornull
if there is no output buffer available.This method returns
null
if and only ifCodec.getOutputBuffer()
returns null.- Specified by:
getOutputBufferInfo
in interfaceCodec
- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
releaseOutputBuffer
public void releaseOutputBuffer(boolean render) throws ExportException
Deprecated.Description copied from interface:Codec
Releases the current output buffer.Only set
render
totrue
when theCodec
is a video decoder. Settingrender
totrue
will first render the buffer to the output surface. In this case, the surface will release the buffer back to theCodec
once it is no longer used/displayed.This should be called after the buffer has been processed. The next output buffer will not be available until the current output buffer has been released.
Calling this method with
render
set totrue
is equivalent to callingCodec.releaseOutputBuffer(long)
with the presentation timestamp of theoutput buffer info
.- Specified by:
releaseOutputBuffer
in interfaceCodec
- Parameters:
render
- Whether the buffer needs to be rendered to the outputSurface
.- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
releaseOutputBuffer
public void releaseOutputBuffer(long renderPresentationTimeUs) throws ExportException
Deprecated.Description copied from interface:Codec
Renders and releases the current output buffer.This method must only be called on video decoders.
This method will first render the buffer to the output surface. The surface will then release the buffer back to the
Codec
once it is no longer used/displayed.This should be called after the buffer has been processed. The next output buffer will not be available until the current output buffer has been released.
- Specified by:
releaseOutputBuffer
in interfaceCodec
- Parameters:
renderPresentationTimeUs
- The presentation timestamp to associate with this buffer, in microseconds.- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
isEnded
public boolean isEnded()
Deprecated.Description copied from interface:Codec
Returns whether theCodec
's output stream has ended, and no more data can be dequeued.
-
release
public void release()
Deprecated.Description copied from interface:Codec
Releases theCodec
.
-
getName
public String getName()
Deprecated.Returns the name of the underlying codec.This name is of the actual codec, which may not be the same as the
mediaCodecName
passed toDefaultCodec(Context, Format, MediaFormat, String, boolean, Surface)
.- Specified by:
getName
in interfaceCodec
- See Also:
MediaCodec.getCanonicalName()
-
-