Browse code

Mark av_metadata_set() as deprecated, and use av_metadata_set2() in its place.

av_metadata_set() is going to be dropped at the next major bump.

Originally committed as revision 22961 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini authored on 2010/04/25 23:27:42
Showing 20 changed files
... ...
@@ -3287,7 +3287,7 @@ static void new_video_stream(AVFormatContext *oc)
3287 3287
     }
3288 3288
     nb_ocodecs++;
3289 3289
     if (video_language) {
3290
-        av_metadata_set(&st->metadata, "language", video_language);
3290
+        av_metadata_set2(&st->metadata, "language", video_language, 0);
3291 3291
         av_freep(&video_language);
3292 3292
     }
3293 3293
 
... ...
@@ -3361,7 +3361,7 @@ static void new_audio_stream(AVFormatContext *oc)
3361 3361
     nb_ocodecs++;
3362 3362
     audio_enc->time_base= (AVRational){1, audio_sample_rate};
3363 3363
     if (audio_language) {
3364
-        av_metadata_set(&st->metadata, "language", audio_language);
3364
+        av_metadata_set2(&st->metadata, "language", audio_language, 0);
3365 3365
         av_freep(&audio_language);
3366 3366
     }
3367 3367
 
... ...
@@ -3402,7 +3402,7 @@ static void new_subtitle_stream(AVFormatContext *oc)
3402 3402
     nb_ocodecs++;
3403 3403
 
3404 3404
     if (subtitle_language) {
3405
-        av_metadata_set(&st->metadata, "language", subtitle_language);
3405
+        av_metadata_set2(&st->metadata, "language", subtitle_language, 0);
3406 3406
         av_freep(&subtitle_language);
3407 3407
     }
3408 3408
 
... ...
@@ -3533,8 +3533,8 @@ static void opt_output_file(const char *filename)
3533 3533
         oc->timestamp = rec_timestamp;
3534 3534
 
3535 3535
         for(; metadata_count>0; metadata_count--){
3536
-            av_metadata_set(&oc->metadata, metadata[metadata_count-1].key,
3537
-                                           metadata[metadata_count-1].value);
3536
+            av_metadata_set2(&oc->metadata, metadata[metadata_count-1].key,
3537
+                                            metadata[metadata_count-1].value, 0);
3538 3538
         }
3539 3539
         av_metadata_conv(oc, oc->oformat->metadata_conv, NULL);
3540 3540
     }
... ...
@@ -2232,10 +2232,10 @@ static int http_prepare_data(HTTPContext *c)
2232 2232
     switch(c->state) {
2233 2233
     case HTTPSTATE_SEND_DATA_HEADER:
2234 2234
         memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx));
2235
-        av_metadata_set(&c->fmt_ctx.metadata, "author"   ,c->stream->author);
2236
-        av_metadata_set(&c->fmt_ctx.metadata, "comment"  ,c->stream->comment);
2237
-        av_metadata_set(&c->fmt_ctx.metadata, "copyright",c->stream->copyright);
2238
-        av_metadata_set(&c->fmt_ctx.metadata, "title"    ,c->stream->title);
2235
+        av_metadata_set2(&c->fmt_ctx.metadata, "author"   , c->stream->author   , 0);
2236
+        av_metadata_set2(&c->fmt_ctx.metadata, "comment"  , c->stream->comment  , 0);
2237
+        av_metadata_set2(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
2238
+        av_metadata_set2(&c->fmt_ctx.metadata, "title"    , c->stream->title    , 0);
2239 2239
 
2240 2240
         for(i=0;i<c->stream->nb_streams;i++) {
2241 2241
             AVStream *st;
... ...
@@ -2939,8 +2939,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
2939 2939
     if (avc == NULL) {
2940 2940
         return -1;
2941 2941
     }
2942
-    av_metadata_set(&avc->metadata, "title",
2943
-                    stream->title[0] ? stream->title : "No Title");
2942
+    av_metadata_set2(&avc->metadata, "title",
2943
+                     stream->title[0] ? stream->title : "No Title", 0);
2944 2944
     avc->nb_streams = stream->nb_streams;
2945 2945
     if (stream->is_multicast) {
2946 2946
         snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d",
... ...
@@ -616,7 +616,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
616 616
                     const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any
617 617
                     const char *iso6392 = av_convert_lang_to(primary_tag, AV_LANG_ISO639_2_BIBL);
618 618
                     if (iso6392)
619
-                        av_metadata_set(&st->metadata, "language", iso6392);
619
+                        av_metadata_set2(&st->metadata, "language", iso6392, 0);
620 620
                 }
621 621
             }
622 622
         }
... ...
@@ -145,8 +145,9 @@ av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int f
145 145
  * @param key tag key to add to m (will be av_strduped)
146 146
  * @param value tag value to add to m (will be av_strduped)
147 147
  * @return >= 0 on success otherwise an error code <0
148
+ * @deprecated Use av_metadata_set2() instead.
148 149
  */
149
-int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
150
+attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
150 151
 #endif
151 152
 
152 153
 /**
... ...
@@ -172,7 +172,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size)
172 172
         char value[1024];
173 173
         get_strz(pb, key, sizeof(key));
174 174
         get_strz(pb, value, sizeof(value));
175
-        av_metadata_set(&s->metadata, key, value);
175
+        av_metadata_set2(&s->metadata, key, value, 0);
176 176
     }
177 177
 }
178 178
 
... ...
@@ -188,17 +188,17 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
188 188
 
189 189
         if(amf_type == AMF_DATA_TYPE_BOOL) {
190 190
             av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val));
191
-            av_metadata_set(&s->metadata, key, str_val);
191
+            av_metadata_set2(&s->metadata, key, str_val, 0);
192 192
         } else if(amf_type == AMF_DATA_TYPE_NUMBER) {
193 193
             snprintf(str_val, sizeof(str_val), "%.f", num_val);
194
-            av_metadata_set(&s->metadata, key, str_val);
194
+            av_metadata_set2(&s->metadata, key, str_val, 0);
195 195
             if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
196 196
             else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0))
197 197
                 vcodec->bit_rate = num_val * 1024.0;
198 198
             else if(!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0))
199 199
                 acodec->bit_rate = num_val * 1024.0;
200 200
         } else if (amf_type == AMF_DATA_TYPE_STRING)
201
-          av_metadata_set(&s->metadata, key, str_val);
201
+            av_metadata_set2(&s->metadata, key, str_val, 0);
202 202
     }
203 203
 
204 204
     return 0;
... ...
@@ -192,7 +192,7 @@ static void get_string(AVFormatContext *s, const char *key,
192 192
     *q = '\0';
193 193
 
194 194
     if (*str)
195
-        av_metadata_set(&s->metadata, key, str);
195
+        av_metadata_set2(&s->metadata, key, str, 0);
196 196
 }
197 197
 
198 198
 /**
... ...
@@ -217,7 +217,7 @@ static int parse_tag(AVFormatContext *s, const uint8_t *buf)
217 217
         av_metadata_set2(&s->metadata, "track", av_d2str(buf[126]), AV_METADATA_DONT_STRDUP_VAL);
218 218
     genre = buf[127];
219 219
     if (genre <= ID3v1_GENRE_MAX)
220
-        av_metadata_set(&s->metadata, "genre", ff_id3v1_genre_str[genre]);
220
+        av_metadata_set2(&s->metadata, "genre", ff_id3v1_genre_str[genre], 0);
221 221
     return 0;
222 222
 }
223 223
 
... ...
@@ -150,7 +150,7 @@ static void read_ttag(AVFormatContext *s, int taglen, const char *key)
150 150
         val = dst;
151 151
 
152 152
     if (val)
153
-        av_metadata_set(&s->metadata, key, val);
153
+        av_metadata_set2(&s->metadata, key, val, 0);
154 154
 }
155 155
 
156 156
 void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
... ...
@@ -1001,14 +1001,14 @@ static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
1001 1001
         if (prefix)  snprintf(key, sizeof(key), "%s/%s", prefix, tags[i].name);
1002 1002
         else         av_strlcpy(key, tags[i].name, sizeof(key));
1003 1003
         if (tags[i].def || !lang) {
1004
-        av_metadata_set(metadata, key, tags[i].string);
1004
+        av_metadata_set2(metadata, key, tags[i].string, 0);
1005 1005
         if (tags[i].sub.nb_elem)
1006 1006
             matroska_convert_tag(s, &tags[i].sub, metadata, key);
1007 1007
         }
1008 1008
         if (lang) {
1009 1009
             av_strlcat(key, "-", sizeof(key));
1010 1010
             av_strlcat(key, lang, sizeof(key));
1011
-            av_metadata_set(metadata, key, tags[i].string);
1011
+            av_metadata_set2(metadata, key, tags[i].string, 0);
1012 1012
             if (tags[i].sub.nb_elem)
1013 1013
                 matroska_convert_tag(s, &tags[i].sub, metadata, key);
1014 1014
         }
... ...
@@ -1157,7 +1157,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
1157 1157
     if (matroska->duration)
1158 1158
         matroska->ctx->duration = matroska->duration * matroska->time_scale
1159 1159
                                   * 1000 / AV_TIME_BASE;
1160
-    av_metadata_set(&s->metadata, "title", matroska->title);
1160
+    av_metadata_set2(&s->metadata, "title", matroska->title, 0);
1161 1161
 
1162 1162
     tracks = matroska->tracks.elem;
1163 1163
     for (i=0; i < matroska->tracks.nb_elem; i++) {
... ...
@@ -1352,8 +1352,8 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
1352 1352
         st->codec->codec_id = codec_id;
1353 1353
         st->start_time = 0;
1354 1354
         if (strcmp(track->language, "und"))
1355
-            av_metadata_set(&st->metadata, "language", track->language);
1356
-        av_metadata_set(&st->metadata, "title", track->name);
1355
+            av_metadata_set2(&st->metadata, "language", track->language, 0);
1356
+        av_metadata_set2(&st->metadata, "title", track->name, 0);
1357 1357
 
1358 1358
         if (track->flag_default)
1359 1359
             st->disposition |= AV_DISPOSITION_DEFAULT;
... ...
@@ -1410,7 +1410,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
1410 1410
             AVStream *st = av_new_stream(s, 0);
1411 1411
             if (st == NULL)
1412 1412
                 break;
1413
-            av_metadata_set(&st->metadata, "filename",attachements[j].filename);
1413
+            av_metadata_set2(&st->metadata, "filename",attachements[j].filename, 0);
1414 1414
             st->codec->codec_id = CODEC_ID_NONE;
1415 1415
             st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
1416 1416
             st->codec->extradata  = av_malloc(attachements[j].bin.size);
... ...
@@ -1438,8 +1438,8 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap)
1438 1438
             ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000},
1439 1439
                            chapters[i].start, chapters[i].end,
1440 1440
                            chapters[i].title);
1441
-            av_metadata_set(&chapters[i].chapter->metadata,
1442
-                            "title", chapters[i].title);
1441
+            av_metadata_set2(&chapters[i].chapter->metadata,
1442
+                             "title", chapters[i].title, 0);
1443 1443
             max_start = chapters[i].start;
1444 1444
         }
1445 1445
 
... ...
@@ -133,7 +133,7 @@ void metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
133 133
                         break;
134 134
                     }
135 135
         }
136
-        av_metadata_set(&dst, key, mtag->value);
136
+        av_metadata_set2(&dst, key, mtag->value, 0);
137 137
     }
138 138
     av_metadata_free(pm);
139 139
     *pm = dst;
... ...
@@ -109,7 +109,7 @@ void ff_metadata_demux_compat(AVFormatContext *ctx)
109 109
 
110 110
 #define FILL_METADATA(s, key, value) {                                        \
111 111
     if (value && *value && !av_metadata_get(s->metadata, #key, NULL, 0))      \
112
-        av_metadata_set(&s->metadata, #key, value);                           \
112
+        av_metadata_set2(&s->metadata, #key, value, 0);                       \
113 113
     }
114 114
 #define FILL_METADATA_STR(s, key)  FILL_METADATA(s, key, s->key)
115 115
 #define FILL_METADATA_INT(s, key) {                                           \
... ...
@@ -86,7 +86,7 @@ static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len)
86 86
 
87 87
     get_be16(pb); // unknown
88 88
     snprintf(buf, sizeof(buf), "%d", get_be16(pb));
89
-    av_metadata_set(&c->fc->metadata, "track", buf);
89
+    av_metadata_set2(&c->fc->metadata, "track", buf, 0);
90 90
 
91 91
     get_be16(pb); // total tracks
92 92
 
... ...
@@ -204,10 +204,10 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
204 204
             get_buffer(pb, str, str_size);
205 205
             str[str_size] = 0;
206 206
         }
207
-        av_metadata_set(&c->fc->metadata, key, str);
207
+        av_metadata_set2(&c->fc->metadata, key, str, 0);
208 208
         if (*language && strcmp(language, "und")) {
209 209
             snprintf(key2, sizeof(key2), "%s-%s", key, language);
210
-            av_metadata_set(&c->fc->metadata, key2, str);
210
+            av_metadata_set2(&c->fc->metadata, key2, str, 0);
211 211
         }
212 212
     }
213 213
 #ifdef DEBUG_METADATA
... ...
@@ -569,10 +569,10 @@ static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
569 569
     if (strcmp(type, "qt  "))
570 570
         c->isom = 1;
571 571
     av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
572
-    av_metadata_set(&c->fc->metadata, "major_brand", type);
572
+    av_metadata_set2(&c->fc->metadata, "major_brand", type, 0);
573 573
     minor_ver = get_be32(pb); /* minor version */
574 574
     snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
575
-    av_metadata_set(&c->fc->metadata, "minor_version", minor_ver_str);
575
+    av_metadata_set2(&c->fc->metadata, "minor_version", minor_ver_str, 0);
576 576
 
577 577
     comp_brand_size = atom.size - 8;
578 578
     if (comp_brand_size < 0)
... ...
@@ -582,7 +582,7 @@ static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
582 582
         return AVERROR(ENOMEM);
583 583
     get_buffer(pb, comp_brands_str, comp_brand_size);
584 584
     comp_brands_str[comp_brand_size] = 0;
585
-    av_metadata_set(&c->fc->metadata, "compatible_brands", comp_brands_str);
585
+    av_metadata_set2(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
586 586
     av_freep(&comp_brands_str);
587 587
 
588 588
     return 0;
... ...
@@ -637,7 +637,7 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
637 637
 
638 638
     lang = get_be16(pb); /* language */
639 639
     if (ff_mov_lang_to_iso639(lang, language))
640
-        av_metadata_set(&st->metadata, "language", language);
640
+        av_metadata_set2(&st->metadata, "language", language, 0);
641 641
     get_be16(pb); /* quality */
642 642
 
643 643
     return 0;
... ...
@@ -963,7 +963,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
963 963
                 language[1] = get8(&p, desc_end);
964 964
                 language[2] = get8(&p, desc_end);
965 965
                 language[3] = 0;
966
-                av_metadata_set(&st->metadata, "language", language);
966
+                av_metadata_set2(&st->metadata, "language", language, 0);
967 967
                 break;
968 968
             case 0x59: /* subtitling descriptor */
969 969
                 language[0] = get8(&p, desc_end);
... ...
@@ -974,14 +974,14 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
974 974
                 comp_page = get16(&p, desc_end);
975 975
                 anc_page = get16(&p, desc_end);
976 976
                 st->codec->sub_id = (anc_page << 16) | comp_page;
977
-                av_metadata_set(&st->metadata, "language", language);
977
+                av_metadata_set2(&st->metadata, "language", language, 0);
978 978
                 break;
979 979
             case 0x0a: /* ISO 639 language descriptor */
980 980
                 language[0] = get8(&p, desc_end);
981 981
                 language[1] = get8(&p, desc_end);
982 982
                 language[2] = get8(&p, desc_end);
983 983
                 language[3] = 0;
984
-                av_metadata_set(&st->metadata, "language", language);
984
+                av_metadata_set2(&st->metadata, "language", language, 0);
985 985
                 break;
986 986
             case 0x05: /* registration descriptor */
987 987
                 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
1109 1109
                 if (name) {
1110 1110
                     AVProgram *program = av_new_program(ts->stream, sid);
1111 1111
                     if(program) {
1112
-                        av_metadata_set(&program->metadata, "name", name);
1113
-                        av_metadata_set(&program->metadata, "provider_name", provider_name);
1112
+                        av_metadata_set2(&program->metadata, "name", name, 0);
1113
+                        av_metadata_set2(&program->metadata, "provider_name", provider_name, 0);
1114 1114
                     }
1115 1115
                 }
1116 1116
                 av_free(name);
... ...
@@ -339,7 +339,7 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
339 339
                 break;
340 340
             *p++ = '\0';
341 341
             PRINT(("NSV NSVf INFO: %s='%s'\n", token, value));
342
-            av_metadata_set(&s->metadata, token, value);
342
+            av_metadata_set2(&s->metadata, token, value, 0);
343 343
         }
344 344
         av_free(strings);
345 345
     }
... ...
@@ -452,7 +452,7 @@ static int decode_info_header(NUTContext *nut){
452 452
             else                      metadata= &s->metadata;
453 453
             if(metadata && strcasecmp(name,"Uses")
454 454
                && strcasecmp(name,"Depends") && strcasecmp(name,"Replaces"))
455
-                av_metadata_set(metadata, name, str_value);
455
+                av_metadata_set2(metadata, name, str_value, 0);
456 456
         }
457 457
     }
458 458
 
... ...
@@ -97,7 +97,7 @@ static int r3d_read_red1(AVFormatContext *s)
97 97
 
98 98
     get_buffer(s->pb, filename, 257);
99 99
     filename[sizeof(filename)-1] = 0;
100
-    av_metadata_set(&st->metadata, "filename", filename);
100
+    av_metadata_set2(&st->metadata, "filename", filename, 0);
101 101
 
102 102
     dprintf(s, "filename %s\n", filename);
103 103
     dprintf(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
... ...
@@ -121,7 +121,7 @@ static void rm_read_metadata(AVFormatContext *s, int wide)
121 121
     for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
122 122
         int len = wide ? get_be16(s->pb) : get_byte(s->pb);
123 123
         get_strl(s->pb, buf, sizeof(buf), len);
124
-        av_metadata_set(&s->metadata, ff_rm_metadata[i], buf);
124
+        av_metadata_set2(&s->metadata, ff_rm_metadata[i], buf, 0);
125 125
     }
126 126
 }
127 127
 
... ...
@@ -131,11 +131,11 @@ static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
131 131
     // for the text in a few cases; samples needed.)
132 132
     error |= read_line(pb, line, sizeof(line));      // ARMovie
133 133
     error |= read_line(pb, line, sizeof(line));      // movie name
134
-    av_metadata_set(&s->metadata, "title"    , line);
134
+    av_metadata_set2(&s->metadata, "title"    , line, 0);
135 135
     error |= read_line(pb, line, sizeof(line));      // date/copyright
136
-    av_metadata_set(&s->metadata, "copyright", line);
136
+    av_metadata_set2(&s->metadata, "copyright", line, 0);
137 137
     error |= read_line(pb, line, sizeof(line));      // author and other
138
-    av_metadata_set(&s->metadata, "author"   , line);
138
+    av_metadata_set2(&s->metadata, "author"   , line, 0);
139 139
 
140 140
     // video headers
141 141
     vst = av_new_stream(s, 0);
... ...
@@ -379,11 +379,11 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
379 379
         }
380 380
         break;
381 381
     case 's':
382
-        av_metadata_set(&s->metadata, "title", p);
382
+        av_metadata_set2(&s->metadata, "title", p, 0);
383 383
         break;
384 384
     case 'i':
385 385
         if (s->nb_streams == 0) {
386
-            av_metadata_set(&s->metadata, "comment", p);
386
+            av_metadata_set2(&s->metadata, "comment", p, 0);
387 387
             break;
388 388
         }
389 389
         break;
... ...
@@ -2544,7 +2544,7 @@ AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int6
2544 2544
 #if LIBAVFORMAT_VERSION_INT < (53<<16)
2545 2545
     av_free(chapter->title);
2546 2546
 #endif
2547
-    av_metadata_set(&chapter->metadata, "title", title);
2547
+    av_metadata_set2(&chapter->metadata, "title", title, 0);
2548 2548
     chapter->id    = id;
2549 2549
     chapter->time_base= time_base;
2550 2550
     chapter->start = start;