00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "avformat.h"
00022 #include "metadata.h"
00023 #include "libavutil/dict.h"
00024 #include "libavutil/avstring.h"
00025
00026 void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
00027 const AVMetadataConv *s_conv)
00028 {
00029
00030
00031 const AVMetadataConv *sc, *dc;
00032 AVDictionaryEntry *mtag = NULL;
00033 AVDictionary *dst = NULL;
00034 const char *key;
00035
00036 if (d_conv == s_conv)
00037 return;
00038
00039 while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) {
00040 key = mtag->key;
00041 if (s_conv)
00042 for (sc=s_conv; sc->native; sc++)
00043 if (!av_strcasecmp(key, sc->native)) {
00044 key = sc->generic;
00045 break;
00046 }
00047 if (d_conv)
00048 for (dc=d_conv; dc->native; dc++)
00049 if (!av_strcasecmp(key, dc->generic)) {
00050 key = dc->native;
00051 break;
00052 }
00053 av_dict_set(&dst, key, mtag->value, 0);
00054 }
00055 av_dict_free(pm);
00056 *pm = dst;
00057 }
00058
00059 void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
00060 const AVMetadataConv *s_conv)
00061 {
00062 int i;
00063 ff_metadata_conv(&ctx->metadata, d_conv, s_conv);
00064 for (i=0; i<ctx->nb_streams ; i++)
00065 ff_metadata_conv(&ctx->streams [i]->metadata, d_conv, s_conv);
00066 for (i=0; i<ctx->nb_chapters; i++)
00067 ff_metadata_conv(&ctx->chapters[i]->metadata, d_conv, s_conv);
00068 for (i=0; i<ctx->nb_programs; i++)
00069 ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv);
00070 }