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.DecoderInputBuffersare used as both decoders' and encoders' input buffers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCodec.DecoderFactoryDeprecated.A factory for decoder instances.static interfaceCodec.EncoderFactoryDeprecated.A factory for encoder instances.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description FormatgetConfigurationFormat()Deprecated.Returns theFormatused for configuring theCodec.SurfacegetInputSurface()Deprecated.Returns the inputSurfaceof an underlying video encoder.default intgetMaxPendingFrameCount()Deprecated.Returns the maximum number of frames that may be pending in the outputCodecat a time, or5as a default value.StringgetName()Deprecated.Returns the name of the underlying codec.ByteBuffergetOutputBuffer()Deprecated.Returns the current outputByteBuffer, ornullif unavailable.MediaCodec.BufferInfogetOutputBufferInfo()Deprecated.Returns theMediaCodec.BufferInfoassociated with the current output buffer, ornullif there is no output buffer available.FormatgetOutputFormat()Deprecated.Returns the current output format, ornullif unavailable.booleanisEnded()Deprecated.Returns whether theCodec's output stream has ended, and no more data can be dequeued.booleanmaybeDequeueInputBuffer(DecoderInputBuffer inputBuffer)Deprecated.Dequeues a writable input buffer, if available.voidqueueInputBuffer(DecoderInputBuffer inputBuffer)Deprecated.Queues an input buffer to theCodec.voidrelease()Deprecated.Releases theCodec.voidreleaseOutputBuffer(boolean render)Deprecated.Releases the current output buffer.voidreleaseOutputBuffer(long renderPresentationTimeUs)Deprecated.Renders and releases the current output buffer.voidsignalEndOfInputStream()Deprecated.Signals end-of-stream on input to a video encoder.
-
-
-
Method Detail
-
getConfigurationFormat
Format getConfigurationFormat()
Deprecated.Returns theFormatused for configuring theCodec.The configuration
Formatis the inputFormatused by theCodec.DecoderFactoryor outputFormatused by theCodec.EncoderFactoryfor 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 outputCodecat a time, or5as 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
Surfaceto 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
Surfaceto receive input.- Parameters:
inputBuffer- The input buffer.- Throws:
ExportException- If the underlying decoder or encoder encounters a problem.
-
signalEndOfInputStream
void signalEndOfInputStream() throws ExportExceptionDeprecated.Signals end-of-stream on input to a video encoder.This method must only be called on video encoders because they must use a
Surfaceas input. For audio/video decoders or audio encoders, theC.BUFFER_FLAG_END_OF_STREAMflag 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, ornullif unavailable.- Throws:
ExportException- If the underlying decoder or encoder encounters a problem.
-
getOutputBuffer
@Nullable ByteBuffer getOutputBuffer() throws ExportException
Deprecated.Returns the current outputByteBuffer, ornullif 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.BufferInfoassociated with the current output buffer, ornullif there is no output buffer available.This method returns
nullif and only ifgetOutputBuffer()returns null.- Throws:
ExportException- If the underlying decoder or encoder encounters a problem.
-
releaseOutputBuffer
void releaseOutputBuffer(boolean render) throws ExportExceptionDeprecated.Releases the current output buffer.Only set
rendertotruewhen theCodecis a video decoder. Settingrendertotruewill first render the buffer to the output surface. In this case, the surface will release the buffer back to theCodeconce 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
renderset totrueis 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 ExportExceptionDeprecated.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
Codeconce 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.
-
-