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:
@@ -131,6 +131,18 @@ player.prepare()
|
||||
|
||||
`ShadeMediaDataSource` serves the plaintext ranges ExoPlayer asks for; a tampered
|
||||
segment fails the read with a `DataSourceException` instead of reaching the decoder.
|
||||
|
||||
Live channels play too: `ShadeMedia.liveMediaSource(liveGrant)` connects a
|
||||
`LiveWatcher` (OkHttp WebSocket, reconnects with backoff, the relay's backlog
|
||||
deduplicated) and turns the frames into one endless WebM or fMP4 stream for
|
||||
ExoPlayer's own extractors: the init, then media from the first keyframe, and after
|
||||
any gap (a reconnect, the relay shedding a slow viewer) nothing until the next
|
||||
keyframe. A late joiner's timeline starts at 0:00: fMP4 through a per-join
|
||||
`TimestampAdjuster`, WebM by rewriting each cluster's Timecode in place. Otherwise a
|
||||
viewer arriving an hour in would wait an hour for the first sample. A different init
|
||||
mid-stream fails playback with a `ParserException`, which is not retried, rather than
|
||||
feeding the decoder a spliced stream. `LiveWatcher` on its own follows text and image
|
||||
channels.
|
||||
`:shade-media-demo` is a small player app for the dev phone: share a watch link to it,
|
||||
or start it with `adb shell am start -n no.zyon.shade.mediademo/.PlayerActivity --es link '<link>'`.
|
||||
Against `shade media serve` on the PC, `adb reverse tcp:3910 tcp:3910` makes a
|
||||
|
||||
Reference in New Issue
Block a user