Skip to content

feat(stream): expose upstream metadata headers#684

Open
stackia wants to merge 1 commit into
mainfrom
codex/upstream-metadata-headers
Open

feat(stream): expose upstream metadata headers#684
stackia wants to merge 1 commit into
mainfrom
codex/upstream-metadata-headers

Conversation

@stackia

@stackia stackia commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • expose a stable, allowlisted set of R2H-* upstream metadata headers for RTSP, multicast, FCC, MPEG-TS, and JPEG snapshot responses
  • add control-only RTSP HEAD probing through OPTIONS and DESCRIBE, while keeping multicast and FCC HEAD requests free of media joins or control requests
  • report negotiated RTSP transport, confirmed payload framing, playback metadata, SDP duration, and FCC startup status when those values are known
  • document the HTTP contract in both Chinese and English and add focused RTSP, multicast, FCC, snapshot, proxy, CORS, and configuration coverage

Motivation

Downstream HTTP clients need a consistent way to understand how a stream was sourced and negotiated without exposing sensitive upstream RTSP details or requiring a media parser. HEAD requests should provide all metadata available from static configuration or SDP without creating a media stream.

Implementation notes

Metadata is stored in a fixed-size stream_metadata_t and frozen when response headers are emitted. Unknown or unconfirmed values are omitted. RTSP HEAD probes stop after DESCRIBE and synchronously release the control connection before queuing the HTTP response, preventing later upstream hangups from dropping the response. The implementation intentionally does not expose FEC state or R2H-Metadata-Version.

Validation

  • CMake build
  • Clang format check
  • Ruff format and lint checks
  • E2E collection: 549 tests
  • RTSP transport: 12 passed
  • RTSP miscellaneous: 12 passed
  • focused Metadata/HEAD RTSP tests: 5 passed
  • VitePress documentation build

@stackia
stackia marked this pull request as ready for review July 19, 2026 11:29
@stackia
stackia requested a review from Copilot July 19, 2026 11:29

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview

The documentation preview has been deployed for this pull request.

@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: 620d21eb22

ℹ️ 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
Comment on lines +2851 to +2852
if (metadata && !metadata->frozen && rtsp_sdp_describes_mp2t_rtp(sdp_body)) {
metadata->upstream_payload = STREAM_PAYLOAD_MP2T_RTP;

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 Scope SDP payload detection to selected media track

When a DESCRIBE SDP has multiple m= sections and a later track advertises MP2T, this sets R2H-Upstream-Payload even though the code immediately below chooses the first media-level a=control for SETUP. For streams whose first track is H264/audio/etc. and a later track is MP2T, HEAD responses and early stream headers can incorrectly report mp2t-rtp for the proxied track; the payload probe should be limited to the same media section selected for SETUP.

Useful? React with 👍 / 👎.

Comment thread src/stream.c
Comment on lines +126 to +128
if (metadata->fcc_type != STREAM_FCC_TYPE_UNKNOWN && metadata->fcc_status == STREAM_FCC_STATUS_UNKNOWN) {
if (origin == STREAM_MEDIA_ORIGIN_FCC_UNICAST) {
metadata->fcc_status = STREAM_FCC_STATUS_ACTIVE;

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 Defer FCC status until media is actually output

When an FCC unicast packet is merely received, this marks status active before stream_process_rtp_payload and the reorder buffer have actually delivered any bytes to the client. If those unicast packets are still buffered or discarded and multicast supplies the first bytes that trigger the HTTP headers, for example after fallback during the reorderer's initial collection, the response will still say R2H-FCC-Status: active instead of fallback; defer the status choice until the origin that actually queues the first media.

Useful? React with 👍 / 👎.

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