DataTrackStream

A stream of frames received from a subscribed RemoteDataTrack.

Collect flow or call next repeatedly. The stream ends when the track is unpublished or the subscription is cancelled.

Close the stream once you are done with it: the subscription lasts as long as the stream does, so an unclosed stream leaves the SFU forwarding frames for it.

remoteTrack.subscribe().onSuccess { stream ->
stream.use { it.flow.collect { frame -> process(frame.payload) } }
}

Properties

Link copied to clipboard
val flow: Flow<DataTrackFrame>

A Flow of incoming frames. Completes normally when the stream ends.

Functions

Link copied to clipboard
open override fun close()

Ends this stream and releases it.

Link copied to clipboard
suspend fun next(): DataTrackFrame?

Returns the next frame, or null once the stream ends (the track is unpublished or the subscription is cancelled).