SrtStream

class SrtStream(context: Context, val connection: SrtConnection) : Stream

Publishes or plays a single-program MPEG-TS stream over connection. Register this stream as a MediaMixer output for capture, or register a StreamView as this stream's output for playback. Codecs/settings and rendering reuse Stream. Supports H.264/H.265 video and ADTS-framed AAC audio; other codecs are rejected.

The connection must be open before publish or play. One active SrtStream may use a connection at a time. Media jobs belong to the connection's owning scope. close stops media processing while keeping the connection open; dispose additionally releases codec/rendering resources. Close before reconnecting.

Parameters

context

Android context for codecs and rendering.

Constructors

Link copied to clipboard
constructor(context: Context, connection: SrtConnection)

Types

Link copied to clipboard

Media-processing state, independent of the connection's handshake state.

Properties

Link copied to clipboard
Link copied to clipboard

Transport connection, owned and closed separately by the caller.

Link copied to clipboard
Link copied to clipboard

Tracks included in the outgoing PMT. Empty derives tracks from the attached mixer. Set before publishing, especially when source formats are not available yet. Reads/assignments use defensive snapshots. Changes while active are rejected.

Link copied to clipboard
val failure: StateFlow<Throwable?>

Most recent startup/processing error; reset when a new publish/play begins.

Link copied to clipboard
open override var hasAudio: Boolean
Link copied to clipboard
open override var hasVideo: Boolean
Link copied to clipboard
Link copied to clipboard

Current media-processing state. Async failures return the stream to IDLE.

Link copied to clipboard
open override val screen: Screen
Link copied to clipboard

Functions

Link copied to clipboard
open override fun append(buffer: MediaBuffer)
Link copied to clipboard
open override fun close()

Cancels media jobs while retaining the connection. Cleanup releases codecs and the transport claim before readyState returns to ReadyState.IDLE.

Link copied to clipboard
open override fun dispose()

Cancels media and releases rendering resources after job cleanup. Idempotent.

Link copied to clipboard
suspend fun play()

Starts MPEG-TS reception and codec playback. Returns after the playback pipeline starts; decoders initialize when in-band parameter sets/ADTS configuration arrive. Attach an output view before calling. Subsequent errors are exposed by failure.

Link copied to clipboard
suspend fun publish()

Starts encoding and publishing. Suspends until codecs have started, then returns. Subsequent errors are exposed through failure. Queue overflow terminates the stream instead of dropping arbitrary TS packets or retaining unbounded data.

Link copied to clipboard
fun queueOutputBuffer(type: MediaType, index: Int, payload: ByteBuffer?, timestamp: Long, sync: Boolean)
Link copied to clipboard
open override fun registerOutput(output: MediaOutput)
Link copied to clipboard
open override fun unregisterOutput(output: MediaOutput)