Interface Codec

  • All Known Implementing Classes:
    DefaultCodec

    public interface Codec
    Provides a layer of abstraction for interacting with decoders and encoders.

    DecoderInputBuffers are used as both decoders' and encoders' input buffers.

    • Field Detail

      • UNLIMITED_PENDING_FRAME_COUNT

        static final int UNLIMITED_PENDING_FRAME_COUNT
        Default value for the pending frame count, which represents applying no limit.
        See Also:
        Constant Field Values
    • Method Detail

      • getName

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

        Surface getInputSurface()
        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()
        Returns the maximum number of frames that may be pending in the output Codec at a time, or UNLIMITED_PENDING_FRAME_COUNT if it's not necessary to enforce a limit.
      • maybeDequeueInputBuffer

        boolean maybeDequeueInputBuffer​(DecoderInputBuffer inputBuffer)
                                 throws TransformationException
        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:
        TransformationException - If the underlying decoder or encoder encounters a problem.
      • signalEndOfInputStream

        void signalEndOfInputStream()
                             throws TransformationException
        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:
        TransformationException - If the underlying video encoder encounters a problem.
      • releaseOutputBuffer

        void releaseOutputBuffer​(boolean render)
                          throws TransformationException
        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.

        Parameters:
        render - Whether the buffer needs to be rendered to the output Surface.
        Throws:
        TransformationException - If the underlying decoder or encoder encounters a problem.
      • isEnded

        boolean isEnded()
        Returns whether the Codec's output stream has ended, and no more data can be dequeued.
      • release

        void release()
        Releases the Codec.