mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #319, move gop_cache and queue_length to play
This commit is contained in:
parent
06ae74dd3f
commit
f7c893d907
10 changed files with 105 additions and 151 deletions
|
@ -594,11 +594,11 @@ void SrsGopCache::dispose()
|
|||
clear();
|
||||
}
|
||||
|
||||
void SrsGopCache::set(bool enabled)
|
||||
void SrsGopCache::set(bool v)
|
||||
{
|
||||
enable_gop_cache = enabled;
|
||||
enable_gop_cache = v;
|
||||
|
||||
if (!enabled) {
|
||||
if (!v) {
|
||||
srs_info("disable gop cache, clear %d packets.", (int)gop_cache.size());
|
||||
clear();
|
||||
return;
|
||||
|
@ -607,6 +607,11 @@ void SrsGopCache::set(bool enabled)
|
|||
srs_info("enable gop cache");
|
||||
}
|
||||
|
||||
bool SrsGopCache::enabled()
|
||||
{
|
||||
return enable_gop_cache;
|
||||
}
|
||||
|
||||
int SrsGopCache::cache(SrsSharedPtrMessage* shared_msg)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
@ -1043,65 +1048,6 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsSource::on_reload_vhost_gop_cache(string vhost)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if (_req->vhost != vhost) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// gop cache changed.
|
||||
bool enabled_cache = _srs_config->get_gop_cache(vhost);
|
||||
|
||||
srs_trace("vhost %s gop_cache changed to %d, source url=%s",
|
||||
vhost.c_str(), enabled_cache, _req->get_stream_url().c_str());
|
||||
|
||||
set_cache(enabled_cache);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsSource::on_reload_vhost_queue_length(string vhost)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if (_req->vhost != vhost) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
double queue_size = _srs_config->get_queue_length(_req->vhost);
|
||||
|
||||
if (true) {
|
||||
std::vector<SrsConsumer*>::iterator it;
|
||||
|
||||
for (it = consumers.begin(); it != consumers.end(); ++it) {
|
||||
SrsConsumer* consumer = *it;
|
||||
consumer->set_queue_size(queue_size);
|
||||
}
|
||||
|
||||
srs_trace("consumers reload queue size success.");
|
||||
}
|
||||
|
||||
if (true) {
|
||||
std::vector<SrsForwarder*>::iterator it;
|
||||
|
||||
for (it = forwarders.begin(); it != forwarders.end(); ++it) {
|
||||
SrsForwarder* forwarder = *it;
|
||||
forwarder->set_queue_size(queue_size);
|
||||
}
|
||||
|
||||
srs_trace("forwarders reload queue size success.");
|
||||
}
|
||||
|
||||
if (true) {
|
||||
publish_edge->set_queue_size(queue_size);
|
||||
srs_trace("publish_edge reload queue size success.");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsSource::on_reload_vhost_play(string vhost)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
@ -1135,6 +1081,49 @@ int SrsSource::on_reload_vhost_play(string vhost)
|
|||
atc = v;
|
||||
}
|
||||
|
||||
// gop cache changed.
|
||||
if (true) {
|
||||
bool v = _srs_config->get_gop_cache(vhost);
|
||||
|
||||
if (v != gop_cache->enabled()) {
|
||||
string url = _req->get_stream_url();
|
||||
srs_trace("vhost %s gop_cache changed to %d, source url=%s", vhost.c_str(), v, url.c_str());
|
||||
gop_cache->set(v);
|
||||
}
|
||||
}
|
||||
|
||||
// queue length
|
||||
if (true) {
|
||||
double v = _srs_config->get_queue_length(_req->vhost);
|
||||
|
||||
if (true) {
|
||||
std::vector<SrsConsumer*>::iterator it;
|
||||
|
||||
for (it = consumers.begin(); it != consumers.end(); ++it) {
|
||||
SrsConsumer* consumer = *it;
|
||||
consumer->set_queue_size(v);
|
||||
}
|
||||
|
||||
srs_trace("consumers reload queue size success.");
|
||||
}
|
||||
|
||||
if (true) {
|
||||
std::vector<SrsForwarder*>::iterator it;
|
||||
|
||||
for (it = forwarders.begin(); it != forwarders.end(); ++it) {
|
||||
SrsForwarder* forwarder = *it;
|
||||
forwarder->set_queue_size(v);
|
||||
}
|
||||
|
||||
srs_trace("forwarders reload queue size success.");
|
||||
}
|
||||
|
||||
if (true) {
|
||||
publish_edge->set_queue_size(v);
|
||||
srs_trace("publish_edge reload queue size success.");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue