[FFmpeg-devel] [PATCH 3/4] Mark av_metadata_set() as deprecated, and use av_metadata_set2() in its place.
Stefano Sabatini
stefano.sabatini-lala
Sat Apr 24 15:32:47 CEST 2010
av_metadata_set() is going to be dropped at the next major bump.
---
ffmpeg.c | 10 +++++-----
ffserver.c | 12 ++++++------
libavformat/asfdec.c | 2 +-
libavformat/avformat.h | 3 ++-
libavformat/cafdec.c | 2 +-
libavformat/flvdec.c | 6 +++---
libavformat/id3v1.c | 4 ++--
libavformat/id3v2.c | 2 +-
libavformat/matroskadec.c | 16 ++++++++--------
libavformat/metadata.c | 2 +-
libavformat/metadata_compat.c | 2 +-
libavformat/mov.c | 14 +++++++-------
libavformat/mpegts.c | 10 +++++-----
libavformat/nsvdec.c | 2 +-
libavformat/nutdec.c | 2 +-
libavformat/r3d.c | 2 +-
libavformat/rmdec.c | 2 +-
libavformat/rpl.c | 6 +++---
libavformat/rtsp.c | 4 ++--
libavformat/utils.c | 2 +-
20 files changed, 53 insertions(+), 52 deletions(-)
diff --git a/ffmpeg.c b/ffmpeg.c
index a314126..36eefe1 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3287,7 +3287,7 @@ static void new_video_stream(AVFormatContext *oc)
}
nb_ocodecs++;
if (video_language) {
- av_metadata_set(&st->metadata, "language", video_language);
+ av_metadata_set2(&st->metadata, "language", video_language, 0);
av_freep(&video_language);
}
@@ -3361,7 +3361,7 @@ static void new_audio_stream(AVFormatContext *oc)
nb_ocodecs++;
audio_enc->time_base= (AVRational){1, audio_sample_rate};
if (audio_language) {
- av_metadata_set(&st->metadata, "language", audio_language);
+ av_metadata_set2(&st->metadata, "language", audio_language, 0);
av_freep(&audio_language);
}
@@ -3402,7 +3402,7 @@ static void new_subtitle_stream(AVFormatContext *oc)
nb_ocodecs++;
if (subtitle_language) {
- av_metadata_set(&st->metadata, "language", subtitle_language);
+ av_metadata_set2(&st->metadata, "language", subtitle_language, 0);
av_freep(&subtitle_language);
}
@@ -3533,8 +3533,8 @@ static void opt_output_file(const char *filename)
oc->timestamp = rec_timestamp;
for(; metadata_count>0; metadata_count--){
- av_metadata_set(&oc->metadata, metadata[metadata_count-1].key,
- metadata[metadata_count-1].value);
+ av_metadata_set2(&oc->metadata, metadata[metadata_count-1].key,
+ metadata[metadata_count-1].value, 0);
}
av_metadata_conv(oc, oc->oformat->metadata_conv, NULL);
}
diff --git a/ffserver.c b/ffserver.c
index 926eec3..7b5b4ec 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -2237,10 +2237,10 @@ static int http_prepare_data(HTTPContext *c)
case HTTPSTATE_SEND_DATA_HEADER:
memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx));
#if LIBAVFORMAT_VERSION_MAJOR < 53
- av_metadata_set(&c->fmt_ctx.metadata, "author" ,c->stream->author);
- av_metadata_set(&c->fmt_ctx.metadata, "comment" ,c->stream->comment);
- av_metadata_set(&c->fmt_ctx.metadata, "copyright",c->stream->copyright);
- av_metadata_set(&c->fmt_ctx.metadata, "title" ,c->stream->title);
+ 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);
#endif
while ((tag = av_metadata_get(c->stream->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
av_metadata_set2(&c->fmt_ctx.metadata, tag->key, tag->value, 0);
@@ -2947,8 +2947,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
if (avc == NULL) {
return -1;
}
- av_metadata_set(&avc->metadata, "title",
- stream->title[0] ? stream->title : "No Title");
+ av_metadata_set2(&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",
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index c505f92..bbc2730 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -616,7 +616,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_set(&st->metadata, "language", iso6392);
+ av_metadata_set2(&st->metadata, "language", iso6392, 0);
}
}
}
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5ff08c0..184e68b 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -145,8 +145,9 @@ av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int f
* @param key tag key to add to m (will be av_strduped)
* @param value tag value to add to m (will be av_strduped)
* @return >= 0 on success otherwise an error code <0
+ * @deprecated Use av_metadata_set2() instead.
*/
-int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
+attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
#endif
/**
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index 3495ea2..c020579 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -172,7 +172,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size)
char value[1024];
get_strz(pb, key, sizeof(key));
get_strz(pb, value, sizeof(value));
- av_metadata_set(&s->metadata, key, value);
+ av_metadata_set2(&s->metadata, key, value, 0);
}
}
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index b5a8eef..fcdf214 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -188,17 +188,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_set(&s->metadata, key, str_val);
+ av_metadata_set2(&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_set(&s->metadata, key, str_val);
+ av_metadata_set2(&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_set(&s->metadata, key, str_val);
+ av_metadata_set2(&s->metadata, key, str_val, 0);
}
return 0;
diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c
index b1e3dc3..c72fca4 100644
--- a/libavformat/id3v1.c
+++ b/libavformat/id3v1.c
@@ -192,7 +192,7 @@ static void get_string(AVFormatContext *s, const char *key,
*q = '\0';
if (*str)
- av_metadata_set(&s->metadata, key, str);
+ av_metadata_set2(&s->metadata, key, str, 0);
}
/**
@@ -217,7 +217,7 @@ static int parse_tag(AVFormatContext *s, const uint8_t *buf)
av_metadata_set2(&s->metadata, "track", av_d2str(buf[126]), AV_METADATA_DONT_STRDUP_VAL);
genre = buf[127];
if (genre <= ID3v1_GENRE_MAX)
- av_metadata_set(&s->metadata, "genre", ff_id3v1_genre_str[genre]);
+ av_metadata_set2(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
return 0;
}
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 89c0e63..6fa11db 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -150,7 +150,7 @@ static void read_ttag(AVFormatContext *s, int taglen, const char *key)
val = dst;
if (val)
- av_metadata_set(&s->metadata, key, val);
+ av_metadata_set2(&s->metadata, key, val, 0);
}
void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 06b384b..bf5b3ef 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1001,14 +1001,14 @@ static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
if (prefix) snprintf(key, sizeof(key), "%s/%s", prefix, tags[i].name);
else av_strlcpy(key, tags[i].name, sizeof(key));
if (tags[i].def || !lang) {
- av_metadata_set(metadata, key, tags[i].string);
+ av_metadata_set2(metadata, key, tags[i].string, 0);
if (tags[i].sub.nb_elem)
matroska_convert_tag(s, &tags[i].sub, metadata, key);
}
if (lang) {
av_strlcat(key, "-", sizeof(key));
av_strlcat(key, lang, sizeof(key));
- av_metadata_set(metadata, key, tags[i].string);
+ av_metadata_set2(metadata, key, tags[i].string, 0);
if (tags[i].sub.nb_elem)
matroska_convert_tag(s, &tags[i].sub, metadata, key);
}
@@ -1157,7 +1157,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (matroska->duration)
matroska->ctx->duration = matroska->duration * matroska->time_scale
* 1000 / AV_TIME_BASE;
- av_metadata_set(&s->metadata, "title", matroska->title);
+ av_metadata_set2(&s->metadata, "title", matroska->title, 0);
tracks = matroska->tracks.elem;
for (i=0; i < matroska->tracks.nb_elem; i++) {
@@ -1352,8 +1352,8 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
- av_metadata_set(&st->metadata, "language", track->language);
- av_metadata_set(&st->metadata, "title", track->name);
+ av_metadata_set2(&st->metadata, "language", track->language, 0);
+ av_metadata_set2(&st->metadata, "title", track->name, 0);
if (track->flag_default)
st->disposition |= AV_DISPOSITION_DEFAULT;
@@ -1410,7 +1410,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVStream *st = av_new_stream(s, 0);
if (st == NULL)
break;
- av_metadata_set(&st->metadata, "filename",attachements[j].filename);
+ av_metadata_set2(&st->metadata, "filename",attachements[j].filename, 0);
st->codec->codec_id = CODEC_ID_NONE;
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codec->extradata = av_malloc(attachements[j].bin.size);
@@ -1438,8 +1438,8 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000},
chapters[i].start, chapters[i].end,
chapters[i].title);
- av_metadata_set(&chapters[i].chapter->metadata,
- "title", chapters[i].title);
+ av_metadata_set2(&chapters[i].chapter->metadata,
+ "title", chapters[i].title, 0);
max_start = chapters[i].start;
}
diff --git a/libavformat/metadata.c b/libavformat/metadata.c
index 0f2b529..ff7ffe9 100644
--- a/libavformat/metadata.c
+++ b/libavformat/metadata.c
@@ -133,7 +133,7 @@ void metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
break;
}
}
- av_metadata_set(&dst, key, mtag->value);
+ av_metadata_set2(&dst, key, mtag->value, 0);
}
av_metadata_free(pm);
*pm = dst;
diff --git a/libavformat/metadata_compat.c b/libavformat/metadata_compat.c
index 9869a17..ac99c05 100644
--- a/libavformat/metadata_compat.c
+++ b/libavformat/metadata_compat.c
@@ -109,7 +109,7 @@ void ff_metadata_demux_compat(AVFormatContext *ctx)
#define FILL_METADATA(s, key, value) { \
if (value && *value && !av_metadata_get(s->metadata, #key, NULL, 0)) \
- av_metadata_set(&s->metadata, #key, value); \
+ av_metadata_set2(&s->metadata, #key, value, 0); \
}
#define FILL_METADATA_STR(s, key) FILL_METADATA(s, key, s->key)
#define FILL_METADATA_INT(s, key) { \
diff --git a/libavformat/mov.c b/libavformat/mov.c
index b49d4cc..2a60c92 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -86,7 +86,7 @@ static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len)
get_be16(pb); // unknown
snprintf(buf, sizeof(buf), "%d", get_be16(pb));
- av_metadata_set(&c->fc->metadata, "track", buf);
+ av_metadata_set2(&c->fc->metadata, "track", buf, 0);
get_be16(pb); // total tracks
@@ -204,10 +204,10 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
get_buffer(pb, str, str_size);
str[str_size] = 0;
}
- av_metadata_set(&c->fc->metadata, key, str);
+ av_metadata_set2(&c->fc->metadata, key, str, 0);
if (*language && strcmp(language, "und")) {
snprintf(key2, sizeof(key2), "%s-%s", key, language);
- av_metadata_set(&c->fc->metadata, key2, str);
+ av_metadata_set2(&c->fc->metadata, key2, str, 0);
}
}
#ifdef DEBUG_METADATA
@@ -569,10 +569,10 @@ static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
if (strcmp(type, "qt "))
c->isom = 1;
av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
- av_metadata_set(&c->fc->metadata, "major_brand", type);
+ av_metadata_set2(&c->fc->metadata, "major_brand", type, 0);
minor_ver = get_be32(pb); /* minor version */
snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
- av_metadata_set(&c->fc->metadata, "minor_version", minor_ver_str);
+ av_metadata_set2(&c->fc->metadata, "minor_version", minor_ver_str, 0);
comp_brand_size = atom.size - 8;
if (comp_brand_size < 0)
@@ -582,7 +582,7 @@ static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return AVERROR(ENOMEM);
get_buffer(pb, comp_brands_str, comp_brand_size);
comp_brands_str[comp_brand_size] = 0;
- av_metadata_set(&c->fc->metadata, "compatible_brands", comp_brands_str);
+ av_metadata_set2(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
av_freep(&comp_brands_str);
return 0;
@@ -637,7 +637,7 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
lang = get_be16(pb); /* language */
if (ff_mov_lang_to_iso639(lang, language))
- av_metadata_set(&st->metadata, "language", language);
+ av_metadata_set2(&st->metadata, "language", language, 0);
get_be16(pb); /* quality */
return 0;
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index d594abc..c92a9c2 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -963,7 +963,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
language[1] = get8(&p, desc_end);
language[2] = get8(&p, desc_end);
language[3] = 0;
- av_metadata_set(&st->metadata, "language", language);
+ av_metadata_set2(&st->metadata, "language", language, 0);
break;
case 0x59: /* subtitling descriptor */
language[0] = get8(&p, desc_end);
@@ -974,14 +974,14 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
comp_page = get16(&p, desc_end);
anc_page = get16(&p, desc_end);
st->codec->sub_id = (anc_page << 16) | comp_page;
- av_metadata_set(&st->metadata, "language", language);
+ av_metadata_set2(&st->metadata, "language", language, 0);
break;
case 0x0a: /* ISO 639 language descriptor */
language[0] = get8(&p, desc_end);
language[1] = get8(&p, desc_end);
language[2] = get8(&p, desc_end);
language[3] = 0;
- av_metadata_set(&st->metadata, "language", language);
+ av_metadata_set2(&st->metadata, "language", language, 0);
break;
case 0x05: /* registration descriptor */
st->codec->codec_tag = bytestream_get_le32(&p);
@@ -1109,8 +1109,8 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
if (name) {
AVProgram *program = av_new_program(ts->stream, sid);
if(program) {
- av_metadata_set(&program->metadata, "name", name);
- av_metadata_set(&program->metadata, "provider_name", provider_name);
+ av_metadata_set2(&program->metadata, "name", name, 0);
+ av_metadata_set2(&program->metadata, "provider_name", provider_name, 0);
}
}
av_free(name);
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index b7e6ba2..44e5097 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -339,7 +339,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
break;
*p++ = '\0';
PRINT(("NSV NSVf INFO: %s='%s'\n", token, value));
- av_metadata_set(&s->metadata, token, value);
+ av_metadata_set2(&s->metadata, token, value, 0);
}
av_free(strings);
}
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 39f185e..522affb 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -452,7 +452,7 @@ static int decode_info_header(NUTContext *nut){
else metadata= &s->metadata;
if(metadata && strcasecmp(name,"Uses")
&& strcasecmp(name,"Depends") && strcasecmp(name,"Replaces"))
- av_metadata_set(metadata, name, str_value);
+ av_metadata_set2(metadata, name, str_value, 0);
}
}
diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 398ef62..556a32b 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -97,7 +97,7 @@ static int r3d_read_red1(AVFormatContext *s)
get_buffer(s->pb, filename, 257);
filename[sizeof(filename)-1] = 0;
- av_metadata_set(&st->metadata, "filename", filename);
+ av_metadata_set2(&st->metadata, "filename", filename, 0);
dprintf(s, "filename %s\n", filename);
dprintf(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 8fc0d96..f4603bf 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -121,7 +121,7 @@ static void rm_read_metadata(AVFormatContext *s, int wide)
for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
int len = wide ? get_be16(s->pb) : get_byte(s->pb);
get_strl(s->pb, buf, sizeof(buf), len);
- av_metadata_set(&s->metadata, ff_rm_metadata[i], buf);
+ av_metadata_set2(&s->metadata, ff_rm_metadata[i], buf, 0);
}
}
diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index b33d865..f0fba3e 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -131,11 +131,11 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
// for the text in a few cases; samples needed.)
error |= read_line(pb, line, sizeof(line)); // ARMovie
error |= read_line(pb, line, sizeof(line)); // movie name
- av_metadata_set(&s->metadata, "title" , line);
+ av_metadata_set2(&s->metadata, "title" , line, 0);
error |= read_line(pb, line, sizeof(line)); // date/copyright
- av_metadata_set(&s->metadata, "copyright", line);
+ av_metadata_set2(&s->metadata, "copyright", line, 0);
error |= read_line(pb, line, sizeof(line)); // author and other
- av_metadata_set(&s->metadata, "author" , line);
+ av_metadata_set2(&s->metadata, "author" , line, 0);
// video headers
vst = av_new_stream(s, 0);
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 06a6e9c..fec91f1 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -379,11 +379,11 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
}
break;
case 's':
- av_metadata_set(&s->metadata, "title", p);
+ av_metadata_set2(&s->metadata, "title", p, 0);
break;
case 'i':
if (s->nb_streams == 0) {
- av_metadata_set(&s->metadata, "comment", p);
+ av_metadata_set2(&s->metadata, "comment", p, 0);
break;
}
break;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 466d079..625a190 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2544,7 +2544,7 @@ AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int6
#if LIBAVFORMAT_VERSION_INT < (53<<16)
av_free(chapter->title);
#endif
- av_metadata_set(&chapter->metadata, "title", title);
+ av_metadata_set2(&chapter->metadata, "title", title, 0);
chapter->id = id;
chapter->time_base= time_base;
chapter->start = start;
--
1.7.0
More information about the ffmpeg-devel
mailing list