/* Returns NULL, or a reference to the pad with the
* buffer with lowest running time */
static GstFlvMuxPad *
-gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts)
+gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts,
+ gboolean timeout)
{
GstFlvMuxPad *best = NULL;
GstBuffer *buffer;
gint64 t = GST_CLOCK_TIME_NONE;
buffer = gst_aggregator_pad_peek_buffer (apad);
- if (!buffer)
- continue;
+ if (!buffer) {
+ if (timeout || GST_PAD_IS_EOS (apad)) {
+ continue;
+ } else {
+ if (best)
+ gst_object_replace ((GstObject **) & best, NULL);
+ best_ts = GST_CLOCK_TIME_NONE;
+ break;
+ }
+ }
if (fpad->drop_deltas) {
if (mux->skip_backwards_streams
"Dropped buffer %" GST_PTR_FORMAT " until keyframe", buffer);
gst_buffer_unref (buffer);
gst_aggregator_pad_drop_buffer (apad);
- continue;
+ if (timeout) {
+ continue;
+ } else {
+ if (best)
+ gst_object_replace ((GstObject **) & best, NULL);
+ best_ts = GST_CLOCK_TIME_NONE;
+ break;
+ }
} else {
/* drop-deltas is set and the buffer isn't delta, drop flag */
fpad->drop_deltas = FALSE;
gst_aggregator_pad_drop_buffer (apad);
/* Look for non-delta buffer */
fpad->drop_deltas = TRUE;
- continue;
+ if (timeout) {
+ continue;
+ } else {
+ if (best)
+ gst_object_replace ((GstObject **) & best, NULL);
+ best_ts = GST_CLOCK_TIME_NONE;
+ break;
+ }
}
}
return GST_FLOW_ERROR;
}
- best = gst_flv_mux_find_best_pad (aggregator, &ts);
+ best = gst_flv_mux_find_best_pad (aggregator, &ts, timeout);
if (!best) {
if (!gst_flv_mux_are_all_pads_eos (mux))
return GST_AGGREGATOR_FLOW_NEED_DATA;
mux->first_timestamp = 0;
}
} else {
- best = gst_flv_mux_find_best_pad (aggregator, &ts);
+ best = gst_flv_mux_find_best_pad (aggregator, &ts, timeout);
}
if (mux->new_tags && mux->streamable) {