1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

for #513, remove hls ram from srs2 to srs3+. 2.0.224

This commit is contained in:
winlin 2016-12-15 14:48:38 +08:00
parent 34e5cdcd12
commit 759c84a395
17 changed files with 26 additions and 556 deletions

View file

@ -61,14 +61,6 @@ using namespace std;
// reset the piece id when deviation overflow this.
#define SRS_JUMP_WHEN_PIECE_DEVIATION 20
ISrsHlsHandler::ISrsHlsHandler()
{
}
ISrsHlsHandler::~ISrsHlsHandler()
{
}
/**
* * the HLS section, only available when HLS enabled.
* */
@ -294,7 +286,6 @@ string SrsDvrAsyncCallOnHlsNotify::to_string()
SrsHlsMuxer::SrsHlsMuxer()
{
req = NULL;
handler = NULL;
hls_fragment = hls_window = 0;
hls_aof_ratio = 1.0;
deviation_ts = 0;
@ -384,12 +375,10 @@ int SrsHlsMuxer::deviation()
return deviation_ts;
}
int SrsHlsMuxer::initialize(ISrsHlsHandler* h)
int SrsHlsMuxer::initialize()
{
int ret = ERROR_SUCCESS;
handler = h;
if ((ret = async->start()) != ERROR_SUCCESS) {
return ret;
}
@ -425,19 +414,10 @@ int SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix,
// when update config, reset the history target duration.
max_td = (int)(fragment * _srs_config->get_hls_td_ratio(r->vhost));
std::string storage = _srs_config->get_hls_storage(r->vhost);
if (storage == "ram") {
should_write_cache = true;
should_write_file = false;
} else if (storage == "disk") {
should_write_cache = false;
should_write_file = true;
} else {
srs_assert(storage == "both");
should_write_cache = true;
should_write_file = true;
}
// TODO: FIXME: refine better for SRS2 only support disk.
should_write_cache = false;
should_write_file = true;
// create m3u8 dir once.
m3u8_dir = srs_path_dirname(m3u8);
@ -755,13 +735,6 @@ int SrsHlsMuxer::segment_close(string log_desc)
srs_info("%s reap ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"PRId64,
log_desc.c_str(), current->sequence_no, current->uri.c_str(), current->duration,
current->segment_start_dts);
// notify handler for update ts.
srs_assert(current->writer);
if (handler && (ret = handler->on_update_ts(req, current->uri, current->writer->cache())) != ERROR_SUCCESS) {
srs_error("notify handler for update ts failed. ret=%d", ret);
return ret;
}
// close the muxer of finished segment.
srs_freep(current->muxer);
@ -829,13 +802,6 @@ int SrsHlsMuxer::segment_close(string log_desc)
}
}
if (should_write_cache) {
if ((ret = handler->on_remove_ts(req, segment->uri)) != ERROR_SUCCESS) {
srs_warn("remove the ts from ram hls failed. ret=%d", ret);
return ret;
}
}
srs_freep(segment);
}
segment_to_remove.clear();
@ -957,12 +923,6 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
return ret;
}
srs_info("write m3u8 %s success.", m3u8_file.c_str());
// notify handler for update m3u8.
if (handler && (ret = handler->on_update_m3u8(req, writer.cache())) != ERROR_SUCCESS) {
srs_error("notify handler for update m3u8 failed. ret=%d", ret);
return ret;
}
return ret;
}
@ -1171,7 +1131,6 @@ SrsHls::SrsHls()
{
_req = NULL;
source = NULL;
handler = NULL;
hls_enabled = false;
hls_can_dispose = false;
@ -1244,14 +1203,13 @@ int SrsHls::cycle()
return ret;
}
int SrsHls::initialize(SrsSource* s, ISrsHlsHandler* h)
int SrsHls::initialize(SrsSource* s)
{
int ret = ERROR_SUCCESS;
source = s;
handler = h;
if ((ret = muxer->initialize(h)) != ERROR_SUCCESS) {
if ((ret = muxer->initialize()) != ERROR_SUCCESS) {
return ret;
}