Revision 03700d39

View differences:

doc/APIchanges
13 13

  
14 14
API changes, most recent first:
15 15

  
16
2010-10-15 - r25493 - lavf 52.83.0 - metadata API
17
  Change demuxers to export metadata in generic format and
18
  muxers to accept generic format. Deprecate the public
19
  conversion API.
20

  
16 21
2010-10-10 - r25441 - lavfi 1.49.0 - AVFilterLink.time_base
17 22
  Add time_base field to AVFilterLink.
18 23

  
libavformat/asfdec.c
659 659
        }
660 660
    }
661 661

  
662
    metadata_conv(&s->metadata, NULL, ff_asf_metadata_conv);
663

  
662 664
    return 0;
663 665
}
664 666

  
......
1235 1237
    asf_read_close,
1236 1238
    asf_read_seek,
1237 1239
    asf_read_pts,
1238
    .metadata_conv = ff_asf_metadata_conv,
1239 1240
};
libavformat/asfenc.c
279 279
    int bit_rate;
280 280
    int64_t duration;
281 281

  
282
    metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
283

  
282 284
    tags[0] = av_metadata_get(s->metadata, "title"    , NULL, 0);
283 285
    tags[1] = av_metadata_get(s->metadata, "author"   , NULL, 0);
284 286
    tags[2] = av_metadata_get(s->metadata, "copyright", NULL, 0);
......
870 872
    asf_write_trailer,
871 873
    .flags = AVFMT_GLOBALHEADER,
872 874
    .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0},
873
    .metadata_conv = ff_asf_metadata_conv,
874 875
};
875 876
#endif
876 877

  
......
892 893
    asf_write_trailer,
893 894
    .flags = AVFMT_GLOBALHEADER,
894 895
    .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0},
895
    .metadata_conv = ff_asf_metadata_conv,
896 896
};
897 897
#endif //CONFIG_ASF_STREAM_MUXER
libavformat/avformat.h
22 22
#define AVFORMAT_AVFORMAT_H
23 23

  
24 24
#define LIBAVFORMAT_VERSION_MAJOR 52
25
#define LIBAVFORMAT_VERSION_MINOR 82
25
#define LIBAVFORMAT_VERSION_MINOR 83
26 26
#define LIBAVFORMAT_VERSION_MICRO  0
27 27

  
28 28
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
......
137 137
 *       sorting will have '-sort' appended. E.g. artist="The Beatles",
138 138
 *       artist-sort="Beatles, The".
139 139
 *
140
 * 4. Tag names are normally exported exactly as stored in the container to
141
 *    allow lossless remuxing to the same format. For container-independent
142
 *    handling of metadata, av_metadata_conv() can convert it to ffmpeg generic
143
 *    format. Follows a list of generic tag names:
140
 * 4. Demuxers attempt to export metadata in a generic format, however tags
141
 *    with no generic equivalents are left as they are stored in the container.
142
 *    Follows a list of generic tag names:
144 143
 *
145 144
 * album        -- name of the set this work belongs to
146 145
 * album_artist -- main creator of the set/album, if different from artist.
......
177 176
}AVMetadataTag;
178 177

  
179 178
typedef struct AVMetadata AVMetadata;
179
#if FF_API_OLD_METADATA
180 180
typedef struct AVMetadataConv AVMetadataConv;
181
#endif
181 182

  
182 183
/**
183 184
 * Get a metadata element with matching key.
......
216 217
 */
217 218
int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
218 219

  
220
#if FF_API_OLD_METADATA
219 221
/**
220
 * Convert all the metadata sets from ctx according to the source and
221
 * destination conversion tables. If one of the tables is NULL, then
222
 * tags are converted to/from ffmpeg generic tag names.
223
 *
224
 * @param d_conv destination tags format conversion table
225
 * @param s_conv source tags format conversion table
222
 * This function is provided for compatibility reason and currently does nothing.
226 223
 */
227
void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
228
                                                   const AVMetadataConv *s_conv);
224
attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
225
                                                                        const AVMetadataConv *s_conv);
226
#endif
229 227

  
230 228
/**
231 229
 * Free all the memory allocated for an AVMetadata struct.
......
349 347

  
350 348
    enum CodecID subtitle_codec; /**< default subtitle codec */
351 349

  
350
#if FF_API_OLD_METADATA
352 351
    const AVMetadataConv *metadata_conv;
352
#endif
353 353

  
354 354
    /* private fields */
355 355
    struct AVOutputFormat *next;
......
465 465
     */
466 466
    int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
467 467

  
468
#if FF_API_OLD_METADATA
468 469
    const AVMetadataConv *metadata_conv;
470
#endif
469 471

  
470 472
    /* private fields */
471 473
    struct AVInputFormat *next;
libavformat/avidec.c
693 693
        clean_index(s);
694 694
    }
695 695

  
696
    ff_metadata_conv_ctx(s, NULL, ff_avi_metadata_conv);
697

  
696 698
    return 0;
697 699
}
698 700

  
......
1332 1334
    avi_read_packet,
1333 1335
    avi_read_close,
1334 1336
    avi_read_seek,
1335
    .metadata_conv = ff_avi_metadata_conv,
1336 1337
};
libavformat/avienc.c
290 290
            return -1;
291 291
        }
292 292
        ff_end_tag(pb, strf);
293
        if ((t = av_metadata_get(s->streams[i]->metadata, "strn", NULL, 0))) {
294
            avi_write_info_tag(s->pb, t->key, t->value);
295
            t = NULL;
296
        }
297
        //FIXME a limitation of metadata conversion system
298
        else if ((t = av_metadata_get(s->streams[i]->metadata, "INAM", NULL, 0))) {
293
        if ((t = av_metadata_get(s->streams[i]->metadata, "title", NULL, 0))) {
299 294
            avi_write_info_tag(s->pb, "strn", t->value);
300 295
            t = NULL;
301 296
        }
......
375 370

  
376 371
    list2 = ff_start_tag(pb, "LIST");
377 372
    put_tag(pb, "INFO");
373
    metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL);
378 374
    for (i = 0; *ff_avi_tags[i]; i++) {
379 375
        if ((t = av_metadata_get(s->metadata, ff_avi_tags[i], NULL, AV_METADATA_MATCH_CASE)))
380 376
            avi_write_info_tag(s->pb, t->key, t->value);
......
647 643
    avi_write_trailer,
648 644
    .codec_tag= (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
649 645
    .flags= AVFMT_VARIABLE_FPS,
650
    .metadata_conv = ff_avi_metadata_conv,
651 646
};
libavformat/flacdec.c
133 133
    .flags= AVFMT_GENERIC_INDEX,
134 134
    .extensions = "flac",
135 135
    .value = CODEC_ID_FLAC,
136
    .metadata_conv = ff_vorbiscomment_metadata_conv,
137 136
};
libavformat/flacenc.c
128 128
    flac_write_packet,
129 129
    flac_write_trailer,
130 130
    .flags= AVFMT_NOTIMESTAMPS,
131
    .metadata_conv = ff_vorbiscomment_metadata_conv,
132 131
};
libavformat/id3v2.c
23 23
#include "id3v1.h"
24 24
#include "libavutil/avstring.h"
25 25
#include "libavutil/intreadwrite.h"
26
#include "metadata.h"
26 27

  
27 28
int ff_id3v2_match(const uint8_t *buf, const char * magic)
28 29
{
......
249 250
        /* Skip to end of tag */
250 251
        url_fseek(s->pb, next, SEEK_SET);
251 252
    }
253
    metadata_conv(&s->metadata, NULL, ff_id3v2_metadata_conv);
252 254

  
253 255
    if (len > 0) {
254 256
        /* Skip padding */
libavformat/matroskadec.c
1048 1048
                matroska_convert_tag(s, &tags[i].sub, metadata, key);
1049 1049
        }
1050 1050
    }
1051
    metadata_conv(metadata, NULL, ff_mkv_metadata_conv);
1051 1052
}
1052 1053

  
1053 1054
static void matroska_convert_tags(AVFormatContext *s)
......
1923 1924
    matroska_read_packet,
1924 1925
    matroska_read_close,
1925 1926
    matroska_read_seek,
1926
    .metadata_conv = ff_mkv_metadata_conv,
1927 1927
};
libavformat/matroskaenc.c
752 752
    ebml_master tags = {0};
753 753
    int i, ret;
754 754

  
755
    ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL);
756

  
755 757
    if (av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) {
756 758
        ret = mkv_write_tag(s, s->metadata, 0, 0, &tags);
757 759
        if (ret < 0) return ret;
......
1186 1188
    .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
1187 1189
    .codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
1188 1190
    .subtitle_codec = CODEC_ID_TEXT,
1189
    .metadata_conv = ff_mkv_metadata_conv,
1190 1191
};
1191 1192
#endif
1192 1193

  
......
1220 1221
    mkv_write_trailer,
1221 1222
    .flags = AVFMT_GLOBALHEADER,
1222 1223
    .codec_tag = (const AVCodecTag* const []){ff_codec_wav_tags, 0},
1223
    .metadata_conv = ff_mkv_metadata_conv,
1224 1224
};
1225 1225
#endif
libavformat/metadata.c
91 91
{
92 92
    return av_metadata_set2(pm, key, value, 0);
93 93
}
94

  
95
void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
96
                                            const AVMetadataConv *s_conv)
97
{
98
    return;
99
}
94 100
#endif
95 101

  
96 102
void av_metadata_free(AVMetadata **pm)
......
140 146
    *pm = dst;
141 147
}
142 148

  
143
void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
144
                                            const AVMetadataConv *s_conv)
149
void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
150
                                                const AVMetadataConv *s_conv)
145 151
{
146 152
    int i;
147 153
    metadata_conv(&ctx->metadata, d_conv, s_conv);
libavformat/metadata.h
39 39
    const char *native;
40 40
    const char *generic;
41 41
};
42
#if !FF_API_OLD_METADATA
43
typedef struct AVMetadataConv AVMetadataConv;
44
#endif
42 45

  
43 46
#if FF_API_OLD_METADATA
44 47
void ff_metadata_demux_compat(AVFormatContext *s);
......
47 50

  
48 51
void metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv,
49 52
                                    const AVMetadataConv *s_conv);
53
void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
54
                                                const AVMetadataConv *s_conv);
50 55

  
51 56
#endif /* AVFORMAT_METADATA_H */
libavformat/mp3.c
195 195
    mp3_read_packet,
196 196
    .flags= AVFMT_GENERIC_INDEX,
197 197
    .extensions = "mp2,mp3,m2a", /* XXX: use probe */
198
    .metadata_conv = ff_id3v2_metadata_conv,
199 198
};
200 199
#endif
201 200

  
......
294 293
    NULL,
295 294
    mp3_write_packet,
296 295
    mp3_write_trailer,
297
    .metadata_conv = ff_id3v2_metadata_conv,
298 296
};
299 297
#endif
300 298

  
......
317 315
    size_pos = url_ftell(s->pb);
318 316
    put_be32(s->pb, 0);
319 317

  
318
    metadata_conv(&s->metadata, ff_id3v2_metadata_conv, NULL);
320 319
    while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
321 320
        uint32_t tag = 0;
322 321

  
......
366 365
    mp3_write_packet,
367 366
    mp3_write_trailer,
368 367
    AVFMT_NOTIMESTAMPS,
369
    .metadata_conv = ff_id3v2_metadata_conv,
370 368
};
371 369
#endif
libavformat/nutdec.c
656 656
    }
657 657
    assert(nut->next_startcode == SYNCPOINT_STARTCODE);
658 658

  
659
    ff_metadata_conv_ctx(s, NULL, ff_nut_metadata_conv);
660

  
659 661
    return 0;
660 662
}
661 663

  
......
931 933
    nut_read_close,
932 934
    read_seek,
933 935
    .extensions = "nut",
934
    .metadata_conv = ff_nut_metadata_conv,
935 936
    .codec_tag = (const AVCodecTag * const []) { ff_codec_bmp_tags, ff_nut_video_tags, ff_codec_wav_tags, ff_nut_subtitle_tags, 0 },
936 937
};
937 938
#endif
libavformat/nutenc.c
491 491
    ByteIOContext *dyn_bc;
492 492
    int i, ret;
493 493

  
494
    ff_metadata_conv_ctx(avctx, ff_nut_metadata_conv, NULL);
495

  
494 496
    ret = url_open_dyn_buf(&dyn_bc);
495 497
    if(ret < 0)
496 498
        return ret;
......
810 812
    write_trailer,
811 813
    .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
812 814
    .codec_tag = (const AVCodecTag * const []){ ff_codec_bmp_tags, ff_nut_video_tags, ff_codec_wav_tags, ff_nut_subtitle_tags, 0 },
813
    .metadata_conv = ff_nut_metadata_conv,
814 815
};
libavformat/oggdec.c
641 641
    ogg_read_seek,
642 642
    ogg_read_timestamp,
643 643
    .extensions = "ogg",
644
    .metadata_conv = ff_vorbiscomment_metadata_conv,
645 644
    .flags = AVFMT_GENERIC_INDEX,
646 645
};
libavformat/oggenc.c
495 495
    ogg_write_header,
496 496
    ogg_write_packet,
497 497
    ogg_write_trailer,
498
    .metadata_conv = ff_vorbiscomment_metadata_conv,
499 498
};
libavformat/oggparsevorbis.c
29 29
#include "libavcodec/bytestream.h"
30 30
#include "avformat.h"
31 31
#include "oggdec.h"
32
#include "vorbiscomment.c"
32 33

  
33 34
static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
34 35
{
......
137 138
        av_log(as, AV_LOG_INFO,
138 139
               "truncated comment header, %i comments not found\n", n);
139 140

  
141
    metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv);
142

  
140 143
    return 0;
141 144
}
142 145

  
libavformat/oma.c
201 201
    .flags= AVFMT_GENERIC_INDEX,
202 202
    .extensions = "oma,aa3",
203 203
    .codec_tag= (const AVCodecTag* const []){codec_oma_tags, 0},
204
    .metadata_conv = ff_id3v2_metadata_conv,
205 204
};
206 205

  
libavformat/vorbiscomment.c
55 55
int ff_vorbiscomment_write(uint8_t **p, AVMetadata **m,
56 56
                           const char *vendor_string, const unsigned count)
57 57
{
58
    metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
58 59
    bytestream_put_le32(p, strlen(vendor_string));
59 60
    bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
60 61
    if (*m) {

Also available in: Unified diff