AsyncMediaSource

An open container of an AsyncMediaRuntime. It is the suspending form of MediaSource, and its members mean what the members of the same name mean there.

A caller that is cancelled while a read, a seek, a pause or a resume is in FFmpeg stops the source for good: the operation unwinds, and every later read fails with FFmpegError.Interrupted. Close the source and open the media again. A caller cancelled while it still waits for the lane changes nothing.

Properties

Link copied to clipboard

What the decode flows do with damaged data. Change it with setCorruptData.

Link copied to clipboard

How many damaged packets and frames the decode flows of this source skipped.

Link copied to clipboard

The container as the last completed operation left it.

Link copied to clipboard

Where a stream's first decoded frame disagreed with what the container declared.

Functions

Link copied to clipboard
open suspend override fun close()

Closes the container and every byte source it owns. An operation of this source that is in FFmpeg is stopped first, and the close waits until it has unwound. The open packet reader of the source closes with it. Packets and frames stay valid until their own close.

Link copied to clipboard
fun decodedFrames(stream: StreamInfo): Flow<AsyncFrame>

The frames of stream, decoded in order. The collector owns each frame it is given.

Link copied to clipboard
fun decodeStreams(streams: List<StreamInfo>): Flow<AsyncFrame>

The frames of streams, decoded in container order. The collector owns each frame from the moment its emit is called with it, and closes it. The flow holds the source's one read position while it is collected, and gives the lane back before it hands over a frame.

Link copied to clipboard
suspend fun extractFrame(atMicros: Long, stream: StreamInfo? = null): AsyncFrame

The first frame of stream, or of the primary video stream, whose time reaches atMicros. The caller owns the frame and closes it.

Link copied to clipboard
fun interrupt()

Stops this source for good. An operation of it that waits for bytes fails with FFmpegError.Interrupted, and so does every later one. Safe from any thread, and it does not wait.

Link copied to clipboard
suspend fun openDecoder(stream: StreamInfo, threadCount: Int = 0, lowDelay: Boolean = false, decoder: DecoderId? = null, options: DecoderOptions? = null, hardware: HardwareAccel? = null, corruptData: CorruptData = CorruptData.Skip): AsyncStreamDecoder

Opens a decoder for stream. The parameters mean what they mean in MediaSource.openDecoder.

Link copied to clipboard

Opens the one packet reader this source can have at a time, for streams.

Link copied to clipboard
suspend fun openSubtitleDecoder(stream: StreamInfo, realTime: Boolean = false): AsyncSubtitleDecoder

Opens a subtitle decoder for stream. See MediaSource.openSubtitleDecoder.

Link copied to clipboard
suspend fun pause(): Boolean

Asks a network source to pause. True when the source paused. See MediaSource.pause.

Link copied to clipboard

Sets corruptDataSkipped back to zero.

Link copied to clipboard
suspend fun resume(): Boolean

Lifts a pause. True when one was in effect. See MediaSource.resume.

Link copied to clipboard
suspend fun seekMicros(micros: Long)

Moves the read position to the keyframe at or before micros on the content timeline.

Link copied to clipboard
suspend fun setCorruptData(value: CorruptData)

Sets what the decode flows started after this call do with damaged data.