feat(media): browser playback, live WebM and log streaming, shade media/live CLI
- Service Worker plays sealed files in native <video>/<audio>/<img> with Range seeking; watch page served by the relay itself (#shade= fragment links, grant never sent to a server) - MSE live player with keyframe-aware joining, gap detection, latency control - WebM splitter (init + clusters, keyframe detection) that puts blocks in timecode order — Chrome rejects ffmpeg's interleaved Opus/VP8 otherwise - Link mode for live channels: epoch seeds from a channel secret, so a link survives publisher restarts and scheduled rotations - File store streams byte ranges itself (Bun.file().slice() in a Response sent whole files to Range requests) - shade media serve|put|get|ls|rm, shade live text|webm|watch Verified end to end in headless Chromium: VP9/Opus film plays and seeks, live VP8/Opus at 2.9 s latency, live logs, sealed JPEG and Opus audio. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,11 @@ export interface LiveGrant {
|
||||
readToken?: Uint8Array;
|
||||
/** Channel title etc., as the publisher described it. */
|
||||
meta?: MediaMeta;
|
||||
/**
|
||||
* Link mode only: the secret every epoch seed derives from. A grant with
|
||||
* it reads this epoch and every later one, with no further grants.
|
||||
*/
|
||||
channelSecret?: Uint8Array;
|
||||
}
|
||||
|
||||
export type Grant = MediaGrant | LiveGrant;
|
||||
@@ -97,6 +102,7 @@ export function encodeGrant(g: Grant): string {
|
||||
seq: g.seq,
|
||||
chainKey: toB64u(g.chainKey),
|
||||
stickyKey: toB64u(g.stickyKey),
|
||||
...(g.channelSecret !== undefined ? { channelSecret: toB64u(g.channelSecret) } : {}),
|
||||
...(g.url !== undefined ? { url: g.url } : {}),
|
||||
...(g.readToken !== undefined ? { token: toB64u(g.readToken) } : {}),
|
||||
...(g.meta !== undefined ? { meta: g.meta } : {}),
|
||||
@@ -175,6 +181,7 @@ export function parseGrant(json: string): Grant {
|
||||
seq: int(o, 'seq', Number.MAX_SAFE_INTEGER),
|
||||
chainKey: fromB64u(str(o, 'chainKey'), 32),
|
||||
stickyKey: fromB64u(str(o, 'stickyKey'), 32),
|
||||
...(o.channelSecret !== undefined ? { channelSecret: fromB64u(str(o, 'channelSecret'), 32) } : {}),
|
||||
...optUrl(o),
|
||||
...optToken(o),
|
||||
...optMeta(o),
|
||||
|
||||
Reference in New Issue
Block a user