1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Fix #665, fix HTTP-FLV reloading bug. 3.0.116

This commit is contained in:
winlin 2020-02-05 14:17:30 +08:00
parent f6fa889393
commit fc769550db
4 changed files with 36 additions and 38 deletions

View file

@ -146,6 +146,7 @@ For previous versions, please read:
## V3 changes ## 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-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, 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 * 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 #939]: https://github.com/ossrs/srs/issues/939
[bug #1186]: https://github.com/ossrs/srs/issues/1186 [bug #1186]: https://github.com/ossrs/srs/issues/1186
[bug #1592]: https://github.com/ossrs/srs/issues/1592 [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 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
[exo #828]: https://github.com/google/ExoPlayer/pull/828 [exo #828]: https://github.com/google/ExoPlayer/pull/828

View file

@ -809,6 +809,11 @@ SrsLiveEntry::SrsLiveEntry(std::string m)
_is_aac = (ext == ".aac"); _is_aac = (ext == ".aac");
} }
SrsLiveEntry::~SrsLiveEntry()
{
srs_freep(req);
}
bool SrsLiveEntry::is_flv() bool SrsLiveEntry::is_flv()
{ {
return _is_flv; return _is_flv;
@ -846,7 +851,6 @@ SrsHttpStreamServer::~SrsHttpStreamServer()
std::map<std::string, SrsLiveEntry*>::iterator it; std::map<std::string, SrsLiveEntry*>::iterator it;
for (it = tflvs.begin(); it != tflvs.end(); ++it) { for (it = tflvs.begin(); it != tflvs.end(); ++it) {
SrsLiveEntry* entry = it->second; SrsLiveEntry* entry = it->second;
srs_freep(entry->req);
srs_freep(entry); srs_freep(entry);
} }
tflvs.clear(); 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"/", "/"); mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/");
entry = new SrsLiveEntry(mount); entry = new SrsLiveEntry(mount);
entry->source = s;
entry->req = r->copy()->as_http();
entry->cache = new SrsBufferCache(s, r); entry->cache = new SrsBufferCache(s, r);
entry->stream = new SrsLiveStream(s, r, entry->cache); 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 SrsHttpStreamServer::on_reload_vhost_http_remux_updated(string vhost)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
// Create new vhost.
if (tflvs.find(vhost) == tflvs.end()) { if (tflvs.find(vhost) == tflvs.end()) {
if ((err = initialize_flv_entry(vhost)) != srs_success) { if ((err = initialize_flv_entry(vhost)) != srs_success) {
return srs_error_wrap(err, "init flv entry"); 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. // and do mount automatically on playing http flv if this stream is a new http_remux stream.
return err; return err;
} }
SrsLiveEntry* tmpl = tflvs[vhost]; // Update all streams for exists vhost.
SrsRequest* req = tmpl->req; // TODO: FIMXE: If url changed, needs more things to deal with.
SrsSource* source = tmpl->source; std::map<std::string, SrsLiveEntry*>::iterator it;
for (it = sflvs.begin(); it != sflvs.end(); ++it) {
if (source && req) { SrsLiveEntry* entry = it->second;
// cleanup the exists http remux. if (!entry || !entry->req || !entry->source) {
http_unmount(source, req); continue;
} }
if (!_srs_config->get_vhost_http_remux_enabled(vhost)) { SrsRequest* req = entry->req;
return err; if (!req || req->vhost != vhost) {
} continue;
}
string old_tmpl_mount = tmpl->mount;
string new_tmpl_mount = _srs_config->get_vhost_http_remux_mount(vhost); SrsSource* source = entry->source;
if (_srs_config->get_vhost_http_remux_enabled(vhost)) {
/** http_mount(source, req);
* TODO: not support to reload different mount url for the time being. } else {
* if the mount is change, need more logical thing to deal with. http_unmount(source, req);
* 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());
} }
} 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()); srs_trace("vhost %s http_remux reload success", vhost.c_str());

View file

@ -207,7 +207,9 @@ private:
bool _is_aac; bool _is_aac;
bool _is_mp3; bool _is_mp3;
public: public:
// We will free the request.
SrsRequest* req; SrsRequest* req;
// Shared source.
SrsSource* source; SrsSource* source;
public: public:
// For template, the mount contains variables. // For template, the mount contains variables.
@ -218,6 +220,7 @@ public:
SrsBufferCache* cache; SrsBufferCache* cache;
SrsLiveEntry(std::string m); SrsLiveEntry(std::string m);
virtual ~SrsLiveEntry();
bool is_flv(); bool is_flv();
bool is_ts(); bool is_ts();

View file

@ -24,6 +24,6 @@
#ifndef SRS_CORE_VERSION3_HPP #ifndef SRS_CORE_VERSION3_HPP
#define SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP
#define SRS_VERSION3_REVISION 115 #define SRS_VERSION3_REVISION 116
#endif #endif