uriplaylistbin: reset element when switching back to NULL

Allow us to re-use the element later.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1121>
This commit is contained in:
Guillaume Desmottes 2023-03-08 14:07:05 +01:00
parent 3ef8a48ded
commit f7c02cb3b0

View file

@ -962,7 +962,13 @@ impl ElementImpl for UriPlaylistBin {
} }
} }
self.parent_change_state(transition) let res = self.parent_change_state(transition);
if transition == gst::StateChange::ReadyToNull {
self.stop();
}
res
} }
} }
@ -1683,6 +1689,20 @@ impl UriPlaylistBin {
} }
} }
} }
fn stop(&self) {
// remove all children and pads
let children = self.obj().children();
let children_ref = children.iter().collect::<Vec<_>>();
self.obj().remove_many(&children_ref).unwrap();
for pad in self.obj().src_pads() {
self.obj().remove_pad(&pad).unwrap();
}
let mut state_guard = self.state.lock().unwrap();
*state_guard = None;
}
} }
#[derive(Default, Clone, Debug)] #[derive(Default, Clone, Debug)]