From dcf37b2c39aa04af609fe58d84f4fc5754d469b7 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Thu, 20 Feb 2014 22:57:22 +0400 Subject: [PATCH] fixed forcing HLS fragment split --- hls/ngx_rtmp_hls_module.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hls/ngx_rtmp_hls_module.c b/hls/ngx_rtmp_hls_module.c index 143e2af..aa04bdb 100644 --- a/hls/ngx_rtmp_hls_module.c +++ b/hls/ngx_rtmp_hls_module.c @@ -1363,13 +1363,14 @@ ngx_rtmp_hls_update_fragment(ngx_rtmp_session_t *s, uint64_t ts, ngx_rtmp_hls_app_conf_t *hacf; ngx_rtmp_hls_frag_t *f; ngx_msec_t ts_frag_len; - ngx_int_t same_frag; + ngx_int_t same_frag, force; ngx_buf_t *b; int64_t d; hacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_hls_module); ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_hls_module); f = NULL; + force = 0; if (ctx->opened) { f = ngx_rtmp_hls_get_frag(s, ctx->nfrags); @@ -1377,9 +1378,8 @@ ngx_rtmp_hls_update_fragment(ngx_rtmp_session_t *s, uint64_t ts, if (d > (int64_t) hacf->max_fraglen * 90 || d < -90000) { ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, - "hls: max fragment length reached: %.3f sec, ", - f->duration); - boundary = 1; + "hls: force fragment split: %.3f sec, ", d / 90000.); + force = 1; } else { f->duration = (ts - ctx->frag_ts) / 90000.; @@ -1410,7 +1410,7 @@ ngx_rtmp_hls_update_fragment(ngx_rtmp_session_t *s, uint64_t ts, break; } - if (boundary) { + if (boundary || force) { ngx_rtmp_hls_close_fragment(s); ngx_rtmp_hls_open_fragment(s, ts, !f); }