comparison metadata.c @ 4158:ea1e24175669 libavformat

Add a metadata compatibility layer, so that when a user application set metadata using old API, it is automatically converted to new API before muxing.
author aurel
date Tue, 06 Jan 2009 00:09:23 +0000
parents 017e68062073
children 6b5c3c5460be
comparison
equal deleted inserted replaced
4157:017e68062073 4158:ea1e24175669
71 if(!m->count) 71 if(!m->count)
72 av_freep(pm); 72 av_freep(pm);
73 73
74 return 0; 74 return 0;
75 } 75 }
76
77 #if LIBAVFORMAT_VERSION_MAJOR < 53
78 #define FILL_METADATA(s, key, value) { \
79 if (value && *value && \
80 !av_metadata_get(s->metadata, #key, NULL, AV_METADATA_IGNORE_CASE)) \
81 av_metadata_set(&s->metadata, (const AVMetadataTag){#key, value}); \
82 }
83 #define FILL_METADATA_STR(s, key) FILL_METADATA(s, key, s->key)
84 #define FILL_METADATA_INT(s, key) { \
85 char number[10]; \
86 snprintf(number, sizeof(number), "%d", s->key); \
87 FILL_METADATA(s, key, number) }
88
89 void ff_metadata_sync_compat(AVFormatContext *ctx)
90 {
91 int i;
92
93 FILL_METADATA_STR(ctx, title);
94 FILL_METADATA_STR(ctx, author);
95 FILL_METADATA_STR(ctx, copyright);
96 FILL_METADATA_STR(ctx, comment);
97 FILL_METADATA_STR(ctx, album);
98 FILL_METADATA_INT(ctx, year);
99 FILL_METADATA_INT(ctx, track);
100 FILL_METADATA_STR(ctx, genre);
101 for (i=0; i<ctx->nb_chapters; i++)
102 FILL_METADATA_STR(ctx->chapters[i], title);
103 for (i=0; i<ctx->nb_programs; i++) {
104 FILL_METADATA_STR(ctx->programs[i], name);
105 FILL_METADATA_STR(ctx->programs[i], provider_name);
106 }
107 for (i=0; i<ctx->nb_streams; i++) {
108 FILL_METADATA_STR(ctx->streams[i], language);
109 FILL_METADATA_STR(ctx->streams[i], filename);
110 }
111 }
112 #endif