Epic: #113 · Milestone: MC6 — Media engine
Why
This is the media engine proper, in Home, replacing the 139-line apps/media_player.home stub. It composes the stdlib bindings (#82), the HEVC driver (#84), the audio server (#81) and the compositor's video plane (#75). Design constraint: ≤ 3 threads (demux+decode-video, decode-audio, present) and bounded queues — no unbounded buffering on a 128 MB budget.
Tasks
- Source abstraction: file (local/USB/NVMe), SMB/NFS (#104), HTTP(S) with range requests, HLS (#87); read-ahead buffer sized by bitrate.
- Demux: MP4/MOV, MKV/WebM, MPEG-TS; track selection; container timestamps → 90 kHz master timeline; edit lists; attachments (fonts for ASS).
- Video: software decoders via bindings on a worker; hardware HEVC path; frame queue with PTS; presentation at vsync with the audio master clock, drop/repeat policy, judder-free 24p on 60 Hz (3:2) and optional mode switch to 24 Hz via #74.
- Audio: decode → resample → mixer; passthrough later.
- Controls: play/pause, seek (keyframe-accurate then exact), ±10 s skip, chapters, 2×/4×/8× trick play using I-frames, audio/subtitle track switch without reopen, playback speed for audio only (music).
- Gapless music; resume points persisted in the library DB; "still watching?" idle prompt.
- Error handling: corrupt streams degrade (skip GOP), never crash the shell; metrics (dropped frames, underruns) in
perf.
Acceptance
x86 QEMU: plays the reference 1080p clips (H.264+AAC MP4, HEVC+FLAC MKV, TS) with A/V drift < 40 ms measured by an embedded beep/flash marker; Pi: same, plus the gates in #88.