From b5d84439fd63e47f54fcbd281cd9f9aa89e756d0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 30 Apr 2009 14:22:27 +0200 Subject: [PATCH] qtdemux: add support for subtitle pictures Add support for subtitle pictures. Fixes #568278. --- gst/qtdemux/qtdemux.c | 55 ++++++++++++++++++++++++++++++++++++ gst/qtdemux/qtdemux.h | 1 + gst/qtdemux/qtdemux_fourcc.h | 1 + 3 files changed, 57 insertions(+) diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 64402051b3..d18d4dfc83 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -272,6 +272,12 @@ GST_STATIC_PAD_TEMPLATE ("audio_%02d", GST_PAD_SOMETIMES, GST_STATIC_CAPS_ANY); +static GstStaticPadTemplate gst_qtdemux_subpsrc_template = +GST_STATIC_PAD_TEMPLATE ("subp_%02d", + GST_PAD_SRC, + GST_PAD_SOMETIMES, + GST_STATIC_CAPS_ANY); + static GstElementClass *parent_class = NULL; static void gst_qtdemux_class_init (GstQTDemuxClass * klass); @@ -303,6 +309,9 @@ static GstCaps *qtdemux_video_caps (GstQTDemux * qtdemux, static GstCaps *qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, guint32 fourcc, const guint8 * data, int len, gchar ** codec_name); +static GstCaps *qtdemux_subp_caps (GstQTDemux * qtdemux, + QtDemuxStream * stream, guint32 fourcc, const guint8 * data, + gchar ** codec_name); GType gst_qtdemux_get_type (void) @@ -1333,6 +1342,7 @@ gst_qtdemux_change_state (GstElement * element, GstStateChange transition) qtdemux->n_streams = 0; qtdemux->n_video_streams = 0; qtdemux->n_audio_streams = 0; + qtdemux->n_subp_streams = 0; gst_segment_init (&qtdemux->segment, GST_FORMAT_TIME); break; } @@ -3273,6 +3283,13 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux, qtdemux->n_audio_streams++; } else if (stream->subtype == FOURCC_strm) { GST_DEBUG_OBJECT (qtdemux, "stream type, not creating pad"); + } else if (stream->subtype == FOURCC_subp) { + gchar *name = g_strdup_printf ("subp_%02d", qtdemux->n_subp_streams); + + stream->pad = + gst_pad_new_from_static_template (&gst_qtdemux_subpsrc_template, name); + g_free (name); + qtdemux->n_subp_streams++; } else { GST_DEBUG_OBJECT (qtdemux, "unknown stream type"); goto done; @@ -4268,6 +4285,18 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) goto unknown_stream; } stream->sampled = TRUE; + } else if (stream->subtype == FOURCC_subp) { + guint32 fourcc; + + stream->sampled = TRUE; + + offset = 16; + stream->fourcc = fourcc = QT_FOURCC (stsd_data + offset + 4); + GST_LOG_OBJECT (qtdemux, "st type: %" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (fourcc)); + + stream->caps = + qtdemux_subp_caps (qtdemux, stream, fourcc, stsd_data, &codec); } else { goto unknown_stream; } @@ -5723,3 +5752,29 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, } return caps; } + +static GstCaps * +qtdemux_subp_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, + guint32 fourcc, const guint8 * stsd_data, gchar ** codec_name) +{ + GstCaps *caps; + + GST_DEBUG_OBJECT (qtdemux, "resolve fourcc %08x", fourcc); + + switch (fourcc) { + case GST_MAKE_FOURCC ('m', 'p', '4', 's'): + _codec ("DVD subtitle"); + caps = gst_caps_new_simple ("video/x-dvd-subpicture", NULL); + break; + default: + { + char *s; + + s = g_strdup_printf ("audio/x-gst-fourcc-%" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (fourcc)); + caps = gst_caps_new_simple (s, NULL); + break; + } + } + return caps; +} diff --git a/gst/qtdemux/qtdemux.h b/gst/qtdemux/qtdemux.h index d227b7f1b5..7b7c135f33 100644 --- a/gst/qtdemux/qtdemux.h +++ b/gst/qtdemux/qtdemux.h @@ -62,6 +62,7 @@ struct _GstQTDemux { gint n_streams; gint n_video_streams; gint n_audio_streams; + gint n_subp_streams; guint major_brand; GNode *moov_node; diff --git a/gst/qtdemux/qtdemux_fourcc.h b/gst/qtdemux/qtdemux_fourcc.h index aa9a1f2da6..adae4fb9c6 100644 --- a/gst/qtdemux/qtdemux_fourcc.h +++ b/gst/qtdemux/qtdemux_fourcc.h @@ -62,6 +62,7 @@ G_BEGIN_DECLS #define FOURCC_stco GST_MAKE_FOURCC('s','t','c','o') #define FOURCC_vide GST_MAKE_FOURCC('v','i','d','e') #define FOURCC_soun GST_MAKE_FOURCC('s','o','u','n') +#define FOURCC_subp GST_MAKE_FOURCC('s','u','b','p') #define FOURCC_strm GST_MAKE_FOURCC('s','t','r','m') #define FOURCC_rtsp GST_MAKE_FOURCC('r','t','s','p') #define FOURCC_co64 GST_MAKE_FOURCC('c','o','6','4')