mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
For #464, refine code
This commit is contained in:
parent
ec362b2774
commit
55c96192e2
2 changed files with 11 additions and 11 deletions
|
@ -41,11 +41,11 @@ SrsCoWorkers::SrsCoWorkers()
|
||||||
SrsCoWorkers::~SrsCoWorkers()
|
SrsCoWorkers::~SrsCoWorkers()
|
||||||
{
|
{
|
||||||
map<string, SrsRequest*>::iterator it;
|
map<string, SrsRequest*>::iterator it;
|
||||||
for (it = vhosts.begin(); it != vhosts.end(); ++it) {
|
for (it = streams.begin(); it != streams.end(); ++it) {
|
||||||
SrsRequest* r = it->second;
|
SrsRequest* r = it->second;
|
||||||
srs_freep(r);
|
srs_freep(r);
|
||||||
}
|
}
|
||||||
vhosts.clear();
|
streams.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsCoWorkers* SrsCoWorkers::instance()
|
SrsCoWorkers* SrsCoWorkers::instance()
|
||||||
|
@ -90,8 +90,8 @@ SrsRequest* SrsCoWorkers::find_stream_info(string vhost, string app, string stre
|
||||||
|
|
||||||
// Get stream information from local cache.
|
// Get stream information from local cache.
|
||||||
string url = srs_generate_stream_url(conf->arg0(), app, stream);
|
string url = srs_generate_stream_url(conf->arg0(), app, stream);
|
||||||
map<string, SrsRequest*>::iterator it = vhosts.find(url);
|
map<string, SrsRequest*>::iterator it = streams.find(url);
|
||||||
if (it == vhosts.end()) {
|
if (it == streams.end()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,13 +105,13 @@ srs_error_t SrsCoWorkers::on_publish(SrsSource* s, SrsRequest* r)
|
||||||
string url = r->get_stream_url();
|
string url = r->get_stream_url();
|
||||||
|
|
||||||
// Delete the previous stream informations.
|
// Delete the previous stream informations.
|
||||||
map<string, SrsRequest*>::iterator it = vhosts.find(url);
|
map<string, SrsRequest*>::iterator it = streams.find(url);
|
||||||
if (it != vhosts.end()) {
|
if (it != streams.end()) {
|
||||||
srs_freep(it->second);
|
srs_freep(it->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always use the latest one.
|
// Always use the latest one.
|
||||||
vhosts[url] = r->copy();
|
streams[url] = r->copy();
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -120,10 +120,10 @@ void SrsCoWorkers::on_unpublish(SrsSource* s, SrsRequest* r)
|
||||||
{
|
{
|
||||||
string url = r->get_stream_url();
|
string url = r->get_stream_url();
|
||||||
|
|
||||||
map<string, SrsRequest*>::iterator it = vhosts.find(url);
|
map<string, SrsRequest*>::iterator it = streams.find(url);
|
||||||
if (it != vhosts.end()) {
|
if (it != streams.end()) {
|
||||||
srs_freep(it->second);
|
srs_freep(it->second);
|
||||||
vhosts.erase(it);
|
streams.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class SrsCoWorkers
|
||||||
private:
|
private:
|
||||||
static SrsCoWorkers* _instance;
|
static SrsCoWorkers* _instance;
|
||||||
private:
|
private:
|
||||||
std::map<std::string, SrsRequest*> vhosts;
|
std::map<std::string, SrsRequest*> streams;
|
||||||
private:
|
private:
|
||||||
SrsCoWorkers();
|
SrsCoWorkers();
|
||||||
virtual ~SrsCoWorkers();
|
virtual ~SrsCoWorkers();
|
||||||
|
|
Loading…
Reference in a new issue