From b0a6b5eac8a268c1255de8d339017293fe80560d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 28 Nov 2016 10:27:56 +0200 Subject: [PATCH] tsdemux: Post an error message on the bus if we activated a program without pads Otherwise decodebin and applications are going to wait forever for pads to appear, which is never going to happen. Happens on this stream, which probably just need support for it added: https://samples.mplayerhq.hu/3D/AVC_codec_in_m2ts_not_recognized/AVC_codec_not_recognized_right_video_sample.m2ts --- gst/mpegtsdemux/tsdemux.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index fe0c3a6d38..c701c37f2a 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -1870,6 +1870,7 @@ gst_ts_demux_program_started (MpegTSBase * base, MpegTSBaseProgram * program) if (demux->requested_program_number == program->program_number || (demux->requested_program_number == -1 && demux->program_number == -1)) { GList *tmp; + gboolean have_pads = FALSE; GST_LOG ("program %d started", program->program_number); demux->program_number = program->program_number; @@ -1906,6 +1907,8 @@ gst_ts_demux_program_started (MpegTSBase * base, MpegTSBaseProgram * program) for (tmp = program->stream_list; tmp; tmp = tmp->next) { TSDemuxStream *stream = (TSDemuxStream *) tmp->data; activate_pad_for_stream (demux, stream); + if (stream->pad) + have_pads = TRUE; } /* If there was a previous program, now is the time to deactivate it @@ -1915,6 +1918,16 @@ gst_ts_demux_program_started (MpegTSBase * base, MpegTSBaseProgram * program) mpegts_base_deactivate_and_free_program (base, demux->previous_program); demux->previous_program = NULL; } + + if (!have_pads) { + /* If we had no pads, this stream is likely corrupted or unsupported and + * there's not much we can do at this point */ + GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, + ("This stream contains no valid or supported streams."), + ("activating program but got no pads")); + return; + } + /* If any of the stream is sparse, push a GAP event before anything else * This is done here, and not in activate_pad_for_stream() because pushing * a GAP event *is* considering data, and we want to ensure the (potential) @@ -1930,6 +1943,7 @@ gst_ts_demux_program_started (MpegTSBase * base, MpegTSBaseProgram * program) gst_pad_push_event (stream->pad, gst_event_new_gap (0, 0)); } } + gst_element_no_more_pads ((GstElement *) demux); } }