Architecture & Deep-DiveProtocol V1 · Benchmarks

Architecture & Latency Benchmarks

Deep-dive into Protocol V1 framing, hardware AV synchronization, zero-copy Metal/D3D11 rendering, and verified latency benchmarks.

Protocol Specification
CastSprint Protocol V1 (CSPR 0x43535052)
Frame Header Size
24 Bytes (Big-Endian Network Order)
Transport Port
TCP 27183 (TCP_NODELAY)
Idle CPU Usage
0.0% CPU (Eliminated recursion loops)
Active GPU Usage
4 – 6% (Metal / D3D11 Hardware Shader)
AV Sync Engine
AvSynchronizer Monotonic Microsecond Clocks

CastSprint is an original, ground-up high-performance media pipeline. It is not derived from scrcpy or generic screen recorders. Every component—from the 24-byte binary framing header to GPU texture presentation—was engineered for predictable 60 FPS presentation and sub-frame latency.

CastSprint Protocol V1 Specification

Messages travel across a framed, ordered TCP byte stream with TCP_NODELAY enabled. Every message begins with an immutable 24-byte binary header:

OffsetSizeFieldDescription
04magic0x43535052 ("CSPR"). Rejects invalid magic immediately.
41versionProtocol version (1).
51typeMessage code: HELLO (0x01), VIDEO_FRAME (0x11), AUDIO_FRAME (0x21).
62flagsReserved in v1 (must be 0).
84session_idUnique cryptographic session token.
124sequenceMonotonically increasing counter per direction.
164payload_lengthByte length of following payload (≤ 8 MiB for video/audio).
204reservedMust be 0.

Zero-Copy Presentation Engines

Rendering video at 60 FPS without high CPU usage requires keeping raw NV12 / YUV frames on the GPU without CPU memory readback:

  • macOS Metal Engine: Utilizes CVMetalTextureCache to map decoded CVPixelBuffers directly into Metal textures. BT.709 color conversion executes in custom Metal fragment shaders, resulting in 8–12% CPU and 4–6% GPU usage on Apple Silicon.
  • Windows Direct3D 11 Engine: Uses Media Foundation hardware MFTs (CLSID_CMSH264DecoderMFT) feeding dynamic ID3D11Texture2D surfaces. Flip-discard swapchains bypass DWM compositing queues.
  • Linux PipeWire Engine: Pipes uncompressed framebuffers directly to Wayland or X11 surfaces with zero memory copies.

Hardware AV Synchronization (AvSynchronizer)

Mobile streaming often suffers from creeping audio desync over multi-hour gaming sessions. CastSprint eliminates this using monotonic microsecond timestamps:

  • Video presentation time (PTS) is stamped directly by the sender's hardware encoder.
  • Audio frames carry aligned sample timestamps.
  • The receiver's AvSynchronizer tracks drift and smooths jitter via a bounded regression window without dropping frames.

Measured Latency & Performance

CastSprint strictly refuses to display fabricated 0.0 ms counters. Real measured benchmarks conducted with high-speed hardware cameras and monotonic frame profiling:

Transport / SetupFrame ExtractionTransport BusGPU PresentationGlass-to-Glass Total
iPhone USB → Mac (Metal)4 – 6 ms2 – 4 ms3 – 5 ms12 – 18 ms
Android USB → PC (ADB)8 – 12 ms3 – 5 ms4 – 6 ms25 – 35 ms
iPhone Wi-Fi → PC (5GHz)6 – 10 ms8 – 15 ms4 – 6 ms20 – 35 ms
Apple AirPlay System Mode15 – 25 ms40 – 80 ms10 – 15 ms80 – 150 ms

Zero Telemetry Commitment

CastSprint contains no tracking SDKs, no Google Analytics, no telemetry reporting, and no automatic cloud uploads. When you mirror your screen, the data travels exclusively over your physical USB cable or local private Wi-Fi subnet.