1 From 55091d9a55ad100b99638503da038432549632f8 Mon Sep 17 00:00:00 2001
2 From: Andreas Oberritter <obi@opendreambox.org>
3 Date: Wed, 21 Mar 2012 15:45:17 +0100
4 Subject: [PATCH 1/3] mpegtsdemux-fix-bd-streamtype-detection.diff
7 gst/mpegdemux/gstmpegtsdemux.c | 134 +++++++++++++++++++++++----------------
8 1 files changed, 79 insertions(+), 55 deletions(-)
10 diff --git a/gst/mpegdemux/gstmpegtsdemux.c b/gst/mpegdemux/gstmpegtsdemux.c
11 index 012c1cc..fffc50f 100644
12 --- a/gst/mpegdemux/gstmpegtsdemux.c
13 +++ b/gst/mpegdemux/gstmpegtsdemux.c
14 @@ -647,6 +647,18 @@ gst_mpegts_demux_get_stream_for_PID (GstMpegTSDemux * demux, guint16 PID)
18 +gst_mpeg_desc_reg_format_id_in_array(GArray *array, guint32 identifier)
21 + for (; i < array->len; ++i) {
22 + guint8 *desc = g_array_index(array, guint8*, i);
23 + if (DESC_REGISTRATION_format_identifier (desc) == identifier)
30 gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
33 @@ -655,6 +667,8 @@ gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
34 GstMpegTSDemuxClass *klass;
35 GstMpegTSDemux *demux;
37 + GArray *stream_desc_reg_array = NULL;
38 + gboolean is_hdmv = FALSE;
40 if (stream->stream_type && stream->stream_type != stream_type)
42 @@ -666,6 +680,31 @@ gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
46 + if (stream->ES_info) {
47 + stream_desc_reg_array =
48 + gst_mpeg_descriptor_find_all (stream->ES_info, DESC_REGISTRATION);
49 + if (stream_desc_reg_array &&
50 + gst_mpeg_desc_reg_format_id_in_array(stream_desc_reg_array, DRF_ID_HDMV)) {
56 + GstMpegTSStream *PMT_stream =
57 + gst_mpegts_demux_get_stream_for_PID (stream->demux, stream->PMT_pid);
58 + GstMPEGDescriptor *program_info = PMT_stream->PMT.program_info;
60 + GArray *program_desc_reg_array =
61 + gst_mpeg_descriptor_find_all (program_info, DESC_REGISTRATION);
62 + if (program_desc_reg_array) {
63 + if (gst_mpeg_desc_reg_format_id_in_array(program_desc_reg_array, DRF_ID_HDMV)) {
66 + g_array_free(program_desc_reg_array, TRUE);
71 switch (stream_type) {
74 @@ -756,11 +795,8 @@ gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
76 case ST_PRIVATE_EA: /* Try to detect a VC1 stream */
78 - guint8 *desc = NULL;
80 - if (stream->ES_info)
81 - desc = gst_mpeg_descriptor_find (stream->ES_info, DESC_REGISTRATION);
82 - if (!(desc && DESC_REGISTRATION_format_identifier (desc) == DRF_ID_VC1)) {
83 + if (!(stream_desc_reg_array &&
84 + gst_mpeg_desc_reg_format_id_in_array(stream_desc_reg_array, DRF_ID_VC1))) {
85 GST_WARNING ("0xea private stream type found but no descriptor "
86 "for VC1. Assuming plain VC1.");
88 @@ -772,47 +808,7 @@ gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
92 - case ST_BD_AUDIO_AC3:
94 - GstMpegTSStream *PMT_stream =
95 - gst_mpegts_demux_get_stream_for_PID (stream->demux, stream->PMT_pid);
96 - GstMPEGDescriptor *program_info = PMT_stream->PMT.program_info;
97 - guint8 *desc = NULL;
100 - desc = gst_mpeg_descriptor_find (program_info, DESC_REGISTRATION);
102 - if (desc && DESC_REGISTRATION_format_identifier (desc) == DRF_ID_HDMV) {
103 - template = klass->audio_template;
104 - name = g_strdup_printf ("audio_%04x", stream->PID);
105 - caps = gst_caps_new_simple ("audio/x-eac3", NULL);
106 - } else if (stream->ES_info && gst_mpeg_descriptor_find (stream->ES_info,
107 - DESC_DVB_ENHANCED_AC3)) {
108 - template = klass->audio_template;
109 - name = g_strdup_printf ("audio_%04x", stream->PID);
110 - caps = gst_caps_new_simple ("audio/x-eac3", NULL);
112 - if (!stream->ES_info ||
113 - !gst_mpeg_descriptor_find (stream->ES_info, DESC_DVB_AC3)) {
114 - GST_WARNING ("AC3 stream type found but no corresponding "
115 - "descriptor to differentiate between AC3 and EAC3. "
116 - "Assuming plain AC3.");
118 - template = klass->audio_template;
119 - name = g_strdup_printf ("audio_%04x", stream->PID);
120 - caps = gst_caps_new_simple ("audio/x-ac3", NULL);
124 - case ST_BD_AUDIO_EAC3:
125 - template = klass->audio_template;
126 - name = g_strdup_printf ("audio_%04x", stream->PID);
127 - caps = gst_caps_new_simple ("audio/x-eac3", NULL);
129 case ST_PS_AUDIO_DTS:
130 - case ST_BD_AUDIO_DTS:
131 - case ST_BD_AUDIO_DTS_HD:
132 - case ST_BD_AUDIO_DTS_HD_MASTER_AUDIO:
133 template = klass->audio_template;
134 name = g_strdup_printf ("audio_%04x", stream->PID);
135 caps = gst_caps_new_simple ("audio/x-dts", NULL);
136 @@ -822,24 +818,52 @@ gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
137 name = g_strdup_printf ("audio_%04x", stream->PID);
138 caps = gst_caps_new_simple ("audio/x-lpcm", NULL);
140 - case ST_BD_AUDIO_LPCM:
141 - template = klass->audio_template;
142 - name = g_strdup_printf ("audio_%04x", stream->PID);
143 - caps = gst_caps_new_simple ("audio/x-private-ts-lpcm", NULL);
145 case ST_PS_DVD_SUBPICTURE:
146 template = klass->subpicture_template;
147 name = g_strdup_printf ("subpicture_%04x", stream->PID);
148 caps = gst_caps_new_simple ("video/x-dvd-subpicture", NULL);
150 - case ST_BD_PGS_SUBPICTURE:
151 - template = klass->subpicture_template;
152 - name = g_strdup_printf ("subpicture_%04x", stream->PID);
153 - caps = gst_caps_new_simple ("subpicture/x-pgs", NULL);
159 + if (!template && is_hdmv) {
160 + switch (stream_type) {
161 + case ST_BD_AUDIO_AC3:
162 + template = klass->audio_template;
163 + name = g_strdup_printf ("audio_%04x", stream->PID);
164 + caps = gst_caps_new_simple ("audio/x-ac3", NULL);
166 + case ST_BD_AUDIO_EAC3:
167 + template = klass->audio_template;
168 + name = g_strdup_printf ("audio_%04x", stream->PID);
169 + caps = gst_caps_new_simple ("audio/x-eac3", NULL);
171 + case ST_BD_AUDIO_DTS:
172 + case ST_BD_AUDIO_DTS_HD:
173 + case ST_BD_AUDIO_DTS_HD_MASTER_AUDIO:
174 + template = klass->audio_template;
175 + name = g_strdup_printf ("audio_%04x", stream->PID);
176 + caps = gst_caps_new_simple ("audio/x-dts", NULL);
178 + case ST_BD_AUDIO_LPCM:
179 + template = klass->audio_template;
180 + name = g_strdup_printf ("audio_%04x", stream->PID);
181 + caps = gst_caps_new_simple ("audio/x-private-ts-lpcm", NULL);
183 + case ST_BD_PGS_SUBPICTURE:
184 + template = klass->subpicture_template;
185 + name = g_strdup_printf ("subpicture_%04x", stream->PID);
186 + caps = gst_caps_new_simple ("subpicture/x-pgs", NULL);
193 + if (stream_desc_reg_array)
194 + g_array_free(stream_desc_reg_array, TRUE);
196 if (name == NULL || template == NULL || caps == NULL) {