Table of Contents

Class DataTrackStream

Namespace
LiveKit.Rtc
Assembly
LivekitRtc.dll

An active subscription to a RemoteDataTrack. Read frames with ReadAsync(CancellationToken) or await foreach; the stream ends when the track is unpublished. Disposing the stream unsubscribes from the track.

public class DataTrackStream : IAsyncEnumerable<DataTrackFrame>, IAsyncDisposable, IDisposable
Inheritance
DataTrackStream
Implements
Inherited Members

Properties

IsEnded

Whether the stream has ended (track unpublished, subscription failed, or disposed).

public bool IsEnded { get; }

Property Value

bool

Methods

Dispose()

Unsubscribes from the track and releases the native resources.

public void Dispose()

DisposeAsync()

Unsubscribes from the track and releases the native resources, like Dispose().

public ValueTask DisposeAsync()

Returns

ValueTask

A completed task.

GetAsyncEnumerator(CancellationToken)

Returns an enumerator that iterates asynchronously through the collection.

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

Parameters

cancellationToken CancellationToken

A CancellationToken that may be used to cancel the asynchronous iteration.

Returns

IAsyncEnumerator<DataTrackFrame>

An enumerator that can be used to iterate asynchronously through the collection.

ReadAsync(CancellationToken)

Reads the next frame, or returns null once the stream has ended.

public Task<DataTrackFrame?> ReadAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels the wait for the next frame.

Returns

Task<DataTrackFrame>

The next frame, or null once the stream has ended.

Exceptions

SubscribeDataTrackException

The subscription could not be established. Thrown once, when the stream ends.