Skip to content

use stream start_time as the availabilityStartTime in DASH manifests #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions dash/ngx_rtmp_dash_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down Expand Up @@ -336,14 +335,16 @@ ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s)
" </Period>\n" \
"</MPD>\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,
Expand Down Expand Up @@ -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;
}
Expand Down