avformat/hlsenc: Redo checking for strftime %s support to avoid warnings
This is intended to avoid -Wformat= warnings on systems where %s might not be supported (and also generally emitted by GCC with -pedantic). Reviewed-by: Liu Steven <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
b0e17e0f95
commit
d085f341d6
@ -1878,18 +1878,23 @@ fail:
|
|||||||
|
|
||||||
static const char * get_default_pattern_localtime_fmt(AVFormatContext *s)
|
static const char * get_default_pattern_localtime_fmt(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
|
HLSContext *hls = s->priv_data;
|
||||||
|
#if HAVE_LIBC_MSVCRT
|
||||||
|
// no %s support on MSVC, which invokes the invalid parameter handler
|
||||||
|
// on unsupported format strings, instead of returning an error
|
||||||
|
int strftime_s_supported = 0;
|
||||||
|
#else
|
||||||
char b[21];
|
char b[21];
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct tm *p, tmbuf;
|
struct tm tmbuf, *p = localtime_r(&t, &tmbuf);
|
||||||
HLSContext *hls = s->priv_data;
|
|
||||||
|
|
||||||
p = localtime_r(&t, &tmbuf);
|
|
||||||
// no %s support when strftime returned error or left format string unchanged
|
// no %s support when strftime returned error or left format string unchanged
|
||||||
// also no %s support on MSVC, which invokes the invalid parameter handler on unsupported format strings, instead of returning an error
|
int strftime_s_supported = strftime(b, sizeof(b), "%s", p) && strcmp(b, "%s");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hls->segment_type == SEGMENT_TYPE_FMP4) {
|
if (hls->segment_type == SEGMENT_TYPE_FMP4) {
|
||||||
return (HAVE_LIBC_MSVCRT || !strftime(b, sizeof(b), "%s", p) || !strcmp(b, "%s")) ? "-%Y%m%d%H%M%S.m4s" : "-%s.m4s";
|
return strftime_s_supported ? "-%s.m4s" : "-%Y%m%d%H%M%S.m4s";
|
||||||
}
|
}
|
||||||
return (HAVE_LIBC_MSVCRT || !strftime(b, sizeof(b), "%s", p) || !strcmp(b, "%s")) ? "-%Y%m%d%H%M%S.ts" : "-%s.ts";
|
return strftime_s_supported ? "-%s.ts" : "-%Y%m%d%H%M%S.ts";
|
||||||
}
|
}
|
||||||
|
|
||||||
static int append_postfix(char *name, int name_buf_len, int i)
|
static int append_postfix(char *name, int name_buf_len, int i)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user