winlin

fix bug of get hls enabled config

@@ -23,14 +23,14 @@ vhost __defaultVhost__ { @@ -23,14 +23,14 @@ vhost __defaultVhost__ {
23 gop_cache on; 23 gop_cache on;
24 forward 127.0.0.1:19350; 24 forward 127.0.0.1:19350;
25 hls { 25 hls {
26 - hls on; 26 + enabled on;
27 hls_path ./objs/nginx/html; 27 hls_path ./objs/nginx/html;
28 hls_fragment 5; 28 hls_fragment 5;
29 hls_window 30; 29 hls_window 30;
30 } 30 }
31 transcode { 31 transcode {
32 - enabled on;  
33 - ffmpeg ./objs/ffmpeg/bin/ffmpeg; 32 + enabled on;
  33 + ffmpeg ./objs/ffmpeg/bin/ffmpeg;
34 engine ld { 34 engine ld {
35 enabled on; 35 enabled on;
36 vfilter { 36 vfilter {
@@ -85,7 +85,7 @@ vhost dev { @@ -85,7 +85,7 @@ vhost dev {
85 gop_cache on; 85 gop_cache on;
86 #forward 127.0.0.1:19350; 86 #forward 127.0.0.1:19350;
87 hls { 87 hls {
88 - hls off; 88 + enabled on;
89 hls_path ./objs/nginx/html; 89 hls_path ./objs/nginx/html;
90 hls_fragment 5; 90 hls_fragment 5;
91 hls_window 30; 91 hls_window 30;
@@ -635,7 +635,7 @@ vhost with-hls.vhost.com { @@ -635,7 +635,7 @@ vhost with-hls.vhost.com {
635 # whether the hls is enabled. 635 # whether the hls is enabled.
636 # if off, donot write hls(ts and m3u8) when publish. 636 # if off, donot write hls(ts and m3u8) when publish.
637 # default: off 637 # default: off
638 - hls on; 638 + enabled on;
639 # the hls output path. 639 # the hls output path.
640 # the app dir is auto created under the hls_path. 640 # the app dir is auto created under the hls_path.
641 # for example, for rtmp stream: 641 # for example, for rtmp stream:
@@ -662,7 +662,7 @@ vhost no-hls.vhost.com { @@ -662,7 +662,7 @@ vhost no-hls.vhost.com {
662 # whether the hls is enabled. 662 # whether the hls is enabled.
663 # if off, donot write hls(ts and m3u8) when publish. 663 # if off, donot write hls(ts and m3u8) when publish.
664 # default: off 664 # default: off
665 - hls off; 665 + enabled off;
666 } 666 }
667 } 667 }
668 # the vhost for min delay, donot cache any stream. 668 # the vhost for min delay, donot cache any stream.
@@ -1312,11 +1312,17 @@ bool SrsConfig::get_hls_enabled(string vhost) @@ -1312,11 +1312,17 @@ bool SrsConfig::get_hls_enabled(string vhost)
1312 return false; 1312 return false;
1313 } 1313 }
1314 1314
1315 - if (hls->arg0() == "off") { 1315 + SrsConfDirective* conf = hls->get("enabled");
  1316 +
  1317 + if (!conf) {
1316 return false; 1318 return false;
1317 } 1319 }
1318 1320
1319 - return true; 1321 + if (conf->arg0() == "on") {
  1322 + return true;
  1323 + }
  1324 +
  1325 + return false;
1320 } 1326 }
1321 1327
1322 string SrsConfig::get_hls_path(string vhost) 1328 string SrsConfig::get_hls_path(string vhost)
@@ -1148,7 +1148,6 @@ int SrsHls::on_publish(SrsRequest* req) @@ -1148,7 +1148,6 @@ int SrsHls::on_publish(SrsRequest* req)
1148 std::string stream = req->stream; 1148 std::string stream = req->stream;
1149 std::string app = req->app; 1149 std::string app = req->app;
1150 1150
1151 - // TODO: support reload.  
1152 if (!config->get_hls_enabled(vhost)) { 1151 if (!config->get_hls_enabled(vhost)) {
1153 return ret; 1152 return ret;
1154 } 1153 }
@@ -1156,7 +1155,6 @@ int SrsHls::on_publish(SrsRequest* req) @@ -1156,7 +1155,6 @@ int SrsHls::on_publish(SrsRequest* req)
1156 // if enabled, open the muxer. 1155 // if enabled, open the muxer.
1157 hls_enabled = true; 1156 hls_enabled = true;
1158 1157
1159 - // TODO: subscribe the reload event.  
1160 int hls_fragment = config->get_hls_fragment(vhost); 1158 int hls_fragment = config->get_hls_fragment(vhost);
1161 int hls_window = config->get_hls_window(vhost); 1159 int hls_window = config->get_hls_window(vhost);
1162 1160