Commit d2d67e42 authored by Anton Khirnov's avatar Anton Khirnov

Remove all uses of now deprecated metadata functions.

parent d9f80ea2
......@@ -39,6 +39,7 @@
#include "libavutil/colorspace.h"
#include "libavutil/fifo.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avstring.h"
#include "libavutil/libm.h"
......@@ -189,7 +190,7 @@ static int64_t start_time = 0;
static int64_t recording_timestamp = 0;
static int64_t input_ts_offset = 0;
static int file_overwrite = 0;
static AVMetadata *metadata;
static AVDictionary *metadata;
static int do_benchmark = 0;
static int do_hex_dump = 0;
static int do_pkt_dump = 0;
......@@ -1894,7 +1895,7 @@ static int copy_chapters(int infile, int outfile)
out_ch->end = FFMIN(rt, in_ch->end - ts_off);
if (metadata_chapters_autocopy)
av_metadata_copy(&out_ch->metadata, in_ch->metadata, 0);
av_dict_copy(&out_ch->metadata, in_ch->metadata, 0);
os->nb_chapters++;
os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapters);
......@@ -2083,8 +2084,8 @@ static int transcode(AVFormatContext **output_files,
icodec = ist->st->codec;
if (metadata_streams_autocopy)
av_metadata_copy(&ost->st->metadata, ist->st->metadata,
AV_METADATA_DONT_OVERWRITE);
av_dict_copy(&ost->st->metadata, ist->st->metadata,
AV_DICT_DONT_OVERWRITE);
ost->st->disposition = ist->st->disposition;
codec->bits_per_raw_sample= icodec->bits_per_raw_sample;
......@@ -2352,7 +2353,7 @@ static int transcode(AVFormatContext **output_files,
/* set meta data information from input file if required */
for (i=0;i<nb_meta_data_maps;i++) {
AVFormatContext *files[2];
AVMetadata **meta[2];
AVDictionary **meta[2];
int j;
#define METADATA_CHECK_INDEX(index, nb_elems, desc)\
......@@ -2395,15 +2396,15 @@ static int transcode(AVFormatContext **output_files,
}
}
av_metadata_copy(meta[0], *meta[1], AV_METADATA_DONT_OVERWRITE);
av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE);
}
/* copy global metadata by default */
if (metadata_global_autocopy) {
for (i = 0; i < nb_output_files; i++)
av_metadata_copy(&output_files[i]->metadata, input_files[0].ctx->metadata,
AV_METADATA_DONT_OVERWRITE);
av_dict_copy(&output_files[i]->metadata, input_files[0].ctx->metadata,
AV_DICT_DONT_OVERWRITE);
}
/* copy chapters according to chapter maps */
......@@ -2818,7 +2819,7 @@ static int opt_metadata(const char *opt, const char *arg)
}
*mid++= 0;
av_metadata_set2(&metadata, arg, mid, 0);
av_dict_set(&metadata, arg, mid, 0);
return 0;
}
......@@ -3523,7 +3524,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx)
parse_forced_key_frames(forced_key_frames, ost, video_enc);
}
if (video_language) {
av_metadata_set2(&st->metadata, "language", video_language, 0);
av_dict_set(&st->metadata, "language", video_language, 0);
av_freep(&video_language);
}
......@@ -3603,7 +3604,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx)
}
audio_enc->time_base= (AVRational){1, audio_sample_rate};
if (audio_language) {
av_metadata_set2(&st->metadata, "language", audio_language, 0);
av_dict_set(&st->metadata, "language", audio_language, 0);
av_freep(&audio_language);
}
......@@ -3699,7 +3700,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx)
}
if (subtitle_language) {
av_metadata_set2(&st->metadata, "language", subtitle_language, 0);
av_dict_set(&st->metadata, "language", subtitle_language, 0);
av_freep(&subtitle_language);
}
......@@ -3830,8 +3831,8 @@ static void opt_output_file(const char *filename)
oc->timestamp = recording_timestamp;
av_metadata_copy(&oc->metadata, metadata, 0);
av_metadata_free(&metadata);
av_dict_copy(&oc->metadata, metadata, 0);
av_dict_free(&metadata);
}
output_files[nb_output_files++] = oc;
......
......@@ -25,6 +25,7 @@
#include "libavcodec/avcodec.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/dict.h"
#include "libavdevice/avdevice.h"
#include "cmdutils.h"
......@@ -160,7 +161,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
AVCodecContext *dec_ctx;
AVCodec *dec;
char val_str[128];
AVMetadataTag *tag = NULL;
AVDictionaryEntry *tag = NULL;
AVRational display_aspect_ratio;
printf("[STREAM]\n");
......@@ -226,7 +227,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
if (stream->nb_frames)
printf("nb_frames=%"PRId64"\n", stream->nb_frames);
while ((tag = av_metadata_get(stream->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
printf("TAG:%s=%s\n", tag->key, tag->value);
printf("[/STREAM]\n");
......@@ -234,7 +235,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
static void show_format(AVFormatContext *fmt_ctx)
{
AVMetadataTag *tag = NULL;
AVDictionaryEntry *tag = NULL;
char val_str[128];
printf("[FORMAT]\n");
......@@ -252,7 +253,7 @@ static void show_format(AVFormatContext *fmt_ctx)
printf("bit_rate=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate,
unit_bit_per_second_str));
while ((tag = av_metadata_get(fmt_ctx->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
printf("TAG:%s=%s\n", tag->key, tag->value);
printf("[/FORMAT]\n");
......
......@@ -36,6 +36,7 @@
#include "libavformat/avio_internal.h"
#include "libavutil/avstring.h"
#include "libavutil/lfg.h"
#include "libavutil/dict.h"
#include "libavutil/random_seed.h"
#include "libavutil/parseutils.h"
#include "libavutil/opt.h"
......@@ -854,7 +855,7 @@ static void close_connection(HTTPContext *c)
ctx = c->rtp_ctx[i];
if (ctx) {
av_write_trailer(ctx);
av_metadata_free(&ctx->metadata);
av_dict_free(&ctx->metadata);
av_free(ctx->streams[0]);
av_free(ctx);
}
......@@ -2224,10 +2225,10 @@ static int http_prepare_data(HTTPContext *c)
switch(c->state) {
case HTTPSTATE_SEND_DATA_HEADER:
memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx));
av_metadata_set2(&c->fmt_ctx.metadata, "author" , c->stream->author , 0);
av_metadata_set2(&c->fmt_ctx.metadata, "comment" , c->stream->comment , 0);
av_metadata_set2(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
av_metadata_set2(&c->fmt_ctx.metadata, "title" , c->stream->title , 0);
av_dict_set(&c->fmt_ctx.metadata, "author" , c->stream->author , 0);
av_dict_set(&c->fmt_ctx.metadata, "comment" , c->stream->comment , 0);
av_dict_set(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
av_dict_set(&c->fmt_ctx.metadata, "title" , c->stream->title , 0);
c->fmt_ctx.streams = av_mallocz(sizeof(AVStream *) * c->stream->nb_streams);
......@@ -2272,7 +2273,7 @@ static int http_prepare_data(HTTPContext *c)
http_log("Error writing output header\n");
return -1;
}
av_metadata_free(&c->fmt_ctx.metadata);
av_dict_free(&c->fmt_ctx.metadata);
len = avio_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer);
c->buffer_ptr = c->pb_buffer;
......@@ -2927,8 +2928,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
if (avc == NULL) {
return -1;
}
av_metadata_set2(&avc->metadata, "title",
stream->title[0] ? stream->title : "No Title", 0);
av_dict_set(&avc->metadata, "title",
stream->title[0] ? stream->title : "No Title", 0);
avc->nb_streams = stream->nb_streams;
if (stream->is_multicast) {
snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d",
......@@ -2954,7 +2955,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
sdp_done:
av_free(avc->streams);
av_metadata_free(&avc->metadata);
av_dict_free(&avc->metadata);
av_free(avc);
av_free(avs);
......
......@@ -20,6 +20,7 @@
*/
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "pcm.h"
#include "aiff.h"
......@@ -79,7 +80,7 @@ static void get_meta(AVFormatContext *s, const char *key, int size)
return;
str[res] = 0;
av_metadata_set2(&s->metadata, key, str, AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(&s->metadata, key, str, AV_DICT_DONT_STRDUP_VAL);
}
/* Returns the number of sound data frames or negative on error */
......
......@@ -21,6 +21,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "apetag.h"
......@@ -57,7 +58,7 @@ static int ape_tag_read_field(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_read(pb, value, size);
value[size] = 0;
av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
......
......@@ -28,6 +28,7 @@
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "internal.h"
#include <unistd.h>
......@@ -505,7 +506,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
if (v->bandwidth)
av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str,
av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,
0);
}
stream_offset += v->ctx->nb_streams;
......
......@@ -24,6 +24,7 @@
#include "libavutil/bswap.h"
#include "libavutil/common.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavcodec/mpegaudio.h"
#include "avformat.h"
#include "avio_internal.h"
......@@ -179,7 +180,7 @@ static void get_tag(AVFormatContext *s, const char *key, int type, int len)
goto finish;
}
if (*value)
av_metadata_set2(&s->metadata, key, value, 0);
av_dict_set(&s->metadata, key, value, 0);
finish:
av_freep(&value);
avio_seek(s->pb, off + len, SEEK_SET);
......@@ -689,7 +690,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any
const char *iso6392 = av_convert_lang_to(primary_tag, AV_LANG_ISO639_2_BIBL);
if (iso6392)
av_metadata_set2(&st->metadata, "language", iso6392, 0);
av_dict_set(&st->metadata, "language", iso6392, 0);
}
}
}
......
......@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "metadata.h"
#include "riff.h"
#include "asf.h"
#include "avio_internal.h"
#include "libavutil/dict.h"
#undef NDEBUG
#include <assert.h>
......@@ -296,7 +296,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
AVMetadataTag *tags[5];
AVDictionaryEntry *tags[5];
int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
int has_title;
int metadata_count;
......@@ -307,11 +307,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
tags[0] = av_metadata_get(s->metadata, "title" , NULL, 0);
tags[1] = av_metadata_get(s->metadata, "author" , NULL, 0);
tags[2] = av_metadata_get(s->metadata, "copyright", NULL, 0);
tags[3] = av_metadata_get(s->metadata, "comment" , NULL, 0);
tags[4] = av_metadata_get(s->metadata, "rating" , NULL, 0);
tags[0] = av_dict_get(s->metadata, "title" , NULL, 0);
tags[1] = av_dict_get(s->metadata, "author" , NULL, 0);
tags[2] = av_dict_get(s->metadata, "copyright", NULL, 0);
tags[3] = av_dict_get(s->metadata, "comment" , NULL, 0);
tags[4] = av_dict_get(s->metadata, "rating" , NULL, 0);
duration = asf->duration + PREROLL_TIME * 10000;
has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
......@@ -381,10 +381,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
end_header(pb, hpos);
}
if (metadata_count) {
AVMetadataTag *tag = NULL;
AVDictionaryEntry *tag = NULL;
hpos = put_header(pb, &ff_asf_extended_content_header);
avio_wl16(pb, metadata_count);
while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_str16(pb, tag->key);
avio_wl16(pb, 0);
put_str16(pb, tag->value);
......
......@@ -161,7 +161,7 @@ attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AV
* this function will allocate a struct for you and put it in *dst
* @param src pointer to source AVDictionary struct
* @param flags flags to use when setting metadata in *dst
* @note metadata is read using the AV_METADATA_IGNORE_SUFFIX flag
* @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
*/
attribute_deprecated void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags);
......@@ -565,7 +565,7 @@ typedef struct AVStream {
*/
AVRational sample_aspect_ratio;
AVMetadata *metadata;
AVDictionary *metadata;
/* Intended mostly for av_read_frame() support. Not supposed to be used by */
/* external applications; try to use something else if at all possible. */
......@@ -633,7 +633,7 @@ typedef struct AVProgram {
enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller
unsigned int *stream_index;
unsigned int nb_stream_indexes;
AVMetadata *metadata;
AVDictionary *metadata;
} AVProgram;
#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
......@@ -643,7 +643,7 @@ typedef struct AVChapter {
int id; ///< unique ID to identify the chapter
AVRational time_base; ///< time base in which the start/end timestamps are specified
int64_t start, end; ///< chapter start/end time in time_base units
AVMetadata *metadata;
AVDictionary *metadata;
} AVChapter;
/**
......@@ -806,7 +806,7 @@ typedef struct AVFormatContext {
struct AVPacketList *packet_buffer_end;
AVMetadata *metadata;
AVDictionary *metadata;
/**
* Remaining size available for raw_packet_buffer, in bytes.
......
......@@ -25,6 +25,7 @@
#include <strings.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/bswap.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "avi.h"
#include "dv.h"
......@@ -261,8 +262,8 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t
AV_WL32(key, tag);
return av_metadata_set2(st ? &st->metadata : &s->metadata, key, value,
AV_METADATA_DONT_STRDUP_VAL);
return av_dict_set(st ? &st->metadata : &s->metadata, key, value,
AV_DICT_DONT_STRDUP_VAL);
}
static void avi_read_info(AVFormatContext *s, uint64_t end)
......@@ -277,7 +278,7 @@ static void avi_read_info(AVFormatContext *s, uint64_t end)
static const char months[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
static void avi_metadata_creation_time(AVDictionary **metadata, char *date)
{
char month[4], time[9], buffer[64];
int i, day, year;
......@@ -288,11 +289,11 @@ static void avi_metadata_creation_time(AVMetadata **metadata, char *date)
if (!strcasecmp(month, months[i])) {
snprintf(buffer, sizeof(buffer), "%.4d-%.2d-%.2d %s",
year, i+1, day, time);
av_metadata_set2(metadata, "creation_time", buffer, 0);
av_dict_set(metadata, "creation_time", buffer, 0);
}
} else if (date[4] == '/' && date[7] == '/') {
date[4] = date[7] = '-';
av_metadata_set2(metadata, "creation_time", date, 0);
av_dict_set(metadata, "creation_time", date, 0);
}
}
......@@ -320,7 +321,7 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
break;
}
if (name)
av_metadata_set2(&s->metadata, name, buffer, 0);
av_dict_set(&s->metadata, name, buffer, 0);
avio_skip(s->pb, size);
}
break;
......@@ -770,7 +771,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt) {
ret = avio_get_str16le(pb, desc_len, desc, sizeof(desc));
avio_skip(pb, desc_len - ret);
if (*desc)
av_metadata_set2(&st->metadata, "title", desc, 0);
av_dict_set(&st->metadata, "title", desc, 0);
avio_rl16(pb); /* flags? */
avio_rl32(pb); /* data size */
......
......@@ -23,6 +23,7 @@
#include "avio_internal.h"
#include "riff.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
/*
* TODO:
......@@ -157,7 +158,7 @@ static int avi_write_header(AVFormatContext *s)
int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
AVCodecContext *stream, *video_enc;
int64_t list1, list2, strh, strf;
AVMetadataTag *t = NULL;
AVDictionaryEntry *t = NULL;
if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
......@@ -297,7 +298,7 @@ static int avi_write_header(AVFormatContext *s)
return -1;
}
ff_end_tag(pb, strf);
if ((t = av_metadata_get(s->streams[i]->metadata, "title", NULL, 0))) {
if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) {
avi_write_info_tag(s->pb, "strn", t->value);
t = NULL;
}
......@@ -379,7 +380,7 @@ static int avi_write_header(AVFormatContext *s)
ffio_wfourcc(pb, "INFO");
ff_metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL);
for (i = 0; *ff_avi_tags[i]; i++) {
if ((t = av_metadata_get(s->metadata, ff_avi_tags[i], NULL, AV_METADATA_MATCH_CASE)))
if ((t = av_dict_get(s->metadata, ff_avi_tags[i], NULL, AV_DICT_MATCH_CASE)))
avi_write_info_tag(s->pb, t->key, t->value);
}
ff_end_tag(pb, list2);
......
......@@ -29,6 +29,7 @@
#include "riff.h"
#include "isom.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "caf.h"
typedef struct {
......@@ -187,7 +188,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size)
char value[1024];
avio_get_str(pb, INT_MAX, key, sizeof(key));
avio_get_str(pb, INT_MAX, value, sizeof(value));
av_metadata_set2(&s->metadata, key, value, 0);
av_dict_set(&s->metadata, key, value, 0);
}
}
......
......@@ -22,6 +22,7 @@
#include "avformat.h"
#include "ffmeta.h"
#include "internal.h"
#include "libavutil/dict.h"
static int probe(AVProbeData *p)
{
......@@ -93,7 +94,7 @@ static uint8_t *unescape(uint8_t *buf, int size)
return ret;
}
static int read_tag(uint8_t *line, AVMetadata **m)
static int read_tag(uint8_t *line, AVDictionary **m)
{
uint8_t *key, *value, *p = line;
......@@ -117,13 +118,13 @@ static int read_tag(uint8_t *line, AVMetadata **m)
return AVERROR(ENOMEM);
}
av_metadata_set2(m, key, value, AV_METADATA_DONT_STRDUP_KEY | AV_METADATA_DONT_STRDUP_VAL);
av_dict_set(m, key, value, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
return 0;
}
static int read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVMetadata **m = &s->metadata;
AVDictionary **m = &s->metadata;
uint8_t line[1024];
while(!s->pb->eof_reached) {
......
......@@ -23,6 +23,7 @@
#include "avformat.h"
#include "ffmeta.h"
#include "libavutil/dict.h"
static void write_escape_str(AVIOContext *s, const uint8_t *str)
......@@ -37,10 +38,10 @@ static void write_escape_str(AVIOContext *s, const uint8_t *str)
}
}
static void write_tags(AVIOContext *s, AVMetadata *m)
static void write_tags(AVIOContext *s, AVDictionary *m)
{
AVMetadataTag *t = NULL;
while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX))) {
AVDictionaryEntry *t = NULL;
while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) {
write_escape_str(s, t->key);
avio_w8(s, '=');
write_escape_str(s, t->value);
......
......@@ -22,7 +22,6 @@
#include "libavcodec/flac.h"
#include "avformat.h"
#include "flacenc.h"
#include "metadata.h"
#include "vorbiscomment.h"
#include "libavcodec/bytestream.h"
......@@ -39,7 +38,7 @@ static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_byte
return 0;
}
static int flac_write_block_comment(AVIOContext *pb, AVMetadata **m,
static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
int last_block, int bitexact)
{
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
......
......@@ -25,6 +25,7 @@
*/
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/mpeg4audio.h"
#include "avformat.h"
......@@ -271,17 +272,17 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
if(amf_type == AMF_DATA_TYPE_BOOL) {
av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val));
av_metadata_set2(&s->metadata, key, str_val, 0);
av_dict_set(&s->metadata, key, str_val, 0);
} else if(amf_type == AMF_DATA_TYPE_NUMBER) {
snprintf(str_val, sizeof(str_val), "%.f", num_val);
av_metadata_set2(&s->metadata, key, str_val, 0);
av_dict_set(&s->metadata, key, str_val, 0);
if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
vcodec->bit_rate = num_val * 1024.0;
else if(!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0))
acodec->bit_rate = num_val * 1024.0;
} else if (amf_type == AMF_DATA_TYPE_STRING)
av_metadata_set2(&s->metadata, key, str_val, 0);
av_dict_set(&s->metadata, key, str_val, 0);
}
return 0;
......
......@@ -23,6 +23,7 @@
#include "internal.h"
#include "avc.h"
#include "metadata.h"
#include "libavutil/dict.h"
#undef NDEBUG
#include <assert.h>
......@@ -177,7 +178,7 @@ static int flv_write_header(AVFormatContext *s)
int i;
double framerate = 0.0;
int metadata_size_pos, data_size;
AVMetadataTag *tag = NULL;
AVDictionaryEntry *tag = NULL;
for(i=0; i<s->nb_streams; i++){
AVCodecContext *enc = s->streams[i]->codec;
......@@ -274,7 +275,7 @@ static int flv_write_header(AVFormatContext *s)
put_amf_double(pb, audio_enc->codec_tag);
}
while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_amf_string(pb, tag->key);
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, tag->value);
......
......@@ -21,6 +21,7 @@
#include "id3v1.h"
#include "libavcodec/avcodec.h"
#include "libavutil/dict.h"
const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] = {
[0] = "Blues",
......@@ -191,7 +192,7 @@ static void get_string(AVFormatContext *s, const char *key,
*q = '\0';
if (*str)
av_metadata_set2(&s->metadata, key, str, 0);
av_dict_set(&s->metadata, key, str, 0);
}
/**
......@@ -215,11 +216,11 @@ static int parse_tag(AVFormatContext *s, const uint8_t *buf)
get_string(s, "comment", buf + 97, 30);
if (buf[125] == 0 && buf[126] != 0) {
snprintf(str, sizeof(str), "%d", buf[126]);
av_metadata_set2(&s->metadata, "track", str, 0);
av_dict_set(&s->metadata, "track", str, 0);
}
genre = buf[127];
if (genre <= ID3v1_GENRE_MAX)
av_metadata_set2(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
av_dict_set(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
return 0;
}
......
......@@ -23,7 +23,7 @@
#include "id3v1.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "metadata.h"
#include "libavutil/dict.h"
#include "avio_internal.h"
int ff_id3v2_match(const uint8_t *buf, const char * magic)
......@@ -133,7 +133,7 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
val = dst;
if (val)
av_metadata_set2(&s->metadata, key, val, AV_METADATA_DONT_OVERWRITE);
av_dict_set(&s->metadata, key, val, AV_DICT_DONT_OVERWRITE);
}
static int is_number(const char *str)
......@@ -142,44 +142,44 @@ static int is_number(const char *str)
return !*str;
}
static AVMetadataTag* get_date_tag(AVMetadata *m, const char *tag)
static AVDictionaryEntry* get_date_tag(AVDictionary *m, const char *tag)
{
AVMetadataTag *t;
if ((t = av_metadata_get(m, tag, NULL, AV_METADATA_MATCH_CASE)) &&
AVDictionaryEntry *t;
if ((t = av_dict_get(m, tag, NULL, AV_DICT_MATCH_CASE)) &&
strlen(t->value) == 4 && is_number(t->value))
return t;
return NULL;
}
static void merge_date(AVMetadata **m)
static void merge_date(AVDictionary **m)
{
AVMetadataTag *t;
AVDictionaryEntry *t;
char date[17] = {0}; // YYYY-MM-DD hh:mm
if (!(t = get_date_tag(*m, "TYER")) &&
!(t = get_date_tag(*m, "TYE")))
return;
av_strlcpy(date, t->value, 5);
av_metadata_set2(m, "TYER", NULL, 0);
av_metadata_set2(m, "TYE", NULL, 0);
av_dict_set(m, "TYER", NULL, 0);
av_dict_set(m, "TYE", NULL, 0);
if (!(t = get_date_tag(*m, "TDAT")) &&
!(t = get_date_tag(*m, "TDA")))
goto finish;
snprintf(date + 4, sizeof(date) - 4, "-%.2s-%.2s", t->value + 2, t->value);
av_metadata_set2(m, "TDAT", NULL, 0);
av_metadata_set2(m, "TDA", NULL, 0);
av_dict_set(m, "TDAT", NULL, 0);
av_dict_set(m, "TDA", NULL, 0);
if (!(t = get_date_tag(*m, "TIME")) &&
!(t = get_date_tag(*m, "TIM")))
goto finish;
snprintf(date + 10, sizeof(date) - 10, " %.2s:%.2s", t->value, t->value + 2);