Skip to content

.NET SDK to manage LiveKit APIs and add realtime video, audio and data features to your .NET app.

License

Notifications You must be signed in to change notification settings

pabloFuente/livekit-server-sdk-dotnet

Repository files navigation

Livekit.Server.Sdk.Dotnet NuGet Version NuGet Downloads | Livekit.Rtc.Dotnet NuGet Version NuGet Downloads

GitHub Actions Workflow Status License badge

LiveKit .NET SDKs

Use this SDK to add realtime video, audio and data features to your .NET app. By connecting to LiveKit Cloud or a self-hosted server, you can quickly build applications such as multi-modal AI, live streaming, or video calls with just a few lines of code.

Packages

This repository contains two complementary .NET packages for different LiveKit use cases:

Livekit.Server.Sdk.Dotnet

NuGet Version NuGet Downloads

Server-side management and authentication SDK for LiveKit. Use it to interact with all LiveKit server APIs, create access tokens, and handle webhooks.

Livekit.Rtc.Dotnet

NuGet Version NuGet Downloads

Real-time communication SDK for .NET server applications. Use it to connect to LiveKit as a server-side participant, and to publish and subscribe to audio, video, and data.

  • Target Framework: netstandard2.1

  • Included Native Binaries: Precompiled for Windows, Linux, macOS (x64 & ARM64)

  • Full Documentation →

Quick Start

Livekit.Server.Sdk.Dotnet - Access Tokens & Server APIs

dotnet add package Livekit.Server.Sdk.Dotnet
using Livekit.Server.Sdk.Dotnet;
// Generate access token
var token = new AccessToken("api-key", "api-secret")
    .WithIdentity("user-123")
    .WithName("John Doe")
    .WithGrants(new VideoGrants { RoomJoin = true, Room = "my-room" });
var jwt = token.ToJwt();

// Manage rooms via API
var roomClient = new RoomServiceClient("https://my.livekit.instance", "api-key", "api-secret");
var rooms = await roomClient.ListRooms(new ListRoomsRequest());

Livekit.Rtc.Dotnet - Real-Time Media

dotnet add package Livekit.Rtc.Dotnet
using LiveKit.Rtc;

// Connect to room as a participant
var room = new Room();

// Add room event handlers
room.ParticipantConnected += (sender, participant) =>
{
    Console.WriteLine($"[ParticipantConnected] {participant.Identity}}");
};

await room.ConnectAsync("wss://my.livekit.instance", token);

// Publish audio track
var audioSource = new AudioSource(48000, 1);
var audioTrack = LocalAudioTrack.Create("audio", audioSource);
await room.LocalParticipant!.PublishTrackAsync(audioTrack);

// Handle events
room.TrackSubscribed += (sender, e) => {
    Console.WriteLine($"Subscribed to track: {e.Track.Sid}");
};

For Developers

Clone repository

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

Note: The --recurse-submodules flag is required to clone the necessary LiveKit protocol submodules.

Build and test

# Build both packages
dotnet build

# Run tests for Server SDK
dotnet test LivekitApi.Tests/LivekitApi.Tests.csproj

# Run tests for RTC SDK
dotnet test LivekitRtc.Tests/LivekitRtc.Tests.csproj

# Build and install both packages locally
./build_local.sh

Perform release

Releases are automated through GitHub Actions thanks to the publish workflow. Both packages Livekit.Server.Sdk.Dotnet and Livekit.Rtc.Dotnet can be released independently. Checkout how to do so:

Upgrade version of livekit/protocol

To upgrade the version of the livekit/protocol Git submodule:

cd protocol
git fetch --all
git checkout <COMMIT_HASH/TAG/BRANCH>
cd ..
git add protocol
git commit -m "Update livekit/protocol to <VERSION>"
git push

Then it may be necessary to re-generate the proto files to actually reflect the changes in livekit/protocol:

./generate_proto.sh

Then try packaging the SDK to test the validity of the changes in the protocol:

dotnet pack -c Debug -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg

This command may throw an error if there are breaking changes in the protocol, as the SDK is configured in strict mode for package validation. The way to overcome these breaking changes is running the package command with option -p:GenerateCompatibilitySuppressionFile=true to generate file CompatibilitySuppressions.xml:

dotnet pack -c Debug -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:GenerateCompatibilitySuppressionFile=true

This compatibility suppression file will allow packaging and publishing the SDK even with breaking changes. Once the new version is available in NuGet, the only thing left is to update in file LivekitApi.csproj property <PackageValidationBaselineVersion>X.Y.Z</PackageValidationBaselineVersion> to the new version (so the new reference for breaking changes is this new version), and delete CompatibilitySuppressions.xml (as it is no longer needed). Workflow publish.yml automatically does this as last step.


Built with ❤️ by pabloFuente


LiveKit Ecosystem
LiveKit SDKsBrowser · iOS/macOS/visionOS · Android · Flutter · React Native · Rust · Node.js · Python · Unity · Unity (WebGL) · ESP32 · .NET (community)
Server APIsNode.js · Golang · Ruby · Java/Kotlin · Python · Rust · PHP (community) · .NET (community)
UI ComponentsReact · Android Compose · SwiftUI · Flutter
Agents FrameworksPython · Node.js · Playground
ServicesLiveKit server · Egress · Ingress · SIP
ResourcesDocs · Example apps · Cloud · Self-hosting · CLI

About

.NET SDK to manage LiveKit APIs and add realtime video, audio and data features to your .NET app.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages