正在显示
5 个修改的文件
包含
117 行增加
和
11 行删除
| @@ -344,6 +344,7 @@ Remark: | @@ -344,6 +344,7 @@ Remark: | ||
| 344 | 344 | ||
| 345 | ## History | 345 | ## History |
| 346 | 346 | ||
| 347 | +* v3.0, 2015-09-14, fix [#459][bug #459], support dvr raw api. 3.0.4 | ||
| 347 | * v3.0, 2015-09-14, fix [#459][bug #459], dvr support apply filter for ng-control dvr module. | 348 | * v3.0, 2015-09-14, fix [#459][bug #459], dvr support apply filter for ng-control dvr module. |
| 348 | * v3.0, 2015-09-14, fix [#319][bug #319], http raw api support update global and vhost. 3.0.3 | 349 | * v3.0, 2015-09-14, fix [#319][bug #319], http raw api support update global and vhost. 3.0.3 |
| 349 | * v3.0, 2015-08-31, fix [#319][bug #319], http raw api support query global and vhost. | 350 | * v3.0, 2015-08-31, fix [#319][bug #319], http raw api support query global and vhost. |
| @@ -850,15 +850,8 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | @@ -850,15 +850,8 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | ||
| 850 | // @see https://github.com/simple-rtmp-server/srs/issues/459#issuecomment-140296597 | 850 | // @see https://github.com/simple-rtmp-server/srs/issues/459#issuecomment-140296597 |
| 851 | SrsConfDirective* nda = new_vhost->get("dvr")? new_vhost->get("dvr")->get("dvr_apply") : NULL; | 851 | SrsConfDirective* nda = new_vhost->get("dvr")? new_vhost->get("dvr")->get("dvr_apply") : NULL; |
| 852 | SrsConfDirective* oda = old_vhost->get("dvr")? old_vhost->get("dvr")->get("dvr_apply") : NULL; | 852 | SrsConfDirective* oda = old_vhost->get("dvr")? old_vhost->get("dvr")->get("dvr_apply") : NULL; |
| 853 | - if (!srs_directive_equals(nda, oda)) { | ||
| 854 | - for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 855 | - ISrsReloadHandler* subscribe = *it; | ||
| 856 | - if ((ret = subscribe->on_reload_vhost_dvr_apply(vhost)) != ERROR_SUCCESS) { | ||
| 857 | - srs_error("vhost %s notify subscribes dvr_apply failed. ret=%d", vhost.c_str(), ret); | ||
| 858 | - return ret; | ||
| 859 | - } | ||
| 860 | - } | ||
| 861 | - srs_trace("vhost %s reload dvr_apply success.", vhost.c_str()); | 853 | + if (!srs_directive_equals(nda, oda) && (ret = do_reload_vhost_dvr_apply(vhost)) != ERROR_SUCCESS) { |
| 854 | + return ret; | ||
| 862 | } | 855 | } |
| 863 | } | 856 | } |
| 864 | 857 | ||
| @@ -2563,6 +2556,60 @@ int SrsConfig::raw_enable_vhost(string vhost, bool& applied) | @@ -2563,6 +2556,60 @@ int SrsConfig::raw_enable_vhost(string vhost, bool& applied) | ||
| 2563 | return ret; | 2556 | return ret; |
| 2564 | } | 2557 | } |
| 2565 | 2558 | ||
| 2559 | +int SrsConfig::raw_enable_dvr(string vhost, string stream, bool& applied) | ||
| 2560 | +{ | ||
| 2561 | + int ret = ERROR_SUCCESS; | ||
| 2562 | + | ||
| 2563 | + applied = false; | ||
| 2564 | + | ||
| 2565 | + SrsConfDirective* conf = root->get("vhost", vhost); | ||
| 2566 | + conf = conf->get_or_create("dvr")->get_or_create("dvr_apply"); | ||
| 2567 | + | ||
| 2568 | + if (conf->args.size() == 1 && (conf->arg0() == "all" || conf->arg0() == "none")) { | ||
| 2569 | + conf->args.clear(); | ||
| 2570 | + } | ||
| 2571 | + | ||
| 2572 | + if (::find(conf->args.begin(), conf->args.end(), stream) == conf->args.end()) { | ||
| 2573 | + conf->args.push_back(stream); | ||
| 2574 | + } | ||
| 2575 | + | ||
| 2576 | + if ((ret = do_reload_vhost_dvr_apply(vhost)) != ERROR_SUCCESS) { | ||
| 2577 | + return ret; | ||
| 2578 | + } | ||
| 2579 | + | ||
| 2580 | + applied = true; | ||
| 2581 | + | ||
| 2582 | + return ret; | ||
| 2583 | +} | ||
| 2584 | + | ||
| 2585 | +int SrsConfig::raw_disable_dvr(string vhost, string stream, bool& applied) | ||
| 2586 | +{ | ||
| 2587 | + int ret = ERROR_SUCCESS; | ||
| 2588 | + | ||
| 2589 | + applied = false; | ||
| 2590 | + | ||
| 2591 | + SrsConfDirective* conf = root->get("vhost", vhost); | ||
| 2592 | + conf = conf->get_or_create("dvr")->get_or_create("dvr_apply"); | ||
| 2593 | + | ||
| 2594 | + std::vector<string>::iterator it; | ||
| 2595 | + | ||
| 2596 | + if ((it = ::find(conf->args.begin(), conf->args.end(), stream)) != conf->args.end()) { | ||
| 2597 | + conf->args.erase(it); | ||
| 2598 | + } | ||
| 2599 | + | ||
| 2600 | + if (conf->args.empty()) { | ||
| 2601 | + conf->args.push_back("none"); | ||
| 2602 | + } | ||
| 2603 | + | ||
| 2604 | + if ((ret = do_reload_vhost_dvr_apply(vhost)) != ERROR_SUCCESS) { | ||
| 2605 | + return ret; | ||
| 2606 | + } | ||
| 2607 | + | ||
| 2608 | + applied = true; | ||
| 2609 | + | ||
| 2610 | + return ret; | ||
| 2611 | +} | ||
| 2612 | + | ||
| 2566 | int SrsConfig::do_reload_listen() | 2613 | int SrsConfig::do_reload_listen() |
| 2567 | { | 2614 | { |
| 2568 | int ret = ERROR_SUCCESS; | 2615 | int ret = ERROR_SUCCESS; |
| @@ -2739,6 +2786,23 @@ int SrsConfig::do_reload_vhost_removed(string vhost) | @@ -2739,6 +2786,23 @@ int SrsConfig::do_reload_vhost_removed(string vhost) | ||
| 2739 | return ret; | 2786 | return ret; |
| 2740 | } | 2787 | } |
| 2741 | 2788 | ||
| 2789 | +int SrsConfig::do_reload_vhost_dvr_apply(string vhost) | ||
| 2790 | +{ | ||
| 2791 | + int ret = ERROR_SUCCESS; | ||
| 2792 | + | ||
| 2793 | + vector<ISrsReloadHandler*>::iterator it; | ||
| 2794 | + for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 2795 | + ISrsReloadHandler* subscribe = *it; | ||
| 2796 | + if ((ret = subscribe->on_reload_vhost_dvr_apply(vhost)) != ERROR_SUCCESS) { | ||
| 2797 | + srs_error("vhost %s notify subscribes dvr_apply failed. ret=%d", vhost.c_str(), ret); | ||
| 2798 | + return ret; | ||
| 2799 | + } | ||
| 2800 | + } | ||
| 2801 | + srs_trace("vhost %s reload dvr_apply success.", vhost.c_str()); | ||
| 2802 | + | ||
| 2803 | + return ret; | ||
| 2804 | +} | ||
| 2805 | + | ||
| 2742 | string SrsConfig::config() | 2806 | string SrsConfig::config() |
| 2743 | { | 2807 | { |
| 2744 | return config_file; | 2808 | return config_file; |
| @@ -399,6 +399,14 @@ public: | @@ -399,6 +399,14 @@ public: | ||
| 399 | * raw enable the disabled vhost. | 399 | * raw enable the disabled vhost. |
| 400 | */ | 400 | */ |
| 401 | virtual int raw_enable_vhost(std::string vhost, bool& applied); | 401 | virtual int raw_enable_vhost(std::string vhost, bool& applied); |
| 402 | + /** | ||
| 403 | + * raw enable the dvr of stream of vhost. | ||
| 404 | + */ | ||
| 405 | + virtual int raw_enable_dvr(std::string vhost, std::string stream, bool& applied); | ||
| 406 | + /** | ||
| 407 | + * raw disable the dvr of stream of vhost. | ||
| 408 | + */ | ||
| 409 | + virtual int raw_disable_dvr(std::string vhost, std::string stream, bool& applied); | ||
| 402 | private: | 410 | private: |
| 403 | virtual int do_reload_listen(); | 411 | virtual int do_reload_listen(); |
| 404 | virtual int do_reload_pid(); | 412 | virtual int do_reload_pid(); |
| @@ -410,6 +418,7 @@ private: | @@ -410,6 +418,7 @@ private: | ||
| 410 | virtual int do_reload_pithy_print_ms(); | 418 | virtual int do_reload_pithy_print_ms(); |
| 411 | virtual int do_reload_vhost_added(std::string vhost); | 419 | virtual int do_reload_vhost_added(std::string vhost); |
| 412 | virtual int do_reload_vhost_removed(std::string vhost); | 420 | virtual int do_reload_vhost_removed(std::string vhost); |
| 421 | + virtual int do_reload_vhost_dvr_apply(std::string vhost); | ||
| 413 | public: | 422 | public: |
| 414 | /** | 423 | /** |
| 415 | * get the config file path. | 424 | * get the config file path. |
| @@ -1002,6 +1002,10 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -1002,6 +1002,10 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 1002 | // @scope @value @param @data description | 1002 | // @scope @value @param @data description |
| 1003 | // vhost ossrs.net create - create vhost ossrs.net | 1003 | // vhost ossrs.net create - create vhost ossrs.net |
| 1004 | // vhost ossrs.net update new.ossrs.net the new name to update vhost | 1004 | // vhost ossrs.net update new.ossrs.net the new name to update vhost |
| 1005 | + // dvr specified updates: | ||
| 1006 | + // @scope @value @param @data description | ||
| 1007 | + // dvr ossrs.net enable live/livestream enable the dvr of stream | ||
| 1008 | + // dvr ossrs.net disable live/livestream disable the dvr of stream | ||
| 1005 | if (rpc == "update") { | 1009 | if (rpc == "update") { |
| 1006 | if (!allow_update) { | 1010 | if (!allow_update) { |
| 1007 | ret = ERROR_SYSTEM_CONFIG_RAW_DISABLED; | 1011 | ret = ERROR_SYSTEM_CONFIG_RAW_DISABLED; |
| @@ -1019,7 +1023,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -1019,7 +1023,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 1019 | if (scope != "listen" && scope != "pid" && scope != "chunk_size" | 1023 | if (scope != "listen" && scope != "pid" && scope != "chunk_size" |
| 1020 | && scope != "ff_log_dir" && scope != "srs_log_tank" && scope != "srs_log_level" | 1024 | && scope != "ff_log_dir" && scope != "srs_log_tank" && scope != "srs_log_level" |
| 1021 | && scope != "srs_log_file" && scope != "max_connections" && scope != "utc_time" | 1025 | && scope != "srs_log_file" && scope != "max_connections" && scope != "utc_time" |
| 1022 | - && scope != "pithy_print_ms" && scope != "vhost" | 1026 | + && scope != "pithy_print_ms" && scope != "vhost" && scope != "dvr" |
| 1023 | ) { | 1027 | ) { |
| 1024 | ret = ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED; | 1028 | ret = ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED; |
| 1025 | srs_error("raw api query invalid scope=%s. ret=%d", scope.c_str(), ret); | 1029 | srs_error("raw api query invalid scope=%s. ret=%d", scope.c_str(), ret); |
| @@ -1231,6 +1235,34 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -1231,6 +1235,34 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 1231 | } else { | 1235 | } else { |
| 1232 | // TODO: support other param. | 1236 | // TODO: support other param. |
| 1233 | } | 1237 | } |
| 1238 | + } else if (scope == "dvr") { | ||
| 1239 | + std::string action = r->query_get("param"); | ||
| 1240 | + std::string stream = r->query_get("data"); | ||
| 1241 | + extra += "/" + stream + " to " + action; | ||
| 1242 | + | ||
| 1243 | + if (action != "enable" && action != "disable") { | ||
| 1244 | + ret = ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED; | ||
| 1245 | + srs_error("raw api query invalid scope=%s, param=%s. ret=%d", scope.c_str(), action.c_str(), ret); | ||
| 1246 | + return srs_api_response_code(w, r, ret); | ||
| 1247 | + } | ||
| 1248 | + | ||
| 1249 | + if (!_srs_config->get_dvr_enabled(value)) { | ||
| 1250 | + ret = ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED; | ||
| 1251 | + srs_error("raw api query invalid scope=%s, value=%s, param=%s. ret=%d", scope.c_str(), value.c_str(), action.c_str(), ret); | ||
| 1252 | + return srs_api_response_code(w, r, ret); | ||
| 1253 | + } | ||
| 1254 | + | ||
| 1255 | + if (action == "enable") { | ||
| 1256 | + if ((ret = _srs_config->raw_enable_dvr(value, stream, applied)) != ERROR_SUCCESS) { | ||
| 1257 | + srs_error("raw api update dvr=%s/%s, param=%s failed. ret=%d", value.c_str(), stream.c_str(), action.c_str(), ret); | ||
| 1258 | + return srs_api_response_code(w, r, ret); | ||
| 1259 | + } | ||
| 1260 | + } else { | ||
| 1261 | + if ((ret = _srs_config->raw_disable_dvr(value, stream, applied)) != ERROR_SUCCESS) { | ||
| 1262 | + srs_error("raw api update dvr=%s/%s, param=%s failed. ret=%d", value.c_str(), stream.c_str(), action.c_str(), ret); | ||
| 1263 | + return srs_api_response_code(w, r, ret); | ||
| 1264 | + } | ||
| 1265 | + } | ||
| 1234 | } else { | 1266 | } else { |
| 1235 | // TODO: support other scope. | 1267 | // TODO: support other scope. |
| 1236 | } | 1268 | } |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 3 | 32 | #define VERSION_MAJOR 3 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 3 | 34 | +#define VERSION_REVISION 4 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论