00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <strings.h>
00022 #include "avformat.h"
00023 #include "metadata.h"
00024 #include "libavutil/dict.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 #endif
00038 #if FF_API_OLD_METADATA
00039 int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
00040 {
00041 return av_metadata_set2(pm, key, value, 0);
00042 }
00043 #endif
00044
00045 #if FF_API_OLD_METADATA2
00046
00047 void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv,
00048 const AVMetadataConv *s_conv)
00049 {
00050 return;
00051 }
00052
00053 void av_metadata_free(AVDictionary **pm)
00054 {
00055 av_dict_free(pm);
00056 }
00057
00058 void av_metadata_copy(AVDictionary **dst, AVDictionary *src, int flags)
00059 {
00060 av_dict_copy(dst, src, flags);
00061 }
00062 #endif
00063
00064 void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
00065 const AVMetadataConv *s_conv)
00066 {
00067
00068
00069 const AVMetadataConv *sc, *dc;
00070 AVDictionaryEntry *mtag = NULL;
00071 AVDictionary *dst = NULL;
00072 const char *key;
00073
00074 if (d_conv == s_conv)
00075 return;
00076
00077 while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) {
00078 key = mtag->key;
00079 if (s_conv)
00080 for (sc=s_conv; sc->native; sc++)
00081 if (!strcasecmp(key, sc->native)) {
00082 key = sc->generic;
00083 break;
00084 }
00085 if (d_conv)
00086 for (dc=d_conv; dc->native; dc++)
00087 if (!strcasecmp(key, dc->generic)) {
00088 key = dc->native;
00089 break;
00090 }
00091 av_dict_set(&dst, key, mtag->value, 0);
00092 }
00093 av_dict_free(pm);
00094 *pm = dst;
00095 }
00096
00097 void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
00098 const AVMetadataConv *s_conv)
00099 {
00100 int i;
00101 ff_metadata_conv(&ctx->metadata, d_conv, s_conv);
00102 for (i=0; i<ctx->nb_streams ; i++)
00103 ff_metadata_conv(&ctx->streams [i]->metadata, d_conv, s_conv);
00104 for (i=0; i<ctx->nb_chapters; i++)
00105 ff_metadata_conv(&ctx->chapters[i]->metadata, d_conv, s_conv);
00106 for (i=0; i<ctx->nb_programs; i++)
00107 ff_metadata_conv(&ctx->programs[i]->metadata, d_conv, s_conv);
00108 }
00109