avidemux: expose xsub as a subtitle instead of as a video

It is placed inside a 'vids' struct, so it was being exposed on
a pad named video_%d. XSUB are subtitles and this patch adds
an special case for it to be exposed in a subpicture_%d pad
This commit is contained in:
Thiago Santos 2014-03-03 16:39:26 -03:00
parent dee861630a
commit fd12ff4c29
2 changed files with 40 additions and 25 deletions

View file

@ -136,8 +136,8 @@ gst_avi_demux_class_init (GstAviDemuxClass * klass)
{ {
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GObjectClass *gobject_class = (GObjectClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass;
GstPadTemplate *videosrctempl, *audiosrctempl, *subsrctempl; GstPadTemplate *videosrctempl, *audiosrctempl, *subsrctempl, *subpicsrctempl;
GstCaps *audcaps, *vidcaps, *subcaps; GstCaps *audcaps, *vidcaps, *subcaps, *subpiccaps;;
GST_DEBUG_CATEGORY_INIT (avidemux_debug, "avidemux", GST_DEBUG_CATEGORY_INIT (avidemux_debug, "avidemux",
0, "Demuxer for AVI streams"); 0, "Demuxer for AVI streams");
@ -165,9 +165,13 @@ gst_avi_demux_class_init (GstAviDemuxClass * klass)
subcaps = gst_caps_new_empty_simple ("application/x-subtitle-avi"); subcaps = gst_caps_new_empty_simple ("application/x-subtitle-avi");
subsrctempl = gst_pad_template_new ("subtitle_%u", subsrctempl = gst_pad_template_new ("subtitle_%u",
GST_PAD_SRC, GST_PAD_SOMETIMES, subcaps); GST_PAD_SRC, GST_PAD_SOMETIMES, subcaps);
subpiccaps = gst_caps_new_empty_simple ("subpicture/x-xsub");
subpicsrctempl = gst_pad_template_new ("subpicture_%u",
GST_PAD_SRC, GST_PAD_SOMETIMES, subpiccaps);
gst_element_class_add_pad_template (gstelement_class, audiosrctempl); gst_element_class_add_pad_template (gstelement_class, audiosrctempl);
gst_element_class_add_pad_template (gstelement_class, videosrctempl); gst_element_class_add_pad_template (gstelement_class, videosrctempl);
gst_element_class_add_pad_template (gstelement_class, subsrctempl); gst_element_class_add_pad_template (gstelement_class, subsrctempl);
gst_element_class_add_pad_template (gstelement_class, subpicsrctempl);
gst_element_class_add_pad_template (gstelement_class, gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sink_templ)); gst_static_pad_template_get (&sink_templ));
@ -255,6 +259,7 @@ gst_avi_demux_reset (GstAviDemux * avi)
avi->num_v_streams = 0; avi->num_v_streams = 0;
avi->num_a_streams = 0; avi->num_a_streams = 0;
avi->num_t_streams = 0; avi->num_t_streams = 0;
avi->num_sp_streams = 0;
avi->main_stream = -1; avi->main_stream = -1;
avi->have_group_id = FALSE; avi->have_group_id = FALSE;
@ -2280,10 +2285,13 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
fourcc = (stream->strf.vids->compression) ? fourcc = (stream->strf.vids->compression) ?
stream->strf.vids->compression : stream->strh->fcc_handler; stream->strf.vids->compression : stream->strh->fcc_handler;
padname = g_strdup_printf ("video_%u", avi->num_v_streams);
templ = gst_element_class_get_pad_template (klass, "video_%u");
caps = gst_riff_create_video_caps (fourcc, stream->strh, caps = gst_riff_create_video_caps (fourcc, stream->strh,
stream->strf.vids, stream->extradata, stream->initdata, &codec_name); stream->strf.vids, stream->extradata, stream->initdata, &codec_name);
/* DXSB is XSUB, and it is placed inside a vids */
if (!caps || fourcc != GST_MAKE_FOURCC ('D', 'X', 'S', 'B')) {
padname = g_strdup_printf ("video_%u", avi->num_v_streams);
templ = gst_element_class_get_pad_template (klass, "video_%u");
if (!caps) { if (!caps) {
caps = gst_caps_new_simple ("video/x-avi-unknown", "fourcc", caps = gst_caps_new_simple ("video/x-avi-unknown", "fourcc",
G_TYPE_INT, fourcc, NULL); G_TYPE_INT, fourcc, NULL);
@ -2306,6 +2314,12 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
caps = gst_avi_demux_check_caps (avi, caps, &stream->rgb8_palette); caps = gst_avi_demux_check_caps (avi, caps, &stream->rgb8_palette);
tag_name = GST_TAG_VIDEO_CODEC; tag_name = GST_TAG_VIDEO_CODEC;
avi->num_v_streams++; avi->num_v_streams++;
} else {
padname = g_strdup_printf ("subpicture_%u", avi->num_sp_streams);
templ = gst_element_class_get_pad_template (klass, "subpicture_%u");
tag_name = NULL;
avi->num_sp_streams++;
}
break; break;
} }
case GST_RIFF_FCC_auds:{ case GST_RIFF_FCC_auds:{

View file

@ -160,6 +160,7 @@ typedef struct _GstAviDemux {
guint num_v_streams; guint num_v_streams;
guint num_a_streams; guint num_a_streams;
guint num_t_streams; /* subtitle text streams */ guint num_t_streams; /* subtitle text streams */
guint num_sp_streams; /* subpicture streams */
guint main_stream; /* used for seeking */ guint main_stream; /* used for seeking */