Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/core/codec-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export function getSupportedFormats(codecs: Codec[]): SupportedFormat[] {
const browserSupported = getBrowserSupportedCodecs();
const selected = codecs.filter((codec) => browserSupported.has(codec));

// Servers only have to support flac and pcm, so the protocol requires at
// least one of them in the list. When neither was requested or survived the
// filter, append both (where the browser decodes them) at lowest priority,
// flac first for its lower bandwidth.
// Servers only have to support flac and pcm at 16-bit and 44.1 or 48 kHz,
// so the list always offers at least one of them that way. When neither was
// requested or survived the filter, append both (where the browser decodes
// them) at lowest priority, flac first for its lower bandwidth.
if (!selected.includes("flac") && !selected.includes("pcm")) {
const fallback = (["flac", "pcm"] as Codec[]).filter((codec) =>
browserSupported.has(codec),
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/codec-support.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Covers browser codec detection (Safari / Firefox / Chrome, with and without
* WebCodecs AudioDecoder), format expansion rules, browser filtering of
* requested codecs, and the flac/pcm entry the protocol requires.
* requested codecs, and the flac/pcm entry every server can serve.
*
* navigator / AudioDecoder / window don't exist in node; each test installs
* the minimal globals it needs and restores them afterward.
Expand Down Expand Up @@ -146,8 +146,9 @@ describe("getSupportedFormats", () => {
expect(formats.some((f) => f.codec === "opus")).toBe(false);
});

// Servers only have to support flac and pcm, so a player must offer at
// least one of them; the fallback is flac then pcm, as the browser allows.
// Servers only have to support flac and pcm at 16-bit and 44.1 or 48 kHz,
// so the list always offers at least one of them that way. The fallback is
// flac then pcm, as the browser allows.
describe("flac/pcm guarantee", () => {
beforeEach(() => {
vi.spyOn(console, "warn").mockImplementation(() => {});
Expand Down
Loading