Interface Codec
-
- All Known Implementing Classes:
DefaultCodec
@Deprecated public interface 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.Provides a layer of abstraction for interacting with decoders and encoders.DecoderInputBuffers
are used as both decoders' and encoders' input buffers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Codec.DecoderFactory
Deprecated.A factory for decoder instances.static interface
Codec.EncoderFactory
Deprecated.A factory for encoder instances.
-
Method Summary
All Methods Instance Methods Abstract Methods Default 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.default 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.
-
-
-
Method Detail
-
getConfigurationFormat
Format getConfigurationFormat()
Deprecated.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.
-
getName
String getName()
Deprecated.Returns the name of the underlying codec.
-
getInputSurface
Surface getInputSurface()
Deprecated.
-
getMaxPendingFrameCount
default int getMaxPendingFrameCount()
Deprecated.Returns the maximum number of frames that may be pending in the outputCodec
at a time, or5
as a default value.
-
maybeDequeueInputBuffer
boolean maybeDequeueInputBuffer(DecoderInputBuffer inputBuffer) throws ExportException
Deprecated.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.- 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
void queueInputBuffer(DecoderInputBuffer inputBuffer) throws ExportException
Deprecated.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.- Parameters:
inputBuffer
- The input buffer.- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
signalEndOfInputStream
void signalEndOfInputStream() throws ExportException
Deprecated.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.- Throws:
ExportException
- If the underlying video encoder encounters a problem.
-
getOutputFormat
@Nullable Format getOutputFormat() throws ExportException
Deprecated.Returns the current output format, ornull
if unavailable.- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
getOutputBuffer
@Nullable ByteBuffer getOutputBuffer() throws ExportException
Deprecated.Returns the current outputByteBuffer
, ornull
if unavailable.This method must not be called on video decoders because they must output to a
Surface
.- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
getOutputBufferInfo
@Nullable MediaCodec.BufferInfo getOutputBufferInfo() throws ExportException
Deprecated.Returns theMediaCodec.BufferInfo
associated with the current output buffer, ornull
if there is no output buffer available.This method returns
null
if and only ifgetOutputBuffer()
returns null.- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
releaseOutputBuffer
void releaseOutputBuffer(boolean render) throws ExportException
Deprecated.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 callingreleaseOutputBuffer(long)
with the presentation timestamp of theoutput buffer info
.- Parameters:
render
- Whether the buffer needs to be rendered to the outputSurface
.- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
releaseOutputBuffer
void releaseOutputBuffer(long renderPresentationTimeUs) throws ExportException
Deprecated.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.
- Parameters:
renderPresentationTimeUs
- The presentation timestamp to associate with this buffer, in microseconds.- Throws:
ExportException
- If the underlying decoder or encoder encounters a problem.
-
isEnded
boolean isEnded()
Deprecated.Returns whether theCodec
's output stream has ended, and no more data can be dequeued.
-
release
void release()
Deprecated.Releases theCodec
.
-
-