From 5d365bade862d121cad780aa57657bef5ed1d3e0 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 27 Jan 2020 19:46:08 +0800 Subject: [PATCH] Fix #1303, do not dispatch previous meta when not publishing. 3.0.109 --- README.md | 2 ++ trunk/src/app/srs_app_source.cpp | 36 +++++++++++++++++++------------- trunk/src/app/srs_app_source.hpp | 5 +++-- trunk/src/core/srs_core.hpp | 2 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index cea746070b..1e27dcf5b8 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-27, Fix [#1303][bug #1303], do not dispatch previous meta when not publishing. 3.0.109 * v3.0, 2020-01-26, Allow use libst.so for ST is MPL license. * v3.0, 2020-01-26, Fix [#607][bug #607], set RTMP identifying recursive depth to 3. * v3.0, 2020-01-25, Fix [#878][bug #878], remove deprecated #EXT-X-ALLOW-CACHE for HLS. 3.0.108 @@ -1628,6 +1629,7 @@ Winlin [bug #703]: https://github.com/ossrs/srs/issues/703 [bug #878]: https://github.com/ossrs/srs/issues/878 [bug #607]: https://github.com/ossrs/srs/issues/607 +[bug #1303]: https://github.com/ossrs/srs/issues/1303 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index dd42b55907..3bf9e0c657 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -903,6 +903,11 @@ srs_error_t SrsOriginHub::cycle() return err; } +bool SrsOriginHub::active() +{ + return is_active; +} + srs_error_t SrsOriginHub::on_meta_data(SrsSharedPtrMessage* shared_metadata, SrsOnMetaDataPacket* packet) { srs_error_t err = srs_success; @@ -2458,10 +2463,10 @@ srs_error_t SrsSource::create_consumer(SrsConnection* conn, SrsConsumer*& consum consumer = new SrsConsumer(this, conn); consumers.push_back(consumer); - + srs_utime_t queue_size = _srs_config->get_queue_length(req->vhost); consumer->set_queue_size(queue_size); - + // if atc, update the sequence header to gop cache time. if (atc && !gop_cache->empty()) { if (meta->data()) { @@ -2474,22 +2479,25 @@ srs_error_t SrsSource::create_consumer(SrsConnection* conn, SrsConsumer*& consum meta->ash()->timestamp = srsu2ms(gop_cache->start_time()); } } - - // Copy metadata and sequence header to consumer. - if ((err = meta->dumps(consumer, atc, jitter_algorithm, dm, ds)) != srs_success) { - return srs_error_wrap(err, "meta dumps"); - } - - // copy gop cache to client. - if (dg && (err = gop_cache->dump(consumer, atc, jitter_algorithm)) != srs_success) { - return srs_error_wrap(err, "gop cache dumps"); + + // If stream is publishing, dumps the sequence header and gop cache. + if (hub->active()) { + // Copy metadata and sequence header to consumer. + if ((err = meta->dumps(consumer, atc, jitter_algorithm, dm, ds)) != srs_success) { + return srs_error_wrap(err, "meta dumps"); + } + + // copy gop cache to client. + if (dg && (err = gop_cache->dump(consumer, atc, jitter_algorithm)) != srs_success) { + return srs_error_wrap(err, "gop cache dumps"); + } } - + // print status. if (dg) { - srs_trace("create consumer, queue_size=%.2f, jitter=%d", queue_size, jitter_algorithm); + srs_trace("create consumer, active=%d, queue_size=%.2f, jitter=%d", hub->active(), queue_size, jitter_algorithm); } else { - srs_trace("create consumer, ignore gop cache, jitter=%d", jitter_algorithm); + srs_trace("create consumer, active=%d, ignore gop cache, jitter=%d", hub->active(), jitter_algorithm); } // for edge, when play edge stream, check the state diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index b0696346eb..dba9540dae 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -330,7 +330,6 @@ class SrsOriginHub : public ISrsReloadHandler private: SrsSource* source; SrsRequest* req; - // Whether the stream hub is active, or stream is publishing. bool is_active; private: // The format, codec information. @@ -364,6 +363,8 @@ class SrsOriginHub : public ISrsReloadHandler // Cycle the hub, process some regular events, // For example, dispose hls in cycle. virtual srs_error_t cycle(); + // Whether the stream hub is active, or stream is publishing. + virtual bool active(); public: // When got a parsed metadata. virtual srs_error_t on_meta_data(SrsSharedPtrMessage* shared_metadata, SrsOnMetaDataPacket* packet); @@ -376,7 +377,7 @@ class SrsOriginHub : public ISrsReloadHandler virtual srs_error_t on_publish(); // When stop publish stream. virtual void on_unpublish(); - // Internal callback. +// Internal callback. public: // For the SrsForwarder to callback to request the sequence headers. virtual srs_error_t on_forwarder_start(SrsForwarder* forwarder); diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index eb575ba5a7..6fb3a06b62 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 108 +#define VERSION_REVISION 109 // The macros generated by configure script. #include