Skip to content

Commit cfc0f60

Browse files
fix(rtmp): chunk decoder multi-chunk reassembly and MSRV compat
The chunk decoder's decode_message() returned Ok(None) after decoding each individual chunk of a multi-chunk message, causing the caller's while-let loop to exit before continuation chunks were processed. When the server sent messages exceeding 128 bytes (the default chunk size) — such as YouTube's _result response to the connect command (~191 bytes, split into two chunks) — the second chunk was stranded in the decoder buffer, the _result was never processed, and the connection timed out. Fix: wrap decode_message() in an internal loop that keeps consuming continuation chunks from the buffer until the message is complete or there truly isn't enough data for the next chunk. Also: - Replace is_multiple_of() with % N == 0 for MSRV < 1.85 compat - Add full_youtube_server_simulation integration test covering the complete Handshaking → Publishing state machine flow Signed-off-by: Devin AI <devin@cognition.ai> Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
1 parent 70fd90c commit cfc0f60

File tree

2 files changed

+319
-167
lines changed

2 files changed

+319
-167
lines changed

crates/nodes/src/transport/rtmp.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,9 @@ fn process_video_packet(
931931
counter.add(1, labels);
932932
stats.sent();
933933

934-
if *packet_count <= 5 || (*packet_count).is_multiple_of(100) {
934+
// `% N == 0` instead of `.is_multiple_of(N)` for MSRV < 1.85 compat.
935+
#[allow(clippy::manual_is_multiple_of)]
936+
if *packet_count <= 5 || *packet_count % 100 == 0 {
935937
tracing::debug!(%node_name, packet = *packet_count, %timestamp_ms, %keyframe, "Sent video");
936938
}
937939

@@ -1013,7 +1015,9 @@ fn process_audio_packet(
10131015
counter.add(1, labels);
10141016
stats.sent();
10151017

1016-
if *packet_count <= 5 || (*packet_count).is_multiple_of(200) {
1018+
// `% N == 0` instead of `.is_multiple_of(N)` for MSRV < 1.85 compat.
1019+
#[allow(clippy::manual_is_multiple_of)]
1020+
if *packet_count <= 5 || *packet_count % 200 == 0 {
10171021
tracing::debug!(%node_name, packet = *packet_count, %timestamp_ms, "Sent audio");
10181022
}
10191023

0 commit comments

Comments
 (0)