aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2009-02-15 02:28:54 +0000
committerAurelien Jacobs <aurel@gnuage.org>2009-02-15 02:28:54 +0000
commit49674dd05235d45caeac0129c1e9dc0bcfea14ea (patch)
treedb0c7927727b0ecfe546b15fe67e32f7c3232b29
parent1333d8fd2012525a181f387dd4f7fbd66328f207 (diff)
downloadffmpeg-49674dd05235d45caeac0129c1e9dc0bcfea14ea.tar.gz
use new metadata API in mov demuxer
Originally committed as revision 17309 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/mov.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index e40abcaf8d..4ed656c658 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -24,6 +24,7 @@
//#define DEBUG
#include "libavutil/intreadwrite.h"
+#include "libavutil/avstring.h"
#include "avformat.h"
#include "riff.h"
#include "isom.h"
@@ -494,6 +495,7 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int version = get_byte(pb);
+ char language[4] = {0};
unsigned lang;
if (version > 1)
@@ -512,7 +514,8 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
st->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
lang = get_be16(pb); /* language */
- ff_mov_lang_to_iso639(lang, st->language);
+ if (ff_mov_lang_to_iso639(lang, language))
+ av_metadata_set(&st->metadata, "language", language);
get_be16(pb); /* quality */
return 0;
@@ -1438,8 +1441,8 @@ static int mov_read_trkn(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
- char *str = NULL;
- int size;
+ char str[1024], key2[16], language[4] = {0};
+ const char *key = NULL;
uint16_t str_size;
if (c->itunes_metadata) {
@@ -1453,29 +1456,31 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
} else return 0;
} else {
str_size = get_be16(pb); // string length
- get_be16(pb); // language
+ ff_mov_lang_to_iso639(get_be16(pb), language);
atom.size -= 4;
}
switch (atom.type) {
- case MKTAG(0xa9,'n','a','m'):
- str = c->fc->title; size = sizeof(c->fc->title); break;
+ case MKTAG(0xa9,'n','a','m'): key = "title"; break;
case MKTAG(0xa9,'A','R','T'):
- case MKTAG(0xa9,'w','r','t'):
- str = c->fc->author; size = sizeof(c->fc->author); break;
- case MKTAG(0xa9,'c','p','y'):
- str = c->fc->copyright; size = sizeof(c->fc->copyright); break;
+ case MKTAG(0xa9,'w','r','t'): key = "author"; break;
+ case MKTAG(0xa9,'c','p','y'): key = "copyright"; break;
case MKTAG(0xa9,'c','m','t'):
- case MKTAG(0xa9,'i','n','f'):
- str = c->fc->comment; size = sizeof(c->fc->comment); break;
- case MKTAG(0xa9,'a','l','b'):
- str = c->fc->album; size = sizeof(c->fc->album); break;
+ case MKTAG(0xa9,'i','n','f'): key = "comment"; break;
+ case MKTAG(0xa9,'a','l','b'): key = "album"; break;
}
- if (!str)
+ if (!key)
return 0;
if (atom.size < 0)
return -1;
- get_buffer(pb, str, FFMIN3(size, str_size, atom.size));
+ str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
+ get_buffer(pb, str, str_size);
+ str[str_size] = 0;
+ av_metadata_set(&c->fc->metadata, key, str);
+ if (*language && strcmp(language, "und")) {
+ snprintf(key2, sizeof(key2), "%s-%s", key, language);
+ av_metadata_set(&c->fc->metadata, key2, str);
+ }
dprintf(c->fc, "%.4s %s %d %lld\n", (char*)&atom.type, str, str_size, atom.size);
return 0;
}