fixed forcing HLS fragment split

This commit is contained in:
Roman Arutyunyan 2014-02-20 22:57:22 +04:00
parent 87bc473cde
commit dcf37b2c39

View file

@ -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_app_conf_t *hacf;
ngx_rtmp_hls_frag_t *f; ngx_rtmp_hls_frag_t *f;
ngx_msec_t ts_frag_len; ngx_msec_t ts_frag_len;
ngx_int_t same_frag; ngx_int_t same_frag, force;
ngx_buf_t *b; ngx_buf_t *b;
int64_t d; int64_t d;
hacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_hls_module); hacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_hls_module);
ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_hls_module); ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_hls_module);
f = NULL; f = NULL;
force = 0;
if (ctx->opened) { if (ctx->opened) {
f = ngx_rtmp_hls_get_frag(s, ctx->nfrags); 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) { if (d > (int64_t) hacf->max_fraglen * 90 || d < -90000) {
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
"hls: max fragment length reached: %.3f sec, ", "hls: force fragment split: %.3f sec, ", d / 90000.);
f->duration); force = 1;
boundary = 1;
} else { } else {
f->duration = (ts - ctx->frag_ts) / 90000.; 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; break;
} }
if (boundary) { if (boundary || force) {
ngx_rtmp_hls_close_fragment(s); ngx_rtmp_hls_close_fragment(s);
ngx_rtmp_hls_open_fragment(s, ts, !f); ngx_rtmp_hls_open_fragment(s, ts, !f);
} }