feat(media,android): live channels in ExoPlayer — LiveWatcher, ShadeLiveDataSource

LiveWatcher is the Android LiveWatchClient (OkHttp WebSocket, subscribe
with the read token, reconnect with backoff, backlog deduplicated by the
subscriber). ShadeLiveDataSource turns frames into one endless WebM/fMP4
stream for ExoPlayer's extractors: init, then media from the first
keyframe, and after a gap nothing until the next keyframe. Late joiners
start at 0:00 (fMP4: per-join TimestampAdjuster; WebM: cluster Timecode
rewritten in place). A changed init fails with a ParserException (not
retried). The demo app plays live video and follows log channels.
LiveSubscriber.close() wipes keys, as in TS.

Verified (Robolectric): late join on H.264/AAC fMP4 and VP8/Opus WebM cut
by the TS splitter (fixtures from scripts/make-live-fixtures.ts) plays
from the keyframe, rebased (mutation check: without the rebase the WebM
test fails, 5020 vs 4250 ms); gap recovery; format change; LiveWatcher
against MockWebServer with a dropped connection and backlog replay.
Kotlin 81/0. Not yet run on a device.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-18 21:53:17 +02:00
parent 8c7300fa51
commit 9efe1bcfd3
13 changed files with 848 additions and 15 deletions

View File

@@ -50,6 +50,10 @@ New package **`@shade/media`** — see `docs/media.md`.
`:shade-android-media` plays sealed files in Media3/ExoPlayer
(`ShadeMediaDataSource`, `ShadeMedia.mediaSource(reader)`), and
`:shade-media-demo` is a player app that opens a shared watch link.
Live channels on Android: `LiveWatcher` (OkHttp) and
`ShadeMedia.liveMediaSource(grant)` play live WebM/fMP4 in ExoPlayer,
with late joining from a keyframe, gap recovery and the timeline rebased
to 0:00.
### Fixed