Class LiveKitRoom
A participant's connection to a LiveKit room: the signalling, the subscriber peer connection the server offers with the others' tracks, and the publisher peer connection this side offers with its own.
Implements
Inherited Members
Namespace: Uniform.LiveKit
Assembly: Uniform.LiveKit.dll
Syntax
public sealed class LiveKitRoom : IAsyncDisposable
Remarks
The server subscribes this participant to every track, and offers each anew on the subscriber connection. IdentityOf(uint) tells whose a received stream is, by the msid of its section, PA_…|TR_….
Properties
| Edit this page View SourceAudioTrackSid
The server's ID of the published microphone, once published.
Declaration
public string? AudioTrackSid { get; }
Property Value
| Type | Description |
|---|---|
| string |
LocalParticipant
This participant, as the server knows it.
Declaration
public ParticipantInfo LocalParticipant { get; }
Property Value
| Type | Description |
|---|---|
| ParticipantInfo |
Name
The room's name.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Participants
The others in the room.
Declaration
public IReadOnlyCollection<ParticipantInfo> Participants { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyCollection<ParticipantInfo> |
Publisher
The publisher connection, once this side published.
Declaration
public AudioPeerConnection? Publisher { get; }
Property Value
| Type | Description |
|---|---|
| AudioPeerConnection |
ServerTrailer
The trailer of frames the server injects, which come unencrypted.
Declaration
public byte[] ServerTrailer { get; }
Property Value
| Type | Description |
|---|---|
| byte[] |
Subscriber
The subscriber connection, once the server offered it.
Declaration
public AudioPeerConnection? Subscriber { get; }
Property Value
| Type | Description |
|---|---|
| AudioPeerConnection |
VideoTrackSid
The server's ID of the published camera, once published with video.
Declaration
public string? VideoTrackSid { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceConnectAsync(string, string, LiveKitRoomOptions?, ILogger?, CancellationToken)
Join the room at url with token.
Declaration
public static Task<LiveKitRoom> ConnectAsync(string url, string token, LiveKitRoomOptions? options = null, ILogger? logger = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | |
| string | token | |
| LiveKitRoomOptions | options | |
| ILogger | logger | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<LiveKitRoom> |
Exceptions
| Type | Condition |
|---|---|
| WebSocketException | When the server cannot be reached or refuses the token. |
DisposeAsync()
Leave the room, and close the connections.
Declaration
public ValueTask DisposeAsync()
Returns
| Type | Description |
|---|---|
| ValueTask |
IdentityOf(uint)
Return the identity of the participant whose stream ssrc is, as the subscriber's offers said; null when unknown.
Declaration
public string? IdentityOf(uint ssrc)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | ssrc |
Returns
| Type | Description |
|---|---|
| string |
MuteAsync(bool, bool, CancellationToken)
Tell the others that a published track is muted or not, e.g. the camera turned off.
Declaration
public Task MuteAsync(bool video, bool muted, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | video | |
| bool | muted | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
PublishAsync(bool, Type, int, int, CancellationToken)
Publish this side's microphone, and with video its camera, encrypted as encryption says; return once the publisher connection connected.
Declaration
public Task<AudioPeerConnection> PublishAsync(bool video, Encryption.Types.Type encryption = Type.None, int width = 640, int height = 480, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | video | Whether to publish video too. |
| Encryption.Types.Type | encryption | How the frames are encrypted, which subscribers learn from the track's info. |
| int | width | Width of the video sent. |
| int | height | Height of the video sent. |
| CancellationToken | cancellationToken | Cancels publishing. |
Returns
| Type | Description |
|---|---|
| Task<AudioPeerConnection> |
Exceptions
| Type | Condition |
|---|---|
| TimeoutException | When the server does not take the tracks in time. |
SetVideoQualityAsync(VideoQuality, CancellationToken)
Ask the server for the quality of the others' video, e.g. a low one for a device that cannot decode more; the server picks the sender's layer of it.
Declaration
public Task SetVideoQualityAsync(VideoQuality quality, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| VideoQuality | quality | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Events
| Edit this page View SourceClosed
Raised when the server closed the signalling or asked this participant to leave.
Declaration
public event Action? Closed
Event Type
| Type | Description |
|---|---|
| Action |
ParticipantChanged
Raised when another participant joins, changes or leaves; on the signalling loop.
Declaration
public event Action<ParticipantInfo>? ParticipantChanged
Event Type
| Type | Description |
|---|---|
| Action<ParticipantInfo> |
SubscriberCreated
Raised when the subscriber connection is created, before it connects, e.g. to listen to its media.
Declaration
public event Action<AudioPeerConnection>? SubscriberCreated
Event Type
| Type | Description |
|---|---|
| Action<AudioPeerConnection> |