diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2009-02-15 16:05:37 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2009-02-15 16:05:37 +0000 |
commit | f702df396d10c68d615c405d23a55be1116822b0 (patch) | |
tree | 68518c8f0a37dc7eae70d16dfed79136d9724b0e /libavformat/matroskadec.c | |
parent | 0334f79994bf714ca9cad523487bd497089cce0b (diff) | |
download | ffmpeg-f702df396d10c68d615c405d23a55be1116822b0.tar.gz |
matroskadec: export language of metadata tags when available
Originally committed as revision 17334 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r-- | libavformat/matroskadec.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 24ceea2551..4ba351456f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -176,6 +176,8 @@ typedef struct { typedef struct { char *name; char *string; + char *lang; + uint64_t def; EbmlList sub; } MatroskaTag; @@ -418,9 +420,9 @@ static EbmlSyntax matroska_index[] = { static EbmlSyntax matroska_simpletag[] = { { MATROSKA_ID_TAGNAME, EBML_UTF8, 0, offsetof(MatroskaTag,name) }, { MATROSKA_ID_TAGSTRING, EBML_UTF8, 0, offsetof(MatroskaTag,string) }, + { MATROSKA_ID_TAGLANG, EBML_STR, 0, offsetof(MatroskaTag,lang), {.s="und"} }, + { MATROSKA_ID_TAGDEFAULT, EBML_UINT, 0, offsetof(MatroskaTag,def) }, { MATROSKA_ID_SIMPLETAG, EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTag,sub), {.n=matroska_simpletag} }, - { MATROSKA_ID_TAGLANG, EBML_NONE }, - { MATROSKA_ID_TAGDEFAULT, EBML_NONE }, { 0 } }; @@ -990,11 +992,21 @@ static void matroska_convert_tag(AVFormatContext *s, EbmlList *list, int i; for (i=0; i < list->nb_elem; i++) { + const char *lang = strcmp(tags[i].lang, "und") ? tags[i].lang : NULL; if (prefix) snprintf(key, sizeof(key), "%s/%s", prefix, tags[i].name); else av_strlcpy(key, tags[i].name, sizeof(key)); + if (tags[i].def || !lang) { av_metadata_set(metadata, key, tags[i].string); if (tags[i].sub.nb_elem) matroska_convert_tag(s, &tags[i].sub, metadata, key); + } + if (lang) { + av_strlcat(key, "-", sizeof(key)); + av_strlcat(key, lang, sizeof(key)); + av_metadata_set(metadata, key, tags[i].string); + if (tags[i].sub.nb_elem) + matroska_convert_tag(s, &tags[i].sub, metadata, key); + } } } |