2 * copyright (c) 2009 Michael Niedermayer
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "libavutil/dict.h"
26 #if FF_API_OLD_METADATA2
28 av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
30 return av_dict_get(m, key, prev, flags);
33 int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags)
35 return av_dict_set(pm, key, value, flags);
38 void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
39 const AVMetadataConv *s_conv)
44 void av_metadata_free(AVDictionary **pm)
49 void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags)
51 av_dict_copy(dst, src, flags);
55 void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
56 const AVMetadataConv *s_conv)
58 /* TODO: use binary search to look up the two conversion tables
59 if the tables are getting big enough that it would matter speed wise */
60 const AVMetadataConv *sc, *dc;
61 AVDictionaryEntry *mtag = NULL;
62 AVDictionary *dst = NULL;
68 while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) {
71 for (sc=s_conv; sc->native; sc++)
72 if (!strcasecmp(key, sc->native)) {
77 for (dc=d_conv; dc->native; dc++)
78 if (!strcasecmp(key, dc->generic)) {
82 av_dict_set(&dst, key, mtag->value, 0);
88 void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
89 const AVMetadataConv *s_conv)
92 ff_metadata_conv(&ctx->metadata, d_conv, s_conv);
93 for (i=0; i<ctx->nb_streams ; i++)
94 ff_metadata_conv(&ctx->streams [i]->metadata, d_conv, s_conv);
95 for (i=0; i<ctx->nb_chapters; i++)
96 ff_metadata_conv(&ctx->chapters[i]->metadata, d_conv, s_conv);
97 for (i=0; i<ctx->nb_programs; i++)
98 ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv);