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

@@ -185,6 +185,13 @@ class LiveSubscriber(grant: LiveGrant) {
}
}
/** Wipe every key held; the subscriber opens nothing afterwards. */
fun close() {
forgetBefore(Long.MAX_VALUE)
link?.first?.fill(0)
link = null
}
private fun epochState(epoch: Long): EpochState? {
epochs[epoch]?.let { return it }
val (secret, from) = link ?: return null