avutil/dict: Unavpriv avpriv_dict_set_timestamp()
And move it to lavf, its only user. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
b306683d12
commit
c389d9ac78
@ -28,7 +28,6 @@
|
||||
#include "libavutil/avstring.h"
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/dict_internal.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/internal.h"
|
||||
@ -826,7 +825,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
|
||||
) {
|
||||
// timezone is ignored, since there is no easy way to offset the UTC
|
||||
// timestamp into the specified timezone
|
||||
avpriv_dict_set_timestamp(&s->metadata, key, 1000 * (int64_t)date.milliseconds);
|
||||
ff_dict_set_timestamp(&s->metadata, key, 1000 * (int64_t)date.milliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "libavutil/dict_internal.h"
|
||||
#include "avformat.h"
|
||||
#include "demux.h"
|
||||
#include "internal.h"
|
||||
@ -96,7 +95,7 @@ static int parse_header(AVFormatContext *s)
|
||||
uint32_t vid_magic;
|
||||
|
||||
avio_skip(s->pb, 0x34);
|
||||
avpriv_dict_set_timestamp(&s->metadata, "creation_time", avio_rl32(s->pb) * 1000000LL);
|
||||
ff_dict_set_timestamp(&s->metadata, "creation_time", avio_rl32(s->pb) * 1000000LL);
|
||||
avio_skip(s->pb, 0x24);
|
||||
|
||||
ifv->width = avio_rl16(s->pb);
|
||||
|
@ -640,4 +640,15 @@ int ff_match_url_ext(const char *url, const char *extensions);
|
||||
int ff_get_frame_filename(char *buf, int buf_size, const char *path,
|
||||
int64_t number, int flags);
|
||||
|
||||
/**
|
||||
* Set a dictionary value to an ISO-8601 compliant timestamp string.
|
||||
*
|
||||
* @param dict pointer to a pointer to a dictionary struct. If *dict is NULL
|
||||
* a dictionary struct is allocated and put in *dict.
|
||||
* @param key metadata key
|
||||
* @param timestamp unix timestamp in microseconds
|
||||
* @return <0 on error
|
||||
*/
|
||||
int ff_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp);
|
||||
|
||||
#endif /* AVFORMAT_INTERNAL_H */
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "libavutil/base64.h"
|
||||
#include "libavutil/bprint.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/dict_internal.h"
|
||||
#include "libavutil/display.h"
|
||||
#include "libavutil/hdr_dynamic_metadata.h"
|
||||
#include "libavutil/intfloat.h"
|
||||
@ -2137,7 +2136,7 @@ static int matroska_aac_sri(int samplerate)
|
||||
static void matroska_metadata_creation_time(AVDictionary **metadata, int64_t date_utc)
|
||||
{
|
||||
/* Convert to seconds and adjust by number of seconds between 2001-01-01 and Epoch */
|
||||
avpriv_dict_set_timestamp(metadata, "creation_time", date_utc / 1000 + 978307200000000LL);
|
||||
ff_dict_set_timestamp(metadata, "creation_time", date_utc / 1000 + 978307200000000LL);
|
||||
}
|
||||
|
||||
static int matroska_parse_flac(AVFormatContext *s,
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/bprint.h"
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "libavutil/dict_internal.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/intfloat.h"
|
||||
@ -1858,7 +1857,7 @@ static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDiction
|
||||
return;
|
||||
}
|
||||
|
||||
avpriv_dict_set_timestamp(metadata, "creation_time", time * 1000000);
|
||||
ff_dict_set_timestamp(metadata, "creation_time", time * 1000000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/dict_internal.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/mem.h"
|
||||
@ -157,6 +156,6 @@ int ff_standardize_creation_time(AVFormatContext *s)
|
||||
int64_t timestamp;
|
||||
int ret = ff_parse_creation_time_metadata(s, ×tamp, 0);
|
||||
if (ret == 1)
|
||||
return avpriv_dict_set_timestamp(&s->metadata, "creation_time", timestamp);
|
||||
return ff_dict_set_timestamp(&s->metadata, "creation_time", timestamp);
|
||||
return ret;
|
||||
}
|
||||
|
@ -56,7 +56,6 @@
|
||||
#include "libavcodec/defs.h"
|
||||
#include "libavcodec/internal.h"
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "libavutil/dict_internal.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/parseutils.h"
|
||||
#include "libavutil/timecode.h"
|
||||
@ -3207,7 +3206,7 @@ static int64_t mxf_timestamp_to_int64(uint64_t timestamp)
|
||||
|
||||
#define SET_TS_METADATA(pb, name, var, str) do { \
|
||||
var = avio_rb64(pb); \
|
||||
if (var && (ret = avpriv_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var))) < 0) \
|
||||
if (var && (ret = ff_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var))) < 0) \
|
||||
return ret; \
|
||||
} while (0)
|
||||
|
||||
|
@ -20,14 +20,17 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "libavutil/avstring.h"
|
||||
#include "libavutil/bprint.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/time.h"
|
||||
#include "libavutil/time_internal.h"
|
||||
|
||||
#include "libavcodec/internal.h"
|
||||
|
||||
@ -596,3 +599,19 @@ int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf
|
||||
par->extradata_size = buf->len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ff_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
|
||||
{
|
||||
time_t seconds = timestamp / 1000000;
|
||||
struct tm *ptm, tmbuf;
|
||||
ptm = gmtime_r(&seconds, &tmbuf);
|
||||
if (ptm) {
|
||||
char buf[32];
|
||||
if (!strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", ptm))
|
||||
return AVERROR_EXTERNAL;
|
||||
av_strlcatf(buf, sizeof(buf), ".%06dZ", (int)(timestamp % 1000000));
|
||||
return av_dict_set(dict, key, buf, 0);
|
||||
} else {
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,8 @@
|
||||
#include "avassert.h"
|
||||
#include "avstring.h"
|
||||
#include "dict.h"
|
||||
#include "dict_internal.h"
|
||||
#include "error.h"
|
||||
#include "mem.h"
|
||||
#include "time_internal.h"
|
||||
#include "bprint.h"
|
||||
|
||||
struct AVDictionary {
|
||||
@ -274,19 +272,3 @@ int av_dict_get_string(const AVDictionary *m, char **buffer,
|
||||
}
|
||||
return av_bprint_finalize(&bprint, buffer);
|
||||
}
|
||||
|
||||
int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
|
||||
{
|
||||
time_t seconds = timestamp / 1000000;
|
||||
struct tm *ptm, tmbuf;
|
||||
ptm = gmtime_r(&seconds, &tmbuf);
|
||||
if (ptm) {
|
||||
char buf[32];
|
||||
if (!strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", ptm))
|
||||
return AVERROR_EXTERNAL;
|
||||
av_strlcatf(buf, sizeof(buf), ".%06dZ", (int)(timestamp % 1000000));
|
||||
return av_dict_set(dict, key, buf, 0);
|
||||
} else {
|
||||
return AVERROR_EXTERNAL;
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_DICT_INTERNAL_H
|
||||
#define AVUTIL_DICT_INTERNAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dict.h"
|
||||
|
||||
/**
|
||||
* Set a dictionary value to an ISO-8601 compliant timestamp string.
|
||||
*
|
||||
* @param dict pointer to a pointer to a dictionary struct. If *dict is NULL
|
||||
* a dictionary struct is allocated and put in *dict.
|
||||
* @param key metadata key
|
||||
* @param timestamp unix timestamp in microseconds
|
||||
* @return <0 on error
|
||||
*/
|
||||
int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp);
|
||||
|
||||
#endif /* AVUTIL_DICT_INTERNAL_H */
|
Loading…
x
Reference in New Issue
Block a user