From 68faa774ed1e19035a205da57842903ac094b1c8 Mon Sep 17 00:00:00 2001 From: RocFang Date: Mon, 26 Feb 2018 05:39:04 +0800 Subject: [PATCH] use hls->initialize to set req of hls --- trunk/src/app/srs_app_hls.cpp | 8 ++++---- trunk/src/app/srs_app_hls.hpp | 2 +- trunk/src/app/srs_app_source.cpp | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 78fc5c2ba3..384cb7a9e8 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -1205,10 +1205,13 @@ int SrsHls::cycle() return ret; } -int SrsHls::initialize(SrsSource* s) +int SrsHls::initialize(SrsSource* s, SrsRequest* r) { int ret = ERROR_SUCCESS; + srs_assert(!_req); + _req = r->copy(); + source = s; if ((ret = muxer->initialize()) != ERROR_SUCCESS) { @@ -1222,9 +1225,6 @@ int SrsHls::on_publish(SrsRequest* req, bool fetch_sequence_header) { int ret = ERROR_SUCCESS; - srs_freep(_req); - _req = req->copy(); - // update the hls time, for hls_dispose. last_update_time = srs_get_system_time_ms(); diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp index 97790c81c9..960a295bb7 100644 --- a/trunk/src/app/srs_app_hls.hpp +++ b/trunk/src/app/srs_app_hls.hpp @@ -391,7 +391,7 @@ class SrsHls /** * initialize the hls by handler and source. */ - virtual int initialize(SrsSource* s); + virtual int initialize(SrsSource* s, SrsRequest* r); /** * publish stream event, continue to write the m3u8, * for the muxer object not destroyed. diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 8b26dd72d3..6fdca502fd 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1080,7 +1080,7 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h) atc = _srs_config->get_atc(_req->vhost); #ifdef SRS_AUTO_HLS - if ((ret = hls->initialize(this)) != ERROR_SUCCESS) { + if ((ret = hls->initialize(this, _req)) != ERROR_SUCCESS) { return ret; } #endif @@ -2175,7 +2175,6 @@ int SrsSource::on_publish() } #endif - // TODO: FIXME: use initialize to set req. #ifdef SRS_AUTO_HLS if ((ret = hls->on_publish(_req, false)) != ERROR_SUCCESS) { srs_error("start hls failed. ret=%d", ret);