changeset 3460:bd563026a5af libavformat

support for 3gp metadata
author bcoudurier
date Wed, 11 Jun 2008 09:40:22 +0000
parents a79f6237c3d2
children 7e3b70da5d13
files movenc.c
diffstat 1 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/movenc.c	Wed Jun 11 09:35:02 2008 +0000
+++ b/movenc.c	Wed Jun 11 09:40:22 2008 +0000
@@ -1216,6 +1216,26 @@
     return (((str[0]-0x60) & 0x1F) << 10) + (((str[1]-0x60) & 0x1F) << 5) + ((str[2]-0x60) & 0x1F);
 }
 
+static int mov_write_3gp_udta_tag(ByteIOContext *pb, AVFormatContext *s,
+                                  const char *tag, const char *str)
+{
+    offset_t pos = url_ftell(pb);
+    if (!utf8len(str))
+        return 0;
+    put_be32(pb, 0);   /* size */
+    put_tag (pb, tag); /* type */
+    put_be32(pb, 0);   /* version + flags */
+    if (!strcmp(tag, "yrrc"))
+        put_be16(pb, s->year);
+    else {
+        put_be16(pb, language_code("eng")); /* language */
+        ascii_to_wc(pb, str);
+        if (!strcmp(tag, "albm") && s->year)
+            put_byte(pb, s->year);
+    }
+    return updateSize(pb, pos);
+}
+
 static int mov_write_udta_tag(ByteIOContext *pb, MOVContext *mov,
                               AVFormatContext *s)
 {
@@ -1235,6 +1255,14 @@
         put_be32(pb, 0); /* size */
         put_tag(pb, "udta");
 
+        if (mov->mode == MODE_3GP || mov->mode == MODE_3G2) {
+            mov_write_3gp_udta_tag(pb, s, "titl", s->title);
+            mov_write_3gp_udta_tag(pb, s, "auth", s->author);
+            mov_write_3gp_udta_tag(pb, s, "gnre", s->genre);
+            mov_write_3gp_udta_tag(pb, s, "dscp", s->comment);
+            mov_write_3gp_udta_tag(pb, s, "albm", s->album);
+            mov_write_3gp_udta_tag(pb, s, "yrrc", "nil");
+        } else {
         /* iTunes meta data */
         mov_write_meta_tag(pb, mov, s);
 
@@ -1247,7 +1275,7 @@
             mov_write_string_tag(pb, "\251des", s->comment       , 0);
             mov_write_string_tag(pb, "\251gen", s->genre         , 0);
         }
-
+        }
         return updateSize(pb, pos);
     }
 
@@ -1330,7 +1358,7 @@
 
     if (mov->mode == MODE_PSP)
         mov_write_uuidusmt_tag(pb, s);
-    else if (mov->mode != MODE_3GP && mov->mode != MODE_3G2)
+    else
         mov_write_udta_tag(pb, mov, s);
 
     return updateSize(pb, pos);