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.
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Includes LEB128 fixes and CVE dep updates.