improved hls boundary check

This commit is contained in:
Roman Arutyunyan 2014-01-02 10:19:57 +04:00
parent 095c659ad8
commit fe0d805179

View file

@ -501,7 +501,7 @@ ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
"%s"
"#EXTINF:%.3f,\n"
"%V%V%s%uL.ts\n",
f->discont ? "#EXT-X-DISCONTINUITY\n" : "",
/*f->discont ? "#EXT-X-DISCONTINUITY\n" :*/ "",
f->duration, &hacf->base_url, &name_part, sep, f->id);
ngx_log_debug5(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
@ -1348,22 +1348,24 @@ ngx_rtmp_hls_update_fragment(ngx_rtmp_session_t *s, uint64_t ts,
ngx_msec_t ts_frag_len;
ngx_int_t same_frag;
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;
if (ctx->opened) {
f = ngx_rtmp_hls_get_frag(s, ctx->nfrags);
f->duration = (ts - ctx->frag_ts) / 90000.;
d = (int64_t) (ts - ctx->frag_ts);
if (f->duration * 1000 > hacf->max_fraglen) {
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");
"hls: max fragment length reached: %.3f sec, ",
f->duration);
boundary = 1;
} else {
f->duration = (ts - ctx->frag_ts) / 90000.;
}
}