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
trackTrackThe video track to stream from.
formatVideoBufferType?Optional video buffer format to convert to.
capacityintThe capacity of the internal channel (0 for unbounded).
Properties
Format
Gets the video format.
public VideoBufferType? Format { get; }
Property Value
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
participantParticipantThe participant.
trackSourceTrackSourceThe track source type.
formatVideoBufferType?Optional video buffer format.
capacityintThe 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
trackTrackThe track.
formatVideoBufferType?Optional video buffer format.
capacityintThe 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
cancellationTokenCancellationTokenCancellation 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
cancellationTokenCancellationTokenCancellation 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
frameEventVideoFrameEventThe frame event if available.
Returns
- bool
True if a frame was available.