1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-14 20:31:56 +00:00

support reload the gop_cache

This commit is contained in:
winlin 2013-12-15 12:08:01 +08:00
parent 2f397d0460
commit 7622878979
5 changed files with 24 additions and 2 deletions

View file

@ -63,6 +63,8 @@ SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd)
SrsClient::~SrsClient()
{
config->unsubscribe(this);
srs_freepa(ip);
srs_freep(req);
srs_freep(res);
@ -71,8 +73,6 @@ SrsClient::~SrsClient()
#ifdef SRS_HTTP
srs_freep(http_hooks);
#endif
config->unsubscribe(this);
}
// TODO: return detail message when error for client.

View file

@ -537,6 +537,7 @@ int SrsConfig::reload()
// merge config: vhost modified.
srs_trace("vhost %s modified, reload its detail.", vhost.c_str());
if (get_vhost_enabled(new_vhost) && get_vhost_enabled(old_vhost)) {
// gop_cache
if (!srs_directive_equals(new_vhost->get("gop_cache"), old_vhost->get("gop_cache"))) {
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
ISrsReloadHandler* subscribe = *it;
@ -547,6 +548,17 @@ int SrsConfig::reload()
}
srs_trace("vhost %s reload gop_cache success.", vhost.c_str());
}
// forward
if (!srs_directive_equals(new_vhost->get("forward"), old_vhost->get("forward"))) {
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
ISrsReloadHandler* subscribe = *it;
if ((ret = subscribe->on_reload_forward(vhost)) != ERROR_SUCCESS) {
srs_error("vhost %s notify subscribes forward failed. ret=%d", vhost.c_str(), ret);
return ret;
}
}
srs_trace("vhost %s reload forward success.", vhost.c_str());
}
// TODO: suppor reload hls/forward/ffmpeg/http
continue;
}

View file

@ -55,3 +55,8 @@ int ISrsReloadHandler::on_reload_gop_cache(string /*vhost*/)
return ERROR_SUCCESS;
}
int ISrsReloadHandler::on_reload_forward(string /*vhost*/)
{
return ERROR_SUCCESS;
}

View file

@ -44,6 +44,7 @@ public:
virtual int on_reload_pithy_print();
virtual int on_reload_vhost_removed(std::string vhost);
virtual int on_reload_gop_cache(std::string vhost);
virtual int on_reload_forward(std::string vhost);
};
#endif

View file

@ -374,10 +374,14 @@ SrsSource::SrsSource(string _stream_url, string _vhost)
_can_publish = true;
gop_cache = new SrsGopCache();
config->subscribe(this);
}
SrsSource::~SrsSource()
{
config->unsubscribe(this);
if (true) {
std::vector<SrsConsumer*>::iterator it;
for (it = consumers.begin(); it != consumers.end(); ++it) {