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.
This commit is contained in:
Tim-Philipp Müller 2006-04-25 16:38:50 +00:00
parent 3763c60ad8
commit da34723a6b
5 changed files with 174 additions and 31 deletions

View file

@ -1,3 +1,18 @@
2006-04-25 Tim-Philipp Müller <tim at centricular dot net>
* 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.
2006-04-25 Wim Taymans <wim@fluendo.com> 2006-04-25 Wim Taymans <wim@fluendo.com>
* gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_setcaps): * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_setcaps):

View file

@ -5,6 +5,7 @@ libgstmatroska_la_SOURCES = \
ebml-write.c \ ebml-write.c \
matroska.c \ matroska.c \
matroska-demux.c \ matroska-demux.c \
matroska-ids.c \
matroska-mux.c matroska-mux.c
noinst_HEADERS = \ noinst_HEADERS = \

View file

@ -359,52 +359,37 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
/* track type (video, audio, combined, subtitle, etc.) */ /* track type (video, audio, combined, subtitle, etc.) */
case GST_MATROSKA_ID_TRACKTYPE:{ case GST_MATROSKA_ID_TRACKTYPE:{
guint64 num; guint64 track_type;
if (context->type != 0) { if (!gst_ebml_read_uint (ebml, &id, &track_type)) {
res = FALSE;
break;
}
if (context->type != 0 && context->type != track_type) {
GST_WARNING GST_WARNING
("More than one tracktype defined in a trackentry - skipping"); ("More than one tracktype defined in a trackentry - skipping");
break; break;
} }
if (!gst_ebml_read_uint (ebml, &id, &num)) {
res = FALSE;
break;
}
context->type = num;
/* ok, so we're actually going to reallocate this thing */ /* ok, so we're actually going to reallocate this thing */
switch (context->type) { switch (track_type) {
case GST_MATROSKA_TRACK_TYPE_VIDEO: case GST_MATROSKA_TRACK_TYPE_VIDEO:
context = (GstMatroskaTrackContext *) gst_matroska_track_init_video_context (&context);
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;
break; break;
case GST_MATROSKA_TRACK_TYPE_AUDIO: case GST_MATROSKA_TRACK_TYPE_AUDIO:
context = (GstMatroskaTrackContext *) gst_matroska_track_init_audio_context (&context);
g_renew (GstMatroskaTrackAudioContext, context, 1);
/* defaults */
((GstMatroskaTrackAudioContext *) context)->channels = 1;
((GstMatroskaTrackAudioContext *) context)->samplerate = 8000;
break; break;
case GST_MATROSKA_TRACK_TYPE_COMPLEX: case GST_MATROSKA_TRACK_TYPE_COMPLEX:
context = (GstMatroskaTrackContext *) gst_matroska_track_init_complex_context (&context);
g_renew (GstMatroskaTrackComplexContext, context, 1);
break; break;
case GST_MATROSKA_TRACK_TYPE_SUBTITLE: case GST_MATROSKA_TRACK_TYPE_SUBTITLE:
context = (GstMatroskaTrackContext *) gst_matroska_track_init_subtitle_context (&context);
g_renew (GstMatroskaTrackSubtitleContext, context, 1);
break; break;
case GST_MATROSKA_TRACK_TYPE_LOGO: case GST_MATROSKA_TRACK_TYPE_LOGO:
case GST_MATROSKA_TRACK_TYPE_CONTROL: case GST_MATROSKA_TRACK_TYPE_CONTROL:
default: default:
GST_WARNING ("Unknown or unsupported track type 0x%x", GST_WARNING ("Unknown or unsupported track type 0x%x", track_type);
context->type);
context->type = 0; context->type = 0;
break; break;
} }
@ -416,7 +401,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
case GST_MATROSKA_ID_TRACKVIDEO:{ case GST_MATROSKA_ID_TRACKVIDEO:{
GstMatroskaTrackVideoContext *videocontext; GstMatroskaTrackVideoContext *videocontext;
if (context->type != GST_MATROSKA_TRACK_TYPE_VIDEO) { if (!gst_matroska_track_init_video_context (&context)) {
GST_WARNING GST_WARNING
("trackvideo EBML entry in non-video track - ignoring track"); ("trackvideo EBML entry in non-video track - ignoring track");
res = FALSE; res = FALSE;
@ -426,6 +411,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
break; break;
} }
videocontext = (GstMatroskaTrackVideoContext *) context; videocontext = (GstMatroskaTrackVideoContext *) context;
demux->src[demux->num_streams - 1] = context;
while (res) { while (res) {
if (!gst_ebml_peek_id (ebml, &demux->level_up, &id)) { 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:{ case GST_MATROSKA_ID_TRACKAUDIO:{
GstMatroskaTrackAudioContext *audiocontext; GstMatroskaTrackAudioContext *audiocontext;
if (context->type != GST_MATROSKA_TRACK_TYPE_AUDIO) { if (!gst_matroska_track_init_audio_context (&context)) {
GST_WARNING GST_WARNING
("trackaudio EBML entry in non-audio track - ignoring track"); ("trackaudio EBML entry in non-audio track - ignoring track");
res = FALSE; res = FALSE;
@ -613,6 +599,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
break; break;
} }
audiocontext = (GstMatroskaTrackAudioContext *) context; audiocontext = (GstMatroskaTrackAudioContext *) context;
demux->src[demux->num_streams - 1] = context;
while (res) { while (res) {
if (!gst_ebml_peek_id (ebml, &demux->level_up, &id)) { 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 */ /* events we don't need to handle */
case GST_EVENT_NAVIGATION: case GST_EVENT_NAVIGATION:
case GST_EVENT_QOS:
res = FALSE;
break; break;
default: 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; res = FALSE;
break; break;
} }

131
gst/matroska/matroska-ids.c Normal file
View file

@ -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;
}

View file

@ -22,6 +22,8 @@
#ifndef __GST_MATROSKA_IDS_H__ #ifndef __GST_MATROSKA_IDS_H__
#define __GST_MATROSKA_IDS_H__ #define __GST_MATROSKA_IDS_H__
#include <gst/gst.h>
#include "ebml-ids.h" #include "ebml-ids.h"
/* /*
@ -299,4 +301,9 @@ typedef struct _Wavpack4Header {
guint32 crc; /* crc for actual decoded data */ guint32 crc; /* crc for actual decoded data */
} Wavpack4Header; } 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__ */ #endif /* __GST_MATROSKA_IDS_H__ */