diff --git a/README.md b/README.md index f6e8e133e..2fb12cdf0 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-02-05, For [#665][bug #665], fix HTTP-FLV reloading bug. 3.0.116 * v3.0, 2020-02-05, For [#1592][bug #1592], fix terminal echo off by redirect process stdin. 3.0.115 * v3.0, 2020-02-04, For [#1186][bug #1186], refactor security check. 3.0.114 * v3.0, 2020-02-04, Fix [#939][bug #939], response right A/V flag in FLV header. 3.0.113 @@ -1644,6 +1645,7 @@ Winlin [bug #939]: https://github.com/ossrs/srs/issues/939 [bug #1186]: https://github.com/ossrs/srs/issues/1186 [bug #1592]: https://github.com/ossrs/srs/issues/1592 +[bug #665]: https://github.com/ossrs/srs/issues/665 [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_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index c7720be19..7a0688fff 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -809,6 +809,11 @@ SrsLiveEntry::SrsLiveEntry(std::string m) _is_aac = (ext == ".aac"); } +SrsLiveEntry::~SrsLiveEntry() +{ + srs_freep(req); +} + bool SrsLiveEntry::is_flv() { return _is_flv; @@ -846,7 +851,6 @@ SrsHttpStreamServer::~SrsHttpStreamServer() std::map::iterator it; for (it = tflvs.begin(); it != tflvs.end(); ++it) { SrsLiveEntry* entry = it->second; - srs_freep(entry->req); srs_freep(entry); } tflvs.clear(); @@ -901,7 +905,9 @@ srs_error_t SrsHttpStreamServer::http_mount(SrsSource* s, SrsRequest* r) mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/"); entry = new SrsLiveEntry(mount); - + + entry->source = s; + entry->req = r->copy()->as_http(); entry->cache = new SrsBufferCache(s, r); entry->stream = new SrsLiveStream(s, r, entry->cache); @@ -971,7 +977,8 @@ srs_error_t SrsHttpStreamServer::on_reload_vhost_added(string vhost) srs_error_t SrsHttpStreamServer::on_reload_vhost_http_remux_updated(string vhost) { srs_error_t err = srs_success; - + + // Create new vhost. if (tflvs.find(vhost) == tflvs.end()) { if ((err = initialize_flv_entry(vhost)) != srs_success) { return srs_error_wrap(err, "init flv entry"); @@ -981,41 +988,27 @@ srs_error_t SrsHttpStreamServer::on_reload_vhost_http_remux_updated(string vhost // and do mount automatically on playing http flv if this stream is a new http_remux stream. return err; } - - SrsLiveEntry* tmpl = tflvs[vhost]; - SrsRequest* req = tmpl->req; - SrsSource* source = tmpl->source; - - if (source && req) { - // cleanup the exists http remux. - http_unmount(source, req); - } - - if (!_srs_config->get_vhost_http_remux_enabled(vhost)) { - return err; - } - - string old_tmpl_mount = tmpl->mount; - string new_tmpl_mount = _srs_config->get_vhost_http_remux_mount(vhost); - - /** - * TODO: not support to reload different mount url for the time being. - * if the mount is change, need more logical thing to deal with. - * such as erase stream from sflvs and free all related resource. - */ - srs_assert(old_tmpl_mount == new_tmpl_mount); - - // do http mount directly with SrsRequest and SrsSource if stream is played already. - if (req) { - std::string sid = req->get_stream_url(); - - // remount stream. - if ((err = http_mount(source, req)) != srs_success) { - return srs_error_wrap(err, "vhost %s http_remux reload failed", vhost.c_str()); + + // Update all streams for exists vhost. + // TODO: FIMXE: If url changed, needs more things to deal with. + std::map::iterator it; + for (it = sflvs.begin(); it != sflvs.end(); ++it) { + SrsLiveEntry* entry = it->second; + if (!entry || !entry->req || !entry->source) { + continue; + } + + SrsRequest* req = entry->req; + if (!req || req->vhost != vhost) { + continue; + } + + SrsSource* source = entry->source; + if (_srs_config->get_vhost_http_remux_enabled(vhost)) { + http_mount(source, req); + } else { + http_unmount(source, req); } - } else { - // for without SrsRequest and SrsSource if stream is not played yet, do http mount automatically - // when start play this http flv stream. } srs_trace("vhost %s http_remux reload success", vhost.c_str()); diff --git a/trunk/src/app/srs_app_http_stream.hpp b/trunk/src/app/srs_app_http_stream.hpp index 720e53e3a..a82e2a5a0 100755 --- a/trunk/src/app/srs_app_http_stream.hpp +++ b/trunk/src/app/srs_app_http_stream.hpp @@ -207,7 +207,9 @@ private: bool _is_aac; bool _is_mp3; public: + // We will free the request. SrsRequest* req; + // Shared source. SrsSource* source; public: // For template, the mount contains variables. @@ -218,6 +220,7 @@ public: SrsBufferCache* cache; SrsLiveEntry(std::string m); + virtual ~SrsLiveEntry(); bool is_flv(); bool is_ts(); diff --git a/trunk/src/core/srs_core_version3.hpp b/trunk/src/core/srs_core_version3.hpp index 523b6f501..7b51a0991 100644 --- a/trunk/src/core/srs_core_version3.hpp +++ b/trunk/src/core/srs_core_version3.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP -#define SRS_VERSION3_REVISION 115 +#define SRS_VERSION3_REVISION 116 #endif