[PATCH 2/6] mpegts: parse audio_type into metadata
Anssi Hannula
anssi.hannula
Fri Jul 16 03:23:11 CEST 2010
---
libavformat/mpegts.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index c561942..4e62d43 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -851,6 +851,20 @@ static PESContext *add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid)
return pes;
}
+static const char *get_audio_type_string(uint8_t audio_type)
+{
+ switch (audio_type) {
+ case 0x01:
+ return "clean effects";
+ case 0x02:
+ return "hearing impaired";
+ case 0x03:
+ return "visual impaired";
+ default:
+ return NULL;
+ }
+}
+
static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
{
MpegTSContext *ts = filter->u.section_filter.opaque;
@@ -861,6 +875,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
int program_info_length, pcr_pid, pid, stream_type;
int desc_list_len, desc_len, desc_tag;
char language[4];
+ uint8_t audio_type;
uint32_t prog_reg_desc = 0; /* registration descriptor */
#ifdef DEBUG
@@ -1010,7 +1025,16 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
all_langs[ch * 4 + 3] = (ch + 1 == tags) ? 0 : '+';
av_metadata_set2(&st->metadata, language_key, language,
AV_METADATA_DONT_STRDUP_KEY);
- p++;
+ audio_type = get8(&p, desc_end);
+ if (audio_type) {
+ char *audio_type_key = av_strdup("channel0/audio_type");
+ if (audio_type_key) {
+ audio_type_key[7] = '0' + ch;
+ av_metadata_set2(&st->metadata, audio_type_key,
+ get_audio_type_string(audio_type),
+ AV_METADATA_DONT_STRDUP_KEY);
+ }
+ }
}
all_langs[tags * 4 - 1] = 0;
av_metadata_set2(&st->metadata, "language", all_langs,
@@ -1021,6 +1045,10 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
language[2] = get8(&p, desc_end);
language[3] = 0;
av_metadata_set2(&st->metadata, "language", language, 0);
+ audio_type = get8(&p, desc_end);
+ if (audio_type)
+ av_metadata_set2(&st->metadata, "audio_type",
+ get_audio_type_string(audio_type), 0);
}
break;
case 0x05: /* registration descriptor */
--
1.7.1
--Boundary-00=_ZzOQMxVxT486NZ+
Content-Type: text/plain;
charset="iso-8859-15";
name="0003-mpegtsenc-handle-audio-channel-specific-language-met.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
filename="0003-mpegtsenc-handle-audio-channel-specific-language-met.patch"
More information about the ffmpeg-devel
mailing list