正在显示
11 个修改的文件
包含
197 行增加
和
144 行删除
| @@ -21,15 +21,25 @@ http_stream { | @@ -21,15 +21,25 @@ http_stream { | ||
| 21 | dir ./objs/nginx/html; | 21 | dir ./objs/nginx/html; |
| 22 | } | 22 | } |
| 23 | vhost __defaultVhost__ { | 23 | vhost __defaultVhost__ { |
| 24 | - # for SRS2. | ||
| 25 | - refer github.com github.io; | ||
| 26 | - refer_publish github.com github.io; | ||
| 27 | - refer_play github.com github.io; | ||
| 28 | - | ||
| 29 | # for SRS1. | 24 | # for SRS1. |
| 30 | http { | 25 | http { |
| 31 | enabled on; | 26 | enabled on; |
| 32 | mount [vhost]/hls; | 27 | mount [vhost]/hls; |
| 33 | dir ./objs/nginx/html/hls; | 28 | dir ./objs/nginx/html/hls; |
| 34 | } | 29 | } |
| 30 | + | ||
| 31 | + # for SRS2. | ||
| 32 | + refer github.com github.io; | ||
| 33 | + refer_publish github.com github.io; | ||
| 34 | + refer_play github.com github.io; | ||
| 35 | + | ||
| 36 | + # for SRS2 | ||
| 37 | + publish_1stpkt_timeout 20000; | ||
| 38 | + publish_normal_timeout 7000; | ||
| 39 | + | ||
| 40 | + # for SRS2 | ||
| 41 | + mr { | ||
| 42 | + enabled off; | ||
| 43 | + latency 350; | ||
| 44 | + } | ||
| 35 | } | 45 | } |
| @@ -334,40 +334,6 @@ vhost security.srs.com { | @@ -334,40 +334,6 @@ vhost security.srs.com { | ||
| 334 | } | 334 | } |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | -# the MR(merged-read) setting for publisher. | ||
| 338 | -# the MW(merged-write) settings for player. | ||
| 339 | -vhost mrw.srs.com { | ||
| 340 | - # whether enable min delay mode for vhost. | ||
| 341 | - # for min latence mode: | ||
| 342 | - # 1. disable the mr for vhost. | ||
| 343 | - # 2. use timeout for cond wait for consumer queue. | ||
| 344 | - # @see https://github.com/simple-rtmp-server/srs/issues/257 | ||
| 345 | - # default: off | ||
| 346 | - min_latency off; | ||
| 347 | - # about MR, read https://github.com/simple-rtmp-server/srs/issues/241 | ||
| 348 | - mr { | ||
| 349 | - # whether enable the MR(merged-read) | ||
| 350 | - # default: off | ||
| 351 | - enabled on; | ||
| 352 | - # the latency in ms for MR(merged-read), | ||
| 353 | - # the performance+ when latency+, and memory+, | ||
| 354 | - # memory(buffer) = latency * kbps / 8 | ||
| 355 | - # for example, latency=500ms, kbps=3000kbps, each publish connection will consume | ||
| 356 | - # memory = 500 * 3000 / 8 = 187500B = 183KB | ||
| 357 | - # when there are 2500 publisher, the total memory of SRS atleast: | ||
| 358 | - # 183KB * 2500 = 446MB | ||
| 359 | - # the value recomment is [300, 2000] | ||
| 360 | - # default: 350 | ||
| 361 | - latency 350; | ||
| 362 | - } | ||
| 363 | - # set the MW(merged-write) latency in ms. | ||
| 364 | - # SRS always set mw on, so we just set the latency value. | ||
| 365 | - # the latency of stream >= mw_latency + mr_latency | ||
| 366 | - # the value recomment is [300, 1800] | ||
| 367 | - # default: 350 | ||
| 368 | - mw_latency 350; | ||
| 369 | -} | ||
| 370 | - | ||
| 371 | # vhost for edge, edge and origin is the same vhost | 337 | # vhost for edge, edge and origin is the same vhost |
| 372 | vhost same.edge.srs.com { | 338 | vhost same.edge.srs.com { |
| 373 | # the mode of vhost, local or remote. | 339 | # the mode of vhost, local or remote. |
| @@ -966,6 +932,58 @@ vhost debug.srs.com { | @@ -966,6 +932,58 @@ vhost debug.srs.com { | ||
| 966 | debug_srs_upnode on; | 932 | debug_srs_upnode on; |
| 967 | } | 933 | } |
| 968 | 934 | ||
| 935 | +# the publish specified configs | ||
| 936 | +vhost publish.srs.com { | ||
| 937 | + # the config for FMLE/Flash publisher, which push RTMP to SRS. | ||
| 938 | + publish { | ||
| 939 | + # about MR, read https://github.com/simple-rtmp-server/srs/issues/241 | ||
| 940 | + # when enabled the mr, SRS will read as large as possible. | ||
| 941 | + # default: off | ||
| 942 | + mr off; | ||
| 943 | + # the latency in ms for MR(merged-read), | ||
| 944 | + # the performance+ when latency+, and memory+, | ||
| 945 | + # memory(buffer) = latency * kbps / 8 | ||
| 946 | + # for example, latency=500ms, kbps=3000kbps, each publish connection will consume | ||
| 947 | + # memory = 500 * 3000 / 8 = 187500B = 183KB | ||
| 948 | + # when there are 2500 publisher, the total memory of SRS atleast: | ||
| 949 | + # 183KB * 2500 = 446MB | ||
| 950 | + # the value recomment is [300, 2000] | ||
| 951 | + # default: 350 | ||
| 952 | + mr_latency 350; | ||
| 953 | + | ||
| 954 | + # the 1st packet timeout in ms for encoder. | ||
| 955 | + # default: 20000 | ||
| 956 | + firstpkt_timeout 20000; | ||
| 957 | + # the normal packet timeout in ms for encoder. | ||
| 958 | + # default: 5000 | ||
| 959 | + normal_timeout 7000; | ||
| 960 | + } | ||
| 961 | +} | ||
| 962 | + | ||
| 963 | +# the MR(merged-read) setting for publisher. | ||
| 964 | +# the MW(merged-write) settings for player. | ||
| 965 | +vhost mrw.srs.com { | ||
| 966 | + # whether enable min delay mode for vhost. | ||
| 967 | + # for min latence mode: | ||
| 968 | + # 1. disable the publish.mr for vhost. | ||
| 969 | + # 2. use timeout for cond wait for consumer queue. | ||
| 970 | + # @see https://github.com/simple-rtmp-server/srs/issues/257 | ||
| 971 | + # default: off | ||
| 972 | + min_latency off; | ||
| 973 | + # set the MW(merged-write) latency in ms. | ||
| 974 | + # SRS always set mw on, so we just set the latency value. | ||
| 975 | + # the latency of stream >= mw_latency + mr_latency | ||
| 976 | + # the value recomment is [300, 1800] | ||
| 977 | + # default: 350 | ||
| 978 | + mw_latency 350; | ||
| 979 | + | ||
| 980 | + # @see publish.srs.com | ||
| 981 | + publish { | ||
| 982 | + mr off; | ||
| 983 | + mr_latenct 350; | ||
| 984 | + } | ||
| 985 | +} | ||
| 986 | + | ||
| 969 | # the vhost for min delay, donot cache any stream. | 987 | # the vhost for min delay, donot cache any stream. |
| 970 | vhost min.delay.com { | 988 | vhost min.delay.com { |
| 971 | # @see vhost mrw.srs.com for detail. | 989 | # @see vhost mrw.srs.com for detail. |
| @@ -1019,12 +1037,12 @@ vhost stream.control.com { | @@ -1019,12 +1037,12 @@ vhost stream.control.com { | ||
| 1019 | # while the sequence header is not changed yet. | 1037 | # while the sequence header is not changed yet. |
| 1020 | # default: off | 1038 | # default: off |
| 1021 | reduce_sequence_header on; | 1039 | reduce_sequence_header on; |
| 1022 | - # the 1st packet timeout in ms for encoder. | ||
| 1023 | - # default: 20000 | ||
| 1024 | - publish_1stpkt_timeout 20000; | ||
| 1025 | - # the normal packet timeout in ms for encoder. | ||
| 1026 | - # default: 5000 | ||
| 1027 | - publish_normal_timeout 7000; | 1040 | + |
| 1041 | + # @see publish.srs.com | ||
| 1042 | + publish { | ||
| 1043 | + firstpkt_timeout 20000; | ||
| 1044 | + normal_timeout 7000; | ||
| 1045 | + } | ||
| 1028 | } | 1046 | } |
| 1029 | 1047 | ||
| 1030 | # the vhost which forward publish streams. | 1048 | # the vhost which forward publish streams. |
| @@ -66,17 +66,20 @@ vhost vhost.srs.com { | @@ -66,17 +66,20 @@ vhost vhost.srs.com { | ||
| 66 | atc_auto on; | 66 | atc_auto on; |
| 67 | 67 | ||
| 68 | min_latency on; | 68 | min_latency on; |
| 69 | - mr { | ||
| 70 | - enabled off; | ||
| 71 | - } | ||
| 72 | mw_latency 100; | 69 | mw_latency 100; |
| 73 | gop_cache off; | 70 | gop_cache off; |
| 74 | queue_length 10; | 71 | queue_length 10; |
| 75 | tcp_nodelay on; | 72 | tcp_nodelay on; |
| 76 | send_min_interval 10.0; | 73 | send_min_interval 10.0; |
| 77 | reduce_sequence_header on; | 74 | reduce_sequence_header on; |
| 78 | - publish_1stpkt_timeout 20000; | ||
| 79 | - publish_normal_timeout 7000; | 75 | + |
| 76 | + publish { | ||
| 77 | + mr off; | ||
| 78 | + mr_latency 350; | ||
| 79 | + | ||
| 80 | + firstpkt_timeout 20000; | ||
| 81 | + normal_timeout 7000; | ||
| 82 | + } | ||
| 80 | 83 | ||
| 81 | refer { | 84 | refer { |
| 82 | enabled off; | 85 | enabled off; |
| @@ -8,9 +8,9 @@ vhost __defaultVhost__ { | @@ -8,9 +8,9 @@ vhost __defaultVhost__ { | ||
| 8 | gop_cache off; | 8 | gop_cache off; |
| 9 | queue_length 10; | 9 | queue_length 10; |
| 10 | min_latency on; | 10 | min_latency on; |
| 11 | - mr { | ||
| 12 | - enabled off; | ||
| 13 | - } | ||
| 14 | mw_latency 100; | 11 | mw_latency 100; |
| 15 | tcp_nodelay on; | 12 | tcp_nodelay on; |
| 13 | + publish { | ||
| 14 | + mr off; | ||
| 15 | + } | ||
| 16 | } | 16 | } |
| @@ -816,16 +816,16 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | @@ -816,16 +816,16 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | ||
| 816 | srs_trace("vhost %s reload exec success.", vhost.c_str()); | 816 | srs_trace("vhost %s reload exec success.", vhost.c_str()); |
| 817 | } | 817 | } |
| 818 | 818 | ||
| 819 | - // mr, only one per vhost | ||
| 820 | - if (!srs_directive_equals(new_vhost->get("mr"), old_vhost->get("mr"))) { | 819 | + // publish, only one per vhost |
| 820 | + if (!srs_directive_equals(new_vhost->get("publish"), old_vhost->get("publish"))) { | ||
| 821 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { | 821 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { |
| 822 | ISrsReloadHandler* subscribe = *it; | 822 | ISrsReloadHandler* subscribe = *it; |
| 823 | - if ((ret = subscribe->on_reload_vhost_mr(vhost)) != ERROR_SUCCESS) { | ||
| 824 | - srs_error("vhost %s notify subscribes mr failed. ret=%d", vhost.c_str(), ret); | 823 | + if ((ret = subscribe->on_reload_vhost_publish(vhost)) != ERROR_SUCCESS) { |
| 824 | + srs_error("vhost %s notify subscribes publish failed. ret=%d", vhost.c_str(), ret); | ||
| 825 | return ret; | 825 | return ret; |
| 826 | } | 826 | } |
| 827 | } | 827 | } |
| 828 | - srs_trace("vhost %s reload mr success.", vhost.c_str()); | 828 | + srs_trace("vhost %s reload publish success.", vhost.c_str()); |
| 829 | } | 829 | } |
| 830 | 830 | ||
| 831 | // chunk_size, only one per vhost. | 831 | // chunk_size, only one per vhost. |
| @@ -876,30 +876,6 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | @@ -876,30 +876,6 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | ||
| 876 | srs_trace("vhost %s reload tcp_nodelay success.", vhost.c_str()); | 876 | srs_trace("vhost %s reload tcp_nodelay success.", vhost.c_str()); |
| 877 | } | 877 | } |
| 878 | 878 | ||
| 879 | - // publish_1stpkt_timeout, only one per vhost | ||
| 880 | - if (!srs_directive_equals(new_vhost->get("publish_1stpkt_timeout"), old_vhost->get("publish_1stpkt_timeout"))) { | ||
| 881 | - for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 882 | - ISrsReloadHandler* subscribe = *it; | ||
| 883 | - if ((ret = subscribe->on_reload_vhost_p1stpt(vhost)) != ERROR_SUCCESS) { | ||
| 884 | - srs_error("vhost %s notify subscribes p1stpt failed. ret=%d", vhost.c_str(), ret); | ||
| 885 | - return ret; | ||
| 886 | - } | ||
| 887 | - } | ||
| 888 | - srs_trace("vhost %s reload p1stpt success.", vhost.c_str()); | ||
| 889 | - } | ||
| 890 | - | ||
| 891 | - // publish_normal_timeout, only one per vhost | ||
| 892 | - if (!srs_directive_equals(new_vhost->get("publish_normal_timeout"), old_vhost->get("publish_normal_timeout"))) { | ||
| 893 | - for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 894 | - ISrsReloadHandler* subscribe = *it; | ||
| 895 | - if ((ret = subscribe->on_reload_vhost_pnt(vhost)) != ERROR_SUCCESS) { | ||
| 896 | - srs_error("vhost %s notify subscribes pnt failed. ret=%d", vhost.c_str(), ret); | ||
| 897 | - return ret; | ||
| 898 | - } | ||
| 899 | - } | ||
| 900 | - srs_trace("vhost %s reload pnt success.", vhost.c_str()); | ||
| 901 | - } | ||
| 902 | - | ||
| 903 | // min_latency, only one per vhost | 879 | // min_latency, only one per vhost |
| 904 | if (!srs_directive_equals(new_vhost->get("min_latency"), old_vhost->get("min_latency"))) { | 880 | if (!srs_directive_equals(new_vhost->get("min_latency"), old_vhost->get("min_latency"))) { |
| 905 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { | 881 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { |
| @@ -1798,20 +1774,6 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | @@ -1798,20 +1774,6 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | ||
| 1798 | if ((dir = vhost->get("min_latency")) != NULL) { | 1774 | if ((dir = vhost->get("min_latency")) != NULL) { |
| 1799 | obj->set("min_latency", dir->dumps_arg0_to_boolean()); | 1775 | obj->set("min_latency", dir->dumps_arg0_to_boolean()); |
| 1800 | } | 1776 | } |
| 1801 | - if ((dir = vhost->get("mr")) != NULL) { | ||
| 1802 | - SrsAmf0Object* mr = SrsAmf0Any::object(); | ||
| 1803 | - obj->set("mr", mr); | ||
| 1804 | - | ||
| 1805 | - for (int i = 0; i < (int)dir->directives.size(); i++) { | ||
| 1806 | - SrsConfDirective* sdir = dir->directives.at(i); | ||
| 1807 | - | ||
| 1808 | - if (sdir->name == "enabled") { | ||
| 1809 | - mr->set("enabled", sdir->dumps_arg0_to_boolean()); | ||
| 1810 | - } else if (sdir->name == "latency") { | ||
| 1811 | - mr->set("latency", sdir->dumps_arg0_to_number()); | ||
| 1812 | - } | ||
| 1813 | - } | ||
| 1814 | - } | ||
| 1815 | if ((dir = vhost->get("mw_latency")) != NULL) { | 1777 | if ((dir = vhost->get("mw_latency")) != NULL) { |
| 1816 | obj->set("mw_latency", dir->dumps_arg0_to_number()); | 1778 | obj->set("mw_latency", dir->dumps_arg0_to_number()); |
| 1817 | } | 1779 | } |
| @@ -1834,11 +1796,25 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | @@ -1834,11 +1796,25 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | ||
| 1834 | if ((dir = vhost->get("reduce_sequence_header")) != NULL) { | 1796 | if ((dir = vhost->get("reduce_sequence_header")) != NULL) { |
| 1835 | obj->set("reduce_sequence_header", dir->dumps_arg0_to_boolean()); | 1797 | obj->set("reduce_sequence_header", dir->dumps_arg0_to_boolean()); |
| 1836 | } | 1798 | } |
| 1837 | - if ((dir = vhost->get("publish_1stpkt_timeout")) != NULL) { | ||
| 1838 | - obj->set("publish_1stpkt_timeout", dir->dumps_arg0_to_number()); | ||
| 1839 | - } | ||
| 1840 | - if ((dir = vhost->get("publish_normal_timeout")) != NULL) { | ||
| 1841 | - obj->set("publish_normal_timeout", dir->dumps_arg0_to_number()); | 1799 | + |
| 1800 | + // publish | ||
| 1801 | + if ((dir = vhost->get("publish")) != NULL) { | ||
| 1802 | + SrsAmf0Object* publish = SrsAmf0Any::object(); | ||
| 1803 | + obj->set("publish", publish); | ||
| 1804 | + | ||
| 1805 | + for (int i = 0; i < (int)dir->directives.size(); i++) { | ||
| 1806 | + SrsConfDirective* sdir = dir->directives.at(i); | ||
| 1807 | + | ||
| 1808 | + if (sdir->name == "mr") { | ||
| 1809 | + publish->set("mr", sdir->dumps_arg0_to_boolean()); | ||
| 1810 | + } else if (sdir->name == "mr_latency") { | ||
| 1811 | + publish->set("mr_latency", sdir->dumps_arg0_to_number()); | ||
| 1812 | + } else if (sdir->name == "firstpkt_timeout") { | ||
| 1813 | + publish->set("firstpkt_timeout", sdir->dumps_arg0_to_number()); | ||
| 1814 | + } else if (sdir->name == "normal_timeout") { | ||
| 1815 | + publish->set("normal_timeout", sdir->dumps_arg0_to_number()); | ||
| 1816 | + } | ||
| 1817 | + } | ||
| 1842 | } | 1818 | } |
| 1843 | 1819 | ||
| 1844 | // refer | 1820 | // refer |
| @@ -2702,9 +2678,8 @@ int SrsConfig::check_config() | @@ -2702,9 +2678,8 @@ int SrsConfig::check_config() | ||
| 2702 | && n != "time_jitter" && n != "mix_correct" | 2678 | && n != "time_jitter" && n != "mix_correct" |
| 2703 | && n != "atc" && n != "atc_auto" | 2679 | && n != "atc" && n != "atc_auto" |
| 2704 | && n != "debug_srs_upnode" | 2680 | && n != "debug_srs_upnode" |
| 2705 | - && n != "mr" && n != "mw_latency" && n != "min_latency" | 2681 | + && n != "publish" && n != "mw_latency" && n != "min_latency" |
| 2706 | && n != "tcp_nodelay" && n != "send_min_interval" && n != "reduce_sequence_header" | 2682 | && n != "tcp_nodelay" && n != "send_min_interval" && n != "reduce_sequence_header" |
| 2707 | - && n != "publish_1stpkt_timeout" && n != "publish_normal_timeout" | ||
| 2708 | && n != "security" && n != "http_remux" | 2683 | && n != "security" && n != "http_remux" |
| 2709 | && n != "http_static" && n != "hds" && n != "exec" | 2684 | && n != "http_static" && n != "hds" && n != "exec" |
| 2710 | ) { | 2685 | ) { |
| @@ -2742,12 +2717,12 @@ int SrsConfig::check_config() | @@ -2742,12 +2717,12 @@ int SrsConfig::check_config() | ||
| 2742 | return ret; | 2717 | return ret; |
| 2743 | } | 2718 | } |
| 2744 | } | 2719 | } |
| 2745 | - } else if (n == "mr") { | 2720 | + } else if (n == "publish") { |
| 2746 | for (int j = 0; j < (int)conf->directives.size(); j++) { | 2721 | for (int j = 0; j < (int)conf->directives.size(); j++) { |
| 2747 | string m = conf->at(j)->name.c_str(); | 2722 | string m = conf->at(j)->name.c_str(); |
| 2748 | - if (m != "enabled" && m != "latency") { | 2723 | + if (m != "mr" && m != "mr_latency" && m != "firstpkt_timeout" && m != "normal_timeout") { |
| 2749 | ret = ERROR_SYSTEM_CONFIG_INVALID; | 2724 | ret = ERROR_SYSTEM_CONFIG_INVALID; |
| 2750 | - srs_error("unsupported vhost mr directive %s, ret=%d", m.c_str(), ret); | 2725 | + srs_error("unsupported vhost publish directive %s, ret=%d", m.c_str(), ret); |
| 2751 | return ret; | 2726 | return ret; |
| 2752 | } | 2727 | } |
| 2753 | } | 2728 | } |
| @@ -3463,12 +3438,12 @@ bool SrsConfig::get_mr_enabled(string vhost) | @@ -3463,12 +3438,12 @@ bool SrsConfig::get_mr_enabled(string vhost) | ||
| 3463 | return SRS_PERF_MR_ENABLED; | 3438 | return SRS_PERF_MR_ENABLED; |
| 3464 | } | 3439 | } |
| 3465 | 3440 | ||
| 3466 | - conf = conf->get("mr"); | 3441 | + conf = conf->get("publish"); |
| 3467 | if (!conf) { | 3442 | if (!conf) { |
| 3468 | return SRS_PERF_MR_ENABLED; | 3443 | return SRS_PERF_MR_ENABLED; |
| 3469 | } | 3444 | } |
| 3470 | 3445 | ||
| 3471 | - conf = conf->get("enabled"); | 3446 | + conf = conf->get("mr"); |
| 3472 | if (!conf || conf->arg0().empty()) { | 3447 | if (!conf || conf->arg0().empty()) { |
| 3473 | return SRS_PERF_MR_ENABLED; | 3448 | return SRS_PERF_MR_ENABLED; |
| 3474 | } | 3449 | } |
| @@ -3483,12 +3458,12 @@ int SrsConfig::get_mr_sleep_ms(string vhost) | @@ -3483,12 +3458,12 @@ int SrsConfig::get_mr_sleep_ms(string vhost) | ||
| 3483 | return SRS_PERF_MR_SLEEP; | 3458 | return SRS_PERF_MR_SLEEP; |
| 3484 | } | 3459 | } |
| 3485 | 3460 | ||
| 3486 | - conf = conf->get("mr"); | 3461 | + conf = conf->get("publish"); |
| 3487 | if (!conf) { | 3462 | if (!conf) { |
| 3488 | return SRS_PERF_MR_SLEEP; | 3463 | return SRS_PERF_MR_SLEEP; |
| 3489 | } | 3464 | } |
| 3490 | 3465 | ||
| 3491 | - conf = conf->get("latency"); | 3466 | + conf = conf->get("mr_latency"); |
| 3492 | if (!conf || conf->arg0().empty()) { | 3467 | if (!conf || conf->arg0().empty()) { |
| 3493 | return SRS_PERF_MR_SLEEP; | 3468 | return SRS_PERF_MR_SLEEP; |
| 3494 | } | 3469 | } |
| @@ -3587,7 +3562,12 @@ int SrsConfig::get_publish_1stpkt_timeout(string vhost) | @@ -3587,7 +3562,12 @@ int SrsConfig::get_publish_1stpkt_timeout(string vhost) | ||
| 3587 | return DEFAULT; | 3562 | return DEFAULT; |
| 3588 | } | 3563 | } |
| 3589 | 3564 | ||
| 3590 | - conf = conf->get("publish_1stpkt_timeout"); | 3565 | + conf = conf->get("publish"); |
| 3566 | + if (!conf) { | ||
| 3567 | + return DEFAULT; | ||
| 3568 | + } | ||
| 3569 | + | ||
| 3570 | + conf = conf->get("firstpkt_timeout"); | ||
| 3591 | if (!conf || conf->arg0().empty()) { | 3571 | if (!conf || conf->arg0().empty()) { |
| 3592 | return DEFAULT; | 3572 | return DEFAULT; |
| 3593 | } | 3573 | } |
| @@ -3607,7 +3587,12 @@ int SrsConfig::get_publish_normal_timeout(string vhost) | @@ -3607,7 +3587,12 @@ int SrsConfig::get_publish_normal_timeout(string vhost) | ||
| 3607 | return DEFAULT; | 3587 | return DEFAULT; |
| 3608 | } | 3588 | } |
| 3609 | 3589 | ||
| 3610 | - conf = conf->get("publish_normal_timeout"); | 3590 | + conf = conf->get("publish"); |
| 3591 | + if (!conf) { | ||
| 3592 | + return DEFAULT; | ||
| 3593 | + } | ||
| 3594 | + | ||
| 3595 | + conf = conf->get("normal_timeout"); | ||
| 3611 | if (!conf || conf->arg0().empty()) { | 3596 | if (!conf || conf->arg0().empty()) { |
| 3612 | return DEFAULT; | 3597 | return DEFAULT; |
| 3613 | } | 3598 | } |
| @@ -5677,7 +5662,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5677,7 +5662,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5677 | { | 5662 | { |
| 5678 | int ret = ERROR_SUCCESS; | 5663 | int ret = ERROR_SUCCESS; |
| 5679 | 5664 | ||
| 5680 | - for (int i = 0; i < root->directives.size(); i++) { | 5665 | + for (int i = 0; i < (int)root->directives.size(); i++) { |
| 5681 | SrsConfDirective* dir = root->directives.at(i); | 5666 | SrsConfDirective* dir = root->directives.at(i); |
| 5682 | 5667 | ||
| 5683 | // SRS2.0, rename global http_stream to http_server. | 5668 | // SRS2.0, rename global http_stream to http_server. |
| @@ -5694,6 +5679,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5694,6 +5679,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5694 | continue; | 5679 | continue; |
| 5695 | } | 5680 | } |
| 5696 | 5681 | ||
| 5682 | + // for each directive of vhost. | ||
| 5697 | std::vector<SrsConfDirective*>::iterator it; | 5683 | std::vector<SrsConfDirective*>::iterator it; |
| 5698 | for (it = dir->directives.begin(); it != dir->directives.end();) { | 5684 | for (it = dir->directives.begin(); it != dir->directives.end();) { |
| 5699 | SrsConfDirective* conf = *it; | 5685 | SrsConfDirective* conf = *it; |
| @@ -5736,6 +5722,66 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5736,6 +5722,66 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5736 | continue; | 5722 | continue; |
| 5737 | } | 5723 | } |
| 5738 | 5724 | ||
| 5725 | + // SRS3.0, change the mr style | ||
| 5726 | + // SRS2: | ||
| 5727 | + // vhost { mr { enabled; latency; } } | ||
| 5728 | + // SRS3+: | ||
| 5729 | + // vhost { publish { mr; mr_latency; } } | ||
| 5730 | + if (conf->name == "mr") { | ||
| 5731 | + it = dir->directives.erase(it); | ||
| 5732 | + | ||
| 5733 | + SrsConfDirective* publish = dir->get_or_create("publish"); | ||
| 5734 | + | ||
| 5735 | + SrsConfDirective* enabled = conf->get("enabled"); | ||
| 5736 | + if (enabled) { | ||
| 5737 | + SrsConfDirective* mr = publish->get_or_create("mr"); | ||
| 5738 | + mr->args = enabled->args; | ||
| 5739 | + } | ||
| 5740 | + | ||
| 5741 | + SrsConfDirective* latency = conf->get("latency"); | ||
| 5742 | + if (latency) { | ||
| 5743 | + SrsConfDirective* mr_latency = publish->get_or_create("mr_latency"); | ||
| 5744 | + mr_latency->args = latency->args; | ||
| 5745 | + } | ||
| 5746 | + | ||
| 5747 | + srs_freep(conf); | ||
| 5748 | + continue; | ||
| 5749 | + } | ||
| 5750 | + | ||
| 5751 | + // SRS3.0, change the publish_1stpkt_timeout | ||
| 5752 | + // SRS2: | ||
| 5753 | + // vhost { publish_1stpkt_timeout; } | ||
| 5754 | + // SRS3+: | ||
| 5755 | + // vhost { publish { firstpkt_timeout; } } | ||
| 5756 | + if (conf->name == "publish_1stpkt_timeout") { | ||
| 5757 | + it = dir->directives.erase(it); | ||
| 5758 | + | ||
| 5759 | + SrsConfDirective* publish = dir->get_or_create("publish"); | ||
| 5760 | + | ||
| 5761 | + SrsConfDirective* firstpkt_timeout = publish->get_or_create("firstpkt_timeout"); | ||
| 5762 | + firstpkt_timeout->args = conf->args; | ||
| 5763 | + | ||
| 5764 | + srs_freep(conf); | ||
| 5765 | + continue; | ||
| 5766 | + } | ||
| 5767 | + | ||
| 5768 | + // SRS3.0, change the publish_normal_timeout | ||
| 5769 | + // SRS2: | ||
| 5770 | + // vhost { publish_normal_timeout; } | ||
| 5771 | + // SRS3+: | ||
| 5772 | + // vhost { publish { normal_timeout; } } | ||
| 5773 | + if (conf->name == "publish_normal_timeout") { | ||
| 5774 | + it = dir->directives.erase(it); | ||
| 5775 | + | ||
| 5776 | + SrsConfDirective* publish = dir->get_or_create("publish"); | ||
| 5777 | + | ||
| 5778 | + SrsConfDirective* normal_timeout = publish->get_or_create("normal_timeout"); | ||
| 5779 | + normal_timeout->args = conf->args; | ||
| 5780 | + | ||
| 5781 | + srs_freep(conf); | ||
| 5782 | + continue; | ||
| 5783 | + } | ||
| 5784 | + | ||
| 5739 | ++it; | 5785 | ++it; |
| 5740 | } | 5786 | } |
| 5741 | } | 5787 | } |
| @@ -424,7 +424,7 @@ void SrsPublishRecvThread::on_read(ssize_t nread) | @@ -424,7 +424,7 @@ void SrsPublishRecvThread::on_read(ssize_t nread) | ||
| 424 | } | 424 | } |
| 425 | #endif | 425 | #endif |
| 426 | 426 | ||
| 427 | -int SrsPublishRecvThread::on_reload_vhost_mr(string vhost) | 427 | +int SrsPublishRecvThread::on_reload_vhost_publish(string vhost) |
| 428 | { | 428 | { |
| 429 | int ret = ERROR_SUCCESS; | 429 | int ret = ERROR_SUCCESS; |
| 430 | 430 |
| @@ -206,7 +206,7 @@ public: | @@ -206,7 +206,7 @@ public: | ||
| 206 | #endif | 206 | #endif |
| 207 | // interface ISrsReloadHandler | 207 | // interface ISrsReloadHandler |
| 208 | public: | 208 | public: |
| 209 | - virtual int on_reload_vhost_mr(std::string vhost); | 209 | + virtual int on_reload_vhost_publish(std::string vhost); |
| 210 | virtual int on_reload_vhost_realtime(std::string vhost); | 210 | virtual int on_reload_vhost_realtime(std::string vhost); |
| 211 | private: | 211 | private: |
| 212 | virtual void set_socket_buffer(int sleep_ms); | 212 | virtual void set_socket_buffer(int sleep_ms); |
| @@ -170,7 +170,7 @@ int ISrsReloadHandler::on_reload_vhost_dvr(string /*vhost*/) | @@ -170,7 +170,7 @@ int ISrsReloadHandler::on_reload_vhost_dvr(string /*vhost*/) | ||
| 170 | return ERROR_SUCCESS; | 170 | return ERROR_SUCCESS; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | -int ISrsReloadHandler::on_reload_vhost_mr(string /*vhost*/) | 173 | +int ISrsReloadHandler::on_reload_vhost_publish(string /*vhost*/) |
| 174 | { | 174 | { |
| 175 | return ERROR_SUCCESS; | 175 | return ERROR_SUCCESS; |
| 176 | } | 176 | } |
| @@ -195,16 +195,6 @@ int ISrsReloadHandler::on_reload_vhost_realtime(string /*vhost*/) | @@ -195,16 +195,6 @@ int ISrsReloadHandler::on_reload_vhost_realtime(string /*vhost*/) | ||
| 195 | return ERROR_SUCCESS; | 195 | return ERROR_SUCCESS; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | -int ISrsReloadHandler::on_reload_vhost_p1stpt(string /*vhost*/) | ||
| 199 | -{ | ||
| 200 | - return ERROR_SUCCESS; | ||
| 201 | -} | ||
| 202 | - | ||
| 203 | -int ISrsReloadHandler::on_reload_vhost_pnt(string /*vhost*/) | ||
| 204 | -{ | ||
| 205 | - return ERROR_SUCCESS; | ||
| 206 | -} | ||
| 207 | - | ||
| 208 | int ISrsReloadHandler::on_reload_vhost_chunk_size(string /*vhost*/) | 198 | int ISrsReloadHandler::on_reload_vhost_chunk_size(string /*vhost*/) |
| 209 | { | 199 | { |
| 210 | return ERROR_SUCCESS; | 200 | return ERROR_SUCCESS; |
| @@ -73,13 +73,11 @@ public: | @@ -73,13 +73,11 @@ public: | ||
| 73 | virtual int on_reload_vhost_hls(std::string vhost); | 73 | virtual int on_reload_vhost_hls(std::string vhost); |
| 74 | virtual int on_reload_vhost_hds(std::string vhost); | 74 | virtual int on_reload_vhost_hds(std::string vhost); |
| 75 | virtual int on_reload_vhost_dvr(std::string vhost); | 75 | virtual int on_reload_vhost_dvr(std::string vhost); |
| 76 | - virtual int on_reload_vhost_mr(std::string vhost); | 76 | + virtual int on_reload_vhost_publish(std::string vhost); |
| 77 | virtual int on_reload_vhost_mw(std::string vhost); | 77 | virtual int on_reload_vhost_mw(std::string vhost); |
| 78 | virtual int on_reload_vhost_smi(std::string vhost); | 78 | virtual int on_reload_vhost_smi(std::string vhost); |
| 79 | virtual int on_reload_vhost_tcp_nodelay(std::string vhost); | 79 | virtual int on_reload_vhost_tcp_nodelay(std::string vhost); |
| 80 | virtual int on_reload_vhost_realtime(std::string vhost); | 80 | virtual int on_reload_vhost_realtime(std::string vhost); |
| 81 | - virtual int on_reload_vhost_p1stpt(std::string vhost); | ||
| 82 | - virtual int on_reload_vhost_pnt(std::string vhost); | ||
| 83 | virtual int on_reload_vhost_chunk_size(std::string vhost); | 81 | virtual int on_reload_vhost_chunk_size(std::string vhost); |
| 84 | virtual int on_reload_vhost_transcode(std::string vhost); | 82 | virtual int on_reload_vhost_transcode(std::string vhost); |
| 85 | virtual int on_reload_vhost_exec(std::string vhost); | 83 | virtual int on_reload_vhost_exec(std::string vhost); |
| @@ -294,7 +294,7 @@ int SrsRtmpConn::on_reload_vhost_realtime(string vhost) | @@ -294,7 +294,7 @@ int SrsRtmpConn::on_reload_vhost_realtime(string vhost) | ||
| 294 | return ret; | 294 | return ret; |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | -int SrsRtmpConn::on_reload_vhost_p1stpt(string vhost) | 297 | +int SrsRtmpConn::on_reload_vhost_publish(string vhost) |
| 298 | { | 298 | { |
| 299 | int ret = ERROR_SUCCESS; | 299 | int ret = ERROR_SUCCESS; |
| 300 | 300 | ||
| @@ -308,20 +308,9 @@ int SrsRtmpConn::on_reload_vhost_p1stpt(string vhost) | @@ -308,20 +308,9 @@ int SrsRtmpConn::on_reload_vhost_p1stpt(string vhost) | ||
| 308 | publish_1stpkt_timeout = p1stpt; | 308 | publish_1stpkt_timeout = p1stpt; |
| 309 | } | 309 | } |
| 310 | 310 | ||
| 311 | - return ret; | ||
| 312 | -} | ||
| 313 | - | ||
| 314 | -int SrsRtmpConn::on_reload_vhost_pnt(string vhost) | ||
| 315 | -{ | ||
| 316 | - int ret = ERROR_SUCCESS; | ||
| 317 | - | ||
| 318 | - if (req->vhost != vhost) { | ||
| 319 | - return ret; | ||
| 320 | - } | ||
| 321 | - | ||
| 322 | int pnt = _srs_config->get_publish_normal_timeout(req->vhost); | 311 | int pnt = _srs_config->get_publish_normal_timeout(req->vhost); |
| 323 | if (pnt != publish_normal_timeout) { | 312 | if (pnt != publish_normal_timeout) { |
| 324 | - srs_trace("p1stpt changed %d=>%d", publish_normal_timeout, pnt); | 313 | + srs_trace("pnt changed %d=>%d", publish_normal_timeout, pnt); |
| 325 | publish_normal_timeout = pnt; | 314 | publish_normal_timeout = pnt; |
| 326 | } | 315 | } |
| 327 | 316 |
| @@ -107,8 +107,7 @@ public: | @@ -107,8 +107,7 @@ public: | ||
| 107 | virtual int on_reload_vhost_smi(std::string vhost); | 107 | virtual int on_reload_vhost_smi(std::string vhost); |
| 108 | virtual int on_reload_vhost_tcp_nodelay(std::string vhost); | 108 | virtual int on_reload_vhost_tcp_nodelay(std::string vhost); |
| 109 | virtual int on_reload_vhost_realtime(std::string vhost); | 109 | virtual int on_reload_vhost_realtime(std::string vhost); |
| 110 | - virtual int on_reload_vhost_p1stpt(std::string vhost); | ||
| 111 | - virtual int on_reload_vhost_pnt(std::string vhost); | 110 | + virtual int on_reload_vhost_publish(std::string vhost); |
| 112 | // interface IKbpsDelta | 111 | // interface IKbpsDelta |
| 113 | public: | 112 | public: |
| 114 | virtual void resample(); | 113 | virtual void resample(); |
-
请 注册 或 登录 后发表评论