winlin

fix bug of config to parse the default value. 2.0.158

@@ -51,6 +51,10 @@ using namespace _srs_internal; @@ -51,6 +51,10 @@ using namespace _srs_internal;
51 51
52 #define SRS_WIKI_URL_LOG "https://github.com/winlinvip/simple-rtmp-server/wiki/v1_CN_SrsLog" 52 #define SRS_WIKI_URL_LOG "https://github.com/winlinvip/simple-rtmp-server/wiki/v1_CN_SrsLog"
53 53
  54 +// when user config an invalid value, macros to perfer true or false.
  55 +#define SRS_CONF_PERFER_FALSE(conf_arg) conf_arg == "on"
  56 +#define SRS_CONF_PERFER_TRUE(conf_arg) conf_arg != "off"
  57 +
54 // '\n' 58 // '\n'
55 #define SRS_LF (char)0x0a 59 #define SRS_LF (char)0x0a
56 60
@@ -1836,11 +1840,11 @@ bool SrsConfig::get_deamon() @@ -1836,11 +1840,11 @@ bool SrsConfig::get_deamon()
1836 srs_assert(root); 1840 srs_assert(root);
1837 1841
1838 SrsConfDirective* conf = root->get("daemon"); 1842 SrsConfDirective* conf = root->get("daemon");
1839 - if (conf && conf->arg0() == "off") {  
1840 - return false; 1843 + if (!conf || conf->arg0().empty()) {
  1844 + return true;
1841 } 1845 }
1842 1846
1843 - return true; 1847 + return SRS_CONF_PERFER_TRUE(conf->arg0());
1844 } 1848 }
1845 1849
1846 SrsConfDirective* SrsConfig::get_root() 1850 SrsConfDirective* SrsConfig::get_root()
@@ -1899,12 +1903,12 @@ int SrsConfig::get_pithy_print_ms() @@ -1899,12 +1903,12 @@ int SrsConfig::get_pithy_print_ms()
1899 1903
1900 bool SrsConfig::get_utc_time() 1904 bool SrsConfig::get_utc_time()
1901 { 1905 {
1902 - SrsConfDirective* utc = root->get("utc_time");  
1903 - if (!utc || utc->arg0().empty()) { 1906 + SrsConfDirective* conf = root->get("utc_time");
  1907 + if (!conf || conf->arg0().empty()) {
1904 return SRS_CONF_DEFAULT_UTC_TIME; 1908 return SRS_CONF_DEFAULT_UTC_TIME;
1905 } 1909 }
1906 1910
1907 - return utc->arg0() == "on"; 1911 + return SRS_CONF_PERFER_FALSE(conf->arg0());
1908 } 1912 }
1909 1913
1910 vector<SrsConfDirective*> SrsConfig::get_stream_casters() 1914 vector<SrsConfDirective*> SrsConfig::get_stream_casters()
@@ -1931,15 +1935,11 @@ bool SrsConfig::get_stream_caster_enabled(SrsConfDirective* sc) @@ -1931,15 +1935,11 @@ bool SrsConfig::get_stream_caster_enabled(SrsConfDirective* sc)
1931 srs_assert(sc); 1935 srs_assert(sc);
1932 1936
1933 SrsConfDirective* conf = sc->get("enabled"); 1937 SrsConfDirective* conf = sc->get("enabled");
1934 - if (!conf) { 1938 + if (!conf || conf->arg0().empty()) {
1935 return SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED; 1939 return SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED;
1936 } 1940 }
1937 -  
1938 - if (conf->arg0() != "on") {  
1939 - return false;  
1940 - }  
1941 -  
1942 - return true; 1941 +
  1942 + return SRS_CONF_PERFER_FALSE(conf->arg0());
1943 } 1943 }
1944 1944
1945 string SrsConfig::get_stream_caster_engine(SrsConfDirective* sc) 1945 string SrsConfig::get_stream_caster_engine(SrsConfDirective* sc)
@@ -1947,7 +1947,7 @@ string SrsConfig::get_stream_caster_engine(SrsConfDirective* sc) @@ -1947,7 +1947,7 @@ string SrsConfig::get_stream_caster_engine(SrsConfDirective* sc)
1947 srs_assert(sc); 1947 srs_assert(sc);
1948 1948
1949 SrsConfDirective* conf = sc->get("caster"); 1949 SrsConfDirective* conf = sc->get("caster");
1950 - if (!conf) { 1950 + if (!conf || conf->arg0().empty()) {
1951 return ""; 1951 return "";
1952 } 1952 }
1953 1953
@@ -1959,7 +1959,7 @@ string SrsConfig::get_stream_caster_output(SrsConfDirective* sc) @@ -1959,7 +1959,7 @@ string SrsConfig::get_stream_caster_output(SrsConfDirective* sc)
1959 srs_assert(sc); 1959 srs_assert(sc);
1960 1960
1961 SrsConfDirective* conf = sc->get("output"); 1961 SrsConfDirective* conf = sc->get("output");
1962 - if (!conf) { 1962 + if (!conf || conf->arg0().empty()) {
1963 return ""; 1963 return "";
1964 } 1964 }
1965 1965
@@ -1971,7 +1971,7 @@ int SrsConfig::get_stream_caster_listen(SrsConfDirective* sc) @@ -1971,7 +1971,7 @@ int SrsConfig::get_stream_caster_listen(SrsConfDirective* sc)
1971 srs_assert(sc); 1971 srs_assert(sc);
1972 1972
1973 SrsConfDirective* conf = sc->get("listen"); 1973 SrsConfDirective* conf = sc->get("listen");
1974 - if (!conf) { 1974 + if (!conf || conf->arg0().empty()) {
1975 return 0; 1975 return 0;
1976 } 1976 }
1977 1977
@@ -1983,7 +1983,7 @@ int SrsConfig::get_stream_caster_rtp_port_min(SrsConfDirective* sc) @@ -1983,7 +1983,7 @@ int SrsConfig::get_stream_caster_rtp_port_min(SrsConfDirective* sc)
1983 srs_assert(sc); 1983 srs_assert(sc);
1984 1984
1985 SrsConfDirective* conf = sc->get("rtp_port_min"); 1985 SrsConfDirective* conf = sc->get("rtp_port_min");
1986 - if (!conf) { 1986 + if (!conf || conf->arg0().empty()) {
1987 return 0; 1987 return 0;
1988 } 1988 }
1989 1989
@@ -1995,7 +1995,7 @@ int SrsConfig::get_stream_caster_rtp_port_max(SrsConfDirective* sc) @@ -1995,7 +1995,7 @@ int SrsConfig::get_stream_caster_rtp_port_max(SrsConfDirective* sc)
1995 srs_assert(sc); 1995 srs_assert(sc);
1996 1996
1997 SrsConfDirective* conf = sc->get("rtp_port_max"); 1997 SrsConfDirective* conf = sc->get("rtp_port_max");
1998 - if (!conf) { 1998 + if (!conf || conf->arg0().empty()) {
1999 return 0; 1999 return 0;
2000 } 2000 }
2001 2001
@@ -2058,15 +2058,11 @@ bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost) @@ -2058,15 +2058,11 @@ bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost)
2058 } 2058 }
2059 2059
2060 SrsConfDirective* conf = vhost->get("enabled"); 2060 SrsConfDirective* conf = vhost->get("enabled");
2061 - if (!conf) { 2061 + if (!conf || conf->arg0().empty()) {
2062 return true; 2062 return true;
2063 } 2063 }
2064 2064
2065 - if (conf->arg0() == "off") {  
2066 - return false;  
2067 - }  
2068 -  
2069 - return true; 2065 + return SRS_CONF_PERFER_TRUE(conf->arg0());
2070 } 2066 }
2071 2067
2072 bool SrsConfig::get_gop_cache(string vhost) 2068 bool SrsConfig::get_gop_cache(string vhost)
@@ -2078,11 +2074,11 @@ bool SrsConfig::get_gop_cache(string vhost) @@ -2078,11 +2074,11 @@ bool SrsConfig::get_gop_cache(string vhost)
2078 } 2074 }
2079 2075
2080 conf = conf->get("gop_cache"); 2076 conf = conf->get("gop_cache");
2081 - if (conf && conf->arg0() == "off") {  
2082 - return false; 2077 + if (!conf || conf->arg0().empty()) {
  2078 + return SRS_PERF_GOP_CACHE;
2083 } 2079 }
2084 2080
2085 - return SRS_PERF_GOP_CACHE; 2081 + return SRS_CONF_PERFER_TRUE(conf->arg0());
2086 } 2082 }
2087 2083
2088 bool SrsConfig::get_debug_srs_upnode(string vhost) 2084 bool SrsConfig::get_debug_srs_upnode(string vhost)
@@ -2094,11 +2090,11 @@ bool SrsConfig::get_debug_srs_upnode(string vhost) @@ -2094,11 +2090,11 @@ bool SrsConfig::get_debug_srs_upnode(string vhost)
2094 } 2090 }
2095 2091
2096 conf = conf->get("debug_srs_upnode"); 2092 conf = conf->get("debug_srs_upnode");
2097 - if (conf && conf->arg0() == "off") {  
2098 - return false; 2093 + if (!conf || conf->arg0().empty()) {
  2094 + return true;
2099 } 2095 }
2100 2096
2101 - return true; 2097 + return SRS_CONF_PERFER_TRUE(conf->arg0());
2102 } 2098 }
2103 2099
2104 bool SrsConfig::get_atc(string vhost) 2100 bool SrsConfig::get_atc(string vhost)
@@ -2110,11 +2106,11 @@ bool SrsConfig::get_atc(string vhost) @@ -2110,11 +2106,11 @@ bool SrsConfig::get_atc(string vhost)
2110 } 2106 }
2111 2107
2112 conf = conf->get("atc"); 2108 conf = conf->get("atc");
2113 - if (conf && conf->arg0() == "on") {  
2114 - return true; 2109 + if (!conf || conf->arg0().empty()) {
  2110 + return false;
2115 } 2111 }
2116 2112
2117 - return false; 2113 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2118 } 2114 }
2119 2115
2120 bool SrsConfig::get_atc_auto(string vhost) 2116 bool SrsConfig::get_atc_auto(string vhost)
@@ -2126,11 +2122,11 @@ bool SrsConfig::get_atc_auto(string vhost) @@ -2126,11 +2122,11 @@ bool SrsConfig::get_atc_auto(string vhost)
2126 } 2122 }
2127 2123
2128 conf = conf->get("atc_auto"); 2124 conf = conf->get("atc_auto");
2129 - if (conf && conf->arg0() == "off") {  
2130 - return false; 2125 + if (!conf || conf->arg0().empty()) {
  2126 + return true;
2131 } 2127 }
2132 2128
2133 - return true; 2129 + return SRS_CONF_PERFER_TRUE(conf->arg0());
2134 } 2130 }
2135 2131
2136 int SrsConfig::get_time_jitter(string vhost) 2132 int SrsConfig::get_time_jitter(string vhost)
@@ -2214,7 +2210,7 @@ int SrsConfig::get_chunk_size(string vhost) @@ -2214,7 +2210,7 @@ int SrsConfig::get_chunk_size(string vhost)
2214 } 2210 }
2215 2211
2216 conf = conf->get("chunk_size"); 2212 conf = conf->get("chunk_size");
2217 - if (!conf) { 2213 + if (!conf || conf->arg0().empty()) {
2218 // vhost does not specify the chunk size, 2214 // vhost does not specify the chunk size,
2219 // use the global instead. 2215 // use the global instead.
2220 return get_global_chunk_size(); 2216 return get_global_chunk_size();
@@ -2237,11 +2233,11 @@ bool SrsConfig::get_mr_enabled(string vhost) @@ -2237,11 +2233,11 @@ bool SrsConfig::get_mr_enabled(string vhost)
2237 } 2233 }
2238 2234
2239 conf = conf->get("enabled"); 2235 conf = conf->get("enabled");
2240 - if (!conf || conf->arg0() != "on") { 2236 + if (!conf || conf->arg0().empty()) {
2241 return SRS_PERF_MR_ENABLED; 2237 return SRS_PERF_MR_ENABLED;
2242 } 2238 }
2243 -  
2244 - return true; 2239 +
  2240 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2245 } 2241 }
2246 2242
2247 int SrsConfig::get_mr_sleep_ms(string vhost) 2243 int SrsConfig::get_mr_sleep_ms(string vhost)
@@ -2294,13 +2290,13 @@ bool SrsConfig::get_realtime_enabled(string vhost) @@ -2294,13 +2290,13 @@ bool SrsConfig::get_realtime_enabled(string vhost)
2294 return SRS_PERF_MIN_LATENCY_ENABLED; 2290 return SRS_PERF_MIN_LATENCY_ENABLED;
2295 } 2291 }
2296 2292
2297 - return conf->arg0() == "on"; 2293 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2298 } 2294 }
2299 2295
2300 int SrsConfig::get_global_chunk_size() 2296 int SrsConfig::get_global_chunk_size()
2301 { 2297 {
2302 SrsConfDirective* conf = root->get("chunk_size"); 2298 SrsConfDirective* conf = root->get("chunk_size");
2303 - if (!conf) { 2299 + if (!conf || conf->arg0().empty()) {
2304 return SRS_CONSTS_RTMP_SRS_CHUNK_SIZE; 2300 return SRS_CONSTS_RTMP_SRS_CHUNK_SIZE;
2305 } 2301 }
2306 2302
@@ -2337,12 +2333,12 @@ bool SrsConfig::get_vhost_http_hooks_enabled(string vhost) @@ -2337,12 +2333,12 @@ bool SrsConfig::get_vhost_http_hooks_enabled(string vhost)
2337 return false; 2333 return false;
2338 } 2334 }
2339 2335
2340 - SrsConfDirective* enabled = conf->get("enabled");  
2341 - if (!enabled || enabled->arg0() != "on") { 2336 + conf = conf->get("enabled");
  2337 + if (!conf || conf->arg0().empty()) {
2342 return false; 2338 return false;
2343 } 2339 }
2344 2340
2345 - return true; 2341 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2346 } 2342 }
2347 2343
2348 SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost) 2344 SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
@@ -2447,11 +2443,11 @@ bool SrsConfig::get_bw_check_enabled(string vhost) @@ -2447,11 +2443,11 @@ bool SrsConfig::get_bw_check_enabled(string vhost)
2447 } 2443 }
2448 2444
2449 conf = conf->get("enabled"); 2445 conf = conf->get("enabled");
2450 - if (!conf || conf->arg0() != "on") { 2446 + if (!conf || conf->arg0().empty()) {
2451 return false; 2447 return false;
2452 } 2448 }
2453 -  
2454 - return true; 2449 +
  2450 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2455 } 2451 }
2456 2452
2457 string SrsConfig::get_bw_check_key(string vhost) 2453 string SrsConfig::get_bw_check_key(string vhost)
@@ -2532,11 +2528,11 @@ bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost) @@ -2532,11 +2528,11 @@ bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost)
2532 } 2528 }
2533 2529
2534 conf = conf->get("mode"); 2530 conf = conf->get("mode");
2535 - if (!conf || conf->arg0() != "remote") { 2531 + if (!conf || conf->arg0().empty()) {
2536 return SRS_CONF_DEFAULT_EDGE_MODE; 2532 return SRS_CONF_DEFAULT_EDGE_MODE;
2537 } 2533 }
2538 2534
2539 - return true; 2535 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2540 } 2536 }
2541 2537
2542 SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost) 2538 SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost)
@@ -2559,11 +2555,11 @@ bool SrsConfig::get_vhost_edge_token_traverse(string vhost) @@ -2559,11 +2555,11 @@ bool SrsConfig::get_vhost_edge_token_traverse(string vhost)
2559 } 2555 }
2560 2556
2561 conf = conf->get("token_traverse"); 2557 conf = conf->get("token_traverse");
2562 - if (!conf || conf->arg0() != "on") { 2558 + if (!conf || conf->arg0().empty()) {
2563 return SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE; 2559 return SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE;
2564 } 2560 }
2565 2561
2566 - return true; 2562 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2567 } 2563 }
2568 2564
2569 string SrsConfig::get_vhost_edge_transform_vhost(string vhost) 2565 string SrsConfig::get_vhost_edge_transform_vhost(string vhost)
@@ -2596,11 +2592,11 @@ bool SrsConfig::get_security_enabled(string vhost) @@ -2596,11 +2592,11 @@ bool SrsConfig::get_security_enabled(string vhost)
2596 } 2592 }
2597 2593
2598 conf = security->get("enabled"); 2594 conf = security->get("enabled");
2599 - if (!conf || conf->arg0() != "on") { 2595 + if (!conf || conf->arg0().empty()) {
2600 return SRS_CONF_DEFAULT_SECURITY_ENABLED; 2596 return SRS_CONF_DEFAULT_SECURITY_ENABLED;
2601 } 2597 }
2602 2598
2603 - return true; 2599 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2604 } 2600 }
2605 2601
2606 SrsConfDirective* SrsConfig::get_security_rules(string vhost) 2602 SrsConfDirective* SrsConfig::get_security_rules(string vhost)
@@ -2646,11 +2642,11 @@ bool SrsConfig::get_transcode_enabled(SrsConfDirective* transcode) @@ -2646,11 +2642,11 @@ bool SrsConfig::get_transcode_enabled(SrsConfDirective* transcode)
2646 } 2642 }
2647 2643
2648 SrsConfDirective* conf = transcode->get("enabled"); 2644 SrsConfDirective* conf = transcode->get("enabled");
2649 - if (!conf || conf->arg0() != "on") { 2645 + if (!conf || conf->arg0().empty()) {
2650 return false; 2646 return false;
2651 } 2647 }
2652 2648
2653 - return true; 2649 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2654 } 2650 }
2655 2651
2656 string SrsConfig::get_transcode_ffmpeg(SrsConfDirective* transcode) 2652 string SrsConfig::get_transcode_ffmpeg(SrsConfDirective* transcode)
@@ -2693,11 +2689,11 @@ bool SrsConfig::get_engine_enabled(SrsConfDirective* engine) @@ -2693,11 +2689,11 @@ bool SrsConfig::get_engine_enabled(SrsConfDirective* engine)
2693 } 2689 }
2694 2690
2695 SrsConfDirective* conf = engine->get("enabled"); 2691 SrsConfDirective* conf = engine->get("enabled");
2696 - if (!conf || conf->arg0() != "on") { 2692 + if (!conf || conf->arg0().empty()) {
2697 return false; 2693 return false;
2698 } 2694 }
2699 2695
2700 - return true; 2696 + return SRS_CONF_PERFER_FALSE(conf->arg0());
2701 } 2697 }
2702 2698
2703 string SrsConfig::get_engine_iformat(SrsConfDirective* engine) 2699 string SrsConfig::get_engine_iformat(SrsConfDirective* engine)
@@ -3027,11 +3023,11 @@ bool SrsConfig::get_ingest_enabled(SrsConfDirective* ingest) @@ -3027,11 +3023,11 @@ bool SrsConfig::get_ingest_enabled(SrsConfDirective* ingest)
3027 3023
3028 SrsConfDirective* conf = ingest->get("enabled"); 3024 SrsConfDirective* conf = ingest->get("enabled");
3029 3025
3030 - if (!conf || conf->arg0() != "on") { 3026 + if (!conf || conf->arg0().empty()) {
3031 return false; 3027 return false;
3032 } 3028 }
3033 3029
3034 - return true; 3030 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3035 } 3031 }
3036 3032
3037 string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* ingest) 3033 string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* ingest)
@@ -3096,11 +3092,11 @@ bool SrsConfig::get_log_tank_file() @@ -3096,11 +3092,11 @@ bool SrsConfig::get_log_tank_file()
3096 srs_assert(root); 3092 srs_assert(root);
3097 3093
3098 SrsConfDirective* conf = root->get("srs_log_tank"); 3094 SrsConfDirective* conf = root->get("srs_log_tank");
3099 - if (conf && conf->arg0() == SRS_CONF_DEFAULT_LOG_TANK_CONSOLE) { 3095 + if (!conf || conf->arg0().empty()) {
3100 return false; 3096 return false;
3101 } 3097 }
3102 3098
3103 - return true; 3099 + return conf->arg0() != SRS_CONF_DEFAULT_LOG_TANK_CONSOLE;
3104 } 3100 }
3105 3101
3106 string SrsConfig::get_log_level() 3102 string SrsConfig::get_log_level()
@@ -3166,15 +3162,11 @@ bool SrsConfig::get_hls_enabled(string vhost) @@ -3166,15 +3162,11 @@ bool SrsConfig::get_hls_enabled(string vhost)
3166 3162
3167 SrsConfDirective* conf = hls->get("enabled"); 3163 SrsConfDirective* conf = hls->get("enabled");
3168 3164
3169 - if (!conf) { 3165 + if (!conf || conf->arg0().empty()) {
3170 return false; 3166 return false;
3171 } 3167 }
3172 3168
3173 - if (conf->arg0() == "on") {  
3174 - return true;  
3175 - }  
3176 -  
3177 - return false; 3169 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3178 } 3170 }
3179 3171
3180 string SrsConfig::get_hls_entry_prefix(string vhost) 3172 string SrsConfig::get_hls_entry_prefix(string vhost)
@@ -3255,11 +3247,11 @@ bool SrsConfig::get_hls_ts_floor(string vhost) @@ -3255,11 +3247,11 @@ bool SrsConfig::get_hls_ts_floor(string vhost)
3255 3247
3256 SrsConfDirective* conf = hls->get("hls_ts_floor"); 3248 SrsConfDirective* conf = hls->get("hls_ts_floor");
3257 3249
3258 - if (!conf || conf->arg0() != "on") { 3250 + if (!conf || conf->arg0().empty()) {
3259 return SRS_CONF_DEFAULT_HLS_TS_FLOOR; 3251 return SRS_CONF_DEFAULT_HLS_TS_FLOOR;
3260 } 3252 }
3261 3253
3262 - return true; 3254 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3263 } 3255 }
3264 3256
3265 double SrsConfig::get_hls_fragment(string vhost) 3257 double SrsConfig::get_hls_fragment(string vhost)
@@ -3408,7 +3400,7 @@ string SrsConfig::get_hls_vcodec(string vhost) @@ -3408,7 +3400,7 @@ string SrsConfig::get_hls_vcodec(string vhost)
3408 3400
3409 SrsConfDirective* conf = hls->get("hls_vcodec"); 3401 SrsConfDirective* conf = hls->get("hls_vcodec");
3410 3402
3411 - if (!conf) { 3403 + if (!conf || conf->arg0().empty()) {
3412 return SRS_CONF_DEFAULT_HLS_VCODEC; 3404 return SRS_CONF_DEFAULT_HLS_VCODEC;
3413 } 3405 }
3414 3406
@@ -3425,11 +3417,11 @@ bool SrsConfig::get_hls_cleanup(string vhost) @@ -3425,11 +3417,11 @@ bool SrsConfig::get_hls_cleanup(string vhost)
3425 3417
3426 SrsConfDirective* conf = hls->get("hls_cleanup"); 3418 SrsConfDirective* conf = hls->get("hls_cleanup");
3427 3419
3428 - if (conf && conf->arg0() != "off") { 3420 + if (!conf || conf->arg0().empty()) {
3429 return SRS_CONF_DEFAULT_HLS_CLEANUP; 3421 return SRS_CONF_DEFAULT_HLS_CLEANUP;
3430 } 3422 }
3431 3423
3432 - return false; 3424 + return SRS_CONF_PERFER_TRUE(conf->arg0());
3433 } 3425 }
3434 3426
3435 SrsConfDirective *SrsConfig::get_hds(const string &vhost) 3427 SrsConfDirective *SrsConfig::get_hds(const string &vhost)
@@ -3453,11 +3445,11 @@ bool SrsConfig::get_hds_enabled(const string &vhost) @@ -3453,11 +3445,11 @@ bool SrsConfig::get_hds_enabled(const string &vhost)
3453 3445
3454 SrsConfDirective* conf = hds->get("enabled"); 3446 SrsConfDirective* conf = hds->get("enabled");
3455 3447
3456 - if (!conf) { 3448 + if (!conf || conf->arg0().empty()) {
3457 return false; 3449 return false;
3458 } 3450 }
3459 -  
3460 - return conf->arg0() == "on"; 3451 +
  3452 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3461 } 3453 }
3462 3454
3463 string SrsConfig::get_hds_path(const string &vhost) 3455 string SrsConfig::get_hds_path(const string &vhost)
@@ -3532,15 +3524,11 @@ bool SrsConfig::get_dvr_enabled(string vhost) @@ -3532,15 +3524,11 @@ bool SrsConfig::get_dvr_enabled(string vhost)
3532 3524
3533 SrsConfDirective* conf = dvr->get("enabled"); 3525 SrsConfDirective* conf = dvr->get("enabled");
3534 3526
3535 - if (!conf) { 3527 + if (!conf || conf->arg0().empty()) {
3536 return false; 3528 return false;
3537 } 3529 }
3538 3530
3539 - if (conf->arg0() == "on") {  
3540 - return true;  
3541 - }  
3542 -  
3543 - return false; 3531 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3544 } 3532 }
3545 3533
3546 string SrsConfig::get_dvr_path(string vhost) 3534 string SrsConfig::get_dvr_path(string vhost)
@@ -3604,11 +3592,11 @@ bool SrsConfig::get_dvr_wait_keyframe(string vhost) @@ -3604,11 +3592,11 @@ bool SrsConfig::get_dvr_wait_keyframe(string vhost)
3604 3592
3605 SrsConfDirective* conf = dvr->get("dvr_wait_keyframe"); 3593 SrsConfDirective* conf = dvr->get("dvr_wait_keyframe");
3606 3594
3607 - if (!conf || conf->arg0() != "off") { 3595 + if (!conf || conf->arg0().empty()) {
3608 return true; 3596 return true;
3609 } 3597 }
3610 3598
3611 - return false; 3599 + return SRS_CONF_PERFER_TRUE(conf->arg0());
3612 } 3600 }
3613 3601
3614 int SrsConfig::get_dvr_time_jitter(string vhost) 3602 int SrsConfig::get_dvr_time_jitter(string vhost)
@@ -3646,11 +3634,11 @@ bool SrsConfig::get_http_api_enabled(SrsConfDirective* conf) @@ -3646,11 +3634,11 @@ bool SrsConfig::get_http_api_enabled(SrsConfDirective* conf)
3646 } 3634 }
3647 3635
3648 conf = conf->get("enabled"); 3636 conf = conf->get("enabled");
3649 - if (conf && conf->arg0() == "on") {  
3650 - return true; 3637 + if (!conf || conf->arg0().empty()) {
  3638 + return false;
3651 } 3639 }
3652 3640
3653 - return false; 3641 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3654 } 3642 }
3655 3643
3656 string SrsConfig::get_http_api_listen() 3644 string SrsConfig::get_http_api_listen()
@@ -3681,8 +3669,8 @@ bool SrsConfig::get_http_api_crossdomain() @@ -3681,8 +3669,8 @@ bool SrsConfig::get_http_api_crossdomain()
3681 if (!conf || conf->arg0().empty()) { 3669 if (!conf || conf->arg0().empty()) {
3682 return SRS_CONF_DEFAULT_HTTP_API_CROSSDOMAIN; 3670 return SRS_CONF_DEFAULT_HTTP_API_CROSSDOMAIN;
3683 } 3671 }
3684 -  
3685 - return conf->arg0() != "off"; 3672 +
  3673 + return SRS_CONF_PERFER_TRUE(conf->arg0());
3686 } 3674 }
3687 3675
3688 bool SrsConfig::get_http_stream_enabled() 3676 bool SrsConfig::get_http_stream_enabled()
@@ -3709,11 +3697,11 @@ bool SrsConfig::get_http_stream_enabled(SrsConfDirective* conf) @@ -3709,11 +3697,11 @@ bool SrsConfig::get_http_stream_enabled(SrsConfDirective* conf)
3709 } 3697 }
3710 3698
3711 conf = conf->get("enabled"); 3699 conf = conf->get("enabled");
3712 - if (conf && conf->arg0() == "on") {  
3713 - return true; 3700 + if (!conf || conf->arg0().empty()) {
  3701 + return false;
3714 } 3702 }
3715 3703
3716 - return false; 3704 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3717 } 3705 }
3718 3706
3719 string SrsConfig::get_http_stream_listen() 3707 string SrsConfig::get_http_stream_listen()
@@ -3761,21 +3749,18 @@ bool SrsConfig::get_vhost_http_enabled(string vhost) @@ -3761,21 +3749,18 @@ bool SrsConfig::get_vhost_http_enabled(string vhost)
3761 SrsConfDirective* conf = vconf->get("http"); 3749 SrsConfDirective* conf = vconf->get("http");
3762 if (!conf) { 3750 if (!conf) {
3763 conf = vconf->get("http_static"); 3751 conf = vconf->get("http_static");
3764 - if (!conf) {  
3765 - return false;  
3766 - }  
3767 } 3752 }
3768 3753
3769 - conf = conf->get("enabled");  
3770 if (!conf) { 3754 if (!conf) {
3771 return false; 3755 return false;
3772 } 3756 }
3773 3757
3774 - if (conf->arg0() == "on") {  
3775 - return true; 3758 + conf = conf->get("enabled");
  3759 + if (!conf || conf->arg0().empty()) {
  3760 + return false;
3776 } 3761 }
3777 3762
3778 - return false; 3763 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3779 } 3764 }
3780 3765
3781 string SrsConfig::get_vhost_http_mount(string vhost) 3766 string SrsConfig::get_vhost_http_mount(string vhost)
@@ -3837,15 +3822,11 @@ bool SrsConfig::get_vhost_http_remux_enabled(string vhost) @@ -3837,15 +3822,11 @@ bool SrsConfig::get_vhost_http_remux_enabled(string vhost)
3837 } 3822 }
3838 3823
3839 conf = conf->get("enabled"); 3824 conf = conf->get("enabled");
3840 - if (!conf) { 3825 + if (!conf || conf->arg0().empty()) {
3841 return false; 3826 return false;
3842 } 3827 }
3843 3828
3844 - if (conf->arg0() == "on") {  
3845 - return true;  
3846 - }  
3847 -  
3848 - return false; 3829 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3849 } 3830 }
3850 3831
3851 double SrsConfig::get_vhost_http_remux_fast_cache(string vhost) 3832 double SrsConfig::get_vhost_http_remux_fast_cache(string vhost)
@@ -3905,15 +3886,11 @@ bool SrsConfig::get_vhost_http_remux_hstrs(string vhost) @@ -3905,15 +3886,11 @@ bool SrsConfig::get_vhost_http_remux_hstrs(string vhost)
3905 } 3886 }
3906 3887
3907 conf = conf->get("hstrs"); 3888 conf = conf->get("hstrs");
3908 - if (!conf) { 3889 + if (!conf || conf->arg0().empty()) {
3909 return false; 3890 return false;
3910 } 3891 }
3911 3892
3912 - if (conf->arg0() == "on") {  
3913 - return true;  
3914 - }  
3915 -  
3916 - return false; 3893 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3917 } 3894 }
3918 3895
3919 SrsConfDirective* SrsConfig::get_heartbeart() 3896 SrsConfDirective* SrsConfig::get_heartbeart()
@@ -3930,11 +3907,11 @@ bool SrsConfig::get_heartbeat_enabled() @@ -3930,11 +3907,11 @@ bool SrsConfig::get_heartbeat_enabled()
3930 } 3907 }
3931 3908
3932 conf = conf->get("enabled"); 3909 conf = conf->get("enabled");
3933 - if (!conf || conf->arg0() != "on") { 3910 + if (!conf || conf->arg0().empty()) {
3934 return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED; 3911 return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED;
3935 } 3912 }
3936 3913
3937 - return true; 3914 + return SRS_CONF_PERFER_FALSE(conf->arg0());
3938 } 3915 }
3939 3916
3940 int64_t SrsConfig::get_heartbeat_interval() 3917 int64_t SrsConfig::get_heartbeat_interval()
@@ -3993,11 +3970,11 @@ bool SrsConfig::get_heartbeat_summaries() @@ -3993,11 +3970,11 @@ bool SrsConfig::get_heartbeat_summaries()
3993 } 3970 }
3994 3971
3995 conf = conf->get("summaries"); 3972 conf = conf->get("summaries");
3996 - if (!conf || conf->arg0() != "on") { 3973 + if (!conf || conf->arg0().empty()) {
3997 return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES; 3974 return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES;
3998 } 3975 }
3999 3976
4000 - return true; 3977 + return SRS_CONF_PERFER_FALSE(conf->arg0());
4001 } 3978 }
4002 3979
4003 SrsConfDirective* SrsConfig::get_stats() 3980 SrsConfDirective* SrsConfig::get_stats()
@@ -49,7 +49,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -49,7 +49,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 #define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html" 49 #define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
50 #define SRS_CONF_DEFAULT_HLS_M3U8_FILE "[app]/[stream].m3u8" 50 #define SRS_CONF_DEFAULT_HLS_M3U8_FILE "[app]/[stream].m3u8"
51 #define SRS_CONF_DEFAULT_HLS_TS_FILE "[app]/[stream]-[seq].ts" 51 #define SRS_CONF_DEFAULT_HLS_TS_FILE "[app]/[stream]-[seq].ts"
52 -#define SRS_CONF_DEFAULT_HLS_TS_FLOOR "off" 52 +#define SRS_CONF_DEFAULT_HLS_TS_FLOOR false
53 #define SRS_CONF_DEFAULT_HLS_FRAGMENT 10 53 #define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
54 #define SRS_CONF_DEFAULT_HLS_TD_RATIO 1.5 54 #define SRS_CONF_DEFAULT_HLS_TD_RATIO 1.5
55 #define SRS_CONF_DEFAULT_HLS_AOF_RATIO 2.0 55 #define SRS_CONF_DEFAULT_HLS_AOF_RATIO 2.0
@@ -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 2 32 #define VERSION_MAJOR 2
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 157 34 +#define VERSION_REVISION 158
35 35
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"