2 * Copyright (c) 2009 Aurelien Jacobs <aurel@gnuage.org>
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
21 #if LIBAVFORMAT_VERSION_MAJOR < 53
25 #include "libavutil/avstring.h"
27 #define SIZE_OFFSET(x) sizeof(((AVFormatContext*)0)->x),offsetof(AVFormatContext,x)
34 { "title", SIZE_OFFSET(title) },
35 { "author", SIZE_OFFSET(author) },
36 { "copyright", SIZE_OFFSET(copyright) },
37 { "comment", SIZE_OFFSET(comment) },
38 { "album", SIZE_OFFSET(album) },
39 { "year", SIZE_OFFSET(year) },
40 { "track", SIZE_OFFSET(track) },
41 { "genre", SIZE_OFFSET(genre) },
43 { "artist", SIZE_OFFSET(author) },
44 { "creator", SIZE_OFFSET(author) },
45 { "written_by", SIZE_OFFSET(author) },
46 { "lead_performer", SIZE_OFFSET(author) },
47 { "description", SIZE_OFFSET(comment) },
48 { "albumtitle", SIZE_OFFSET(album) },
49 { "date_written", SIZE_OFFSET(year) },
50 { "date_released", SIZE_OFFSET(year) },
51 { "tracknumber", SIZE_OFFSET(track) },
52 { "part_number", SIZE_OFFSET(track) },
55 void ff_metadata_demux_compat(AVFormatContext *ctx)
60 if ((m = ctx->metadata))
61 for (j=0; j<m->count; j++)
62 for (i=0; i<FF_ARRAY_ELEMS(compat_tab); i++)
63 if (!strcasecmp(m->elems[j].key, compat_tab[i].name)) {
64 int *ptr = (int *)((char *)ctx+compat_tab[i].offset);
66 if (compat_tab[i].size > sizeof(int))
67 av_strlcpy((char *)ptr, m->elems[j].value, compat_tab[i].size);
69 *ptr = atoi(m->elems[j].value);
72 for (i=0; i<ctx->nb_chapters; i++)
73 if ((m = ctx->chapters[i]->metadata))
74 for (j=0; j<m->count; j++)
75 if (!strcasecmp(m->elems[j].key, "title")) {
76 av_free(ctx->chapters[i]->title);
77 ctx->chapters[i]->title = av_strdup(m->elems[j].value);
80 for (i=0; i<ctx->nb_programs; i++)
81 if ((m = ctx->programs[i]->metadata))
82 for (j=0; j<m->count; j++) {
83 if (!strcasecmp(m->elems[j].key, "name")) {
84 av_free(ctx->programs[i]->name);
85 ctx->programs[i]->name = av_strdup(m->elems[j].value);
87 if (!strcasecmp(m->elems[j].key, "provider_name")) {
88 av_free(ctx->programs[i]->provider_name);
89 ctx->programs[i]->provider_name = av_strdup(m->elems[j].value);
93 for (i=0; i<ctx->nb_streams; i++)
94 if ((m = ctx->streams[i]->metadata))
95 for (j=0; j<m->count; j++) {
96 if (!strcasecmp(m->elems[j].key, "language"))
97 av_strlcpy(ctx->streams[i]->language, m->elems[j].value, 4);
98 if (!strcasecmp(m->elems[j].key, "filename")) {
99 av_free(ctx->streams[i]->filename);
100 ctx->streams[i]->filename= av_strdup(m->elems[j].value);
105 #endif /* LIBAVFORMAT_VERSION_MAJOR < 53 */