1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-12 11:21:52 +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.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

View file

@ -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<std::string, SrsLiveEntry*>::iterator it;
for (it = tflvs.begin(); it != tflvs.end(); ++it) {
SrsLiveEntry* entry = it->second;
srs_freep(entry->req);
srs_freep(entry);
}
tflvs.clear();
@ -902,6 +906,8 @@ srs_error_t SrsHttpStreamServer::http_mount(SrsSource* s, SrsRequest* r)
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);
@ -972,6 +978,7 @@ 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");
@ -982,40 +989,26 @@ srs_error_t SrsHttpStreamServer::on_reload_vhost_http_remux_updated(string vhost
return err;
}
SrsLiveEntry* tmpl = tflvs[vhost];
SrsRequest* req = tmpl->req;
SrsSource* source = tmpl->source;
// Update all streams for exists vhost.
// TODO: FIMXE: If url changed, needs more things to deal with.
std::map<std::string, SrsLiveEntry*>::iterator it;
for (it = sflvs.begin(); it != sflvs.end(); ++it) {
SrsLiveEntry* entry = it->second;
if (!entry || !entry->req || !entry->source) {
continue;
}
if (source && req) {
// cleanup the exists http remux.
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);
}
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());
}
} 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());

View file

@ -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();

View file

@ -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