Agash.StreamTransport.WebRtc
0.2.0-dev5
dotnet add package Agash.StreamTransport.WebRtc --version 0.2.0-dev5
NuGet\Install-Package Agash.StreamTransport.WebRtc -Version 0.2.0-dev5
<PackageReference Include="Agash.StreamTransport.WebRtc" Version="0.2.0-dev5" />
<PackageVersion Include="Agash.StreamTransport.WebRtc" Version="0.2.0-dev5" />
<PackageReference Include="Agash.StreamTransport.WebRtc" />
paket add Agash.StreamTransport.WebRtc --version 0.2.0-dev5
#r "nuget: Agash.StreamTransport.WebRtc, 0.2.0-dev5"
#:package Agash.StreamTransport.WebRtc@0.2.0-dev5
#addin nuget:?package=Agash.StreamTransport.WebRtc&version=0.2.0-dev5&prerelease
#tool nuget:?package=Agash.StreamTransport.WebRtc&version=0.2.0-dev5&prerelease
Agash.StreamTransport.WebRtc
A small, modern WebRTC stack for .NET 11 with the parts a point-to-point media transport uses: ICE/STUN,
SRTP, RTP/RTCP, SDP/JSEP, a peer connection, and loss recovery (NACK with RTX retransmission, PLI keyframe
requests, FlexFEC, and a sequence-aware H.265 packet buffer that reassembles complete frames before decode).
Behaviour follows libwebrtc where interop and correctness depend on it: the NACK requester, RTX unwrap and
h26x_packet_buffer are ports of their libwebrtc counterparts. The code is idiomatic modern .NET (spans,
ArrayPool, readonly record struct, source-generated logging).
SRTP offers SRTP_AEAD_AES_128_GCM, SRTP_AEAD_AES_256_GCM and, for peers that offer no GCM profile,
SRTP_AES128_CM_HMAC_SHA1_80, with a 1024-packet replay window per SSRC.
Crypto is the platform's own (AesGcm, Aes, HMACSHA1, CertificateRequest). DTLS 1.2 and 1.3 come from
Dtls.Core, which is built on the same primitives, so there is no native
or third-party crypto dependency.
The package is the transport under Agash.StreamTransport.
Scope: audio and video over RTP/SRTP. There are no data channels and no SCTP.
Quick start
Two PeerConnections in one process, negotiating through direct calls where an application would use its
signaling channel:
var opus = new SdpCodec(111, "opus", 48000, 2, null, []);
var certificate = RtcCertificate.Generate();
await using var offerer = new PeerConnection(
new PeerConnectionOptions { Media = [new MediaLine("0", SdpMediaKind.Audio, LocalSsrc: 0x1111_1111, [opus])] },
certificate);
await using var answerer = new PeerConnection(
new PeerConnectionOptions { Media = [new MediaLine("0", SdpMediaKind.Audio, LocalSsrc: 0x2222_2222, [opus])] },
certificate);
// Trickle ICE: each side hands its candidates to the other as they are gathered.
offerer.LocalIceCandidate += c => answerer.AddRemoteIceCandidate(c);
answerer.LocalIceCandidate += c => offerer.AddRemoteIceCandidate(c);
var connected = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
offerer.StateChanged += s => { if (s == PeerConnectionState.Connected) connected.TrySetResult(); };
answerer.RtpReceived += (header, payload) => Console.WriteLine($"{payload.Length} bytes, PT {header.PayloadType}");
// Offer and answer.
SdpDescription offer = offerer.CreateOffer();
answerer.SetRemoteDescription(offer, SdpType.Offer);
SdpDescription answer = answerer.CreateAnswer();
offerer.SetRemoteDescription(answer, SdpType.Answer);
await connected.Task; // ICE and the DTLS handshake are done; SRTP is keyed.
offerer.TrySendRtp(payloadType: 111, ssrc: 0x1111_1111, rtpTimestamp: 160, marker: true, payload,
new RtpExtensionValues(captureNtp));
payload is the encoded frame (a byte[]) and captureNtp the capture time as a 64-bit NTP timestamp
carried in the abs-capture-time header extension. TrySendRtp returns false, dropping the packet, when DTLS-SRTP is not established yet.
The types are in Agash.StreamTransport.WebRtc, .Sdp and .Rtp. A PeerConnectionOptions.SocketFactory
replaces the UDP sockets, which is how the tests run connections in memory.
Diagnostics
The meter and activity source Agash.StreamTransport.WebRtc (WebRtcDiagnostics). With DI the meter
comes from the host's IMeterFactory; PeerConnection and IceAgent take one too. Nothing is
recorded until something listens.
| Instrument | Unit | What |
|---|---|---|
streamtransport.webrtc.connections.active |
{connection} |
peer connections not yet disposed |
streamtransport.webrtc.connect.duration |
s |
ICE start to DTLS-SRTP up, by streamtransport.outcome: connected, ice_failed, dtls_failed, closed |
streamtransport.webrtc.ice.selected_paths |
{path} |
selected pairs by local and remote candidate kind (host, srflx, prflx, relay) and network.type (ipv6, ipv4) |
streamtransport.webrtc.ice.consent_lost |
{event} |
selected paths that stopped answering consent checks |
streamtransport.webrtc.ice.restarts |
{restart} |
ICE restarts |
streamtransport.webrtc.turn.allocations |
{allocation} |
TURN allocations by network.transport and outcome |
streamtransport.webrtc.rtp.packets.sent |
{packet} |
media packets sent |
streamtransport.webrtc.nack.sequences |
{packet} |
lost packets asked for again |
streamtransport.webrtc.rtx.packets |
{packet} |
retransmissions sent and recovered |
The activity streamtransport.webrtc.connect spans ICE and the DTLS handshake, with the selected
path's candidate kinds and address family. DTLS itself reports on the Dtls.Core meter.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Agash.StreamTransport.Abstractions (>= 0.2.0-dev5)
- Agash.StreamTransport.Adaptation (>= 0.2.0-dev5)
- Agash.StreamTransport.Media (>= 0.2.0-dev5)
- Agash.StreamTransport.Stun (>= 0.2.0-dev5)
- Agash.StreamTransport.WebRtc.Abstractions (>= 0.2.0-dev5)
- Dtls.Core (>= 0.1.0-dev2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Agash.StreamTransport.WebRtc:
| Package | Downloads |
|---|---|
|
Agash.StreamTransport.WebRtc.DependencyInjection
Dependency-injection wiring for the Agash.StreamTransport WebRTC stack: registers the DTLS certificate, the congestion controller, and a peer-connection factory via Microsoft.Extensions.DependencyInjection. |
|
|
Agash.StreamTransport.AspNetCore
WHIP and WHEP endpoints for Agash.StreamTransport in an ASP.NET Core application: ingest from OBS or a browser, play to browsers, mapped onto the host's own routing. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.0-dev5 | 67 | 11/11/2026 |
| 0.2.0-dev4 | 98 | 11/3/2026 |
| 0.2.0-dev3 | 86 | 11/3/2026 |
| 0.2.0-dev2 | 328 | 11/2/2026 |
| 0.2.0-dev1 | 84 | 11/2/2026 |
| 0.1.6-alpha | 153 | 9/23/2026 |
| 0.1.5-alpha | 118 | 8/31/2026 |
| 0.1.4-alpha | 109 | 8/13/2026 |
| 0.1.3-alpha | 245 | 8/12/2026 |
| 0.1.2-alpha | 97 | 8/12/2026 |
| 0.1.1-alpha | 118 | 6/23/2026 |
| 0.1.0-alpha | 106 | 6/20/2026 |
| 0.0.0-alpha.0 | 92 | 6/20/2026 |