changeset 4525:c66cf692bea0 libavformat

use new metadata API in mpegts muxer
author aurel
date Wed, 18 Feb 2009 00:00:38 +0000
parents e2abb4e5017c
children ae2fe097a3e0
files mpegtsenc.c
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mpegtsenc.c	Tue Feb 17 21:43:57 2009 +0000
+++ b/mpegtsenc.c	Wed Feb 18 00:00:38 2009 +0000
@@ -216,6 +216,7 @@
     for(i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
         MpegTSWriteStream *ts_st = st->priv_data;
+        AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0);
         switch(st->codec->codec_id) {
         case CODEC_ID_MPEG1VIDEO:
         case CODEC_ID_MPEG2VIDEO:
@@ -252,21 +253,19 @@
         /* write optional descriptors here */
         switch(st->codec->codec_type) {
         case CODEC_TYPE_AUDIO:
-            if (strlen(st->language) == 3) {
+            if (lang && strlen(lang->value) == 3) {
                 *q++ = 0x0a; /* ISO 639 language descriptor */
                 *q++ = 4;
-                *q++ = st->language[0];
-                *q++ = st->language[1];
-                *q++ = st->language[2];
+                *q++ = lang->value[0];
+                *q++ = lang->value[1];
+                *q++ = lang->value[2];
                 *q++ = 0; /* undefined type */
             }
             break;
         case CODEC_TYPE_SUBTITLE:
             {
                 const char *language;
-                language = st->language;
-                if (strlen(language) != 3)
-                    language = "eng";
+                language = lang && strlen(lang->value)==3 ? lang->value : "eng";
                 *q++ = 0x59;
                 *q++ = 8;
                 *q++ = language[0];
@@ -383,6 +382,7 @@
     MpegTSWriteStream *ts_st;
     MpegTSService *service;
     AVStream *st;
+    AVMetadataTag *title;
     int i, total_bit_rate;
     const char *service_name;
     uint64_t sdt_size, pat_pmt_size, pos;
@@ -390,9 +390,8 @@
     ts->tsid = DEFAULT_TSID;
     ts->onid = DEFAULT_ONID;
     /* allocate a single DVB service */
-    service_name = s->title;
-    if (service_name[0] == '\0')
-        service_name = DEFAULT_SERVICE_NAME;
+    title = av_metadata_get(s->metadata, "title", NULL, 0);
+    service_name = title ? title->value : DEFAULT_SERVICE_NAME;
     service = mpegts_add_service(ts, DEFAULT_SID,
                                  DEFAULT_PROVIDER_NAME, service_name);
     service->pmt.write_packet = section_write_packet;