RemoteViewer.SessionKit
0.9.12
See the version list below for details.
dotnet add package RemoteViewer.SessionKit --version 0.9.12
NuGet\Install-Package RemoteViewer.SessionKit -Version 0.9.12
<PackageReference Include="RemoteViewer.SessionKit" Version="0.9.12" />
<PackageVersion Include="RemoteViewer.SessionKit" Version="0.9.12" />
<PackageReference Include="RemoteViewer.SessionKit" />
paket add RemoteViewer.SessionKit --version 0.9.12
#r "nuget: RemoteViewer.SessionKit, 0.9.12"
#:package RemoteViewer.SessionKit@0.9.12
#addin nuget:?package=RemoteViewer.SessionKit&version=0.9.12
#tool nuget:?package=RemoteViewer.SessionKit&version=0.9.12
SessionKit
Remote desktop as a library — for .NET. Drop cross-platform screen sharing and remote control into your own application, riding whatever secure channel you already have.
RemoteViewer.SessionKit is the session layer of a remote-desktop stack: it captures a screen, encodes it,
streams it, and injects the operator's mouse/keyboard back — plus clipboard, file transfer, and audio — all
multiplexed over a single transport-agnostic byte channel (ISessionChannel) that you provide. It does not
open sockets, traverse NATs, or run a relay: you bring the pipe (a WebSocket, a raw socket with framing, an SSH
tunnel, or ConnectKit for an encrypted NAT-traversing one), and SessionKit
is what flows over it.
your app ──▶ SessionHost(channel, screenSource, inputSink) // device: capture → encode → send, apply input
your app ──▶ ViewerSession(channel) // operator: OnFrame(bgra) + SendMouse/SendKey/…
If you're building remote support, an RMM/kiosk/POS tool, an industrial-HMI console, or any .NET app that needs "see and control that machine" — SessionKit is the embeddable core, without bundling a third-party product.
Why SessionKit
- .NET-native. A single NuGet package (net8.0 / net9.0), one dependency (SkiaSharp). No native SDK to vendor,
no C++ interop for you to maintain — it's
using RemoteViewer.SessionKit;and go. - Transport-agnostic. SessionKit never assumes a network. Anything that can carry a byte message — preserving message boundaries — is a valid channel, so it slots into apps that already have a connection.
- Cross-platform, both ends. Windows, Linux, and macOS can each be the host (the controlled device) and the viewer (the operator). Capture, input, and codecs are chosen per OS behind stable seams.
- Hardware H.264, license-clean. Video is JPEG-tile deltas by default, or hardware H.264 via each OS's native codec — Media Foundation (Windows), VideoToolbox (macOS), VA-API (Linux). Using the OS codec means the OS covers the H.264 patent licensing. The codec is negotiated automatically.
- Composable. Screen source, input sink, clipboard, and channel are all interfaces — swap in your own, or use the built-ins. Pairs with ConnectKit for a batteries-included-but-not-monolithic stack.
Install
dotnet add package RemoteViewer.SessionKit
Requires the .NET 8 or .NET 9 SDK. Sole dependency: SkiaSharp. New here? The downloads & getting-started hub has 5-minute quickstarts for the whole family (ConnectKit · SessionKit · ServerKit) and is where you get Premium/Suite keys.
30-second example
Host — capture this machine and apply the operator's input:
using RemoteViewer.SessionKit;
using RemoteViewer.SessionKit.Capture;
using RemoteViewer.SessionKit.Input;
var host = new SessionHost(
channel, // your ISessionChannel
WindowsScreenCapture.CreateBest(out _), // DXGI→GDI on Windows; see below for Linux/macOS
new WindowsInputSink(), // applies the viewer's mouse/keyboard
new HostOptions { MaxWidth = 1920, MaxFps = 15, Quality = 70 });
host.Start(); // capture/send loop runs until Dispose()
Viewer — show frames and drive the host:
using RemoteViewer.SessionKit;
using RemoteViewer.SessionKit.Input;
var viewer = new ViewerSession(channel);
viewer.OnFrame += frame =>
{
// frame.Bgra is tight BGRA8888 (Width*Height*4). Wrap it in your UI's bitmap and blit.
};
viewer.Start();
viewer.SendMouseMove(0.5f, 0.5f); // coordinates are normalized 0..1 across the frame
viewer.SendMouseButton(MouseButton.Left, down: true);
viewer.SendMouseButton(MouseButton.Left, down: false);
viewer.SendText("hello");
Full walkthrough (including a runnable offline selftest): GETTING-STARTED.md.
What's in the box
| Capability | Windows | Linux | macOS |
|---|---|---|---|
| Screen capture | DXGI (→ GDI fallback) | X11 (XGetImage) |
CoreGraphics¹ |
| Input inject | SendInput | XTest (mouse + Unicode text) | CGEvent (mouse + Unicode text) |
| H.264 encode | Media Foundation | VA-API (Intel/AMD) | VideoToolbox |
| H.264 decode | Media Foundation | VA-API | VideoToolbox |
| Clipboard | Win32 (text + image) | X11 via xclip (text + img) |
NSPasteboard (text + image)² |
| File transfer | ✓ (chunked, hashed) | ✓ | ✓ |
| Audio | WASAPI loopback + playback | PulseAudio (sink monitor) | CoreAudio (AudioQueue)³ |
| Two-way audio | + WASAPI mic capture | + PulseAudio mic (source) | + CoreAudio mic |
| Multi-monitor | GDI enum + select⁵ | XRandR enum + select | CoreGraphics enum + select |
| Cursor overlay | GetCursorInfo + shape | XFixes (shape + serial) | CoreGraphics + NSCursor shape⁴ |
¹ Needs Screen Recording permission; SessionKit ships preflight/request helpers. ² macOS clipboard converts a
copied TIFF (e.g. a screenshot) to PNG on read. ³ macOS capture is the default input device (system-audio loopback
needs ScreenCaptureKit or a virtual device). ⁴ macOS cursor shape is NSCursor.currentSystemCursor (this process's app cursor; the true system-wide glyph is a
ScreenCaptureKit follow-up). ⁵ The GDI source is
multi-monitor aware; the DXGI fast path is single-output, so multi-monitor uses GDI on Windows (DXGI multi-output
is a follow-up). Everything is multiplexed on one channel by a 1-byte tag.
Audio playback rides a jitter buffer (JitterBufferAudioSink) — pre-roll, wall-clock-paced release, a silence
floor for gaps/clock drift, and bounded latency — so remote audio stays smooth on jittery links. See
GETTING-STARTED for tuning.
Video is JPEG-tile deltas (only changed 16×16 tiles, JPEG-compressed) by default — no codec, works everywhere.
Supply an IVideoEncoder/IVideoDecoder to opt into H.264 instead; JPEG remains the automatic fallback.
Adaptive quality: the viewer reports what it actually receives, and the host lowers JPEG quality then frame
rate on a congested link (and raises them back when it clears) between the Quality/MaxFps ceilings and the
MinQuality/MinFps floors. Under H.264 the same signal retargets the encoder bitrate (Min/MaxBitrateKbps)
instead — the MF, VideoToolbox, and VA-API encoders all support it. On by default (HostOptions.Adaptive); watch
it via SessionHost.OnAdapt.
Loss recovery: video frames are sequence-numbered, so on a lossy transport the viewer detects a gap and asks for a keyframe (and drops stale frames), while the host sends a periodic keyframe backstop — a dropped delta or H.264 P-frame is repainted fast instead of leaving the screen corrupted. On by default; see GETTING-STARTED.
Security: SessionKit doesn't authenticate or encrypt the peer — that's the channel's job (run it over
ConnectKit's paired, encrypted channel). On top it offers a session consent gate: with
HostOptions.RequireControlApproval, the viewer's input is blocked until the host GrantControls it (and can be
revoked). See GETTING-STARTED.
Standard (free) & Premium (licensed)
SessionKit is one package. The Standard tier is free; Premium features unlock at runtime with a license key
— SessionKitLicense.Activate(yourKey) (see docs/LICENSING.md). Keys are issued by the central
AccountManagement service (payload product must be "sessionkit") and verified offline against an embedded public
key. Without a key, Premium
features degrade gracefully (H.264 falls back to JPEG-tile, adaptive is off at fixed quality, multi-monitor shows
the primary only) or throw when explicitly constructed (reconnect, jitter buffer, cursor, two-way audio).
| Standard (free) | Premium (licensed) | |
|---|---|---|
| Screen capture · input · clipboard · file transfer (both ways) | ✅ | ✅ |
| JPEG-tile video · host→viewer audio · control-approval consent gate | ✅ | ✅ |
| Hardware H.264 (MF/VA-API/VideoToolbox) + dynamic bitrate | — | ✅ |
| Adaptive quality (auto quality/FPS/bitrate to the link) | — | ✅ |
| Multi-monitor (enumerate + switch the captured display) | — | ✅ |
| Two-way audio (operator mic → host) + jitter buffer | — | ✅ |
Auto-reconnect (ReconnectingSessionChannel) |
— | ✅ |
| Cursor overlay (stream the host pointer to the viewer) | — | ✅ |
SessionKitLicense.Activate(key); // unlock Premium (buy a key on the project site)
if (SessionKitLicense.IsLicensed) { … } // or SessionKitLicense.Allows("h264")
A Suite bundle key (SessionKit Premium + ServerKit — see the product-family pricing at
remote-viewer.com) also unlocks Premium: it is issued as an ordinary SessionKit
key with features:["premium"], so the same Activate call covers everything, no extra setup.
Bring your own channel
public interface ISessionChannel
{
void Send(ReadOnlySpan<byte> data); // send one whole message
event Action<byte[]>? OnData; // one message received (boundaries preserved)
event Action? OnClosed;
}
The one rule: one Send must arrive as exactly one OnData. Datagram-like transports (ConnectKit,
WebSocket messages) satisfy this directly; over a raw TCP stream, add length-prefix framing in your adapter.
Codec negotiation
Supplying an encoder is always safe. The host doesn't assume the viewer can decode H.264 — on connect the viewer advertises the codecs it can decode, and the host switches to H.264 only when it can also encode it, else it stays on the JPEG-tile baseline every viewer understands. A viewer that can't do H.264 simply keeps getting JPEG.
Interoperable, verified
The H.264 wire format is platform-independent Annex-B. The full 3×3 encode/decode matrix — Media Foundation, VideoToolbox, VA-API — cross-decodes in every direction, verified on real Windows, macOS, and Linux hardware (including colorspace handling and multi-slice pictures). A Linux box captured over X11, encoded on its Intel iGPU, and streamed over TCP to a decoding viewer end-to-end.
Status — 0.9.9
Pre-1.0 but broadly exercised: 93 unit tests, an offline selftest, live two-process sessions on all three
OSes, and the cross-OS codec matrix above. Since 0.9.0 this adds — all verified on real Windows/Linux/macOS
hardware — 3-OS audio + two-way audio, an audio jitter buffer, cursor overlay (incl. macOS NSCursor),
adaptive quality + dynamic H.264 bitrate, sequence-numbered loss recovery, auto-reconnect,
multi-monitor, macOS clipboard, viewer→host file upload, a control-approval consent gate, and the
Standard/Premium license gate. The shipped package is a plain Release build (not obfuscated); the license gate is a soft deterrent backed by the central-signed key.
The public API (SessionHost / ViewerSession / ISessionChannel and the capture/input/codec seams) is settling
toward 1.0; remaining work (native Wayland capture, macOS ScreenCaptureKit) is additive behind the existing
interfaces and won't break your code.
Build & test from source
dotnet build SessionKit.slnx -c Release
dotnet test SessionKit.slnx
dotnet run --project samples/SessionKit.Sample -- selftest # offline host→loopback→viewer
License
Commercial / proprietary — see LICENSE.txt. Installation requires accepting the license terms. For evaluation, pricing, and Premium/Suite keys, see remote-viewer.com/downloads (or the product page).
Part of the RemoteViewer family
SessionKit is one layer of a three-part remote-desktop stack — Connection · Session · Server — that you adopt one piece at a time:
| Layer | Package / product | What it does | Cost |
|---|---|---|---|
| Connection | ConnectKit (RemoteViewer.ConnectKit) |
The encrypted, NAT-traversing pipe (IConnectChannel) — hole-punching, relay/gateway fallback, end-to-end crypto (J-PAKE + AES-256-GCM). |
Free |
| Session | SessionKit (RemoteViewer.SessionKit) |
What rides the pipe — screen capture, encode, input, clipboard, files, audio. This package. | Free + Premium |
| Server | ServerKit | Managed coordination/relay, peer-cap licensing, and a control plane + portal for running fleets. | Usage / tier |
Connection is never a paywall. ConnectKit is free and perpetual; you only pay on the session axis (SessionKit
Premium features) or the server axis (ServerKit scale/tier). SessionKit itself takes no ConnectKit dependency —
the two combine through a thin IConnectChannel → ISessionChannel adapter (shown in the sample), so you can pair
SessionKit with ConnectKit or any transport you like. A Suite bundle buys SessionKit Premium + ServerKit
together (a single key unlocks Premium here); see the family pricing.
Downloads, 5-minute quickstarts, and Premium/Suite keys → remote-viewer.com/downloads.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
0.9.12 — Viewer now recovers when the host restarts its stream while the channel stays up (e.g. a new SessionHost numbering frames from 1 on a desktop switch): a large backward video-sequence jump rebases and repaints instead of dropping every frame as stale. Tunable via ViewerOptions.StreamRestartSeqDrop (default 256). Additive, no API breaks.
0.9.11 — License authority moved to the central AccountManagement service (embedded central public key; the signed payload `product` must be `sessionkit`). The package is now a plain Release build (no obfuscation) — public API unchanged, more reliable and easier to debug.
0.9.10 — Expose the H264Nal Annex-B helper (public) with an allocation-free IsKeyframe, so an integrator forwarding raw H.264 to a browser (WebCodecs) can label keyframes without re-implementing NAL scanning. Additive, no API breaks.
0.9.9 — Since 0.9.0, all verified on real Windows/Linux/macOS hardware: 3-OS audio plus two-way audio (operator mic → host), an audio jitter buffer, cursor overlay (incl. macOS NSCursor), adaptive quality with dynamic H.264 bitrate, sequence-numbered loss recovery, auto-reconnect, multi-monitor (enumerate + switch), macOS clipboard, viewer→host file upload, and a session control-approval consent gate.
This release also introduces the Standard (free) / Premium (licensed) split: Premium features unlock at runtime via SessionKitLicense.Activate(key) and degrade gracefully (or throw when explicitly constructed) without one. A Suite bundle key (SessionKit Premium + ServerKit) unlocks Premium too.
Part of the RemoteViewer family — Connection = ConnectKit (free), Session = SessionKit, Server = ServerKit. Downloads, 5-minute quickstarts, and Premium/Suite keys: https://www.remote-viewer.com/downloads