Skip to content

fix(rtsp): echo OPTIONS Session header in DESCRIBE#523

Merged
stackia merged 3 commits into
mainfrom
cursor/da84fbb4
Jun 12, 2026
Merged

fix(rtsp): echo OPTIONS Session header in DESCRIBE#523
stackia merged 3 commits into
mainfrom
cursor/da84fbb4

Conversation

@stackia

@stackia stackia commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Forward the Session header from OPTIONS into the subsequent DESCRIBE request, fixing playback against HMS-style RTSP edge nodes that assign a session before DESCRIBE.
  • Extend the RTSP mock server with an options_session_id mode and add a regression test in test_rtsp_transport.py.

Fixes #502 (RTSP unicast failure on HMS edge nodes).

Test plan

  • uv run pytest e2e/test_rtsp_transport.py::TestRTSPTCPStream::test_describe_echoes_options_session -v
  • Verify affected RTSP unicast sources play through rtp2httpd

Made with Cursor

HMS edge nodes assign a session during OPTIONS and drop the connection
when DESCRIBE omits it. Add an E2E mock and regression test.

Co-authored-by: Cursor <cursoragent@cursor.com>
@stackia stackia marked this pull request as ready for review June 12, 2026 05:29
Keep both IPv6 host support from main and HMS OPTIONS Session mock.

Co-authored-by: Cursor <cursoragent@cursor.com>
@stackia stackia requested a review from Copilot June 12, 2026 05:31

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a069424a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/rtsp.c Outdated
Comment on lines +1454 to +1456
if (session->session_id[0] != '\0') {
snprintf(extra_headers, sizeof(extra_headers), "Accept: application/sdp\r\nSession: %s\r\n", session->session_id);
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Echo the pre-setup Session on SETUP too

When an OPTIONS response establishes session->session_id, this path now echoes it only on DESCRIBE, but the subsequent SETUP request is still constructed with just Transport: in the RTSP_STATE_DESCRIBED branch. HMS-style servers that require the OPTIONS-issued Session to be echoed after DESCRIBE will still reject or close on SETUP, and the new mock does not catch this because it only enforces the header on DESCRIBE.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 5c7db74. Session injection is now centralized in rtsp_prepare_request(), so every request after the session is established (DESCRIBE, SETUP, PLAY, keepalive, TEARDOWN) echoes it, per RFC 2326 §12.37. The mock now also enforces the Session echo on all post-OPTIONS requests, and the e2e test asserts DESCRIBE/SETUP/PLAY all carry it.

@github-actions

Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-523.eastasia.1.azurestaticapps.net

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the RTSP client state machine to echo a Session header learned during the initial OPTIONS exchange in the subsequent DESCRIBE request, improving compatibility with HMS-style RTSP edge nodes that establish a session before DESCRIBE. It also extends the E2E mock RTSP server to simulate this behavior and adds a regression test.

Changes:

  • Echo Session from OPTIONS (if present) in the following DESCRIBE request (src/rtsp.c).
  • Extend the mock RTSP server to optionally return a Session in OPTIONS and require it in DESCRIBE (e2e/helpers/mock_rtsp.py).
  • Add an E2E regression test covering the OPTIONS→DESCRIBE Session echo (e2e/test_rtsp_transport.py).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/rtsp.c Adds conditional inclusion of Session header when preparing DESCRIBE after OPTIONS.
e2e/helpers/mock_rtsp.py Adds options_session_id mode to simulate servers assigning session at OPTIONS time.
e2e/test_rtsp_transport.py Adds regression test asserting DESCRIBE echoes the Session value from OPTIONS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rtsp.c Outdated
Comment on lines +1505 to +1507
if (session->session_id[0] != '\0') {
snprintf(extra_headers, sizeof(extra_headers), "Accept: application/sdp\r\nSession: %s\r\n", session->session_id);
} else {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Good catch — fixed in 5c7db74. rtsp_handle_redirect() now clears session_id before connecting to the new server, so a session learned from the previous server is never echoed to the redirected-to server.

Comment thread e2e/helpers/mock_rtsp.py Outdated
Comment on lines +148 to +150
"RTSP/1.0 200 OK\r\nCSeq: %s\r\n"
"Public: OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN\r\n\r\n" % cseq
"%s"
"Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE\r\n\r\n" % (cseq, session_line)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 5c7db74 — restored OPTIONS in the mock's Public header (back to the original list).

Address PR review feedback:
- Inject the Session header in rtsp_prepare_request() whenever a session
  is established, so SETUP (and every other request) also echoes a
  Session assigned at OPTIONS time, per RFC 2326 section 12.37
- Clear stale session_id on redirect so requests to the redirected-to
  server don't carry the previous server's session
- Mock: restore OPTIONS in the Public header and enforce the Session
  echo on all post-OPTIONS requests, not just DESCRIBE

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://thankful-water-0a297bf00-523.eastasia.1.azurestaticapps.net

@stackia stackia merged commit 49b5142 into main Jun 12, 2026
10 checks passed
@stackia stackia deleted the cursor/da84fbb4 branch June 12, 2026 05:47
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.

部分地址无法播放

2 participants