mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-27 05:51:01 +00:00
fallbackswitch: Correctly handle incoming non-default segments
We need to convert buffer timestamps to the outgoing [0, -1] segment of aggregator. This won't work correctly for negative DTS as is.
This commit is contained in:
parent
b7dba68ab9
commit
50ee0c1a1d
1 changed files with 16 additions and 2 deletions
|
@ -112,7 +112,7 @@ impl FallbackSwitch {
|
|||
&self,
|
||||
agg: &gst_base::Aggregator,
|
||||
state: &mut OutputState,
|
||||
buffer: gst::Buffer,
|
||||
mut buffer: gst::Buffer,
|
||||
fallback_sinkpad: Option<&gst_base::AggregatorPad>,
|
||||
) -> Result<Option<(gst::Buffer, gst::Caps, bool)>, gst::FlowError> {
|
||||
// If we got a buffer on the sinkpad just handle it
|
||||
|
@ -132,6 +132,13 @@ impl FallbackSwitch {
|
|||
gst::FlowError::Error
|
||||
})?;
|
||||
|
||||
{
|
||||
// FIXME: This will not work correctly for negative DTS
|
||||
let buffer = buffer.make_mut();
|
||||
buffer.set_pts(segment.to_running_time(buffer.get_pts()));
|
||||
buffer.set_dts(segment.to_running_time(buffer.get_dts()));
|
||||
}
|
||||
|
||||
let mut active_sinkpad = self.active_sinkpad.lock().unwrap();
|
||||
let pad_change = &*active_sinkpad != self.sinkpad.upcast_ref::<gst::Pad>();
|
||||
if pad_change {
|
||||
|
@ -202,7 +209,7 @@ impl FallbackSwitch {
|
|||
// If we have a fallback sinkpad and timeout, try to get a fallback buffer from here
|
||||
// and drop all too old buffers in the process
|
||||
loop {
|
||||
let buffer = fallback_sinkpad
|
||||
let mut buffer = fallback_sinkpad
|
||||
.pop_buffer()
|
||||
.ok_or(gst_base::AGGREGATOR_FLOW_NEED_DATA)?;
|
||||
|
||||
|
@ -227,6 +234,13 @@ impl FallbackSwitch {
|
|||
})?;
|
||||
let running_time = fallback_segment.to_running_time(buffer.get_pts());
|
||||
|
||||
{
|
||||
// FIXME: This will not work correctly for negative DTS
|
||||
let buffer = buffer.make_mut();
|
||||
buffer.set_pts(fallback_segment.to_running_time(buffer.get_pts()));
|
||||
buffer.set_dts(fallback_segment.to_running_time(buffer.get_dts()));
|
||||
}
|
||||
|
||||
// If we never had a real buffer, initialize with the running time of the fallback
|
||||
// sinkpad so that we still output fallback buffers after the timeout
|
||||
if state.last_sinkpad_time.is_none() {
|
||||
|
|
Loading…
Reference in a new issue