summaryrefslogtreecommitdiff
path: root/libavformat/mpegtsenc.c
diff options
context:
space:
mode:
authorAnssi Hannula <anssi.hannula@iki.fi>2011-02-17 17:26:35 +0200
committerRonald S. Bultje <rsbultje@gmail.com>2011-03-07 14:43:03 -0500
commit435cebd01560691e9322bdb0aa5af5b2bc76c3f8 (patch)
tree1056bebe6a49a3d96db3509f6a8b2518d2b003e9 /libavformat/mpegtsenc.c
parent89e568feeca69b1e4b975d0b26aeafbe72fd5418 (diff)
mpegtsenc: handle multiple language tags per stream
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavformat/mpegtsenc.c')
-rw-r--r--libavformat/mpegtsenc.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 02bde7c4be..11a840f8e4 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -283,12 +283,24 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
/* write optional descriptors here */
switch(st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
- if (lang && strlen(lang->value) == 3) {
+ if (lang) {
+ char *p;
+ char *next = lang->value;
+ uint8_t *len_ptr;
+
*q++ = 0x0a; /* ISO 639 language descriptor */
- *q++ = 4;
- *q++ = lang->value[0];
- *q++ = lang->value[1];
- *q++ = lang->value[2];
+ len_ptr = q++;
+ *len_ptr = 0;
+
+ for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
+ next = strchr(p, ',');
+ if (strlen(p) != 3 && (!next || next != p + 3))
+ continue; /* not a 3-letter code */
+
+ *q++ = *p++;
+ *q++ = *p++;
+ *q++ = *p++;
+
if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
*q++ = 0x01;
else if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
@@ -297,6 +309,12 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
*q++ = 0x03;
else
*q++ = 0; /* undefined type */
+
+ *len_ptr += 4;
+ }
+
+ if (*len_ptr == 0)
+ q -= 2; /* no language codes were written */
}
break;
case AVMEDIA_TYPE_SUBTITLE: