Skip to content

Let apps report a preferred stream format - #256

Merged
maximmaxim345 merged 2 commits into
mainfrom
feat/preferred-format
Nov 26, 2026
Merged

maximmaxim345 merged 2 commits into
mainfrom
feat/preferred-format

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

What does this implement/fix?

Apps can now tell the server which format they prefer at runtime with setPreferredFormat(), for example to switch between FLAC and Opus without reconnecting. It sends the optional format field of the client/state player object, which replaced stream/request-format in the spec. null clears the preference.

The new supportedFormats getter lists the formats the player advertised, since they depend on the browser. MessageType.STREAM_REQUEST_FORMAT stays, marked deprecated. The sample player has a dropdown for it.

Related issue or spec PR (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue): bugfix
  • New feature (non-breaking change which adds functionality): new-feature
  • Enhancement to an existing feature: enhancement
  • Breaking change (changes the public API or the protocol in a way that is not backwards compatible): breaking-change
  • Refactor (no behavior change): refactor
  • Documentation only: documentation
  • Maintenance / chore: maintenance
  • CI / workflow change: ci
  • Dependencies bump: dependencies

@github-actions github-actions Bot added the new-feature Adds new functionality label Nov 26, 2026
@maximmaxim345
maximmaxim345 requested an adaptive review from Copilot November 26, 2026 13:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The E2E test does not cover codec preference changes during active playback, verify the new format and decoded audio without reconnecting, or confirm that clearing the preference restores the server’s default selection.

1 open issue
What changed in this PR

Adds runtime stream-format preferences to the SDK through client/state, allowing apps to request format changes without reconnecting while retaining the deprecated message enum for compatibility.

Changes:

  • Exposes preferred-format controls and browser-supported format lists through the public player API.
  • Adds a sample-player dropdown and documents API usage.
  • Adds validation tests and an integration check for server adoption of a preference.
File Description
tests/​unit/​protocol-handler.test.ts Tests preference reporting, clearing, and validation.
tests/​helpers/​sendspin-server.py Exposes the server’s preferred format to tests.
tests/​helpers/​aiosendspin-server.ts Types the preferred-format test response.
tests/​e2e/​sendspin-security.e2e.test.ts Checks server adoption of a reported preference.
src/​types.ts Adds the state format field and deprecates the old message enum.
src/​index.ts Exposes format preferences and supported formats publicly.
src/​core/​protocol-handler.ts Validates preferences and includes them in state updates.
src/​core/​core.ts Delegates format APIs to the protocol handler.
README.md Documents runtime format preferences.
public/​app.js Populates and handles the format dropdown.
index.html Adds the preferred-format control.

Review effort: Balanced (adaptive)

Comment thread tests/e2e/sendspin-security.e2e.test.ts Resolved
@maximmaxim345
maximmaxim345 marked this pull request as ready for review November 26, 2026 13:59
@maximmaxim345
maximmaxim345 merged commit 7ee7ca3 into main Nov 26, 2026
6 checks passed
@maximmaxim345
maximmaxim345 deleted the feat/preferred-format branch November 26, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature Adds new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emit stream/request-format to adapt to changing network/CPU conditions

2 participants