Skip to content

feat: E-RTMP v2 connect negotiation and multitrack relay (0.4.0)#128

Merged
AlexanderWagnerDev merged 75 commits into
mainfrom
feat/ertmp-v2-multitrack-0.4.0
Jul 15, 2026
Merged

feat: E-RTMP v2 connect negotiation and multitrack relay (0.4.0)#128
AlexanderWagnerDev merged 75 commits into
mainfrom
feat/ertmp-v2-multitrack-0.4.0

Conversation

@AlexanderWagnerDev

@AlexanderWagnerDev AlexanderWagnerDev commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Release 0.4.0 with E-RTMP v2 connect negotiation (\ ourCcList, numeric \capsEx\ bitmask, \�ideoFourCcInfoMap,
    econnect, _error) wired into the live session path.
  • Add multitrack media support: opaque relay of full multitrack A/V messages, per-track \on_frame_cb\ with \Frame.track_id, and init-cache replay for late-joining players.
  • Enhanced init-frame classification (HEVC/AV1/Opus/AAC), \onMetaData\ caching/replay, client Aggregate + onMetaData receive, and legacy commands (\pause, \seek,
    eceiveAudio,
    eceiveVideo, \closeStream).

Test plan

  • \cargo test\ in \librtmp2/\
  • Publish multitrack E-RTMP v2 stream and verify late-joining player receives cached sequence-start headers
  • Verify connect _result\ includes negotiated \capsEx\ with multitrack bit
  • Smoke-test legacy H.264/AAC publisher + player still works

Made with Cursor


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

AlexanderWagnerDev and others added 2 commits July 14, 2026 22:06
Replace marketing-style feature claims with what is actually wired into
the live session path versus parser-only library code.
Wire enhanced connect caps, multitrack media parsing and opaque relay, per-track callbacks, init-cache for HEVC/AV1/Opus, onMetaData replay, legacy commands, and client Aggregate/onMetaData receive into the live session path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/session/conn.rs Outdated
Comment thread src/session/conn.rs
AlexanderWagnerDev and others added 3 commits July 14, 2026 22:28
Import Reconnect from types, add track_id to all explicit Frame initializers, and simplify multitrack callback dispatch.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Only strip negotiated ModEx prefixes when bytes are not enhanced A/V tags; copy multitrack track payloads into frame_cb_scratch before callbacks; relay opaque original payloads.

Co-authored-by: Cursor <cursoragent@cursor.com>
@AlexanderWagnerDev AlexanderWagnerDev self-assigned this Jul 14, 2026
Respond with simple S1/S2 to complex C1 instead of rejecting ffmpeg; fix multitrack init-cache test payload; keep frame payload alive in e2e_multiple_frames.

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

Copy link
Copy Markdown
Contributor Author

@codex review

@AlexanderWagnerDev

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread src/ertmp/connect_amf.rs Outdated
Comment thread src/client/mod.rs Outdated
When a client sends capsEx=0, negotiate_caps now keeps the zero mask instead of substituting server defaults. Play-side frame callbacks mirror Conn by splitting multitrack A/V via foreach_track and scratch buffer.

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

@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: d0649380ba

ℹ️ 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/ertmp/connect_amf.rs
Comment thread src/ertmp/multitrack_media.rs Outdated
Comment thread src/server/mod.rs Outdated
Comment thread src/message/command.rs Outdated
Comment thread src/server/mod.rs Outdated
Comment thread src/client/mod.rs
Comment thread src/session/conn.rs Outdated
Comment thread src/ertmp/multitrack_media.rs Outdated
Comment thread src/server/mod.rs Outdated
Comment thread src/ertmp/connect_amf.rs Outdated
Comment thread src/ertmp/connect_amf.rs
AlexanderWagnerDev and others added 4 commits July 14, 2026 22:58
Object and long-string capsEx forms now seed the v2 default bitmask while numeric capsEx=0 still disables extended bits. Also stop re-reading the AMF object marker after read_type.

Co-authored-by: Cursor <cursoragent@cursor.com>
Multitrack nibble order, outer keyframe detection, legacy capsEx/videoFourCcInfoMap parsing, closeStream 3-arg form, ModEx strip on legacy AAC, client aggregate subtag cap, init-cache limits/receiveVideo replay, and per-track sequence header retention.

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

Copy link
Copy Markdown
Contributor Author

@codex review

@AlexanderWagnerDev

Copy link
Copy Markdown
Contributor Author

@cursor review

@AlexanderWagnerDev

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

Comment thread src/session/conn.rs
Comment thread src/session/conn.rs Outdated
Relay onMetaData with the RTMP message timestamp (including aggregate sub-tags). Do not default to paused when pause AMF parsing fails.

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

@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: 617d3d2531

ℹ️ 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/session/conn.rs
Comment thread src/ertmp/connect_amf.rs Outdated
Comment thread src/server/mod.rs
Comment thread src/server/mod.rs
Comment thread src/ertmp/connect_amf.rs Outdated
Comment thread src/ertmp/connect_amf.rs Outdated
Comment thread src/server/mod.rs Outdated
Comment thread src/session/conn.rs
Comment thread src/media/init_cache.rs Outdated
Comment thread src/message/command.rs Outdated
@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_65ff277f-a829-45e3-8679-e4ddcb277214)

Comment thread src/session/conn.rs Outdated
Comment thread src/session/conn.rs Outdated
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 96bbda5

Comment thread src/server/mod.rs
Comment thread src/server/mod.rs
Comment on lines 689 to +696
for frame in &relay_frames {
let player_count = self.count_relay_players(frame);
if player_count > 0
&& relay_sends.saturating_add(player_count) > MAX_RELAY_SENDS_PER_POLL
{
break;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. Relay budget throttles fanout 🔗 Cross-repo conflict ☼ Reliability

This PR adds a hard-coded per-poll() relay-send budget (MAX_RELAY_SENDS_PER_POLL = 4096) that
can defer relaying queued publisher frames to later ticks; librtmp2-server runs server.poll() on a
fixed 50ms interval, so high fan-out streams can see increased relay latency and potentially more
backpressure when librtmp2-server upgrades to v0.4.0. Because librtmp2-server also configures
bounded relay-queue memory, this change can shift when/if publishers hit relay backpressure compared
to prior versions.
Agent Prompt
### Issue description
`librtmp2::server::Server::poll()` now enforces a hard-coded relay send budget (`MAX_RELAY_SENDS_PER_POLL`) and stops relaying when the budget would be exceeded, re-queuing the remainder. Downstream `librtmp2-server` polls every 50ms and also configures bounded relay queue memory, so this budget can increase relay latency/backpressure under high fan-out after upgrading to `librtmp2` v0.4.0.

### Issue Context
- The budget is currently not configurable from the public API.
- `librtmp2-server` drives `Server::poll(0)` in a fixed-interval loop and sets `server.resource_limits` based on its own config defaults.

### Fix Focus Areas
- src/server/mod.rs[65-70]
- src/server/mod.rs[687-696]

### Suggested approach
- Expose the relay-send budget as a public knob (e.g., add `max_relay_sends_per_poll` to `ResourceLimits` or `ServerConfig`, with a sensible default equal to the current constant).
- Use that configured value instead of the hard-coded constant.
- Document the new behavior/knob in the changelog or README so downstream integrators (notably `librtmp2-server`) can tune it relative to their poll cadence and max-connection targets.
- (Optional) Add a regression test ensuring the default remains bounded but configurable.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2806866

Comment thread .github/workflows/pr128-relay-budget-fixes.yml Outdated
Comment thread .github/workflows/pr128-relay-budget-fixes.yml Outdated
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2c17e5b

Comment thread .github/workflows/pr128-relay-budget-fixes.yml Outdated
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4390983

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d0a1ec0

@AlexanderWagnerDev AlexanderWagnerDev merged commit 99a2347 into main Jul 15, 2026
31 checks passed
@AlexanderWagnerDev AlexanderWagnerDev deleted the feat/ertmp-v2-multitrack-0.4.0 branch July 15, 2026 14:56
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