Codec

Base class for asynchronous Android media encoding and decoding.

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard
interface Listener

Receives input, format, and output callbacks from the codec.

Link copied to clipboard
open class Setting(codec: Codec?)

Common codec configuration forwarded to the associated codec.

Properties

Link copied to clipboard
open var codec: MediaCodec?

The android.media.MediaCodec instance.

Link copied to clipboard
abstract var inputMimeType: String

Specifies the input mime type.

Link copied to clipboard
open override val isRunning: AtomicBoolean

Indicates whether the receiver is running.

Link copied to clipboard

The listener for codec buffer and format callbacks, or null.

Link copied to clipboard
var mode: Int

The processing mode: MODE_ENCODE or MODE_DECODE. Set before starting the codec.

Link copied to clipboard

Additional media format options applied during configure.

Link copied to clipboard
abstract var outputMimeType: String

Specifies the output mime type.

Link copied to clipboard

The surface for a video media codec.

Functions

Link copied to clipboard
open fun configure(codec: MediaCodec)

Installs callbacks and configures the codec with its media format, options, surface, and processing mode.

Link copied to clipboard

Releases the Android codec, callback thread, and cached output format.

Link copied to clipboard
Link copied to clipboard
open override fun onError(codec: MediaCodec, e: MediaCodec.CodecException)
Link copied to clipboard
open override fun onInputBufferAvailable(codec: MediaCodec, index: Int)
Link copied to clipboard
open fun onMetricsFlushed(codec: MediaCodec, metrics: PersistableBundle)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun onOutputFormatChanged(codec: MediaCodec, format: MediaFormat)
Link copied to clipboard
override fun startRunning()

Tells the receiver to start running.

Link copied to clipboard
override fun stopRunning()

Tells the receiver to stop running.

Link copied to clipboard
fun withCurrentCodec(instance: MediaCodec, operation: () -> Unit): Boolean

Runs a short, nonblocking operation only while instance is the running codec. Use after waiting for input outside the codec's lifetime lock.