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 #if FF_API_OLD_METADATA2
00027 AVDictionaryEntry *
00028 av_metadata_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
00029 {
00030 return av_dict_get(m, key, prev, flags);
00031 }
00032
00033 int av_metadata_set2(AVDictionary **pm, const char *key, const char *value, int flags)
00034 {
00035 return av_dict_set(pm, key, value, flags);
00036 }
00037
00038 void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
00039 const AVMetadataConv *s_conv)
00040 {
00041 return;
00042 }
00043
00044 void av_metadata_free(AVDictionary **pm)
00045 {
00046 av_dict_free(pm);
00047 }
00048
00049 void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags)
00050 {
00051 av_dict_copy(dst, src, flags);
00052 }
00053 #endif
00054
00055 void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
00056 const AVMetadataConv *s_conv)
00057 {
00058
00059
00060 const AVMetadataConv *sc, *dc;
00061 AVDictionaryEntry *mtag = NULL;
00062 AVDictionary *dst = NULL;
00063 const char *key;
00064
00065 if (d_conv == s_conv)
00066 return;
00067
00068 while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) {
00069 key = mtag->key;
00070 if (s_conv)
00071 for (sc=s_conv; sc->native; sc++)
00072 if (!av_strcasecmp(key, sc->native)) {
00073 key = sc->generic;
00074 break;
00075 }
00076 if (d_conv)
00077 for (dc=d_conv; dc->native; dc++)
00078 if (!av_strcasecmp(key, dc->generic)) {
00079 key = dc->native;
00080 break;
00081 }
00082 av_dict_set(&dst, key, mtag->value, 0);
00083 }
00084 av_dict_free(pm);
00085 *pm = dst;
00086 }
00087
00088 void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
00089 const AVMetadataConv *s_conv)
00090 {
00091 int i;
00092 ff_metadata_conv(&ctx->metadata, d_conv, s_conv);
00093 for (i=0; i<ctx->nb_streams ; i++)
00094 ff_metadata_conv(&ctx->streams [i]->metadata, d_conv, s_conv);
00095 for (i=0; i<ctx->nb_chapters; i++)
00096 ff_metadata_conv(&ctx->chapters[i]->metadata, d_conv, s_conv);
00097 for (i=0; i<ctx->nb_programs; i++)
00098 ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv);
00099 }
00100