diff --git a/gst/flv/gstflvdemux.c b/gst/flv/gstflvdemux.c index 37dd614b62..4492d30bea 100644 --- a/gst/flv/gstflvdemux.c +++ b/gst/flv/gstflvdemux.c @@ -112,6 +112,8 @@ gst_flv_demux_cleanup (GstFLVDemux * demux) demux->push_tags = FALSE; demux->got_par = FALSE; + demux->audio_start = demux->video_start = GST_CLOCK_TIME_NONE; + demux->no_more_pads = FALSE; gst_segment_init (&demux->segment, GST_FORMAT_TIME); diff --git a/gst/flv/gstflvdemux.h b/gst/flv/gstflvdemux.h index 806ab1365d..6c130d0552 100644 --- a/gst/flv/gstflvdemux.h +++ b/gst/flv/gstflvdemux.h @@ -93,6 +93,7 @@ struct _GstFLVDemux gboolean audio_need_segment; gboolean audio_linked; GstBuffer * audio_codec_data; + GstClockTime audio_start; /* Video infos */ guint32 w; @@ -106,6 +107,7 @@ struct _GstFLVDemux gboolean video_linked; gboolean got_par; GstBuffer * video_codec_data; + GstClockTime video_start; gboolean random_access; gboolean need_header; diff --git a/gst/flv/gstflvparse.c b/gst/flv/gstflvparse.c index 21772daf68..a6d18b72e6 100644 --- a/gst/flv/gstflvparse.c +++ b/gst/flv/gstflvparse.c @@ -553,6 +553,12 @@ gst_flv_parse_tag_audio (GstFLVDemux * demux, GstBuffer * buffer) GST_LOG_OBJECT (demux, "parsing an audio tag"); + if (demux->no_more_pads && !demux->audio_pad) { + GST_WARNING_OBJECT (demux, + "Signaled no-more-pads already but had no audio pad -- ignoring"); + goto beach; + } + g_return_val_if_fail (GST_BUFFER_SIZE (buffer) == demux->tag_size, GST_FLOW_ERROR); @@ -784,6 +790,20 @@ gst_flv_parse_tag_audio (GstFLVDemux * demux, GstBuffer * buffer) GST_BUFFER_SIZE (outbuf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)), GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)), GST_BUFFER_OFFSET (outbuf)); + if (!GST_CLOCK_TIME_IS_VALID (demux->audio_start)) { + demux->audio_start = GST_BUFFER_TIMESTAMP (outbuf); + } + + if (G_UNLIKELY (!demux->no_more_pads + && GST_CLOCK_DIFF (demux->audio_start, + GST_BUFFER_TIMESTAMP (outbuf) > 6 * GST_SECOND))) { + GST_DEBUG_OBJECT (demux, + "Signalling no-more-pads because no video stream was found" + " after 6 seconds of audio"); + gst_element_no_more_pads (GST_ELEMENT_CAST (demux)); + demux->no_more_pads = TRUE; + } + /* Push downstream */ ret = gst_pad_push (demux->audio_pad, outbuf); if (G_UNLIKELY (ret != GST_FLOW_OK)) { @@ -889,9 +909,16 @@ gst_flv_parse_tag_video (GstFLVDemux * demux, GstBuffer * buffer) GST_LOG_OBJECT (demux, "parsing a video tag"); + GST_LOG_OBJECT (demux, "pts bytes %02X %02X %02X %02X", data[0], data[1], data[2], data[3]); + if (demux->no_more_pads && !demux->video_pad) { + GST_WARNING_OBJECT (demux, + "Signaled no-more-pads already but had no audio pad -- ignoring"); + goto beach; + } + /* Grab information about video tag */ pts = GST_READ_UINT24_BE (data); /* read the pts extension to 32 bits integer */ @@ -1114,6 +1141,20 @@ gst_flv_parse_tag_video (GstFLVDemux * demux, GstBuffer * buffer) GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)), GST_BUFFER_OFFSET (outbuf), keyframe); + if (!GST_CLOCK_TIME_IS_VALID (demux->video_start)) { + demux->video_start = GST_BUFFER_TIMESTAMP (outbuf); + } + + if (G_UNLIKELY (!demux->no_more_pads + && GST_CLOCK_DIFF (demux->video_start, + GST_BUFFER_TIMESTAMP (outbuf) > 6 * GST_SECOND))) { + GST_DEBUG_OBJECT (demux, + "Signalling no-more-pads because no audio stream was found" + " after 6 seconds of video"); + gst_element_no_more_pads (GST_ELEMENT_CAST (demux)); + demux->no_more_pads = TRUE; + } + /* Push downstream */ ret = gst_pad_push (demux->video_pad, outbuf);