mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
for #474, refine the hls publish, donot fetch from source when publish
This commit is contained in:
parent
44bcb4045f
commit
83a9ff9f5d
3 changed files with 18 additions and 13 deletions
|
@ -1252,7 +1252,7 @@ int SrsHls::initialize(SrsSource* s, ISrsHlsHandler* h)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsHls::on_publish(SrsRequest* req)
|
int SrsHls::on_publish(SrsRequest* req, bool fetch_sequence_header)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
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.
|
// ok, the hls can be dispose, or need to be dispose.
|
||||||
hls_can_dispose = true;
|
hls_can_dispose = true;
|
||||||
|
|
||||||
// notice the source to get the cached sequence header.
|
// when publish, don't need to fetch sequence header, which is old and maybe corrupt.
|
||||||
// when reload to start hls, hls will never get the sequence header in stream,
|
// when reload, we must fetch the sequence header from source cache.
|
||||||
// use the SrsSource.on_hls_start to push the sequence header to HLS.
|
if (fetch_sequence_header) {
|
||||||
if ((ret = source->on_hls_start()) != ERROR_SUCCESS) {
|
// notice the source to get the cached sequence header.
|
||||||
srs_error("callback source hls start failed. ret=%d", ret);
|
// when reload to start hls, hls will never get the sequence header in stream,
|
||||||
return ret;
|
// 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;
|
return ret;
|
||||||
|
|
|
@ -424,10 +424,11 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual int initialize(SrsSource* s, ISrsHlsHandler* h);
|
virtual int initialize(SrsSource* s, ISrsHlsHandler* h);
|
||||||
/**
|
/**
|
||||||
* publish stream event, continue to write the m3u8,
|
* publish stream event, continue to write the m3u8,
|
||||||
* for the muxer object not destroyed.
|
* for the muxer object not destroyed.
|
||||||
*/
|
* @param fetch_sequence_header whether fetch sequence from source.
|
||||||
virtual int on_publish(SrsRequest* req);
|
*/
|
||||||
|
virtual int on_publish(SrsRequest* req, bool fetch_sequence_header);
|
||||||
/**
|
/**
|
||||||
* the unpublish event, only close the muxer, donot destroy the
|
* the unpublish event, only close the muxer, donot destroy the
|
||||||
* muxer, for when we continue to publish, the m3u8 will continue.
|
* 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
|
#ifdef SRS_AUTO_HLS
|
||||||
hls->on_unpublish();
|
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);
|
srs_error("hls publish failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2039,7 +2039,7 @@ int SrsSource::on_publish()
|
||||||
|
|
||||||
// TODO: FIXME: use initialize to set req.
|
// TODO: FIXME: use initialize to set req.
|
||||||
#ifdef SRS_AUTO_HLS
|
#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);
|
srs_error("start hls failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue