-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Proposed 2.0.26 release with RTMP encode/decode fixes #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add timestamp offset tracking for late subscribers joining live streams. Keyframe detection mode now properly switches to SEND_ALL once a keyframe is available. Added waitingForKeyframe flag to track state when waiting for the first keyframe before allowing frame sending. Changes: - Add publisherTimestampOffset field for tracking publisher timestamp - Add waitingForKeyframe flag to control frame sending before first keyframe - Initialize streamStartTS to 0 for late subscribers to generate proper relative timestamps - Enhance debug logging for keyframe availability and codec state - Clean up unused code in RTMP protocol encoders/decoders
The decode(byte[]) method was incorrectly processing LEB128 encoded data, treating it as big-endian when LEB128 is by definition little-endian (Little Endian Base 128). Key fixes: - decode(byte[]): Now correctly reads bytes in little-endian order, where the LSB 7-bit group comes first. Each byte is processed sequentially with the 7 data bits shifted into position. - encode(byte[]): Simplified to delegate to decode, as the original logic was fundamentally broken for LEB128 encoding. LEB128 format per AV1 spec: - Each byte contains 7 bits of data (LSB) + 1 continuation bit (MSB) - Bytes are read in the order they appear in the packet - First byte contains least significant 7-bit group Example: value 150 - Old (wrong): Would read bytes in big-endian order, producing incorrect results - New (correct): Reads [0x96, 0x01] as: (0x16 << 0) | (0x01 << 7) = 22 + 128 = 150 Also fixed test data with correct LEB128 expected values.
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
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 proposes the 2.0.26 release of Red5 Server, which includes critical RTMP encode/decode fixes, LEB128 encoding/decoding improvements, and dependency updates to address CVE vulnerabilities.
- Version bump from 2.0.25 to 2.0.26 across all modules
- Refactored RTMP codec to remove Red5.getConnectionLocal() usage and pass connection directly to encoder
- Fixed LEB128 encode/decode logic to properly handle little-endian base-128 format
- Updated dependencies: Spring (6.2.11 → 6.2.15), Tomcat (11.0.14 → 11.0.15), Commons-lang3 (3.17.0 → 3.18.0)
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| pom.xml | Updated parent version to 2.0.26 and dependency versions (Spring, Tomcat, Commons-lang3) |
| common/pom.xml, client/pom.xml, io/pom.xml, server/pom.xml, service/pom.xml, servlet/pom.xml, tests/pom.xml | Updated parent version references to 2.0.26 |
| common/src/main/java/org/red5/server/api/Red5.java | Updated version strings to 2.0.26 |
| client/src/main/java/org/red5/client/Red5Client.java | Updated client version string to 2.0.26 |
| io/src/main/java/org/red5/io/utils/LEB128.java | Rewrote decode(byte[]) to properly handle LEB128 little-endian format; simplified encode(byte[]) to delegate to decode |
| io/src/test/java/org/red5/io/utils/LEB128Test.java | Enhanced test with better documentation and round-trip validation |
| common/src/main/java/org/red5/server/net/rtmp/event/BaseEvent.java | Set default sourceType to SOURCE_TYPE_LIVE |
| common/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolEncoder.java | Removed Red5.getConnectionLocal() usage; added conn field set via setConnection() |
| common/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolDecoder.java | Removed unused Red5.getConnectionLocal() import and encoding check |
| common/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaProtocolEncoder.java | Updated to set connection on encoder instead of using Red5.getConnectionLocal() |
| common/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaProtocolDecoder.java | Removed Red5.getConnectionLocal() usage |
| common/src/main/java/org/red5/server/stream/ClientBroadcastStream.java | Added debug logging when setting source type to LIVE |
| common/src/main/java/org/red5/server/stream/PlayEngine.java | Added late subscriber timestamp handling, keyframe waiting logic, and extensive debug logging |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
common/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolEncoder.java
Show resolved
Hide resolved
common/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolEncoder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolEncoder.java
Show resolved
Hide resolved
common/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolEncoder.java
Show resolved
Hide resolved
common/src/main/java/org/red5/server/net/rtmp/codec/RTMPProtocolEncoder.java
Outdated
Show resolved
Hide resolved
…olEncoder.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…olEncoder.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…olEncoder.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…olEncoder.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
PlayEngine changes: - Track audio and video base timestamps separately for late subscribers - Both audio and video now start at ts=2 for proper A/V sync - Reorder playLive() to send audio config before keyframe (DTS ordering fix) - Add debug logging for video frame delivery path RTMPConnection changes: - Reduce BytesRead acknowledgement interval from 1MB to 128KB - More frequent acknowledgements improve encoder compatibility - Add debug logging for BytesRead messages RTMP codec improvements: - Enhanced extended timestamp handling for timestamps >= 0xFFFFFF - Per-channel timestamp offset tracking for discontinuity compensation - Improved timestamp delta calculations in encoder Debug logging additions: - ClientBroadcastStream: video reception and livePipe push logging - VideoFrameDropper: state transition and frame drop decision logging - TestRTMPUtils: comprehensive tests for RTMP utility methods
Includes LEB128 fixes and CVE dep updates.