feat: E-RTMP v2 connect negotiation and multitrack relay (0.4.0)#128
Conversation
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>
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>
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>
|
@codex review |
|
@cursor review |
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>
There was a problem hiding this comment.
💡 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".
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>
|
@codex review |
|
@cursor review |
|
@coderabbitai full review |
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>
There was a problem hiding this comment.
💡 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".
Bugbot couldn't run - usage limit reachedBugbot 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) |
|
Code review by qodo was updated up to the latest commit 96bbda5 |
| 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; | ||
| } | ||
|
|
There was a problem hiding this comment.
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
|
Code review by qodo was updated up to the latest commit 2806866 |
|
Code review by qodo was updated up to the latest commit 2c17e5b |
|
Code review by qodo was updated up to the latest commit 4390983 |
|
Code review by qodo was updated up to the latest commit d0a1ec0 |
Summary
econnect, _error) wired into the live session path.
eceiveAudio,
eceiveVideo, \closeStream).
Test plan
Made with Cursor
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.