task-vuplus-enigma2
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-enigma2 / gstreamer / gst-plugins-bad-0.10.23 / 0001-mpegtsdemux-fix-bd-streamtype-detection.diff.patch
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
5
6 ---
7  gst/mpegdemux/gstmpegtsdemux.c |  134 +++++++++++++++++++++++----------------
8  1 files changed, 79 insertions(+), 55 deletions(-)
9
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)
15  }
16  
17  static gboolean
18 +gst_mpeg_desc_reg_format_id_in_array(GArray *array, guint32 identifier)
19 +{
20 +  guint i = 0;
21 +  for (; i < array->len; ++i) {
22 +    guint8 *desc = g_array_index(array, guint8*, i);
23 +    if (DESC_REGISTRATION_format_identifier (desc) == identifier)
24 +      return TRUE;
25 +  }
26 +  return FALSE;
27 +}
28 +
29 +static gboolean
30  gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
31      guint8 stream_type)
32  {
33 @@ -655,6 +667,8 @@ gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
34    GstMpegTSDemuxClass *klass;
35    GstMpegTSDemux *demux;
36    GstCaps *caps;
37 +  GArray *stream_desc_reg_array = NULL;
38 +  gboolean is_hdmv = FALSE;
39  
40    if (stream->stream_type && stream->stream_type != stream_type)
41      goto wrong_type;
42 @@ -666,6 +680,31 @@ gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
43    template = NULL;
44    caps = NULL;
45  
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)) {
51 +      is_hdmv = TRUE;
52 +    }
53 +  }
54 +
55 +  if (!is_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;
59 +    if (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)) {
64 +          is_hdmv = TRUE;
65 +        }
66 +        g_array_free(program_desc_reg_array, TRUE);
67 +      }
68 +    }
69 +  }
70 +
71    switch (stream_type) {
72      case ST_VIDEO_MPEG1:
73      case ST_VIDEO_MPEG2:
74 @@ -756,11 +795,8 @@ gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
75        break;
76      case ST_PRIVATE_EA:        /* Try to detect a VC1 stream */
77      {
78 -      guint8 *desc = NULL;
79 -
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.");
87        }
88 @@ -772,47 +808,7 @@ gst_mpegts_demux_fill_stream (GstMpegTSStream * stream, guint8 id,
89            NULL);
90        break;
91      }
92 -    case ST_BD_AUDIO_AC3:
93 -    {
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;
98 -
99 -      if (program_info)
100 -        desc = gst_mpeg_descriptor_find (program_info, DESC_REGISTRATION);
101 -
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);
111 -      } else {
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.");
117 -        }
118 -        template = klass->audio_template;
119 -        name = g_strdup_printf ("audio_%04x", stream->PID);
120 -        caps = gst_caps_new_simple ("audio/x-ac3", NULL);
121 -      }
122 -      break;
123 -    }
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);
128 -      break;
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);
139        break;
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);
144 -      break;
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);
149        break;
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);
154 -      break;
155      default:
156        break;
157    }
158 +
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);
165 +        break;
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);
170 +        break;
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);
177 +        break;
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);
182 +        break;
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);
187 +        break;
188 +      default:
189 +        break;
190 +    }
191 +  }
192 +
193 +  if (stream_desc_reg_array)
194 +    g_array_free(stream_desc_reg_array, TRUE);
195 +
196    if (name == NULL || template == NULL || caps == NULL) {
197      if (name)
198        g_free (name);
199 -- 
200 1.7.5.4
201