feat(app): implement Phase 5 local UDP sender->receiver loopback

Wire the first end-to-end pipeline: capture -> encode -> packetize ->
UDP -> depacketize -> decode -> render.

- UdpRtpTransport: raw POSIX UDP sockets (IPv4 via getaddrinfo), a
  receive jthread woken by socket close on stop; port 0 skips binding
  so the sender uses an OS-assigned source port. ASIO stays deferred
  to the signaling phase per ARCHITECTURE.md.
- SdlRenderer: SDL3 window/renderer with RGBA texture upload; the
  texture is recreated on resolution change. RendererFactory now
  returns RendererResult so SDL init failures carry a message,
  mirroring the codec/capture error patterns.
- screencast binary: parse_cli plus SenderPipeline/ReceiverPipeline
  per the app scaffolds; the sender creates its encoder once capture
  reports real dimensions, the receiver keeps a bounded 3-frame queue
  to hold latency down and renders on its own thread until the window
  closes. cli argv signature fixed to 'const char* const*' so main's
  argv converts implicitly.
- Encoder: drop AV_CODEC_FLAG_GLOBAL_HEADER so libx264 repeats SPS/PPS
  in-band at each keyframe -- the receiver decodes from the bitstream
  alone, which also makes mid-stream joins and later PLI recovery
  work without out-of-band parameter negotiation. The round-trip test
  now exercises exactly that path.
- tests: new udp-loopback integration test pushes synthetic frames
  through a real localhost socket and decodes 10/10 frames with the
  right dimensions; valgrind clean (loopback + codec). meson test 4/4.

Manual validation on the desktop (receiver window shows the captured
desktop) is documented in docs/RUNBOOK.md.
This commit is contained in:
2026-09-07 11:02:40 +02:00
parent b5e8d7174c
commit 10870bc6c9
20 changed files with 1057 additions and 61 deletions
+4 -2
View File
@@ -85,14 +85,16 @@ int main() {
expect_codec_result("encoder create", encoder_result);
auto encoder = std::move(sc::codec_value(encoder_result));
// Without GLOBAL_HEADER the encoder carries no extradata; SPS/PPS are
// emitted in-band ahead of every keyframe. This mirrors the streaming
// path, where a receiver starts decoding from the bitstream alone.
const auto extradata = encoder->get_extradata();
assert(!extradata.empty());
assert(extradata.empty());
sc::DecoderConfig decoder_config;
decoder_config.codec_name = "h264";
decoder_config.width = kWidth;
decoder_config.height = kHeight;
decoder_config.extradata = extradata;
auto decoder_result = sc::DecoderFactory::create(decoder_config);
expect_codec_result("decoder create", decoder_result);