Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Anssi Hannula authored on 2011/02/18 00:26:35... | ... |
@@ -283,12 +283,24 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) |
283 | 283 |
/* write optional descriptors here */ |
284 | 284 |
switch(st->codec->codec_type) { |
285 | 285 |
case AVMEDIA_TYPE_AUDIO: |
286 |
- if (lang && strlen(lang->value) == 3) { |
|
286 |
+ if (lang) { |
|
287 |
+ char *p; |
|
288 |
+ char *next = lang->value; |
|
289 |
+ uint8_t *len_ptr; |
|
290 |
+ |
|
287 | 291 |
*q++ = 0x0a; /* ISO 639 language descriptor */ |
288 |
- *q++ = 4; |
|
289 |
- *q++ = lang->value[0]; |
|
290 |
- *q++ = lang->value[1]; |
|
291 |
- *q++ = lang->value[2]; |
|
292 |
+ len_ptr = q++; |
|
293 |
+ *len_ptr = 0; |
|
294 |
+ |
|
295 |
+ for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) { |
|
296 |
+ next = strchr(p, ','); |
|
297 |
+ if (strlen(p) != 3 && (!next || next != p + 3)) |
|
298 |
+ continue; /* not a 3-letter code */ |
|
299 |
+ |
|
300 |
+ *q++ = *p++; |
|
301 |
+ *q++ = *p++; |
|
302 |
+ *q++ = *p++; |
|
303 |
+ |
|
292 | 304 |
if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS) |
293 | 305 |
*q++ = 0x01; |
294 | 306 |
else if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) |
... | ... |
@@ -297,6 +309,12 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) |
297 | 297 |
*q++ = 0x03; |
298 | 298 |
else |
299 | 299 |
*q++ = 0; /* undefined type */ |
300 |
+ |
|
301 |
+ *len_ptr += 4; |
|
302 |
+ } |
|
303 |
+ |
|
304 |
+ if (*len_ptr == 0) |
|
305 |
+ q -= 2; /* no language codes were written */ |
|
300 | 306 |
} |
301 | 307 |
break; |
302 | 308 |
case AVMEDIA_TYPE_SUBTITLE: |