Fix Snapserver.stream_control() so command-specific parameters are sent in the nested params object expected by Snapserver's Stream.Control JSON-RPC API.
The current implementation passes control_params into _request() as a generic parameters mapping, which causes values such as position or offset to be flattened into the top-level request parameters.
This means parameterless commands such as play, pause, playPause, stop, next, and previous can work, while parameterized commands such as seek and setPosition are sent with an invalid payload.
This PR sends control arguments under the required nested params key, makes control_params optional, defaults parameterless commands to "params": {}, preserves the existing parameterless transport controls, and enables correctly formatted seek and setPosition requests.
Tests
Adds regression tests for the exact JSON-RPC payload generated for:
a parameterless pause command
a parameterized setPosition command
The tests verify that Stream.Control requests match the format expected by Snapserver.
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
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.
Summary
Fix Snapserver.stream_control() so command-specific parameters are sent in the nested params object expected by Snapserver's Stream.Control JSON-RPC API.
The current implementation passes control_params into _request() as a generic parameters mapping, which causes values such as position or offset to be flattened into the top-level request parameters.
This means parameterless commands such as play, pause, playPause, stop, next, and previous can work, while parameterized commands such as seek and setPosition are sent with an invalid payload.
Current behavior
A call such as:
currently produces the equivalent of:
{ "id": "stream", "command": "setPosition", "position": 12.5 }Snapserver expects:
{ "id": "stream", "command": "setPosition", "params": { "position": 12.5 } }Changes
This PR sends control arguments under the required nested params key, makes control_params optional, defaults parameterless commands to "params": {}, preserves the existing parameterless transport controls, and enables correctly formatted seek and setPosition requests.
Tests
Adds regression tests for the exact JSON-RPC payload generated for:
The tests verify that Stream.Control requests match the format expected by Snapserver.