summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2006-04-25 16:38:50 +0000
committerTim-Philipp Müller <tim@centricular.net>2006-04-25 16:38:50 +0000
commitda34723a6bf9b305d69cf23215ad20d7747cbdb9 (patch)
tree6c6039493d2d1cd377e9037487e1d128c9f202b8 /gst
parent3763c60ad84881b821202fed825eefa7cf31b845 (diff)
gst/matroska/: Handle case where the TrackType ebml chunk does not come before the
Original commit message from CVS: * gst/matroska/Makefile.am: * gst/matroska/matroska-demux.c: (gst_matroska_demux_add_stream), (gst_matroska_demux_handle_src_event): * gst/matroska/matroska-ids.c: (gst_matroska_track_init_video_context), (gst_matroska_track_init_audio_context), (gst_matroska_track_init_subtitle_context), (gst_matroska_track_init_complex_context): * gst/matroska/matroska-ids.h: Handle case where the TrackType ebml chunk does not come before the TrackInfoAudio or TrackInfoVideo ebml chunk (#339446). Ignore QoS events.
Diffstat (limited to 'gst')
-rw-r--r--gst/matroska/Makefile.am1
-rw-r--r--gst/matroska/matroska-demux.c51
-rw-r--r--gst/matroska/matroska-ids.c131
-rw-r--r--gst/matroska/matroska-ids.h7
4 files changed, 159 insertions, 31 deletions
diff --git a/gst/matroska/Makefile.am b/gst/matroska/Makefile.am
index e4e58bb4..87e3d9e6 100644
--- a/gst/matroska/Makefile.am
+++ b/gst/matroska/Makefile.am
@@ -5,6 +5,7 @@ libgstmatroska_la_SOURCES = \
ebml-write.c \
matroska.c \
matroska-demux.c \
+ matroska-ids.c \
matroska-mux.c
noinst_HEADERS = \
diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index 99ae00a7..bc98a0b5 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -359,52 +359,37 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
/* track type (video, audio, combined, subtitle, etc.) */
case GST_MATROSKA_ID_TRACKTYPE:{
- guint64 num;
+ guint64 track_type;
- if (context->type != 0) {
- GST_WARNING
- ("More than one tracktype defined in a trackentry - skipping");
+ if (!gst_ebml_read_uint (ebml, &id, &track_type)) {
+ res = FALSE;
break;
}
- if (!gst_ebml_read_uint (ebml, &id, &num)) {
- res = FALSE;
+
+ if (context->type != 0 && context->type != track_type) {
+ GST_WARNING
+ ("More than one tracktype defined in a trackentry - skipping");
break;
}
- context->type = num;
/* ok, so we're actually going to reallocate this thing */
- switch (context->type) {
+ switch (track_type) {
case GST_MATROSKA_TRACK_TYPE_VIDEO:
- context = (GstMatroskaTrackContext *)
- g_renew (GstMatroskaTrackVideoContext, context, 1);
- ((GstMatroskaTrackVideoContext *) context)->display_width = 0;
- ((GstMatroskaTrackVideoContext *) context)->display_height = 0;
- ((GstMatroskaTrackVideoContext *) context)->pixel_width = 0;
- ((GstMatroskaTrackVideoContext *) context)->pixel_height = 0;
- ((GstMatroskaTrackVideoContext *) context)->eye_mode = 0;
- ((GstMatroskaTrackVideoContext *) context)->asr_mode = 0;
- ((GstMatroskaTrackVideoContext *) context)->fourcc = 0;
+ gst_matroska_track_init_video_context (&context);
break;
case GST_MATROSKA_TRACK_TYPE_AUDIO:
- context = (GstMatroskaTrackContext *)
- g_renew (GstMatroskaTrackAudioContext, context, 1);
- /* defaults */
- ((GstMatroskaTrackAudioContext *) context)->channels = 1;
- ((GstMatroskaTrackAudioContext *) context)->samplerate = 8000;
+ gst_matroska_track_init_audio_context (&context);
break;
case GST_MATROSKA_TRACK_TYPE_COMPLEX:
- context = (GstMatroskaTrackContext *)
- g_renew (GstMatroskaTrackComplexContext, context, 1);
+ gst_matroska_track_init_complex_context (&context);
break;
case GST_MATROSKA_TRACK_TYPE_SUBTITLE:
- context = (GstMatroskaTrackContext *)
- g_renew (GstMatroskaTrackSubtitleContext, context, 1);
+ gst_matroska_track_init_subtitle_context (&context);
break;
case GST_MATROSKA_TRACK_TYPE_LOGO:
case GST_MATROSKA_TRACK_TYPE_CONTROL:
default:
- GST_WARNING ("Unknown or unsupported track type 0x%x",
- context->type);
+ GST_WARNING ("Unknown or unsupported track type 0x%x", track_type);
context->type = 0;
break;
}
@@ -416,7 +401,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
case GST_MATROSKA_ID_TRACKVIDEO:{
GstMatroskaTrackVideoContext *videocontext;
- if (context->type != GST_MATROSKA_TRACK_TYPE_VIDEO) {
+ if (!gst_matroska_track_init_video_context (&context)) {
GST_WARNING
("trackvideo EBML entry in non-video track - ignoring track");
res = FALSE;
@@ -426,6 +411,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
break;
}
videocontext = (GstMatroskaTrackVideoContext *) context;
+ demux->src[demux->num_streams - 1] = context;
while (res) {
if (!gst_ebml_peek_id (ebml, &demux->level_up, &id)) {
@@ -603,7 +589,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
case GST_MATROSKA_ID_TRACKAUDIO:{
GstMatroskaTrackAudioContext *audiocontext;
- if (context->type != GST_MATROSKA_TRACK_TYPE_AUDIO) {
+ if (!gst_matroska_track_init_audio_context (&context)) {
GST_WARNING
("trackaudio EBML entry in non-audio track - ignoring track");
res = FALSE;
@@ -613,6 +599,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
break;
}
audiocontext = (GstMatroskaTrackAudioContext *) context;
+ demux->src[demux->num_streams - 1] = context;
while (res) {
if (!gst_ebml_peek_id (ebml, &demux->level_up, &id)) {
@@ -1288,10 +1275,12 @@ gst_matroska_demux_handle_src_event (GstPad * pad, GstEvent * event)
/* events we don't need to handle */
case GST_EVENT_NAVIGATION:
+ case GST_EVENT_QOS:
+ res = FALSE;
break;
default:
- GST_WARNING ("Unhandled event of type %d", GST_EVENT_TYPE (event));
+ GST_WARNING ("Unhandled %s event, dropped", GST_EVENT_TYPE_NAME (event));
res = FALSE;
break;
}
diff --git a/gst/matroska/matroska-ids.c b/gst/matroska/matroska-ids.c
new file mode 100644
index 00000000..dde46769
--- /dev/null
+++ b/gst/matroska/matroska-ids.c
@@ -0,0 +1,131 @@
+/* GStreamer Matroska muxer/demuxer
+ * (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ * (C) 2006 Tim-Philipp Müller <tim centricular net>
+ *
+ * matroska-ids.c: matroska track context utility functions
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "matroska-ids.h"
+
+gboolean
+gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context)
+{
+ GstMatroskaTrackVideoContext *video_context;
+
+ g_assert (p_context != NULL && *p_context != NULL);
+
+ /* already set up? (track info might come before track type) */
+ if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_VIDEO) {
+ GST_LOG ("video context already set up");
+ return TRUE;
+ }
+
+ /* it better not have been set up as some other track type ... */
+ if ((*p_context)->type != 0) {
+ g_return_val_if_reached (FALSE);
+ }
+
+ video_context = g_renew (GstMatroskaTrackVideoContext, *p_context, 1);
+ *p_context = (GstMatroskaTrackContext *) video_context;
+
+ /* defaults */
+ (*p_context)->type = GST_MATROSKA_TRACK_TYPE_VIDEO;
+ video_context->display_width = 0;
+ video_context->display_height = 0;
+ video_context->pixel_width = 0;
+ video_context->pixel_height = 0;
+ video_context->eye_mode = 0;
+ video_context->asr_mode = 0;
+ video_context->fourcc = 0;
+ return TRUE;
+}
+
+gboolean
+gst_matroska_track_init_audio_context (GstMatroskaTrackContext ** p_context)
+{
+ GstMatroskaTrackAudioContext *audio_context;
+
+ g_assert (p_context != NULL && *p_context != NULL);
+
+ /* already set up? (track info might come before track type) */
+ if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_AUDIO)
+ return TRUE;
+
+ /* it better not have been set up as some other track type ... */
+ if ((*p_context)->type != 0) {
+ g_return_val_if_reached (FALSE);
+ }
+
+ audio_context = g_renew (GstMatroskaTrackAudioContext, *p_context, 1);
+ *p_context = (GstMatroskaTrackContext *) audio_context;
+
+ /* defaults */
+ (*p_context)->type = GST_MATROSKA_TRACK_TYPE_AUDIO;
+ audio_context->channels = 1;
+ audio_context->samplerate = 8000;
+ return TRUE;
+}
+
+gboolean
+gst_matroska_track_init_subtitle_context (GstMatroskaTrackContext ** p_context)
+{
+ GstMatroskaTrackSubtitleContext *subtitle_context;
+
+ g_assert (p_context != NULL && *p_context != NULL);
+
+ /* already set up? (track info might come before track type) */
+ if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_SUBTITLE)
+ return TRUE;
+
+ /* it better not have been set up as some other track type ... */
+ if ((*p_context)->type != 0) {
+ g_return_val_if_reached (FALSE);
+ }
+
+ subtitle_context = g_renew (GstMatroskaTrackSubtitleContext, *p_context, 1);
+ *p_context = (GstMatroskaTrackContext *) subtitle_context;
+
+ (*p_context)->type = GST_MATROSKA_TRACK_TYPE_SUBTITLE;
+ return TRUE;
+}
+
+gboolean
+gst_matroska_track_init_complex_context (GstMatroskaTrackContext ** p_context)
+{
+ GstMatroskaTrackComplexContext *complex_context;
+
+ g_assert (p_context != NULL && *p_context != NULL);
+
+ /* already set up? (track info might come before track type) */
+ if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_COMPLEX)
+ return TRUE;
+
+ /* it better not have been set up as some other track type ... */
+ if ((*p_context)->type != 0) {
+ g_return_val_if_reached (FALSE);
+ }
+
+ complex_context = g_renew (GstMatroskaTrackComplexContext, *p_context, 1);
+ *p_context = (GstMatroskaTrackContext *) complex_context;
+ (*p_context)->type = GST_MATROSKA_TRACK_TYPE_COMPLEX;
+ return TRUE;
+}
diff --git a/gst/matroska/matroska-ids.h b/gst/matroska/matroska-ids.h
index c8c6d371..4a00ba1b 100644
--- a/gst/matroska/matroska-ids.h
+++ b/gst/matroska/matroska-ids.h
@@ -22,6 +22,8 @@
#ifndef __GST_MATROSKA_IDS_H__
#define __GST_MATROSKA_IDS_H__
+#include <gst/gst.h>
+
#include "ebml-ids.h"
/*
@@ -299,4 +301,9 @@ typedef struct _Wavpack4Header {
guint32 crc; /* crc for actual decoded data */
} Wavpack4Header;
+gboolean gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context);
+gboolean gst_matroska_track_init_audio_context (GstMatroskaTrackContext ** p_context);
+gboolean gst_matroska_track_init_subtitle_context (GstMatroskaTrackContext ** p_context);
+gboolean gst_matroska_track_init_complex_context (GstMatroskaTrackContext ** p_context);
+
#endif /* __GST_MATROSKA_IDS_H__ */