- C 75.6%
- Rust 23.6%
- Metal 0.4%
- HLSL 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
QUIC transport, own UI renderer (Metal / D3D11), hardware H.264 screen streaming with stream audio, Opus voice. macOS and Windows clients, server and hub. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
| .cargo | ||
| apps | ||
| crates | ||
| scripts | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
shithole-app
ICQ-style Discord alternative with self-hosted servers. Rust, minimal dependencies.
Quick start
cargo build --release
./target/release/shithole-server --name "My server" # data in ./shithole-data, UDP 4433
./target/release/shithole # the app: enter host[:port] and a name
The server prints its certificate fingerprint; the app remembers it on first connect
(trust on first use) or you can paste it in. The account is an ed25519 key in
~/Library/Application Support/shithole/account.key; the first account on a server owns it.
Development helpers for the app: SHITHOLE_CONNECT=host:port SHITHOLE_NAME=… connects at
start, SHITHOLE_PROFILE=x uses a separate account (two clients on one Mac),
SHITHOLE_NO_AUDIO, SHITHOLE_AUTOSTREAM, SHITHOLE_AUTOWATCH, SHITHOLE_PRINT_WINDOW.
cargo run --release -p client-core --example say -- host:port Name "text" posts messages.
Windows
Cross-compiled from macOS with mingw-w64 (brew install mingw-w64, rustup target add x86_64-pc-windows-gnu):
export PATH="$HOME/.cargo/bin:$PATH" # rustup's toolchain, not Homebrew's rustc
cargo build --release --target x86_64-pc-windows-gnu -p client -p server
Needs Windows 10 1903+ (Windows.Graphics.Capture, flip-model swap chains). Backends:
platform-win (Win32), render-d3d11 (HLSL port of ui.metal; check with
glslangValidator -D -S frag -e ui_fragment -V crates/render-d3d11/shaders/ui.hlsl),
text-dwrite, audio-win (WASAPI + vendored libopus 1.5.2), media-win
(WGC → D3D11 video processor → Media Foundation H.264, hardware with software fallback),
stream-win. Settings live in %APPDATA%\shithole. Release builds have no console;
started from a terminal they log to it.
Detachable panels
The channel tree, chat and stream can live in their own windows (⧉ to pop out, ↩ or
closing the window to dock back); the choice is remembered in config.txt
(window.tree, window.chat, window.stream). The stream opens in its own window by default.
Layout
| Crate | What |
|---|---|
crates/media |
Platform-independent types: EncodedFrame, codecs, Annex B helpers, host clock |
crates/net |
Media wire format (sans-I/O): video sender with retransmit history, receiver with NACK (incl. tail-loss detection), in-order release and refresh requests, feedback messages, clock sync |
crates/media-mac |
ScreenCaptureKit capture, VideoToolbox hardware encode (with LTR) / decode, test pattern |
crates/transport |
QUIC (quinn): endpoints, certificate pinning by fingerprint, datagram channels |
crates/render-metal |
Metal backend: zero-copy NV12 video presenter |
crates/proto |
Client ↔ server control protocol, compact binary codec |
crates/client-core |
Client library: account key, connection, state model (+ e2e tests) |
crates/ui |
UI core: draw list, glyph atlas, immediate-mode widgets, Frutiger Aero theme |
crates/text-mac |
CoreText shaping/rasterization |
crates/platform-mac |
Window, input, IME, clipboard, on-demand frames |
crates/audio-mac |
Voice: AVAudioEngine with voice processing, Opus via AudioToolbox, jitter buffers |
crates/stream-mac |
Screen share broadcaster/viewer for the app |
apps/server |
shithole-server: SQLite, auth, chat, voice + screen-share relay (SFU) |
apps/client |
shithole: the desktop app |
apps/videolab |
Local pipeline test bench with a simulated network link |
Loss recovery
- NACK. Packets carry a sequence number. The receiver waits a short reorder window, then asks for missing packets (repeating about once per RTT); the sender resends from a ~0.5 s history. Frames are released strictly in order.
- Refresh. If a frame can't be completed within its deadline (~2 NACK rounds), the receiver drops it, stops decoding and sends a refresh request. The encoder answers with an LTR refresh: a small P-frame referencing a long-term reference frame the receiver has acknowledged. Without LTR it falls back to a keyframe.
- Bitrate adaptation (GCC-style). The receiver watches the delay trend of each frame's packets (a growing queue shows up long before loss), the queuing delay and the loss rate, and reports an estimate 5× per second. The sender combines it with the fill level of QUIC's send queue and retunes the encoder on the fly. Retransmissions are capped at 30% of the media bitrate so they can't flood a congested link.
VideoToolbox has no periodic intra refresh; LTR is Apple's equivalent for real-time
recovery. Intra refresh fits behind the same request_refresh() on NVENC/AMF/QSV.
videolab
capture → encode → packetize → simulated link (delay, jitter, loss both ways) → reassemble → decode → Metal window, with per-stage stats every second.
cargo run --release -p videolab -- --help
cargo run --release -p videolab # main display, HEVC 1080p60, RTT 30 ms
cargo run --release -p videolab -- --source test # synthetic pattern, no permission needed
cargo run --release -p videolab -- --loss 2 --jitter 10 # 2% loss each way, reordering
cargo run --release -p videolab -- --loss 2 --no-nack # refresh-only recovery
cargo run --release -p videolab -- --source test --headless --frames 600 --loss 3
# bottleneck: 20 Mbit/s, drops to 2.5 at second 8, back at 18
cargo run --release -p videolab -- --source test --headless --frames 1680 --bandwidth 20000,8:2500,18:20000
Over the network (QUIC)
# on the machine being captured
cargo run --release -p videolab -- send --listen 0.0.0.0:4433
# prints the certificate fingerprint and a ready-made recv command
# on the viewer
cargo run --release -p videolab -- recv --connect HOST:4433 --fingerprint <64 hex digits>
Video and feedback travel as QUIC datagrams (first byte = channel). The sender's
self-signed certificate is pinned by SHA-256 fingerprint; without --fingerprint the
receiver accepts any certificate and prints what it saw. The receiver estimates the clock
offset to the sender (ping/pong, lowest-RTT sample), so latency columns are valid across
machines. --loss drops that share of received packets on each side for testing.
Screen capture needs Screen Recording permission for the terminal app (System Settings → Privacy & Security → Screen Recording).
Latency columns: encode = capture → encoded, decoded = capture → decoded frame
(includes simulated one-way delay), on-screen = capture → Metal presentedTime.