|
|
|
@ -28,7 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
#include <srs_rtmp_stack.hpp>
|
|
|
|
|
#include <srs_app_json.hpp>
|
|
|
|
|
#include <srs_protocol_json.hpp>
|
|
|
|
|
#include <srs_protocol_kbps.hpp>
|
|
|
|
|
#include <srs_app_conn.hpp>
|
|
|
|
|
#include <srs_app_config.hpp>
|
|
|
|
@ -47,6 +47,8 @@ SrsStatisticVhost::SrsStatisticVhost()
|
|
|
|
|
|
|
|
|
|
kbps = new SrsKbps();
|
|
|
|
|
kbps->set_io(NULL, NULL);
|
|
|
|
|
|
|
|
|
|
nb_clients = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatisticVhost::~SrsStatisticVhost()
|
|
|
|
@ -54,6 +56,33 @@ SrsStatisticVhost::~SrsStatisticVhost()
|
|
|
|
|
srs_freep(kbps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsStatisticVhost::dumps(stringstream& ss)
|
|
|
|
|
{
|
|
|
|
|
int ret = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
// dumps the config of vhost.
|
|
|
|
|
bool hls_enabled = _srs_config->get_hls_enabled(vhost);
|
|
|
|
|
bool enabled = _srs_config->get_vhost_enabled(vhost);
|
|
|
|
|
|
|
|
|
|
ss << SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_ORG("id", id) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("name", vhost) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_BOOL("enabled", enabled) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_NAME("hls") << SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_BOOL("enabled", hls_enabled);
|
|
|
|
|
if (hls_enabled) {
|
|
|
|
|
ss << SRS_JFIELD_CONT;
|
|
|
|
|
ss << SRS_JFIELD_ORG("fragment", _srs_config->get_hls_fragment(vhost));
|
|
|
|
|
}
|
|
|
|
|
ss << SRS_JOBJECT_END
|
|
|
|
|
<< SRS_JOBJECT_END;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatisticStream::SrsStatisticStream()
|
|
|
|
|
{
|
|
|
|
|
id = srs_generate_id();
|
|
|
|
@ -73,6 +102,8 @@ SrsStatisticStream::SrsStatisticStream()
|
|
|
|
|
|
|
|
|
|
kbps = new SrsKbps();
|
|
|
|
|
kbps->set_io(NULL, NULL);
|
|
|
|
|
|
|
|
|
|
nb_clients = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatisticStream::~SrsStatisticStream()
|
|
|
|
@ -80,6 +111,48 @@ SrsStatisticStream::~SrsStatisticStream()
|
|
|
|
|
srs_freep(kbps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsStatisticStream::dumps(stringstream& ss)
|
|
|
|
|
{
|
|
|
|
|
int ret = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
ss << SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_ORG("id", id) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("name", stream) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("vhost", vhost->id) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("app", app) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("status", status) << SRS_JFIELD_CONT;
|
|
|
|
|
|
|
|
|
|
if (!has_video) {
|
|
|
|
|
ss << SRS_JFIELD_NULL("video") << SRS_JFIELD_CONT;
|
|
|
|
|
} else {
|
|
|
|
|
ss << SRS_JFIELD_NAME("video") << SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_STR("codec", srs_codec_video2str(vcodec)) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("profile", srs_codec_avc_profile2str(avc_profile)) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("level", srs_codec_avc_level2str(avc_level))
|
|
|
|
|
<< SRS_JOBJECT_END
|
|
|
|
|
<< SRS_JFIELD_CONT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!has_audio) {
|
|
|
|
|
ss << SRS_JFIELD_NULL("audio");
|
|
|
|
|
} else {
|
|
|
|
|
ss << SRS_JFIELD_NAME("audio") << SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_STR("codec", srs_codec_audio2str(acodec)) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("sample_rate", (int)flv_sample_rates[asample_rate]) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("channel", (int)asound_type + 1) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("profile", srs_codec_aac_object2str(aac_object))
|
|
|
|
|
<< SRS_JOBJECT_END;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ss << SRS_JOBJECT_END;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SrsStatisticStream::publish()
|
|
|
|
|
{
|
|
|
|
|
status = STATISTIC_STREAM_STATUS_PUBLISHING;
|
|
|
|
@ -92,6 +165,26 @@ void SrsStatisticStream::close()
|
|
|
|
|
status = STATISTIC_STREAM_STATUS_IDLING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatisticClient::SrsStatisticClient()
|
|
|
|
|
{
|
|
|
|
|
id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatisticClient::~SrsStatisticClient()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsStatisticClient::dumps(stringstream& ss)
|
|
|
|
|
{
|
|
|
|
|
int ret = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
ss << SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_ORG("id", id)
|
|
|
|
|
<< SRS_JOBJECT_END;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatistic* SrsStatistic::_instance = new SrsStatistic();
|
|
|
|
|
|
|
|
|
|
SrsStatistic::SrsStatistic()
|
|
|
|
@ -107,14 +200,14 @@ SrsStatistic::~SrsStatistic()
|
|
|
|
|
srs_freep(kbps);
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
std::map<std::string, SrsStatisticVhost*>::iterator it;
|
|
|
|
|
std::map<int64_t, SrsStatisticVhost*>::iterator it;
|
|
|
|
|
for (it = vhosts.begin(); it != vhosts.end(); it++) {
|
|
|
|
|
SrsStatisticVhost* vhost = it->second;
|
|
|
|
|
srs_freep(vhost);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (true) {
|
|
|
|
|
std::map<std::string, SrsStatisticStream*>::iterator it;
|
|
|
|
|
std::map<int64_t, SrsStatisticStream*>::iterator it;
|
|
|
|
|
for (it = streams.begin(); it != streams.end(); it++) {
|
|
|
|
|
SrsStatisticStream* stream = it->second;
|
|
|
|
|
srs_freep(stream);
|
|
|
|
@ -127,6 +220,11 @@ SrsStatistic::~SrsStatistic()
|
|
|
|
|
srs_freep(client);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vhosts.clear();
|
|
|
|
|
rvhosts.clear();
|
|
|
|
|
streams.clear();
|
|
|
|
|
rstreams.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatistic* SrsStatistic::instance()
|
|
|
|
@ -134,16 +232,29 @@ SrsStatistic* SrsStatistic::instance()
|
|
|
|
|
return _instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatisticStream* SrsStatistic::find_stream(int stream_id)
|
|
|
|
|
SrsStatisticVhost* SrsStatistic::find_vhost(int vid)
|
|
|
|
|
{
|
|
|
|
|
std::map<int64_t, SrsStatisticVhost*>::iterator it;
|
|
|
|
|
if ((it = vhosts.find(vid)) != vhosts.end()) {
|
|
|
|
|
return it->second;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatisticStream* SrsStatistic::find_stream(int sid)
|
|
|
|
|
{
|
|
|
|
|
std::map<int64_t, SrsStatisticStream*>::iterator it;
|
|
|
|
|
if ((it = streams.find(sid)) != streams.end()) {
|
|
|
|
|
return it->second;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatisticClient* SrsStatistic::find_client(int cid)
|
|
|
|
|
{
|
|
|
|
|
std::map<int, SrsStatisticClient*>::iterator it;
|
|
|
|
|
for (it = clients.begin(); it != clients.end(); it++) {
|
|
|
|
|
SrsStatisticClient* client = it->second;
|
|
|
|
|
SrsStatisticStream* stream = client->stream;
|
|
|
|
|
|
|
|
|
|
if (stream_id == stream->id) {
|
|
|
|
|
return stream;
|
|
|
|
|
}
|
|
|
|
|
if ((it = clients.find(cid)) != clients.end()) {
|
|
|
|
|
return it->second;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
@ -215,6 +326,10 @@ int SrsStatistic::on_client(int id, SrsRequest* req)
|
|
|
|
|
} else {
|
|
|
|
|
client = clients[id];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// got client.
|
|
|
|
|
stream->nb_clients++;
|
|
|
|
|
vhost->nb_clients++;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
@ -222,12 +337,19 @@ int SrsStatistic::on_client(int id, SrsRequest* req)
|
|
|
|
|
void SrsStatistic::on_disconnect(int id)
|
|
|
|
|
{
|
|
|
|
|
std::map<int, SrsStatisticClient*>::iterator it;
|
|
|
|
|
it = clients.find(id);
|
|
|
|
|
if (it != clients.end()) {
|
|
|
|
|
SrsStatisticClient* client = it->second;
|
|
|
|
|
srs_freep(client);
|
|
|
|
|
clients.erase(it);
|
|
|
|
|
if ((it = clients.find(id)) == clients.end()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsStatisticClient* client = it->second;
|
|
|
|
|
SrsStatisticStream* stream = client->stream;
|
|
|
|
|
SrsStatisticVhost* vhost = stream->vhost;
|
|
|
|
|
|
|
|
|
|
srs_freep(client);
|
|
|
|
|
clients.erase(it);
|
|
|
|
|
|
|
|
|
|
stream->nb_clients--;
|
|
|
|
|
vhost->nb_clients--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SrsStatistic::kbps_add_delta(SrsConnection* conn)
|
|
|
|
@ -256,14 +378,14 @@ SrsKbps* SrsStatistic::kbps_sample()
|
|
|
|
|
{
|
|
|
|
|
kbps->sample();
|
|
|
|
|
if (true) {
|
|
|
|
|
std::map<std::string, SrsStatisticVhost*>::iterator it;
|
|
|
|
|
std::map<int64_t, SrsStatisticVhost*>::iterator it;
|
|
|
|
|
for (it = vhosts.begin(); it != vhosts.end(); it++) {
|
|
|
|
|
SrsStatisticVhost* vhost = it->second;
|
|
|
|
|
vhost->kbps->sample();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (true) {
|
|
|
|
|
std::map<std::string, SrsStatisticStream*>::iterator it;
|
|
|
|
|
std::map<int64_t, SrsStatisticStream*>::iterator it;
|
|
|
|
|
for (it = streams.begin(); it != streams.end(); it++) {
|
|
|
|
|
SrsStatisticStream* stream = it->second;
|
|
|
|
|
stream->kbps->sample();
|
|
|
|
@ -283,29 +405,17 @@ int SrsStatistic::dumps_vhosts(stringstream& ss)
|
|
|
|
|
int ret = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
ss << SRS_JARRAY_START;
|
|
|
|
|
std::map<std::string, SrsStatisticVhost*>::iterator it;
|
|
|
|
|
std::map<int64_t, SrsStatisticVhost*>::iterator it;
|
|
|
|
|
for (it = vhosts.begin(); it != vhosts.end(); it++) {
|
|
|
|
|
SrsStatisticVhost* vhost = it->second;
|
|
|
|
|
|
|
|
|
|
if (it != vhosts.begin()) {
|
|
|
|
|
ss << SRS_JFIELD_CONT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dumps the config of vhost.
|
|
|
|
|
bool hls_enabled = _srs_config->get_hls_enabled(vhost->vhost);
|
|
|
|
|
|
|
|
|
|
ss << SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_ORG("id", vhost->id) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("name", vhost->vhost) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("send_bytes", vhost->kbps->get_send_bytes()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("recv_bytes", vhost->kbps->get_recv_bytes()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_NAME("hls") << SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_BOOL("enabled", hls_enabled);
|
|
|
|
|
if (hls_enabled) {
|
|
|
|
|
ss << SRS_JFIELD_CONT;
|
|
|
|
|
ss << SRS_JFIELD_ORG("fragment", _srs_config->get_hls_fragment(vhost->vhost));
|
|
|
|
|
if ((ret = vhost->dumps(ss)) != ERROR_SUCCESS) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
ss << SRS_JOBJECT_END
|
|
|
|
|
<< SRS_JOBJECT_END;
|
|
|
|
|
}
|
|
|
|
|
ss << SRS_JARRAY_END;
|
|
|
|
|
|
|
|
|
@ -317,61 +427,47 @@ int SrsStatistic::dumps_streams(stringstream& ss)
|
|
|
|
|
int ret = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
ss << SRS_JARRAY_START;
|
|
|
|
|
std::map<std::string, SrsStatisticStream*>::iterator it;
|
|
|
|
|
std::map<int64_t, SrsStatisticStream*>::iterator it;
|
|
|
|
|
for (it = streams.begin(); it != streams.end(); it++) {
|
|
|
|
|
SrsStatisticStream* stream = it->second;
|
|
|
|
|
|
|
|
|
|
if (it != streams.begin()) {
|
|
|
|
|
ss << SRS_JFIELD_CONT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int client_num = 0;
|
|
|
|
|
std::map<int, SrsStatisticClient*>::iterator it_client;
|
|
|
|
|
for (it_client = clients.begin(); it_client != clients.end(); it_client++) {
|
|
|
|
|
SrsStatisticClient* client = it_client->second;
|
|
|
|
|
if (client->stream == stream) {
|
|
|
|
|
client_num++;
|
|
|
|
|
}
|
|
|
|
|
if ((ret = stream->dumps(ss)) != ERROR_SUCCESS) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ss << SRS_JARRAY_END;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ss << SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_ORG("id", stream->id) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("name", stream->stream) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("vhost", stream->vhost->id) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("app", stream->app) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("clients", client_num) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("send_bytes", stream->kbps->get_send_bytes()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("recv_bytes", stream->kbps->get_recv_bytes()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("status", stream->status) << SRS_JFIELD_CONT;
|
|
|
|
|
|
|
|
|
|
if (!stream->has_video) {
|
|
|
|
|
ss << SRS_JFIELD_NULL("video") << SRS_JFIELD_CONT;
|
|
|
|
|
} else {
|
|
|
|
|
ss << SRS_JFIELD_NAME("video")
|
|
|
|
|
<< SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_STR("codec", srs_codec_video2str(stream->vcodec)) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("profile", srs_codec_avc_profile2str(stream->avc_profile)) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("level", srs_codec_avc_level2str(stream->avc_level))
|
|
|
|
|
<< SRS_JOBJECT_END
|
|
|
|
|
<< SRS_JFIELD_CONT;
|
|
|
|
|
int SrsStatistic::dumps_clients(stringstream& ss, int start, int count)
|
|
|
|
|
{
|
|
|
|
|
int ret = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
ss << SRS_JARRAY_START;
|
|
|
|
|
std::map<int, SrsStatisticClient*>::iterator it = clients.begin();
|
|
|
|
|
for (int i = 0; i < count && it != clients.end(); it++) {
|
|
|
|
|
if (i < start) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!stream->has_audio) {
|
|
|
|
|
ss << SRS_JFIELD_NULL("audio");
|
|
|
|
|
} else {
|
|
|
|
|
ss << SRS_JFIELD_NAME("audio")
|
|
|
|
|
<< SRS_JOBJECT_START
|
|
|
|
|
<< SRS_JFIELD_STR("codec", srs_codec_audio2str(stream->acodec)) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("sample_rate", (int)flv_sample_rates[stream->asample_rate]) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_ORG("channel", (int)stream->asound_type + 1) << SRS_JFIELD_CONT
|
|
|
|
|
<< SRS_JFIELD_STR("profile", srs_codec_aac_object2str(stream->aac_object))
|
|
|
|
|
<< SRS_JOBJECT_END;
|
|
|
|
|
|
|
|
|
|
SrsStatisticClient* client = it->second;
|
|
|
|
|
|
|
|
|
|
if (i != start) {
|
|
|
|
|
ss << SRS_JFIELD_CONT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ss << SRS_JOBJECT_END;
|
|
|
|
|
if ((ret = client->dumps(ss)) != ERROR_SUCCESS) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ss << SRS_JARRAY_END;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -380,14 +476,15 @@ SrsStatisticVhost* SrsStatistic::create_vhost(SrsRequest* req)
|
|
|
|
|
SrsStatisticVhost* vhost = NULL;
|
|
|
|
|
|
|
|
|
|
// create vhost if not exists.
|
|
|
|
|
if (vhosts.find(req->vhost) == vhosts.end()) {
|
|
|
|
|
if (rvhosts.find(req->vhost) == rvhosts.end()) {
|
|
|
|
|
vhost = new SrsStatisticVhost();
|
|
|
|
|
vhost->vhost = req->vhost;
|
|
|
|
|
vhosts[req->vhost] = vhost;
|
|
|
|
|
rvhosts[req->vhost] = vhost;
|
|
|
|
|
vhosts[vhost->id] = vhost;
|
|
|
|
|
return vhost;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vhost = vhosts[req->vhost];
|
|
|
|
|
vhost = rvhosts[req->vhost];
|
|
|
|
|
|
|
|
|
|
return vhost;
|
|
|
|
|
}
|
|
|
|
@ -399,17 +496,18 @@ SrsStatisticStream* SrsStatistic::create_stream(SrsStatisticVhost* vhost, SrsReq
|
|
|
|
|
SrsStatisticStream* stream = NULL;
|
|
|
|
|
|
|
|
|
|
// create stream if not exists.
|
|
|
|
|
if (streams.find(url) == streams.end()) {
|
|
|
|
|
if (rstreams.find(url) == rstreams.end()) {
|
|
|
|
|
stream = new SrsStatisticStream();
|
|
|
|
|
stream->vhost = vhost;
|
|
|
|
|
stream->stream = req->stream;
|
|
|
|
|
stream->app = req->app;
|
|
|
|
|
stream->url = url;
|
|
|
|
|
streams[url] = stream;
|
|
|
|
|
rstreams[url] = stream;
|
|
|
|
|
streams[stream->id] = stream;
|
|
|
|
|
return stream;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream = streams[url];
|
|
|
|
|
stream = rstreams[url];
|
|
|
|
|
|
|
|
|
|
return stream;
|
|
|
|
|
}
|
|
|
|
|