mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine code to use the one coding style.
This commit is contained in:
parent
4bb17f0c81
commit
40ed2249e8
3 changed files with 34 additions and 32 deletions
|
@ -525,8 +525,8 @@ int SrsApiVhosts::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
std::set<std::string> vhost_set;
|
std::set<std::string> vhost_set;
|
||||||
SrsStreamInfoMap* pool = SrsStatistic::instance()->get_pool();
|
std::map<void*, SrsStreamInfo*>* pool = SrsStatistic::instance()->get_pool();
|
||||||
SrsStreamInfoMap::iterator it;
|
std::map<void*, SrsStreamInfo*>::iterator it;
|
||||||
for (it = pool->begin(); it != pool->end(); it++) {
|
for (it = pool->begin(); it != pool->end(); it++) {
|
||||||
if (it->second->_req == NULL)
|
if (it->second->_req == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
@ -572,8 +572,8 @@ int SrsApiStreams::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
|
||||||
if (query_name.size() > 0 || query_vhost.size() > 0) {
|
if (query_name.size() > 0 || query_vhost.size() > 0) {
|
||||||
ss << __SRS_JARRAY_START;
|
ss << __SRS_JARRAY_START;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
SrsStreamInfoMap* pool = SrsStatistic::instance()->get_pool();
|
std::map<void*, SrsStreamInfo*>* pool = SrsStatistic::instance()->get_pool();
|
||||||
SrsStreamInfoMap::iterator it;
|
std::map<void*, SrsStreamInfo*>::iterator it;
|
||||||
for (it = pool->begin(); it != pool->end(); it++) {
|
for (it = pool->begin(); it != pool->end(); it++) {
|
||||||
SrsRequest* reqinfo = it->second->_req;
|
SrsRequest* reqinfo = it->second->_req;
|
||||||
if (reqinfo == NULL)
|
if (reqinfo == NULL)
|
||||||
|
|
|
@ -32,44 +32,54 @@ SrsStreamInfo::SrsStreamInfo()
|
||||||
|
|
||||||
SrsStreamInfo::~SrsStreamInfo()
|
SrsStreamInfo::~SrsStreamInfo()
|
||||||
{
|
{
|
||||||
if (_req != NULL)
|
srs_freep(_req);
|
||||||
delete _req;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatistic *SrsStatistic::_instance = NULL;
|
SrsStatistic* SrsStatistic::_instance = NULL;
|
||||||
|
|
||||||
SrsStatistic::SrsStatistic()
|
SrsStatistic::SrsStatistic()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatistic::~SrsStatistic()
|
SrsStatistic::~SrsStatistic()
|
||||||
{
|
{
|
||||||
SrsStreamInfoMap::iterator it;
|
std::map<void*, SrsStreamInfo*>::iterator it;
|
||||||
for (it = pool.begin(); it != pool.end(); it++) {
|
for (it = pool.begin(); it != pool.end(); it++) {
|
||||||
delete it->second;
|
SrsStreamInfo* si = it->second;
|
||||||
|
srs_freep(si);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStreamInfoMap* SrsStatistic::get_pool()
|
SrsStatistic* SrsStatistic::instance()
|
||||||
|
{
|
||||||
|
if (_instance == NULL) {
|
||||||
|
_instance = new SrsStatistic();
|
||||||
|
}
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<void*, SrsStreamInfo*>* SrsStatistic::get_pool()
|
||||||
{
|
{
|
||||||
return &pool;
|
return &pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStreamInfo* SrsStatistic::get(void *p)
|
SrsStreamInfo* SrsStatistic::get(void *p)
|
||||||
{
|
{
|
||||||
SrsStreamInfoMap::iterator it = pool.find(p);
|
std::map<void*, SrsStreamInfo*>::iterator it = pool.find(p);
|
||||||
if (it == pool.end()) {
|
if (it == pool.end()) {
|
||||||
pool[p] = new SrsStreamInfo();
|
SrsStreamInfo* si = new SrsStreamInfo();
|
||||||
return pool[p];
|
pool[p] = si;
|
||||||
|
return si;
|
||||||
} else {
|
} else {
|
||||||
return it->second;
|
SrsStreamInfo* si = it->second;
|
||||||
|
return si;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsStatistic::add_request_info(void *p, SrsRequest *req)
|
void SrsStatistic::add_request_info(void *p, SrsRequest *req)
|
||||||
{
|
{
|
||||||
SrsStreamInfo *info = get(p);
|
SrsStreamInfo* info = get(p);
|
||||||
if (info->_req == NULL)
|
if (info->_req == NULL) {
|
||||||
info->_req = req->copy();
|
info->_req = req->copy();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -39,32 +39,24 @@ class SrsStreamInfo
|
||||||
public:
|
public:
|
||||||
SrsStreamInfo();
|
SrsStreamInfo();
|
||||||
virtual ~SrsStreamInfo();
|
virtual ~SrsStreamInfo();
|
||||||
|
public:
|
||||||
SrsRequest *_req;
|
SrsRequest *_req;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<void*, SrsStreamInfo*> SrsStreamInfoMap;
|
|
||||||
|
|
||||||
class SrsStatistic
|
class SrsStatistic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static SrsStatistic *instance()
|
static SrsStatistic* instance();
|
||||||
{
|
public:
|
||||||
if (_instance == NULL) {
|
virtual std::map<void*, SrsStreamInfo*>* get_pool();
|
||||||
_instance = new SrsStatistic();
|
|
||||||
}
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual SrsStreamInfoMap* get_pool();
|
|
||||||
|
|
||||||
virtual void add_request_info(void *p, SrsRequest *req);
|
virtual void add_request_info(void *p, SrsRequest *req);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SrsStatistic();
|
SrsStatistic();
|
||||||
virtual ~SrsStatistic();
|
virtual ~SrsStatistic();
|
||||||
|
private:
|
||||||
static SrsStatistic *_instance;
|
static SrsStatistic *_instance;
|
||||||
SrsStreamInfoMap pool;
|
std::map<void*, SrsStreamInfo*> pool;
|
||||||
|
private:
|
||||||
virtual SrsStreamInfo *get(void *p);
|
virtual SrsStreamInfo *get(void *p);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue