From bf82e750f4cfa4ded861c53599ea3cda52afaa08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 23 Sep 2020 19:21:38 +0300 Subject: [PATCH] utils/fallbacksrc: Remove custom source elements from internal bin when shutting down Otherwise we can't add it again later to a new bin when starting up again. --- utils/fallbackswitch/src/fallbacksrc.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utils/fallbackswitch/src/fallbacksrc.rs b/utils/fallbackswitch/src/fallbacksrc.rs index 2f1aa3d8..4bd103bf 100644 --- a/utils/fallbackswitch/src/fallbacksrc.rs +++ b/utils/fallbackswitch/src/fallbacksrc.rs @@ -1109,6 +1109,18 @@ impl FallbackSrc { state.video_stream = None; state.audio_stream = None; + if let Source::Element(ref source) = state.configured_source { + // Explicitly remove the source element from the CustomSource so that we can + // later create a new CustomSource and add it again there. + if source.has_as_parent(&state.source) { + let _ = source.set_state(gst::State::Null); + let _ = state + .source + .downcast_ref::() + .unwrap() + .remove(source); + } + } element.remove(&state.source).unwrap(); if let Some(timeout) = state.source_pending_restart_timeout.take() { -- GitLab