1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

support query specified vhost

This commit is contained in:
winlin 2015-08-21 17:00:52 +08:00
parent 66a26bdce8
commit 2edcf1d4ff
3 changed files with 179 additions and 40 deletions

View file

@ -115,6 +115,11 @@ struct SrsStatisticClient
public:
SrsStatisticStream* stream;
int id;
public:
SrsStatisticClient();
virtual ~SrsStatisticClient();
public:
virtual int dumps(std::stringstream& ss);
};
class SrsStatistic
@ -123,10 +128,19 @@ private:
static SrsStatistic *_instance;
// the id to identify the sever.
int64_t _server_id;
// key: vhost name, value: vhost object.
std::map<std::string, SrsStatisticVhost*> vhosts;
// key: stream url, value: stream object.
std::map<std::string, SrsStatisticStream*> streams;
private:
// key: vhost id, value: vhost object.
std::map<int64_t, SrsStatisticVhost*> vhosts;
// key: vhost url, value: vhost Object.
// @remark a fast index for vhosts.
std::map<std::string, SrsStatisticVhost*> rvhosts;
private:
// key: stream id, value: stream Object.
std::map<int64_t, SrsStatisticStream*> streams;
// key: stream url, value: stream Object.
// @remark a fast index for streams.
std::map<std::string, SrsStatisticStream*> rstreams;
private:
// key: client id, value: stream object.
std::map<int, SrsStatisticClient*> clients;
// server total kbps.
@ -137,7 +151,10 @@ private:
public:
static SrsStatistic* instance();
public:
virtual SrsStatisticStream* find_stream(int stream_id);
virtual SrsStatisticVhost* find_vhost(int vid);
virtual SrsStatisticStream* find_stream(int sid);
virtual SrsStatisticClient* find_client(int cid);
public:
/**
* when got video info for stream.
*/
@ -198,6 +215,12 @@ public:
* dumps the streams to sstream in json.
*/
virtual int dumps_streams(std::stringstream& ss);
/**
* dumps the clients to sstream in json.
* @param start the start index, from 0.
* @param count the max count of clients to dump.
*/
virtual int dumps_clients(std::stringstream& ss, int start, int count);
private:
virtual SrsStatisticVhost* create_vhost(SrsRequest* req);
virtual SrsStatisticStream* create_stream(SrsStatisticVhost* vhost, SrsRequest* req);