changeset 4372:6d94691fff91 libavformat

use new metadata API in asf muxer
author aurel
date Wed, 04 Feb 2009 01:37:16 +0000
parents 6957efa06a1b
children 7eef34a6f1c0
files asf-enc.c
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/asf-enc.c	Tue Feb 03 23:18:12 2009 +0000
+++ b/asf-enc.c	Wed Feb 04 01:37:16 2009 +0000
@@ -271,6 +271,7 @@
 {
     ASFContext *asf = s->priv_data;
     ByteIOContext *pb = s->pb;
+    AVMetadataTag *title, *author, *copyright, *comment;
     int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
     int has_title;
     AVCodecContext *enc;
@@ -278,8 +279,13 @@
     int bit_rate;
     int64_t duration;
 
+    title     = av_metadata_get(s->metadata, "title"    , NULL, 0);
+    author    = av_metadata_get(s->metadata, "author"   , NULL, 0);
+    copyright = av_metadata_get(s->metadata, "copyright", NULL, 0);
+    comment   = av_metadata_get(s->metadata, "comment"  , NULL, 0);
+
     duration = asf->duration + PREROLL_TIME * 10000;
-    has_title = (s->title[0] || s->author[0] || s->copyright[0] || s->comment[0]);
+    has_title = title || author || copyright || comment;
 
     bit_rate = 0;
     for(n=0;n<s->nb_streams;n++) {
@@ -327,15 +333,15 @@
     /* title and other infos */
     if (has_title) {
         hpos = put_header(pb, &comment_header);
-        if ( s->title[0]     ) { put_le16(pb, 2 * (strlen(s->title    ) + 1)); } else { put_le16(pb, 0); }
-        if ( s->author[0]    ) { put_le16(pb, 2 * (strlen(s->author   ) + 1)); } else { put_le16(pb, 0); }
-        if ( s->copyright[0] ) { put_le16(pb, 2 * (strlen(s->copyright) + 1)); } else { put_le16(pb, 0); }
-        if ( s->comment[0]   ) { put_le16(pb, 2 * (strlen(s->comment  ) + 1)); } else { put_le16(pb, 0); }
+        put_le16(pb, title     ? 2 * (strlen(title->value    ) + 1) : 0);
+        put_le16(pb, author    ? 2 * (strlen(author->value   ) + 1) : 0);
+        put_le16(pb, copyright ? 2 * (strlen(copyright->value) + 1) : 0);
+        put_le16(pb, comment   ? 2 * (strlen(comment->value  ) + 1) : 0);
         put_le16(pb, 0);
-        if ( s->title[0]     ) put_str16_nolen(pb, s->title);
-        if ( s->author[0]    ) put_str16_nolen(pb, s->author);
-        if ( s->copyright[0] ) put_str16_nolen(pb, s->copyright);
-        if ( s->comment[0]   ) put_str16_nolen(pb, s->comment);
+        if (title    ) put_str16_nolen(pb, title->value    );
+        if (author   ) put_str16_nolen(pb, author->value   );
+        if (copyright) put_str16_nolen(pb, copyright->value);
+        if (comment  ) put_str16_nolen(pb, comment->value  );
         end_header(pb, hpos);
     }