diff --git a/apps/sandbox/templates/spf-moq-player/index.html b/apps/sandbox/templates/spf-moq-player/index.html index b89c399bbb..f6fde4b904 100644 --- a/apps/sandbox/templates/spf-moq-player/index.html +++ b/apps/sandbox/templates/spf-moq-player/index.html @@ -251,7 +251,7 @@

MoQ Player

<simple-moq-video> inside the real <live-video-player> shell and skin — the MoQ engine driving actual Video.js controls. Defaults to a loopback relay: an in-page MSF - publisher speaking draft-20 bytes over an in-memory transport, so playback works with no server. Point at a real + publisher speaking draft-22 bytes over an in-memory transport, so playback works with no server. Point at a real relay with a full MSF URL (?relay=moqt://…%23msf:… — percent-encode the #, or the browser reads it as this page's fragment), or compose one from parts: relay host, broadcast path (what your token was issued for, e.g. mattypoo/room/42), and an optional JWT — the same diff --git a/apps/sandbox/templates/spf-moq-player/loopback-relay.ts b/apps/sandbox/templates/spf-moq-player/loopback-relay.ts index c9367107c1..41dafbaf98 100644 --- a/apps/sandbox/templates/spf-moq-player/loopback-relay.ts +++ b/apps/sandbox/templates/spf-moq-player/loopback-relay.ts @@ -45,9 +45,14 @@ const LOC_TIMESTAMP = 0x10; /** * The vi64 varint of draft-15+ (§8.1) — leading ones on the first byte give the encoded length minus one, so an L-byte - * encoding carries 7L value bits. NOT the QUIC RFC 9000 varint. + * encoding of up to 8 bytes carries 7L value bits, and the 9-byte form (first byte 0xFF) a full 64. NOT the QUIC RFC + * 9000 varint. Encoding stops at 8 bytes: their 56 bits hold every safe integer (up to `Number.MAX_SAFE_INTEGER`), and + * anything else is rejected rather than mis-encoded — a double can hold some larger integers exactly, such as 2^56. */ function varintByteLength(value: number): number { + if (!Number.isSafeInteger(value) || value < 0) + throw new RangeError(`varint: ${value} is not a safe unsigned integer`); + for (let length = 1; length < 8; length++) { if (value < 2 ** (7 * length)) return length; } @@ -684,8 +689,11 @@ export function createLoopbackRelay({ onLog }: LoopbackRelayOptions = {}): Loopb } const { value, done } = await reader.read(); - // Cancellation *is* the stream lifecycle (§6.4.2.3): the subscriber - // aborting its sending direction ends the subscription. + // A FIN only means the subscriber will send nothing more (§6.4.2.2), + // yet this loopback ends the subscription on it as well as on a + // cancellation (§6.4.2.3), which lands in the catch below. The player + // cancels with a reset and FINs only after the publisher has, so the + // shortcut never cuts a live subscription short. if (done) break; const merged = new Uint8Array(buffer.length + value.length); diff --git a/packages/spf/package.json b/packages/spf/package.json index c78b038449..94390e22df 100644 --- a/packages/spf/package.json +++ b/packages/spf/package.json @@ -80,7 +80,7 @@ }, "dependencies": { "@caprid/moq-core": "^0.1.1", - "@caprid/moq-media": "^0.1.1", + "@caprid/moq-media": "0.1.0", "@videojs/media": "workspace:*", "@videojs/utils": "workspace:*", "signal-polyfill": "^0.2.2" diff --git a/packages/spf/src/playback/actors/dom/audio-renderer.ts b/packages/spf/src/playback/actors/dom/audio-renderer.ts index 232dca6ce9..1cb1dd9773 100644 --- a/packages/spf/src/playback/actors/dom/audio-renderer.ts +++ b/packages/spf/src/playback/actors/dom/audio-renderer.ts @@ -198,10 +198,7 @@ const MAX_PLAYBACK_RATE = 2; const createDefaultAudioPlayer: CreateAudioPlayer = async (context) => { if (!context.baseContext) throw new Error('audio renderer context has no baseContext to host the AudioWorklet'); - // WebCodecs, not the core's WebAssembly libopus: that decoder is single-stream and ignores the OpusHead - // channel mapping, so a multistream (above stereo) track the catalog allows would decode as noise. A lost - // frame plays as silence instead of being concealed. - return createCoreAudioPlayer({ context: context.baseContext, lossConcealment: false }); + return createCoreAudioPlayer({ context: context.baseContext }); }; export function createAudioRendererActor(options: CreateAudioRendererOptions): AudioRendererActor { diff --git a/packages/spf/src/playback/actors/dom/tests/audio-renderer.test.ts b/packages/spf/src/playback/actors/dom/tests/audio-renderer.test.ts index add2aad311..dac483314a 100644 --- a/packages/spf/src/playback/actors/dom/tests/audio-renderer.test.ts +++ b/packages/spf/src/playback/actors/dom/tests/audio-renderer.test.ts @@ -1,4 +1,3 @@ -import { createAudioPlayer as createCoreAudioPlayer } from '@caprid/moq-media'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'; import type { JitterFrame } from '../../track-subscriber'; @@ -11,12 +10,6 @@ import { createAudioRendererActor, } from '../audio-renderer'; -vi.mock('@caprid/moq-media', async (importOriginal) => { - const original = await importOriginal(); - - return { ...original, createAudioPlayer: vi.fn(original.createAudioPlayer) }; -}); - const FRAME_US = 20_000; const JITTER_TARGET_US = 60_000; const TICK_MS = 10; @@ -579,9 +572,6 @@ describe('createAudioRendererActor', () => { await vi.advanceTimersByTimeAsync(0); expect(addModule).toHaveBeenCalledTimes(1); - // WebCodecs decoding: the core's WebAssembly libopus ignores a multistream - // OpusHead's channel mapping. - expect(createCoreAudioPlayer).toHaveBeenCalledWith({ context: baseContext, lossConcealment: false }); expect(renderer.snapshot.get().context.error).toBe(workletUnavailable); renderer.destroy(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 16b615102c..cabe0cead0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1251,8 +1251,8 @@ importers: specifier: ^0.1.1 version: 0.1.1 '@caprid/moq-media': - specifier: ^0.1.1 - version: 0.1.1 + specifier: 0.1.0 + version: 0.1.0 '@videojs/media': specifier: workspace:* version: link:../media @@ -2109,12 +2109,16 @@ packages: cpu: [x64] os: [win32] + '@caprid/moq-core@0.1.0': + resolution: {integrity: sha512-GWNqRU+XODpG/4fCUQVXYZtONVibYOY4BwYH4rt7lQuvBJ0sh49W4gw+1jAhY+a924bMGSSGzJ1shr8G5xMMmQ==} + engines: {node: '>=24'} + '@caprid/moq-core@0.1.1': resolution: {integrity: sha512-y6jUAxcqwutliM3gfIQeWspmw/rtfcJDgktgyx/JkRQwlMeiojMv8No6X4uVyTm2HwBDTRRagTVpDjtPQuhNrw==} engines: {node: '>=24'} - '@caprid/moq-media@0.1.1': - resolution: {integrity: sha512-H4KkqLqgdYz01hT2aG+gtza/Af9fXAOjfoMcR0OlbelQmnd9IC4ngCNlp17bPqyfUr7OOtiJzHN0EUxUrk91vQ==} + '@caprid/moq-media@0.1.0': + resolution: {integrity: sha512-Iu2+r7JYZoRYzoM9Xf3aK2KqBH8x26NGpKhdI3jFICoSr3IeAIXPYaad46HkHq68ottv5LwV4cxyVaFGrQfbZg==} engines: {node: '>=24'} '@capsizecss/unpack@4.0.0': @@ -11018,11 +11022,13 @@ snapshots: '@bruits/satteri-win32-x64-msvc@0.10.5': optional: true + '@caprid/moq-core@0.1.0': {} + '@caprid/moq-core@0.1.1': {} - '@caprid/moq-media@0.1.1': + '@caprid/moq-media@0.1.0': dependencies: - '@caprid/moq-core': 0.1.1 + '@caprid/moq-core': 0.1.0 '@capsizecss/unpack@4.0.0': dependencies: