Livekit.Rtc.Dotnet 0.1.0

dotnet add package Livekit.Rtc.Dotnet --version 0.1.0
                    
NuGet\Install-Package Livekit.Rtc.Dotnet -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Livekit.Rtc.Dotnet" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Livekit.Rtc.Dotnet" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Livekit.Rtc.Dotnet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Livekit.Rtc.Dotnet --version 0.1.0
                    
#r "nuget: Livekit.Rtc.Dotnet, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Livekit.Rtc.Dotnet@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Livekit.Rtc.Dotnet&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Livekit.Rtc.Dotnet&version=0.1.0
                    
Install as a Cake Tool

NuGet Version NuGet Downloads GitHub Actions Workflow Status License badge

Livekit.Rtc.Dotnet

.NET SDK to integrate LiveKit's real-time video, audio, and data capabilities into your .NET applications using WebRTC. Access the same powerful API offered by client SDKs, but directly from your .NET server: connect to rooms as a participant, publish and subscribe to audio/video tracks, send and receive data messages, perform RPC calls, and more.

This SDK does not provide Server APIs to manage LiveKit resources such as Rooms, Egress, Ingress or SIP. If you want to manage LiveKit APIs from your .NET backend, please check Livekit.Server.Sdk.Dotnet instead.

Design principles

This library is crafted based on three core principles:

  1. Livekit.Rtc.Dotnet uses the C# auto-generated protobuf implementation of LiveKit RTC protocol. This ensures compatibility and ease of maintenance as the API evolves.
  2. Livekit.Rtc.Dotnet uses C# FFI bindings to the LiveKit Rust SDK. This allows us to leverage existing, well-tested code for WebRTC functionality that is already in use in other LiveKit SDKs. It brings the benefits of native performance for any OS platform while providing a common .NET interface. The library includes precompiled native binaries for Windows, Linux, and macOS, for both x64 and ARM64 architectures.
  3. Livekit.Rtc.Dotnet maintains full feature parity with other LiveKit RTC SDKs for the server side, especially the two more mature ones: Node.js and Python.

Features

Real-Time Media

Publish and subscribe to audio/video tracks with full programmatic control. Process frames in real-time, mix audio sources, and build custom media pipelines. Perfect for server-side processing.

Data & Communication

Send reliable or lossy data messages, implement RPC request-response patterns, and build real-time chat with topic-based channels. Full control over data flow between participants.

Room & Participant Management

Active speaker detection, transcription support, connection quality monitoring, and 25+ event types for comprehensive room state management.

Security & Encryption

Built-in end-to-end encryption (E2EE) with AES-GCM, key rotation, and per-participant key management. Keep your sensitive communications secure, also in your .NET server.

Production-Ready

Automatic reconnection, multi-room support, isolated contexts, and battle-tested WebRTC implementation from the LiveKit Rust SDK.

Installation

dotnet add package Livekit.Rtc.Dotnet

Usage

Basic Connection

using LiveKit.Rtc;

var room = new Room();
await room.ConnectAsync("wss://your-livekit-server.com", "your-access-token",
    new RoomOptions { AutoSubscribe = true });

Console.WriteLine($"Connected to {room.Name}");
await room.DisconnectAsync();

Publishing Audio

var audioSource = new AudioSource(48000, 1); // 48kHz, mono
var audioTrack = LocalAudioTrack.Create("my-audio", audioSource);
var publication = await room.LocalParticipant!.PublishTrackAsync(audioTrack);

// Capture audio frames
var audioData = new short[480]; // 10ms at 48kHz
var audioFrame = new AudioFrame(audioData, 48000, 1, 480);
await audioSource.CaptureFrameAsync(audioFrame);

Publishing Video

var videoSource = new VideoSource(1920, 1080);
var videoTrack = LocalVideoTrack.Create("my-video", videoSource);
await room.LocalParticipant!.PublishTrackAsync(videoTrack);

// Capture video frames
var videoData = new byte[1920 * 1080 * 4]; // RGBA
var videoFrame = new VideoFrame(1920, 1080, Proto.VideoBufferType.Rgba, videoData);
videoSource.CaptureFrame(videoFrame);

Receiving Media

room.TrackSubscribed += async (sender, e) => {
    if (e.Track is RemoteVideoTrack videoTrack) {
        using var videoStream = new VideoStream(videoTrack);
        await foreach (var frame in videoStream.WithCancellation(cts.Token)) {
            // Process video frame
            Console.WriteLine($"Frame: {frame.Frame.Width}x{frame.Frame.Height}");
        }
    }
};

Event Handling

room.ParticipantConnected += (sender, participant) => {
    Console.WriteLine($"{participant.Identity} joined");
};

room.ActiveSpeakersChanged += (sender, e) => {
    Console.WriteLine($"Active speakers: {e.Speakers.Count}");
};

room.DataReceived += (sender, e) => {
    var message = Encoding.UTF8.GetString(e.Data);
    Console.WriteLine($"Data from {e.Participant.Identity}: {message}");
};

End-to-End Encryption

var key = new byte[32]; // AES-256 key
var options = new RoomOptions {
    E2EE = new E2EEOptions {
        KeyProviderOptions = new KeyProviderOptions { SharedKey = key }
    }
};

await room.ConnectAsync(url, token, options);
// All tracks automatically encrypted/decrypted

RPC Communication

// Register RPC method handler
room.LocalParticipant!.RegisterRpcMethod("greet", async (data) => {
    return $"Hello, {data.CallerIdentity}!";
});

// Call RPC method on another participant
var response = await room.LocalParticipant!.PerformRpcAsync(
    destinationIdentity: "other-participant",
    method: "greet",
    payload: "{}",
    responseTimeout: 5
);

Example apps

At LivekitRtc.Example you can find several example applications demonstrating the usage of LiveKit.Rtc.Dotnet SDK. See the examples README for more details.

For developers of the SDK

Clone repository

Make sure to clone with submodule option:

git clone --recurse-submodules https://github.com/pabloFuente/livekit-server-sdk-dotnet.git

Run tests

All E2E tests automatically launch necessary services as Docker containers with Testcontainers.

dotnet test LivekitRtc.Tests

Building from source

Prerequisites:

1. Get native FFI libraries

Option 1: download pre-compiled binaries from LiveKit Rust SDK releases

The easiest way to get the latest FFI binaries without building from source:

# From LivekitRtc directory
./download_ffi.sh          # Downloads latest version
./download_ffi.sh 0.12.44  # Or specify a version

This downloads pre-compiled binaries from LiveKit Rust SDK releases for all supported platforms (Windows, Linux, macOS on x64 and ARM64).

Option 2: building native libraries from source

If you want to modify the Rust/FFI code or use unreleased features. You will need:

# From LivekitRtc directory
git submodule update --init --recursive
cd rust-sdks/livekit-ffi
cargo build --release

After building, copy the native libraries from target/release/ to the appropriate runtimes/{rid}/native/ folders. Take into account that Rust builds for the host platform by default, so you may need to cross-compile for other platforms.

2. Generate Protocol Buffers

# From the root directory (livekit-server-sdk-dotnet/.)
./generate_proto.sh

3. Build the .NET SDK

# From LivekitRtc directory
dotnet build

Perform release

  1. Create a commit for the new version updating the <Version> property in LivekitRtc.csproj.
  2. Make sure to run script ./build_local.sh to properly format all files with csharpier. Commit any changes in the repo after the script finishes.
  3. Create a new release in GitHub with:
    • Release title rtc-X.Y.Z
    • A new tag rtc-X.Y.Z
    • Description with relevant changes (e.g., Update to LiveKit Rust SDK vA.B.C)

The rtc- prefix in the tag is mandatory for the publish workflow to identify that it is a release for package Livekit.Rtc.Dotnet specifically.

After creating the release, workflow publish.yml will automatically publish the new version to NuGet and will perform the necessary post-release tasks.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 397 1/26/2026