diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 24c70992a8..7e021904d0 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -48,6 +48,7 @@ using namespace std; #include #include #include +#include using namespace _srs_internal; @@ -1688,6 +1689,7 @@ int SrsConfig::global_to_json(SrsAmf0Object* obj) SrsAmf0Object* sobjs = SrsAmf0Any::object(); int nb_vhosts = 0; + SrsStatistic* stat = SrsStatistic::instance(); for (int i = 0; i < (int)root->directives.size(); i++) { SrsConfDirective* dir = root->directives.at(i); if (!dir->is_vhost()) { @@ -1698,6 +1700,9 @@ int SrsConfig::global_to_json(SrsAmf0Object* obj) SrsAmf0Object* sobj = SrsAmf0Any::object(); sobjs->set(dir->arg0(), sobj); + SrsStatisticVhost* svhost = stat->find_vhost(dir->arg0()); + sobj->set("id", SrsAmf0Any::number(svhost? (double)svhost->id : 0)); + sobj->set("enabled", SrsAmf0Any::boolean(get_vhost_enabled(dir->name))); sobj->set("dvr", SrsAmf0Any::boolean(get_dvr_enabled(dir->name))); sobj->set("http_static", SrsAmf0Any::boolean(get_vhost_http_enabled(dir->name))); diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index 583a85d09c..615ff3e75b 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -275,6 +275,15 @@ SrsStatisticVhost* SrsStatistic::find_vhost(int vid) return NULL; } +SrsStatisticVhost* SrsStatistic::find_vhost(string name) +{ + std::map::iterator it; + if ((it = rvhosts.find(name)) != rvhosts.end()) { + return it->second; + } + return NULL; +} + SrsStatisticStream* SrsStatistic::find_stream(int sid) { std::map::iterator it; diff --git a/trunk/src/app/srs_app_statistic.hpp b/trunk/src/app/srs_app_statistic.hpp index 175aceb105..d74e79e695 100644 --- a/trunk/src/app/srs_app_statistic.hpp +++ b/trunk/src/app/srs_app_statistic.hpp @@ -156,6 +156,7 @@ class SrsStatistic static SrsStatistic* instance(); public: virtual SrsStatisticVhost* find_vhost(int vid); + virtual SrsStatisticVhost* find_vhost(std::string name); virtual SrsStatisticStream* find_stream(int sid); virtual SrsStatisticClient* find_client(int cid); public: