正在显示
3 个修改的文件
包含
33 行增加
和
1 行删除
| @@ -1468,6 +1468,24 @@ int SrsConfig::persistence() | @@ -1468,6 +1468,24 @@ int SrsConfig::persistence() | ||
| 1468 | return ret; | 1468 | return ret; |
| 1469 | } | 1469 | } |
| 1470 | 1470 | ||
| 1471 | +int SrsConfig::minimal_to_json(SrsAmf0Object* obj) | ||
| 1472 | +{ | ||
| 1473 | + int ret = ERROR_SUCCESS; | ||
| 1474 | + | ||
| 1475 | + for (int i = 0; i < (int)root->directives.size(); i++) { | ||
| 1476 | + SrsConfDirective* dir = root->directives.at(i); | ||
| 1477 | + if (dir->is_vhost()) { | ||
| 1478 | + continue; | ||
| 1479 | + } | ||
| 1480 | + | ||
| 1481 | + if (dir->name == "listen") { | ||
| 1482 | + obj->set(dir->name, dir->dumps_args()); | ||
| 1483 | + } | ||
| 1484 | + } | ||
| 1485 | + | ||
| 1486 | + return ret; | ||
| 1487 | +} | ||
| 1488 | + | ||
| 1471 | int SrsConfig::global_to_json(SrsAmf0Object* obj) | 1489 | int SrsConfig::global_to_json(SrsAmf0Object* obj) |
| 1472 | { | 1490 | { |
| 1473 | int ret = ERROR_SUCCESS; | 1491 | int ret = ERROR_SUCCESS; |
| @@ -322,6 +322,10 @@ public: | @@ -322,6 +322,10 @@ public: | ||
| 322 | */ | 322 | */ |
| 323 | virtual int global_to_json(SrsAmf0Object* obj); | 323 | virtual int global_to_json(SrsAmf0Object* obj); |
| 324 | /** | 324 | /** |
| 325 | + * dumps the minimal sections to json. | ||
| 326 | + */ | ||
| 327 | + virtual int minimal_to_json(SrsAmf0Object* obj); | ||
| 328 | + /** | ||
| 325 | * dumps the vhost section to json. | 329 | * dumps the vhost section to json. |
| 326 | */ | 330 | */ |
| 327 | virtual int vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj); | 331 | virtual int vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj); |
| @@ -917,6 +917,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -917,6 +917,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 917 | // for rpc=query, to get the configs of server. | 917 | // for rpc=query, to get the configs of server. |
| 918 | // @param scope the scope to query for config, it can be: | 918 | // @param scope the scope to query for config, it can be: |
| 919 | // global, the configs belongs to the root, donot includes any sub directives. | 919 | // global, the configs belongs to the root, donot includes any sub directives. |
| 920 | + // minimal, the minimal summary of server, for preview stream to got the port serving. | ||
| 920 | // vhost, the configs for specified vhost by @param vhost. | 921 | // vhost, the configs for specified vhost by @param vhost. |
| 921 | // @param vhost the vhost name for @param scope is vhost to query config. | 922 | // @param vhost the vhost name for @param scope is vhost to query config. |
| 922 | // for the default vhost, must be __defaultVhost__ | 923 | // for the default vhost, must be __defaultVhost__ |
| @@ -929,7 +930,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -929,7 +930,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 929 | 930 | ||
| 930 | std::string scope = r->query_get("scope"); | 931 | std::string scope = r->query_get("scope"); |
| 931 | std::string vhost = r->query_get("vhost"); | 932 | std::string vhost = r->query_get("vhost"); |
| 932 | - if (scope.empty() || (scope != "global" && scope != "vhost")) { | 933 | + if (scope.empty() || (scope != "global" && scope != "vhost" && scope != "minimal")) { |
| 933 | ret = ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED; | 934 | ret = ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED; |
| 934 | srs_error("raw api query invalid scope=%s. ret=%d", scope.c_str(), ret); | 935 | srs_error("raw api query invalid scope=%s. ret=%d", scope.c_str(), ret); |
| 935 | return srs_api_response_code(w, r, ret); | 936 | return srs_api_response_code(w, r, ret); |
| @@ -957,6 +958,15 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -957,6 +958,15 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 957 | srs_error("raw api query vhost failed. ret=%d", ret); | 958 | srs_error("raw api query vhost failed. ret=%d", ret); |
| 958 | return srs_api_response_code(w, r, ret); | 959 | return srs_api_response_code(w, r, ret); |
| 959 | } | 960 | } |
| 961 | + } else if (scope == "minimal") { | ||
| 962 | + SrsAmf0Object* data = SrsAmf0Any::object(); | ||
| 963 | + obj->set("minimal", data); | ||
| 964 | + | ||
| 965 | + // query minimal scope. | ||
| 966 | + if ((ret = _srs_config->minimal_to_json(data)) != ERROR_SUCCESS) { | ||
| 967 | + srs_error("raw api query global failed. ret=%d", ret); | ||
| 968 | + return srs_api_response_code(w, r, ret); | ||
| 969 | + } | ||
| 960 | } else { | 970 | } else { |
| 961 | SrsAmf0Object* data = SrsAmf0Any::object(); | 971 | SrsAmf0Object* data = SrsAmf0Any::object(); |
| 962 | obj->set("global", data); | 972 | obj->set("global", data); |
-
请 注册 或 登录 后发表评论