正在显示
3 个修改的文件
包含
15 行增加
和
0 行删除
| @@ -48,6 +48,7 @@ using namespace std; | @@ -48,6 +48,7 @@ using namespace std; | ||
| 48 | #include <srs_core_performance.hpp> | 48 | #include <srs_core_performance.hpp> |
| 49 | #include <srs_kernel_file.hpp> | 49 | #include <srs_kernel_file.hpp> |
| 50 | #include <srs_rtmp_amf0.hpp> | 50 | #include <srs_rtmp_amf0.hpp> |
| 51 | +#include <srs_app_statistic.hpp> | ||
| 51 | 52 | ||
| 52 | using namespace _srs_internal; | 53 | using namespace _srs_internal; |
| 53 | 54 | ||
| @@ -1688,6 +1689,7 @@ int SrsConfig::global_to_json(SrsAmf0Object* obj) | @@ -1688,6 +1689,7 @@ int SrsConfig::global_to_json(SrsAmf0Object* obj) | ||
| 1688 | SrsAmf0Object* sobjs = SrsAmf0Any::object(); | 1689 | SrsAmf0Object* sobjs = SrsAmf0Any::object(); |
| 1689 | int nb_vhosts = 0; | 1690 | int nb_vhosts = 0; |
| 1690 | 1691 | ||
| 1692 | + SrsStatistic* stat = SrsStatistic::instance(); | ||
| 1691 | for (int i = 0; i < (int)root->directives.size(); i++) { | 1693 | for (int i = 0; i < (int)root->directives.size(); i++) { |
| 1692 | SrsConfDirective* dir = root->directives.at(i); | 1694 | SrsConfDirective* dir = root->directives.at(i); |
| 1693 | if (!dir->is_vhost()) { | 1695 | if (!dir->is_vhost()) { |
| @@ -1698,6 +1700,9 @@ int SrsConfig::global_to_json(SrsAmf0Object* obj) | @@ -1698,6 +1700,9 @@ int SrsConfig::global_to_json(SrsAmf0Object* obj) | ||
| 1698 | SrsAmf0Object* sobj = SrsAmf0Any::object(); | 1700 | SrsAmf0Object* sobj = SrsAmf0Any::object(); |
| 1699 | sobjs->set(dir->arg0(), sobj); | 1701 | sobjs->set(dir->arg0(), sobj); |
| 1700 | 1702 | ||
| 1703 | + SrsStatisticVhost* svhost = stat->find_vhost(dir->arg0()); | ||
| 1704 | + sobj->set("id", SrsAmf0Any::number(svhost? (double)svhost->id : 0)); | ||
| 1705 | + | ||
| 1701 | sobj->set("enabled", SrsAmf0Any::boolean(get_vhost_enabled(dir->name))); | 1706 | sobj->set("enabled", SrsAmf0Any::boolean(get_vhost_enabled(dir->name))); |
| 1702 | sobj->set("dvr", SrsAmf0Any::boolean(get_dvr_enabled(dir->name))); | 1707 | sobj->set("dvr", SrsAmf0Any::boolean(get_dvr_enabled(dir->name))); |
| 1703 | sobj->set("http_static", SrsAmf0Any::boolean(get_vhost_http_enabled(dir->name))); | 1708 | sobj->set("http_static", SrsAmf0Any::boolean(get_vhost_http_enabled(dir->name))); |
| @@ -275,6 +275,15 @@ SrsStatisticVhost* SrsStatistic::find_vhost(int vid) | @@ -275,6 +275,15 @@ SrsStatisticVhost* SrsStatistic::find_vhost(int vid) | ||
| 275 | return NULL; | 275 | return NULL; |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | +SrsStatisticVhost* SrsStatistic::find_vhost(string name) | ||
| 279 | +{ | ||
| 280 | + std::map<string, SrsStatisticVhost*>::iterator it; | ||
| 281 | + if ((it = rvhosts.find(name)) != rvhosts.end()) { | ||
| 282 | + return it->second; | ||
| 283 | + } | ||
| 284 | + return NULL; | ||
| 285 | +} | ||
| 286 | + | ||
| 278 | SrsStatisticStream* SrsStatistic::find_stream(int sid) | 287 | SrsStatisticStream* SrsStatistic::find_stream(int sid) |
| 279 | { | 288 | { |
| 280 | std::map<int64_t, SrsStatisticStream*>::iterator it; | 289 | std::map<int64_t, SrsStatisticStream*>::iterator it; |
| @@ -156,6 +156,7 @@ public: | @@ -156,6 +156,7 @@ public: | ||
| 156 | static SrsStatistic* instance(); | 156 | static SrsStatistic* instance(); |
| 157 | public: | 157 | public: |
| 158 | virtual SrsStatisticVhost* find_vhost(int vid); | 158 | virtual SrsStatisticVhost* find_vhost(int vid); |
| 159 | + virtual SrsStatisticVhost* find_vhost(std::string name); | ||
| 159 | virtual SrsStatisticStream* find_stream(int sid); | 160 | virtual SrsStatisticStream* find_stream(int sid); |
| 160 | virtual SrsStatisticClient* find_client(int cid); | 161 | virtual SrsStatisticClient* find_client(int cid); |
| 161 | public: | 162 | public: |
-
请 注册 或 登录 后发表评论