Skip to content

Remove SessionIdPolicy; always use latest session ID#3

Merged
steelbrain merged 1 commit into
mainfrom
steelbrain/auto-session-id
Apr 27, 2026
Merged

Remove SessionIdPolicy; always use latest session ID#3
steelbrain merged 1 commit into
mainfrom
steelbrain/auto-session-id

Conversation

@steelbrain

Copy link
Copy Markdown
Owner

Cameras occasionally return a different Session ID on audio SETUP than was issued on video SETUP. Previously the default policy threw, with .useFirst available as an opt-in escape hatch. Neither covered the case where the camera only honors the latest ID at PLAY time, so users hit dead-ends without a clear remedy.

The new behavior unconditionally adopts whatever ID the latest SETUP returned. This matches what most of the ecosystem already does silently — GStreamer rtspsrc, Live555 (and VLC via Live555), gortsplib/MediaMTX, and ExoPlayer all overwrite on every response. FFmpeg is the lone "use first" outlier, and retina (the Rust project IPCamKit was ported from) is the only library that exposes a policy enum at all.

Removes the public SessionIdPolicy type and the
sessionIdPolicy: parameter from RTSPClientSession.init; breaking change, ships in 0.2.0.

Cameras occasionally return a different Session ID on audio SETUP
than was issued on video SETUP. Previously the default policy
threw, with `.useFirst` available as an opt-in escape hatch.
Neither covered the case where the camera only honors the latest
ID at PLAY time, so users hit dead-ends without a clear remedy.

The new behavior unconditionally adopts whatever ID the latest
SETUP returned. This matches what most of the ecosystem already
does silently — GStreamer rtspsrc, Live555 (and VLC via Live555),
gortsplib/MediaMTX, and ExoPlayer all overwrite on every response.
FFmpeg is the lone "use first" outlier, and retina (the Rust
project IPCamKit was ported from) is the only library that
exposes a policy enum at all.

Removes the public `SessionIdPolicy` type and the
`sessionIdPolicy:` parameter from `RTSPClientSession.init`;
breaking change, ships in 0.2.0.
@steelbrain steelbrain merged commit 41f6f0d into main Apr 27, 2026
2 checks passed
@steelbrain steelbrain deleted the steelbrain/auto-session-id branch April 27, 2026 19:14
steelbrain added a commit that referenced this pull request May 30, 2026
Cap the unparsed read buffer (4 MiB) and Content-Length (2 MiB) so a
camera that never frames a message, or declares an absurd body, can no
longer exhaust memory. Trim header field names (not just values) so
"CSeq : 1" still routes; tolerate bare-LF line endings and tab/junk in
the status line (Postel). Scan for the header terminator in place via
withUnsafeBytes instead of copying the whole buffer each call, which was
O(n^2) as a body streams in.

Addresses audit findings #2/#3/#15/#37/#39/#42/#56. Adds regression
tests including a mixed CRLF-headers/bare-LF-terminator case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant