Table of Contents

Class VideoStream

Namespace
LiveKit.Rtc
Assembly
LivekitRtc.dll

A video stream for receiving video frames from a remote track or participant. Implements IAsyncEnumerable for modern async iteration patterns.

public class VideoStream : IAsyncDisposable, IDisposable, IAsyncEnumerable<VideoFrameEvent>
Inheritance
VideoStream
Implements
Inherited Members

Constructors

VideoStream(Track, VideoBufferType?, int)

Initializes a new VideoStream from a track.

public VideoStream(Track track, VideoBufferType? format = null, int capacity = 0)

Parameters

track Track

The video track to stream from.

format VideoBufferType?

Optional video buffer format to convert to.

capacity int

The capacity of the internal channel (0 for unbounded).

Properties

Format

Gets the video format.

public VideoBufferType? Format { get; }

Property Value

VideoBufferType?

Methods

Dispose()

Stops the stream and releases the native stream. Pending reads return null and later reads throw ObjectDisposedException.

public void Dispose()

DisposeAsync()

Stops the stream and releases the native stream. Pending reads return null and later reads throw ObjectDisposedException.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that completes once the stream is released.

FromParticipant(Participant, TrackSource, VideoBufferType?, int)

Creates a VideoStream from a participant's track source.

public static VideoStream FromParticipant(Participant participant, TrackSource trackSource, VideoBufferType? format = null, int capacity = 0)

Parameters

participant Participant

The participant.

trackSource TrackSource

The track source type.

format VideoBufferType?

Optional video buffer format.

capacity int

The capacity of the internal channel.

Returns

VideoStream

A new VideoStream instance.

FromTrack(Track, VideoBufferType?, int)

Creates a VideoStream from an existing track.

public static VideoStream FromTrack(Track track, VideoBufferType? format = null, int capacity = 0)

Parameters

track Track

The track.

format VideoBufferType?

Optional video buffer format.

capacity int

The capacity of the internal channel.

Returns

VideoStream

A new VideoStream instance.

GetAsyncEnumerator(CancellationToken)

Returns an async enumerator for iterating over video frames.

public IAsyncEnumerator<VideoFrameEvent> GetAsyncEnumerator(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

IAsyncEnumerator<VideoFrameEvent>

An async enumerator of video frame events.

ReadAsync(CancellationToken)

Reads the next video frame event from the stream.

public ValueTask<VideoFrameEvent?> ReadAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<VideoFrameEvent?>

The next video frame event, or null if the stream has ended.

TryRead(out VideoFrameEvent)

Tries to read the next video frame event without blocking.

public bool TryRead(out VideoFrameEvent frameEvent)

Parameters

frameEvent VideoFrameEvent

The frame event if available.

Returns

bool

True if a frame was available.