Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-09-15 02:01:51 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2016-09-15 03:31:42 +0300
commit6f062eb8d0e17398f225c537d5fd78f5ae880906 (patch)
tree0758960a6ee0c3fff29c8374ecd361fb129a5f13 /libavformat
parent76c28360b5612fac068b25107e43e4bc5c4652de (diff)
avformat/hlsenc: Emulate strftime("%z") using other functions if it does not work
This should fix the code on windows Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/hlsenc.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 46b439d796..0ca59329b6 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -537,7 +537,7 @@ static int hls_window(AVFormatContext *s, int last)
avio_printf(out, "#EXT-X-BYTERANGE:%"PRIi64"@%"PRIi64"\n",
en->size, en->pos);
if (hls->flags & HLS_PROGRAM_DATE_TIME) {
- time_t tt;
+ time_t tt, wrongsecs;
int milli;
struct tm *tm, tmpbuf;
char buf0[128], buf1[128];
@@ -545,8 +545,18 @@ static int hls_window(AVFormatContext *s, int last)
milli = av_clip(lrint(1000*(prog_date_time - tt)), 0, 999);
tm = localtime_r(&tt, &tmpbuf);
strftime(buf0, sizeof(buf0), "%Y-%m-%dT%H:%M:%S", tm);
- if (!strftime(buf1, sizeof(buf1), "%z", tm))
- av_strlcpy(buf1, "Z", sizeof(buf1));
+ if (!strftime(buf1, sizeof(buf1), "%z", tm) || buf1[1]<'0' ||buf1[1]>'2') {
+ int tz_min, dst = tm->tm_isdst;
+ tm = gmtime_r(&tt, &tmpbuf);
+ tm->tm_isdst = dst;
+ wrongsecs = mktime(tm);
+ tz_min = (abs(wrongsecs - tt) + 30) / 60;
+ snprintf(buf1, sizeof(buf1),
+ "%c%02d%02d",
+ wrongsecs <= tt ? '+' : '-',
+ tz_min / 60,
+ tz_min % 60);
+ }
avio_printf(out, "#EXT-X-PROGRAM-DATE-TIME:%s.%03d%s\n", buf0, milli, buf1);
prog_date_time += en->duration;
}