diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index d8437bae3..fe73551ee 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -1252,7 +1252,7 @@ int SrsHls::initialize(SrsSource* s, ISrsHlsHandler* h) return ret; } -int SrsHls::on_publish(SrsRequest* req) +int SrsHls::on_publish(SrsRequest* req, bool fetch_sequence_header) { int ret = ERROR_SUCCESS; @@ -1282,12 +1282,16 @@ int SrsHls::on_publish(SrsRequest* req) // ok, the hls can be dispose, or need to be dispose. hls_can_dispose = true; - // notice the source to get the cached sequence header. - // when reload to start hls, hls will never get the sequence header in stream, - // use the SrsSource.on_hls_start to push the sequence header to HLS. - if ((ret = source->on_hls_start()) != ERROR_SUCCESS) { - srs_error("callback source hls start failed. ret=%d", ret); - return ret; + // when publish, don't need to fetch sequence header, which is old and maybe corrupt. + // when reload, we must fetch the sequence header from source cache. + if (fetch_sequence_header) { + // notice the source to get the cached sequence header. + // when reload to start hls, hls will never get the sequence header in stream, + // use the SrsSource.on_hls_start to push the sequence header to HLS. + if ((ret = source->on_hls_start()) != ERROR_SUCCESS) { + srs_error("callback source hls start failed. ret=%d", ret); + return ret; + } } return ret; diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp index dd9f8953c..0ffdf5b74 100644 --- a/trunk/src/app/srs_app_hls.hpp +++ b/trunk/src/app/srs_app_hls.hpp @@ -424,10 +424,11 @@ public: */ virtual int initialize(SrsSource* s, ISrsHlsHandler* h); /** - * publish stream event, continue to write the m3u8, - * for the muxer object not destroyed. - */ - virtual int on_publish(SrsRequest* req); + * publish stream event, continue to write the m3u8, + * for the muxer object not destroyed. + * @param fetch_sequence_header whether fetch sequence from source. + */ + virtual int on_publish(SrsRequest* req, bool fetch_sequence_header); /** * the unpublish event, only close the muxer, donot destroy the * muxer, for when we continue to publish, the m3u8 will continue. diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 409f55fd5..fa3596034 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1180,7 +1180,7 @@ int SrsSource::on_reload_vhost_hls(string vhost) #ifdef SRS_AUTO_HLS hls->on_unpublish(); - if ((ret = hls->on_publish(_req)) != ERROR_SUCCESS) { + if ((ret = hls->on_publish(_req, true)) != ERROR_SUCCESS) { srs_error("hls publish failed. ret=%d", ret); return ret; } @@ -2039,7 +2039,7 @@ int SrsSource::on_publish() // TODO: FIXME: use initialize to set req. #ifdef SRS_AUTO_HLS - if ((ret = hls->on_publish(_req)) != ERROR_SUCCESS) { + if ((ret = hls->on_publish(_req, false)) != ERROR_SUCCESS) { srs_error("start hls failed. ret=%d", ret); return ret; }