Skip to content

Commit fe0d805

Browse files
committed
improved hls boundary check
1 parent 095c659 commit fe0d805

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

hls/ngx_rtmp_hls_module.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
501501
"%s"
502502
"#EXTINF:%.3f,\n"
503503
"%V%V%s%uL.ts\n",
504-
f->discont ? "#EXT-X-DISCONTINUITY\n" : "",
504+
/*f->discont ? "#EXT-X-DISCONTINUITY\n" :*/ "",
505505
f->duration, &hacf->base_url, &name_part, sep, f->id);
506506

507507
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,
13481348
ngx_msec_t ts_frag_len;
13491349
ngx_int_t same_frag;
13501350
ngx_buf_t *b;
1351+
int64_t d;
13511352

13521353
hacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_hls_module);
1353-
13541354
ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_hls_module);
1355-
13561355
f = NULL;
13571356

13581357
if (ctx->opened) {
1359-
13601358
f = ngx_rtmp_hls_get_frag(s, ctx->nfrags);
1361-
f->duration = (ts - ctx->frag_ts) / 90000.;
1359+
d = (int64_t) (ts - ctx->frag_ts);
13621360

1363-
if (f->duration * 1000 > hacf->max_fraglen) {
1361+
if (d > (int64_t) hacf->max_fraglen * 90 || d < -90000) {
13641362
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
1365-
"hls: max fragment length reached");
1363+
"hls: max fragment length reached: %.3f sec, ",
1364+
f->duration);
13661365
boundary = 1;
1366+
1367+
} else {
1368+
f->duration = (ts - ctx->frag_ts) / 90000.;
13671369
}
13681370
}
13691371

0 commit comments

Comments
 (0)