diff --git a/dash/ngx_rtmp_dash_module.c b/dash/ngx_rtmp_dash_module.c index a6b4c9e..1dd27ce 100644 --- a/dash/ngx_rtmp_dash_module.c +++ b/dash/ngx_rtmp_dash_module.c @@ -1049,6 +1049,10 @@ ngx_rtmp_dash_update_fragments(ngx_rtmp_session_t *s, ngx_int_t boundary, ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_dash_module); f = ngx_rtmp_dash_get_frag(s, ctx->nfrags); + ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "dash: update_fragments: timestamp=%ui, f-timestamp=%ui, boundary=%i, dacf-fraglen=%ui", + timestamp, f->timestamp, boundary, dacf->fraglen); + d = (int32_t) (timestamp - f->timestamp); if (d >= 0) { @@ -1063,26 +1067,44 @@ ngx_rtmp_dash_update_fragments(ngx_rtmp_session_t *s, ngx_int_t boundary, hit = (-d > 1000); } + ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "dash: update_fragments: d=%i, f-duration=%ui, hit=%i", + d, f->duration, hit); + if (ctx->has_video && !hit) { boundary = 0; + ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "dash: update_fragments: boundary=0 cos has_video && !hit"); } if (!ctx->has_video && ctx->has_audio) { boundary = hit; + ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "dash: update_fragments: boundary=hit cos !has_video && has_audio"); } if (ctx->audio.mdat_size >= NGX_RTMP_DASH_MAX_MDAT) { boundary = 1; + ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "dash: update_fragments: boundary=1 cos audio max mdat"); } if (ctx->video.mdat_size >= NGX_RTMP_DASH_MAX_MDAT) { boundary = 1; + ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "dash: update_fragments: boundary=1 cos video max mdat"); } if (!ctx->opened) { boundary = 1; + ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "dash: update_fragments: boundary=1 cos !opened"); } + ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "dash: update_fragments: boundary=%i", + boundary); + if (boundary) { ngx_rtmp_dash_close_fragments(s); ngx_rtmp_dash_open_fragments(s); @@ -1432,7 +1454,7 @@ ngx_rtmp_dash_cleanup_dir(ngx_str_t *ppath, ngx_msec_t playlen) name.data[name.len - 2] == 'a' && name.data[name.len - 1] == 'w') { - max_age = playlen / 1000; + max_age = playlen / 500; } else { ngx_log_debug1(NGX_LOG_DEBUG_RTMP, ngx_cycle->log, 0, @@ -1468,7 +1490,8 @@ ngx_rtmp_dash_cleanup(void *data) ngx_rtmp_dash_cleanup_dir(&cleanup->path, cleanup->playlen); - return cleanup->playlen / 500; + // Next callback in half of playlist length time + return cleanup->playlen / 2000; } static ngx_int_t diff --git a/hls/ngx_rtmp_hls_module.c b/hls/ngx_rtmp_hls_module.c index a91ec62..bc51a15 100644 --- a/hls/ngx_rtmp_hls_module.c +++ b/hls/ngx_rtmp_hls_module.c @@ -2305,7 +2305,7 @@ ngx_rtmp_hls_cleanup_dir(ngx_str_t *ppath, ngx_msec_t playlen) name.data[name.len - 2] == 'u' && name.data[name.len - 1] == '8') { - max_age = playlen / 1000; + max_age = playlen / 500; } else if (name.len >= 4 && name.data[name.len - 4] == '.' && name.data[name.len - 3] == 'k' && @@ -2348,7 +2348,8 @@ ngx_rtmp_hls_cleanup(void *data) ngx_rtmp_hls_cleanup_dir(&cleanup->path, cleanup->playlen); - return cleanup->playlen / 500; + // Next callback in half of playlist length time + return cleanup->playlen / 2000; } @@ -2454,7 +2455,7 @@ ngx_rtmp_hls_merge_app_conf(ngx_conf_t *cf, void *parent, void *child) ngx_conf_merge_value(conf->hls, prev->hls, 0); ngx_conf_merge_msec_value(conf->fraglen, prev->fraglen, 5000); ngx_conf_merge_msec_value(conf->max_fraglen, prev->max_fraglen, - conf->fraglen * 10); + conf->fraglen * 2); ngx_conf_merge_msec_value(conf->muxdelay, prev->muxdelay, 700); ngx_conf_merge_msec_value(conf->sync, prev->sync, 2); ngx_conf_merge_msec_value(conf->playlen, prev->playlen, 30000);