From 3adfa42ad5ea5dcef1fe9b72cda960104b1998b8 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Sat, 9 May 2020 15:16:34 +1000 Subject: [PATCH] use the stream start_time as the availabilityStartTime in the dash manifest. this is in line with what the mpeg dash spec says the value should be. this makes dash.js v3 happier without upsetting v2. --- dash/ngx_rtmp_dash_module.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dash/ngx_rtmp_dash_module.c b/dash/ngx_rtmp_dash_module.c index 81bc34351..9eb0f97c1 100644 --- a/dash/ngx_rtmp_dash_module.c +++ b/dash/ngx_rtmp_dash_module.c @@ -52,7 +52,6 @@ typedef struct { ngx_str_t playlist_bak; ngx_str_t name; ngx_str_t stream; - time_t start_time; ngx_uint_t nfrags; ngx_uint_t frag; @@ -211,7 +210,6 @@ ngx_rtmp_dash_rename_file(u_char *src, u_char *dst) #endif } - static ngx_int_t ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s) { @@ -226,10 +224,11 @@ ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s) ngx_rtmp_codec_ctx_t *codec_ctx; ngx_rtmp_dash_frag_t *f; ngx_rtmp_dash_app_conf_t *dacf; + time_t now; static u_char buffer[NGX_RTMP_DASH_BUFSIZE]; - static u_char start_time[sizeof("1970-09-28T12:00:00Z")]; - static u_char pub_time[sizeof("1970-09-28T12:00:00Z")]; + u_char start_time[sizeof("1970-09-28T12:00:00Z")]; + u_char pub_time[sizeof("1970-09-28T12:00:00Z")]; dacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_dash_module); ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_dash_module); @@ -336,14 +335,16 @@ ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s) " \n" \ "\n" - ngx_libc_gmtime(ctx->start_time, &tm); + now = ngx_time(); + + ngx_libc_gmtime(now - (s->current_time / 1000), &tm); ngx_sprintf(start_time, "%4d-%02d-%02dT%02d:%02d:%02dZ%Z", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - ngx_libc_gmtime(ngx_time(), &tm); + ngx_libc_gmtime(now, &tm); ngx_sprintf(pub_time, "%4d-%02d-%02dT%02d:%02d:%02dZ%Z", tm.tm_year + 1900, tm.tm_mon + 1, @@ -942,8 +943,6 @@ ngx_rtmp_dash_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v) "dash: playlist='%V' playlist_bak='%V' stream_pattern='%V'", &ctx->playlist, &ctx->playlist_bak, &ctx->stream); - ctx->start_time = ngx_time(); - if (ngx_rtmp_dash_ensure_directory(s) != NGX_OK) { return NGX_ERROR; }