for #474, refine the hls publish, donot fetch from source when publish

pull/483/head
winlin 10 years ago
parent 44bcb4045f
commit 83a9ff9f5d

@ -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;

@ -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.

@ -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;
}

Loading…
Cancel
Save