Class 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 default Codec implementation that uses MediaCodec.
    • Field Detail

      • DEFAULT_PCM_ENCODING

        public static final int DEFAULT_PCM_ENCODING
        Deprecated.
        See Also:
        Constant Field Values
    • Method Detail

      • getInputSurface

        public Surface getInputSurface()
        Deprecated.
        Description copied from interface: Codec
        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.

        Specified by:
        getInputSurface in interface Codec
      • getMaxPendingFrameCount

        public int getMaxPendingFrameCount()
        Deprecated.
        Description copied from interface: Codec
        Returns the maximum number of frames that may be pending in the output Codec at a time, or 5 as a default value.
        Specified by:
        getMaxPendingFrameCount in interface Codec
      • 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 interface Codec
        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

        public void queueInputBuffer​(DecoderInputBuffer inputBuffer)
                              throws ExportException
        Deprecated.
        Description copied from interface: Codec
        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.

        Specified by:
        queueInputBuffer in interface Codec
        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, the C.BUFFER_FLAG_END_OF_STREAM flag should be set on the last input buffer queued.

        Specified by:
        signalEndOfInputStream in interface Codec
        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, or null if unavailable.
        Specified by:
        getOutputFormat in interface Codec
        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 output ByteBuffer, or null if unavailable.

        This method must not be called on video decoders because they must output to a Surface.

        Specified by:
        getOutputBuffer in interface Codec
        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 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 Codec.releaseOutputBuffer(long) with the presentation timestamp of the output buffer info.

        Specified by:
        releaseOutputBuffer in interface Codec
        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

        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 interface Codec
        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 the Codec's output stream has ended, and no more data can be dequeued.
        Specified by:
        isEnded in interface Codec
      • release

        public void release()
        Deprecated.
        Description copied from interface: Codec
        Releases the Codec.
        Specified by:
        release in interface Codec