diff options
author | Guillaume Desmottes <guillaume.desmottes@onestream.live> | 2023-03-08 16:07:05 +0300 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@onestream.live> | 2023-03-08 16:34:20 +0300 |
commit | f7c02cb3b0d75ac96ae1f39a69e0d97d5d4788f8 (patch) | |
tree | d9dc71bf69b7ca9a86a67af5530119e040a627bd /utils/uriplaylistbin | |
parent | 3ef8a48ded99c95d6a35937366e3122d7cdc0879 (diff) |
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>
Diffstat (limited to 'utils/uriplaylistbin')
-rw-r--r-- | utils/uriplaylistbin/src/uriplaylistbin/imp.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index 620d5cb4f..50f2493b9 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -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)] |