diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 860df66e1..a568386eb 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2021-10-28, Merge [#2186](https://github.com/ossrs/srs/pull/2186): Gop: Ignore zero timestamp when shrinking. v4.0.187 * v4.0, 2021-10-27, Merge [#1963](https://github.com/ossrs/srs/pull/1963): Cluster: Origin server shouldn't be it's own coworker. v4.0.186 * v4.0, 2021-10-25, Merge [#2692](https://github.com/ossrs/srs/pull/2692): API: Add server_id into http_hooks. v4.0.185 * v4.0, 2021-10-22, Merge [#2687](https://github.com/ossrs/srs/pull/2687): API: Always stat client event if auth fail. v4.0.183 diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index aae228b48..d6209b651 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -255,8 +255,11 @@ srs_error_t SrsMessageQueue::enqueue(SrsSharedPtrMessage* msg, bool* is_overflow srs_error_t err = srs_success; msgs.push_back(msg); - - if (msg->is_av()) { + + // If jitter is off, the timestamp of first sequence header is zero, which wll cause SRS to shrink and drop the + // keyframes even if there is not overflow packets in queue, so we must ignore the zero timestamps, please + // @see https://github.com/ossrs/srs/pull/2186#issuecomment-953383063 + if (msg->is_av() && msg->timestamp != 0) { if (av_start_time == -1) { av_start_time = srs_utime_t(msg->timestamp * SRS_UTIME_MILLISECONDS); } @@ -267,7 +270,7 @@ srs_error_t SrsMessageQueue::enqueue(SrsSharedPtrMessage* msg, bool* is_overflow if (max_queue_size <= 0) { return err; } - + while (av_end_time - av_start_time > max_queue_size) { // notice the caller queue already overflow and shrinked. if (is_overflow) { @@ -338,8 +341,7 @@ void SrsMessageQueue::shrink() SrsSharedPtrMessage* audio_sh = NULL; int msgs_size = (int)msgs.size(); - // remove all msg - // igone the sequence header + // Remove all msgs, mark the sequence headers. for (int i = 0; i < (int)msgs.size(); i++) { SrsSharedPtrMessage* msg = msgs.at(i); @@ -358,9 +360,10 @@ void SrsMessageQueue::shrink() } msgs.clear(); - // update av_start_time + // Update av_start_time, the start time of queue. av_start_time = av_end_time; - //push_back secquence header and update timestamp + + // Push back sequence headers and update their timestamps. if (video_sh) { video_sh->timestamp = srsu2ms(av_end_time); msgs.push_back(video_sh); diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index bb24f9adf..9b733cf82 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 186 +#define VERSION_REVISION 187 #endif