mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-08 15:32:32 +00:00
flvmux: Return NEED_DATA when we drop a buffer
When we are dropping a buffer in find_best_pad (e.g. waiting for a keyframe, or skipping backwards timestamp), return GST_AGGREGATOR_FLOW_NEED_DATA to make sure we have enough data at the next run. Otherwise, a stream that accidentally fell behind (e.g. relinking race, or just waiting for a keyframe) will never get the opportunity to catch up to the other one, because the other one will always keep advancing. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/696>
This commit is contained in:
parent
75f6ca8a11
commit
c95cc6a015
1 changed files with 30 additions and 7 deletions
|
@ -1850,7 +1850,8 @@ gst_flv_mux_rewrite_header (GstFlvMux * mux)
|
||||||
/* Returns NULL, or a reference to the pad with the
|
/* Returns NULL, or a reference to the pad with the
|
||||||
* buffer with lowest running time */
|
* buffer with lowest running time */
|
||||||
static GstFlvMuxPad *
|
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;
|
GstFlvMuxPad *best = NULL;
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
|
@ -1871,8 +1872,16 @@ gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts)
|
||||||
gint64 t = GST_CLOCK_TIME_NONE;
|
gint64 t = GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
buffer = gst_aggregator_pad_peek_buffer (apad);
|
buffer = gst_aggregator_pad_peek_buffer (apad);
|
||||||
if (!buffer)
|
if (!buffer) {
|
||||||
continue;
|
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 (fpad->drop_deltas) {
|
||||||
if (mux->skip_backwards_streams
|
if (mux->skip_backwards_streams
|
||||||
|
@ -1881,7 +1890,14 @@ gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts)
|
||||||
"Dropped buffer %" GST_PTR_FORMAT " until keyframe", buffer);
|
"Dropped buffer %" GST_PTR_FORMAT " until keyframe", buffer);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
gst_aggregator_pad_drop_buffer (apad);
|
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 {
|
} else {
|
||||||
/* drop-deltas is set and the buffer isn't delta, drop flag */
|
/* drop-deltas is set and the buffer isn't delta, drop flag */
|
||||||
fpad->drop_deltas = FALSE;
|
fpad->drop_deltas = FALSE;
|
||||||
|
@ -1902,7 +1918,14 @@ gst_flv_mux_find_best_pad (GstAggregator * aggregator, GstClockTime * ts)
|
||||||
gst_aggregator_pad_drop_buffer (apad);
|
gst_aggregator_pad_drop_buffer (apad);
|
||||||
/* Look for non-delta buffer */
|
/* Look for non-delta buffer */
|
||||||
fpad->drop_deltas = TRUE;
|
fpad->drop_deltas = TRUE;
|
||||||
continue;
|
if (timeout) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
if (best)
|
||||||
|
gst_object_replace ((GstObject **) & best, NULL);
|
||||||
|
best_ts = GST_CLOCK_TIME_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1958,7 +1981,7 @@ gst_flv_mux_aggregate (GstAggregator * aggregator, gboolean timeout)
|
||||||
return GST_FLOW_ERROR;
|
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 (!best) {
|
||||||
if (!gst_flv_mux_are_all_pads_eos (mux))
|
if (!gst_flv_mux_are_all_pads_eos (mux))
|
||||||
return GST_AGGREGATOR_FLOW_NEED_DATA;
|
return GST_AGGREGATOR_FLOW_NEED_DATA;
|
||||||
|
@ -1981,7 +2004,7 @@ gst_flv_mux_aggregate (GstAggregator * aggregator, gboolean timeout)
|
||||||
mux->first_timestamp = 0;
|
mux->first_timestamp = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if (mux->new_tags && mux->streamable) {
|
||||||
|
|
Loading…
Reference in a new issue