web/moq: the WebSocket binding's capsules, WebTransport and the binding behind one transport interface (WebTransport first, offering moqt-22 and the relay's certificate hash; the binding as the fallback, or forced), a MOQT session (SETUP with the token, requests, every data stream read concurrently, GOAWAY), and the payload framings a WAI track carries. web/room: the room client (WebCodecs publishing with receipts, verified subscriptions, a late joiner's FETCH, the composed canvas and the mixed AudioWorklet, the events timeline and captions with their origin, the move after GOAWAY). web/compose: the composition corpus in the page. e2e: the relay on loopback from a test configuration, real Chrome through Playwright with a fake camera and microphone, each browser under memguard. Co-Authored-By: Claude Opus 5.5 <[email protected]>
37 lines
1.7 KiB
JavaScript
37 lines
1.7 KiB
JavaScript
// The payload framings a WAI track carries (SPEC §5), round-tripped
|
|
// (`node --test web/moq/media.test.mjs`).
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import * as media from "./media.js";
|
|
|
|
test("an IVF file of one VP9 frame", () => {
|
|
const f = Uint8Array.from([0x82, 0x49, 0x83, 0x42, 0x00]);
|
|
const b = media.ivfOne(f, 320, 240, 66666);
|
|
assert.equal(String.fromCharCode(...b.subarray(0, 4)), "DKIF");
|
|
assert.equal(String.fromCharCode(...b.subarray(8, 12)), "VP90");
|
|
assert.deepEqual(media.ivfFrames(b), [{ data: f, timestamp: 66666 }]);
|
|
});
|
|
|
|
test("an AV1 payload of one temporal unit", () => {
|
|
const tu = Uint8Array.from([0x12, 0x00, 0x0a, 0x0b]);
|
|
const b = media.av1One(tu, 320, 240, 15, 1);
|
|
assert.deepEqual(media.av1Units(b), [tu]);
|
|
assert.throws(() => media.av1Units(Uint8Array.from([...b, 0])));
|
|
});
|
|
|
|
test("an Ogg Opus stream of one packet, its CRCs checked", () => {
|
|
const pk = Uint8Array.from({ length: 300 }, (_, i) => i & 0xff);
|
|
const b = media.oggOpusOne(pk, { channels: 1, samples: 960 });
|
|
assert.deepEqual(media.oggOpusPackets(b), [pk]);
|
|
// The first page's CRC, for "OpusHead" with these fields, is the Ogg CRC-32 of RFC 3533.
|
|
const bad = b.slice();
|
|
bad[40] ^= 1;
|
|
assert.throws(() => media.oggOpusPackets(bad), /CRC/);
|
|
});
|
|
|
|
test("a manifest names its capability and keeps its member order", () => {
|
|
const m = JSON.parse(media.manifestFor("wai.video.vp9", { width: 320, height: 240, key: true }));
|
|
assert.deepEqual(Object.keys(m), ["wai", "media", "intent", "model_requirement", "conditioning", "target"]);
|
|
assert.equal(m.model_requirement.capability, "wai.video.vp9");
|
|
assert.equal(media.CAPABILITY_OF("av01.0.04M.08"), "wai.video.av1");
|
|
});
|