Skip to content

protocol/chunk: reset chunk encoder state on stream end - #4

Merged
torresjeff merged 1 commit into
torresjeff:mainfrom
urlynn:fix/protocol-bugs
Sep 5, 2026
Merged

torresjeff merged 1 commit into
torresjeff:mainfrom
urlynn:fix/protocol-bugs

Conversation

@urlynn

@urlynn urlynn commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The server's per-connection chunk encoder keeps its per-chunk-stream timestamp/format state across sessions. When a publisher disconnects and reconnects on the same downstream connection, the new session's first timestamp (0) is encoded as a delta against the stale high timestamp -> timestamp regression. Reference implementations bind encoder state to the session (ffmpeg rtmp_close frees prev_pkt, SRS builds a fresh SrsProtocol per connection).

Add ChunkEncoder::reset() (clears per-stream state, keeps chunk size) and call it from handle_stream_ended.

The server's per-connection chunk encoder keeps its per-chunk-stream
timestamp/format state across sessions. When a publisher disconnects and
reconnects on the same downstream connection, the new session's first
timestamp (0) is encoded as a delta against the stale high timestamp ->
timestamp regression. Reference implementations bind encoder state to the
session (ffmpeg rtmp_close frees prev_pkt, SRS builds a fresh SrsProtocol
per connection).

Add ChunkEncoder::reset() (clears per-stream state, keeps chunk size) and
call it from handle_stream_ended.
@torresjeff

Copy link
Copy Markdown
Owner

Thanks for this!

@torresjeff
torresjeff merged commit f635a4c into torresjeff:main Sep 5, 2026
@urlynn
urlynn deleted the fix/protocol-bugs branch September 5, 2026 12:35
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.

2 participants