rtsp source: add rtspScale option to inject RFC 2326 Scale header on PLAY#5800
Open
Adiel-Sharabi wants to merge 1 commit into
Open
rtsp source: add rtspScale option to inject RFC 2326 Scale header on PLAY#5800Adiel-Sharabi wants to merge 1 commit into
Adiel-Sharabi wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5800 +/- ##
=======================================
Coverage 62.59% 62.59%
=======================================
Files 220 220
Lines 18779 18783 +4
=======================================
+ Hits 11754 11758 +4
- Misses 6060 6061 +1
+ Partials 965 964 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…PLAY Adds a new per-path option `rtspScale` for the RTSP static source. When set, the value is sent as the `Scale` header in the PLAY request, per RFC 2326 §12.34. Negative values play in reverse (-1.0 = realtime reverse, -2.0 = 2x reverse), values > 1 fast-forward, 0 < x < 1 plays in slow motion. Default empty = header omitted = current behavior. Useful when the upstream RTSP server is a VMS (Nx Witness, Pelco, Genetec, etc.) that honors Scale for archive playback. gortsplib's Client.Play(*headers.Range) doesn't accept a Scale parameter, so the header is injected via the existing OnRequest hook when Method == PLAY. Backward-compatible: no behavior change when rtspScale is empty. - internal/conf/path.go: add RTSPScale string field to Path - internal/staticsources/rtsp/source.go: inject Scale header in OnRequest - internal/staticsources/rtsp/source_test.go: TestScale verifies the header is set - api/openapi.yaml: add rtspScale to PathConf schema (keeps go2api lint in sync) - mediamtx.yml: document the new field Verified against a Nx Meta 6.1.1 server with a real Axis IP camera — the server returns 200 OK to the PLAY with Scale: -1.0 and streams reverse playback.
7430bf3 to
2b38dd4
Compare
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.
Summary
Adds a new per-path option
rtspScalefor the RTSP static source. When set, the value is sent as theScaleheader in the PLAY request, per RFC 2326 §12.34.-1.0= realtime reverse,-2.0= 2x reverseWhy
I'm integrating MediaMTX as the broker between a Windows access-control system and a Nx Meta VMS server. The VMS honors
Scale: -1.0to play archive recordings in reverse, which the customer needs for incident review (operator scrubs backwards through footage).gortsplib.Client.Play(*headers.Range)doesn't expose a Scale parameter anddoPlay()is unexported, so the cleanest way to inject the header is through the existingOnRequesthook on the static-sourceClient. When the request method isPLAYandrtspScaleis non-empty, we set the header before the request leaves the client.Other VMS servers (Pelco, Genetec, some Milestone deployments) follow the same RFC and would benefit too.
What's in the change
internal/conf/path.goRTSPScale stringfield onPath(json:rtspScale)internal/staticsources/rtsp/source.goOnRequesthook injectsScaleheader on PLAY whenRTSPScale != ""(10 lines)internal/staticsources/rtsp/source_test.goTestScale— verifies the header lands on the server sidemediamtx.ymlrtspRangeStartTotal diff: 4 files, 107 insertions, 0 deletions. No deprecations, no behavior change for users who don't set the field.
Example
Verification
TestScalepasses (go test ./internal/staticsources/rtsp/ -run TestScale)Scale: -1.0and streams the (server-side-interpreted) reverse playback.rtspScaleproduces identical RTSP traffic to current behavior.Open question for maintainers
Naming: I went with
rtspScaleto match the existingrtspRange{Type,Start}family. Happy to rename tortspPlayScaleor similar if you prefer.Test plan
go test ./...rtspScale: "-1.0"against any RTSP server that supports Scale; observe the header in the PLAY exchange (e.g. viatcpdump -Aor the server's debug log)