Mercurial > libavformat.hg
changeset 4497:dc79722bbc25 libavformat
matroskadec: export language of metadata tags when available
author | aurel |
---|---|
date | Sun, 15 Feb 2009 16:05:37 +0000 |
parents | 4b63fdf6ecc3 |
children | d7a7c516f281 |
files | matroskadec.c |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/matroskadec.c Sun Feb 15 16:00:58 2009 +0000 +++ b/matroskadec.c Sun Feb 15 16:05:37 2009 +0000 @@ -176,6 +176,8 @@ typedef struct { char *name; char *string; + char *lang; + uint64_t def; EbmlList sub; } MatroskaTag; @@ -418,9 +420,9 @@ 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 @@ 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); + } } }