AsyncMediaRuntime

Reads media whose bytes may answer later, from an AsyncMediaByteSource.

A runtime owns one lane, which is the one place it runs codec work. Every operation of every handle it gave out waits its turn there, so the sources of one runtime take turns and the sources of two runtimes do not wait for each other. On the JVM, Android and native the lane is a thread. On the web it is a codec module of its own, apart from the one MediaSource uses.

Create one with FFmpeg.createAsyncRuntime(), or on the web with KiteFFmpegWeb.loadAsyncRuntime. Close it when every source is done: the close also closes every source, reader, decoder, packet and frame that is still open.

While one source waits for bytes, every other operation of the same runtime waits too, the copy and the close of a frame included. Copy the pictures and the sound you need before you start a read that may wait.

Properties

Link copied to clipboard

What FFmpeg this runtime runs. On the web it describes the runtime's own codec module.

Functions

Link copied to clipboard
open suspend override fun close()

Stops every source, waits for the work in the lane, then closes every handle and source. The runtime refuses every operation from this call on.

Link copied to clipboard
suspend fun open(io: AsyncMediaByteSource, options: Map<String, String> = emptyMap(), interrupt: OpenInterrupt? = null, url: String? = null, mimeType: String? = null, nestedOpener: AsyncMediaByteOpener? = null): AsyncMediaSource

Opens media from io. The parameters mean what they mean in the byte-source MediaSource.open, and nestedOpener serves the other addresses the media names.