Skip to content

Commit fd016ed

Browse files
RocFangwinlinvip
authored andcommitted
use hls->initialize to set req of hls (#1077)
1 parent 1721e4e commit fd016ed

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

trunk/src/app/srs_app_hls.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1205,10 +1205,13 @@ int SrsHls::cycle()
12051205
return ret;
12061206
}
12071207

1208-
int SrsHls::initialize(SrsSource* s)
1208+
int SrsHls::initialize(SrsSource* s, SrsRequest* r)
12091209
{
12101210
int ret = ERROR_SUCCESS;
12111211

1212+
srs_assert(!_req);
1213+
_req = r->copy();
1214+
12121215
source = s;
12131216

12141217
if ((ret = muxer->initialize()) != ERROR_SUCCESS) {
@@ -1222,9 +1225,6 @@ int SrsHls::on_publish(SrsRequest* req, bool fetch_sequence_header)
12221225
{
12231226
int ret = ERROR_SUCCESS;
12241227

1225-
srs_freep(_req);
1226-
_req = req->copy();
1227-
12281228
// update the hls time, for hls_dispose.
12291229
last_update_time = srs_get_system_time_ms();
12301230

trunk/src/app/srs_app_hls.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class SrsHls
391391
/**
392392
* initialize the hls by handler and source.
393393
*/
394-
virtual int initialize(SrsSource* s);
394+
virtual int initialize(SrsSource* s, SrsRequest* r);
395395
/**
396396
* publish stream event, continue to write the m3u8,
397397
* for the muxer object not destroyed.

trunk/src/app/srs_app_source.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h)
10801080
atc = _srs_config->get_atc(_req->vhost);
10811081

10821082
#ifdef SRS_AUTO_HLS
1083-
if ((ret = hls->initialize(this)) != ERROR_SUCCESS) {
1083+
if ((ret = hls->initialize(this, _req)) != ERROR_SUCCESS) {
10841084
return ret;
10851085
}
10861086
#endif
@@ -2175,7 +2175,6 @@ int SrsSource::on_publish()
21752175
}
21762176
#endif
21772177

2178-
// TODO: FIXME: use initialize to set req.
21792178
#ifdef SRS_AUTO_HLS
21802179
if ((ret = hls->on_publish(_req, false)) != ERROR_SUCCESS) {
21812180
srs_error("start hls failed. ret=%d", ret);

0 commit comments

Comments
 (0)