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 @@
<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