From 398620d52c3116c70f4367055077c92df626e8e3 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 19 May 2026 11:33:42 -0400 Subject: [PATCH] Edge: Fix RTMP late-join missing sequence headers. v6.0.186 (#4678) Backport of the RTMP late-join fix from v8.0.2 / v7.0.150 to the 6.0 release line. The HTTP-FLV inverted-guard bug from that fix does not apply to v6 (the lazy edge-mount mechanism that introduced it does not exist on this branch). RTMP players that join an edge stream after the first player fail to decode. After v6.0.179 (#4512) stopped creating SrsOriginHub on edge, the hub_active gate in SrsLiveSource::consumer_dumps() always evaluated false on edge. That gate guards the dump of cached onMetaData + AVC sequence header + AAC sequence header + GOP cache to a new consumer. Result: the first player attaches before the edge-pull starts and gets headers via the live fan-out, but every subsequent player gets coded payload with no codec config and ffmpeg aborts with `dimensions not set` / `Could not write header`. Fall back to the meta cache state when hub is NULL, so the dump path runs once the edge-pull has populated the cache. (trunk/src/app/srs_app_source.cpp) Co-Authored-By: Claude Opus 4.7 (1M context) --- trunk/doc/CHANGELOG.md | 1 + trunk/src/app/srs_app_source.cpp | 5 ++++- trunk/src/core/srs_core_version6.hpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 24887fb73..e8c84c3c8 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2026-05-19, Merge [#4678](https://github.com/ossrs/srs/pull/4678): Edge: Fix RTMP late-join missing sequence headers. v6.0.186 (#4678) * v6.0, 2025-12-06, Merge [#4605](https://github.com/ossrs/srs/pull/4605): DVR: Fix HEVC mp4 recording error. v6.0.185 (#4605) * v6.0, 2025-12-03, Merge [#4588](https://github.com/ossrs/srs/pull/4588): RTMP: Ignore FMLE start packet after flash publish. v6.0.184 (#4588) * v6.0, 2025-10-21, Merge [#4535](https://github.com/ossrs/srs/issues/4535): Bridge: Fix heap-use-after-free in SrsCompositeBridge iterator. v6.0.183 (#4535) diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 18b62f27a..8066f9f89 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -2721,7 +2721,10 @@ srs_error_t SrsLiveSource::consumer_dumps(SrsLiveConsumer* consumer, bool ds, bo } // If stream is publishing, dumps the sequence header and gop cache. - bool hub_active = hub ? hub->active() : false; + // On edge, hub is NULL; the source is "publishing" once the edge-pull has + // populated the meta cache. Late-joining consumers must still receive the + // cached metadata + sequence headers + GOP via this path. + bool hub_active = hub ? hub->active() : (meta->data() || meta->vsh() || meta->ash()); if (hub_active) { // Copy metadata and sequence header to consumer. if ((err = meta->dumps(consumer, atc, jitter_algorithm, dm, ds)) != srs_success) { diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index daddadf0c..def6a117f 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 185 +#define VERSION_REVISION 186 #endif