From 199aaa40212bdc70649326df3b4f10997cc71190 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 22 Oct 2012 11:39:37 +0200 Subject: [PATCH] qtdemux: add support for 'generic' samples Add support for stuffing a complete stream into 1 sample. See https://bugzilla.gnome.org/show_bug.cgi?id=686550 --- gst/isomp4/qtdemux.c | 47 ++++++++++++++++++++++++++++++++++++- gst/isomp4/qtdemux_fourcc.h | 1 + 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 98ed3c332e..42ab6421fa 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -431,6 +431,10 @@ static GstCaps *qtdemux_audio_caps (GstQTDemux * qtdemux, static GstCaps *qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, guint32 fourcc, const guint8 * data, gchar ** codec_name); +static GstCaps *qtdemux_generic_caps (GstQTDemux * qtdemux, + QtDemuxStream * stream, guint32 fourcc, const guint8 * stsd_data, + gchar ** codec_name); + static gboolean qtdemux_parse_samples (GstQTDemux * qtdemux, QtDemuxStream * stream, guint32 n); static GstFlowReturn qtdemux_expose_streams (GstQTDemux * qtdemux); @@ -5214,6 +5218,13 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux, gst_pad_new_from_static_template (&gst_qtdemux_subsrc_template, name); g_free (name); qtdemux->n_sub_streams++; + } else if (stream->caps) { + gchar *name = g_strdup_printf ("video_%u", qtdemux->n_video_streams); + + stream->pad = + gst_pad_new_from_static_template (&gst_qtdemux_videosrc_template, name); + g_free (name); + qtdemux->n_video_streams++; } else { GST_DEBUG_OBJECT (qtdemux, "unknown stream type"); goto done; @@ -7506,7 +7517,22 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) break; } } else { - goto unknown_stream; + /* everything in 1 sample */ + stream->sampled = TRUE; + + stream->caps = + qtdemux_generic_caps (qtdemux, stream, fourcc, stsd_data, &codec); + + if (stream->caps == NULL) + goto unknown_stream; + + if (codec) { + list = gst_tag_list_new_empty (); + gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, + GST_TAG_SUBTITLE_CODEC, codec, NULL); + g_free (codec); + codec = NULL; + } } /* promote to sampled format */ @@ -9855,3 +9881,22 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, } return caps; } + +static GstCaps * +qtdemux_generic_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, + guint32 fourcc, const guint8 * stsd_data, gchar ** codec_name) +{ + GstCaps *caps; + + switch (fourcc) { + case GST_MAKE_FOURCC ('m', '1', 'v', ' '): + _codec ("MPEG 1 video"); + caps = gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 1, + "systemstream", G_TYPE_BOOLEAN, FALSE, NULL); + break; + default: + caps = NULL; + break; + } + return caps; +} diff --git a/gst/isomp4/qtdemux_fourcc.h b/gst/isomp4/qtdemux_fourcc.h index 716dfc98c5..27704f5e2d 100644 --- a/gst/isomp4/qtdemux_fourcc.h +++ b/gst/isomp4/qtdemux_fourcc.h @@ -174,6 +174,7 @@ G_BEGIN_DECLS #define FOURCC_mp4s GST_MAKE_FOURCC('m','p','4','s') #define FOURCC_gama GST_MAKE_FOURCC('g','a','m','a') #define FOURCC_apcs GST_MAKE_FOURCC('a','p','c','s') +#define FOURCC_m1v GST_MAKE_FOURCC('m','1','v',' ') /* SVQ3 fourcc */ #define FOURCC_SEQH GST_MAKE_FOURCC('S','E','Q','H')