Repository navigation
Let apps report a preferred stream format - #256
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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 optionalformatfield of theclient/stateplayer object, which replacedstream/request-formatin the spec.nullclears the preference.The new
supportedFormatsgetter lists the formats the player advertised, since they depend on the browser.MessageType.STREAM_REQUEST_FORMATstays, marked deprecated. The sample player has a dropdown for it.Related issue or spec PR (if applicable):
stream/request-formatto adapt to changing network/CPU conditions #115stream/request-formatintoclient/statespec#195Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies