mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
support reload the gop_cache
This commit is contained in:
parent
2f397d0460
commit
7622878979
5 changed files with 24 additions and 2 deletions
|
@ -63,6 +63,8 @@ SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd)
|
||||||
|
|
||||||
SrsClient::~SrsClient()
|
SrsClient::~SrsClient()
|
||||||
{
|
{
|
||||||
|
config->unsubscribe(this);
|
||||||
|
|
||||||
srs_freepa(ip);
|
srs_freepa(ip);
|
||||||
srs_freep(req);
|
srs_freep(req);
|
||||||
srs_freep(res);
|
srs_freep(res);
|
||||||
|
@ -71,8 +73,6 @@ SrsClient::~SrsClient()
|
||||||
#ifdef SRS_HTTP
|
#ifdef SRS_HTTP
|
||||||
srs_freep(http_hooks);
|
srs_freep(http_hooks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
config->unsubscribe(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: return detail message when error for client.
|
// TODO: return detail message when error for client.
|
||||||
|
|
|
@ -537,6 +537,7 @@ int SrsConfig::reload()
|
||||||
// merge config: vhost modified.
|
// merge config: vhost modified.
|
||||||
srs_trace("vhost %s modified, reload its detail.", vhost.c_str());
|
srs_trace("vhost %s modified, reload its detail.", vhost.c_str());
|
||||||
if (get_vhost_enabled(new_vhost) && get_vhost_enabled(old_vhost)) {
|
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"))) {
|
if (!srs_directive_equals(new_vhost->get("gop_cache"), old_vhost->get("gop_cache"))) {
|
||||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||||
ISrsReloadHandler* subscribe = *it;
|
ISrsReloadHandler* subscribe = *it;
|
||||||
|
@ -547,6 +548,17 @@ int SrsConfig::reload()
|
||||||
}
|
}
|
||||||
srs_trace("vhost %s reload gop_cache success.", vhost.c_str());
|
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
|
// TODO: suppor reload hls/forward/ffmpeg/http
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,3 +55,8 @@ int ISrsReloadHandler::on_reload_gop_cache(string /*vhost*/)
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ISrsReloadHandler::on_reload_forward(string /*vhost*/)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
virtual int on_reload_pithy_print();
|
virtual int on_reload_pithy_print();
|
||||||
virtual int on_reload_vhost_removed(std::string vhost);
|
virtual int on_reload_vhost_removed(std::string vhost);
|
||||||
virtual int on_reload_gop_cache(std::string vhost);
|
virtual int on_reload_gop_cache(std::string vhost);
|
||||||
|
virtual int on_reload_forward(std::string vhost);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -374,10 +374,14 @@ SrsSource::SrsSource(string _stream_url, string _vhost)
|
||||||
_can_publish = true;
|
_can_publish = true;
|
||||||
|
|
||||||
gop_cache = new SrsGopCache();
|
gop_cache = new SrsGopCache();
|
||||||
|
|
||||||
|
config->subscribe(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsSource::~SrsSource()
|
SrsSource::~SrsSource()
|
||||||
{
|
{
|
||||||
|
config->unsubscribe(this);
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
std::vector<SrsConsumer*>::iterator it;
|
std::vector<SrsConsumer*>::iterator it;
|
||||||
for (it = consumers.begin(); it != consumers.end(); ++it) {
|
for (it = consumers.begin(); it != consumers.end(); ++it) {
|
||||||
|
|
Loading…
Reference in a new issue