From 98f700a090ebab5c7dbe5b1f713c78082945d97e Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 21 Apr 2016 10:56:44 +0200 Subject: [PATCH] dash: Ensure directory exists before opening fragments Streams that take a long time from initial Publish to actually sending data might get their directories reaped. Testcase: Xsplit Encoder with stream delay set to a value larger than the playlist length. --- dash/ngx_rtmp_dash_module.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dash/ngx_rtmp_dash_module.c b/dash/ngx_rtmp_dash_module.c index 1dd27ce..fbe5055 100644 --- a/dash/ngx_rtmp_dash_module.c +++ b/dash/ngx_rtmp_dash_module.c @@ -20,6 +20,7 @@ static void * ngx_rtmp_dash_create_app_conf(ngx_conf_t *cf); static char * ngx_rtmp_dash_merge_app_conf(ngx_conf_t *cf, void *parent, void *child); static ngx_int_t ngx_rtmp_dash_write_init_segments(ngx_rtmp_session_t *s); +static ngx_int_t ngx_rtmp_dash_ensure_directory(ngx_rtmp_session_t *s); #define NGX_RTMP_DASH_BUFSIZE (1024*1024) @@ -773,6 +774,10 @@ ngx_rtmp_dash_open_fragments(ngx_rtmp_session_t *s) return NGX_OK; } + if (ngx_rtmp_dash_ensure_directory(s) != NGX_OK) { + return NGX_ERROR; + } + ngx_rtmp_dash_open_fragment(s, &ctx->video, ctx->id, 'v'); ngx_rtmp_dash_open_fragment(s, &ctx->audio, ctx->id, 'a');