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.

    • Method Detail

      • getName

        String getName()
        Deprecated.
        Returns the name of the underlying codec.
      • getInputSurface

        Surface getInputSurface()
        Deprecated.
        Returns the input Surface 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.

      • getMaxPendingFrameCount

        default int getMaxPendingFrameCount()
        Deprecated.
        Returns the maximum number of frames that may be pending in the output Codec at a time, or 5 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, at inputBuffer.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 the Codec. 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, the C.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, or null if unavailable.
        Throws:
        ExportException - If the underlying decoder or encoder encounters a problem.
      • getOutputBuffer

        @Nullable
        ByteBuffer getOutputBuffer()
                            throws ExportException
        Deprecated.
        Returns the current output ByteBuffer, or null 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.
      • releaseOutputBuffer

        void releaseOutputBuffer​(boolean render)
                          throws ExportException
        Deprecated.
        Releases the current output buffer.

        Only set render to true when the Codec is a video decoder. Setting render to true will first render the buffer to the output surface. In this case, the surface will 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.

        Calling this method with render set to true is equivalent to calling releaseOutputBuffer(long) with the presentation timestamp of the output buffer info.

        Parameters:
        render - Whether the buffer needs to be rendered to the output Surface.
        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 the Codec's output stream has ended, and no more data can be dequeued.
      • release

        void release()
        Deprecated.
        Releases the Codec.