diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-04-20 21:45:47 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-04-20 21:45:56 +0200 |
commit | 5a14fca9aacaf9ad4fd6b30792463949180e4300 (patch) | |
tree | ee77f225d164ef43b8c3fecbc021b03d6661b2c4 /libavformat/dashenc.c | |
parent | 1e2e22ec616b4a7adb1091d2466e8b5aeb04e7b3 (diff) | |
parent | 2cc3936599b6fc63143036659653d1be0624360f (diff) | |
download | ffmpeg-5a14fca9aacaf9ad4fd6b30792463949180e4300.tar.gz |
Merge commit '2cc3936599b6fc63143036659653d1be0624360f'
* commit '2cc3936599b6fc63143036659653d1be0624360f':
dashenc: Add a publishTime field in dynamic manifests
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/dashenc.c')
-rw-r--r-- | libavformat/dashenc.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index cc88676170..caa2a2153d 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -424,6 +424,17 @@ static void write_time(AVIOContext *out, int64_t time) avio_printf(out, "%d.%dS", seconds, fractions / (AV_TIME_BASE / 10)); } +static void format_date_now(char *buf, int size) +{ + time_t t = time(NULL); + struct tm *ptm, tmbuf; + ptm = gmtime_r(&t, &tmbuf); + if (ptm) { + if (!strftime(buf, size, "%Y-%m-%dT%H:%M:%S", ptm)) + buf[0] = '\0'; + } +} + static int write_manifest(AVFormatContext *s, int final) { DASHContext *c = s->priv_data; @@ -451,22 +462,19 @@ static int write_manifest(AVFormatContext *s, int final) avio_printf(out, "\"\n"); } else { int64_t update_period = c->last_duration / AV_TIME_BASE; + char now_str[100]; if (c->use_template && !c->use_timeline) update_period = 500; avio_printf(out, "\tminimumUpdatePeriod=\"PT%"PRId64"S\"\n", update_period); avio_printf(out, "\tsuggestedPresentationDelay=\"PT%"PRId64"S\"\n", c->last_duration / AV_TIME_BASE); if (!c->availability_start_time[0] && s->nb_streams > 0 && c->streams[0].nb_segments > 0) { - time_t t = time(NULL); - struct tm *ptm, tmbuf; - ptm = gmtime_r(&t, &tmbuf); - if (ptm) { - if (!strftime(c->availability_start_time, sizeof(c->availability_start_time), - "%Y-%m-%dT%H:%M:%S", ptm)) - c->availability_start_time[0] = '\0'; - } + format_date_now(c->availability_start_time, sizeof(c->availability_start_time)); } if (c->availability_start_time[0]) avio_printf(out, "\tavailabilityStartTime=\"%s\"\n", c->availability_start_time); + format_date_now(now_str, sizeof(now_str)); + if (now_str[0]) + avio_printf(out, "\tpublishTime=\"%s\"\n", now_str); if (c->window_size && c->use_template) { avio_printf(out, "\ttimeShiftBufferDepth=\""); write_time(out, c->last_duration * c->window_size); |