mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-18 08:06:31 +00:00
fmp4mux: Fix state cleanup on flush
State cleanup was incomplete. If a flush happens we do not have any buffers anymore so all buffer queue related settings must be cleared on the state. Flush action has been moved into state impl. The GstAggregatorPad flush() was implemented as well as the pad flush handler - with different implementations. Unify it. Fixes #636 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1945>
This commit is contained in:
parent
050e582366
commit
be6074f4f4
1 changed files with 33 additions and 27 deletions
|
@ -335,6 +335,15 @@ impl Stream {
|
||||||
fn caps_or_tag_change(&self) -> bool {
|
fn caps_or_tag_change(&self) -> bool {
|
||||||
self.next_caps.is_some() || self.tag_changed
|
self.next_caps.is_some() || self.tag_changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn flush(&mut self) {
|
||||||
|
self.queued_gops.clear();
|
||||||
|
self.dts_offset = None;
|
||||||
|
self.current_position = gst::ClockTime::ZERO;
|
||||||
|
self.fragment_filled = false;
|
||||||
|
self.pre_queue.clear();
|
||||||
|
self.running_time_utc_time_mapping = None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -389,6 +398,22 @@ struct State {
|
||||||
manual_fragment_boundaries: BTreeSet<gst::ClockTime>,
|
manual_fragment_boundaries: BTreeSet<gst::ClockTime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl State {
|
||||||
|
fn flush(&mut self) {
|
||||||
|
for stream in &mut self.streams {
|
||||||
|
stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
self.current_offset = 0;
|
||||||
|
self.fragment_offsets.clear();
|
||||||
|
self.manual_fragment_boundaries.clear();
|
||||||
|
self.end_pts = None;
|
||||||
|
self.fragment_start_pts = None;
|
||||||
|
self.fragment_end_pts = None;
|
||||||
|
self.chunk_start_pts = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(crate) struct FMP4Mux {
|
pub(crate) struct FMP4Mux {
|
||||||
state: Mutex<State>,
|
state: Mutex<State>,
|
||||||
|
@ -3772,23 +3797,8 @@ impl AggregatorImpl for FMP4Mux {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
fn flush(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
let mut state = self.state.lock().unwrap();
|
gst::trace!(CAT, imp = self, "Flush");
|
||||||
|
self.state.lock().unwrap().flush();
|
||||||
for stream in &mut state.streams {
|
|
||||||
stream.queued_gops.clear();
|
|
||||||
stream.dts_offset = None;
|
|
||||||
stream.current_position = gst::ClockTime::ZERO;
|
|
||||||
stream.fragment_filled = false;
|
|
||||||
stream.pre_queue.clear();
|
|
||||||
stream.running_time_utc_time_mapping = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
state.current_offset = 0;
|
|
||||||
state.fragment_offsets.clear();
|
|
||||||
state.manual_fragment_boundaries.clear();
|
|
||||||
|
|
||||||
drop(state);
|
|
||||||
|
|
||||||
self.parent_flush()
|
self.parent_flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4544,16 +4554,12 @@ impl AggregatorPadImpl for FMP4MuxPad {
|
||||||
let mux = aggregator.downcast_ref::<super::FMP4Mux>().unwrap();
|
let mux = aggregator.downcast_ref::<super::FMP4Mux>().unwrap();
|
||||||
let mut mux_state = mux.imp().state.lock().unwrap();
|
let mut mux_state = mux.imp().state.lock().unwrap();
|
||||||
|
|
||||||
for stream in &mut mux_state.streams {
|
if let Some(stream) = mux_state
|
||||||
if stream.sinkpad == *self.obj() {
|
.streams
|
||||||
stream.queued_gops.clear();
|
.iter_mut()
|
||||||
stream.dts_offset = None;
|
.find(|s| s.sinkpad == *self.obj())
|
||||||
stream.current_position = gst::ClockTime::ZERO;
|
{
|
||||||
stream.fragment_filled = false;
|
stream.flush();
|
||||||
stream.pre_queue.clear();
|
|
||||||
stream.running_time_utc_time_mapping = None;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drop(mux_state);
|
drop(mux_state);
|
||||||
|
|
Loading…
Reference in a new issue