From eaf91927cc7721e0371088e318e025b56d1cba37 Mon Sep 17 00:00:00 2001 From: selikhov Date: Sat, 3 Oct 2026 06:44:55 +0300 Subject: [PATCH] voelin-media: apply a camera's new background effect A source's input was kept when its background changed as long as both the old and the new effect needed a mask, but the background filter is set up with its effect when the input starts. So switching a camera from blur to a colour or an image, or changing the blur strength, changed the scene and nothing on screen. The input now restarts whenever the effect differs, as it already did when the effect went on or off. Co-Authored-By: Claude Opus 5.5 --- crates/voelin-media/src/studio/mod.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/voelin-media/src/studio/mod.rs b/crates/voelin-media/src/studio/mod.rs index 3ed24fb..b444c58 100644 --- a/crates/voelin-media/src/studio/mod.rs +++ b/crates/voelin-media/src/studio/mod.rs @@ -798,8 +798,10 @@ impl Studio { wanted.iter().any(|(w, kind, background)| { w == id && input.kind().same_input(kind) - // A background filter is set up when the input starts. - && input.background().needs_mask() == background.needs_mask() + // A background filter is set up when the input starts, + // with the effect it applies: another effect (or + // strength, image, colour) needs a new input. + && input.background() == background }) }); } @@ -1196,6 +1198,25 @@ mod tests { assert!(studio.apply(Command::RenameScene { scene: 99, name: "x".into() }).await.is_err()); } + #[tokio::test] + async fn a_new_background_effect_reaches_the_input() { + let studio = Studio::start(one_colour_scene()).await.unwrap(); + for background in [ + Background::Blur { strength: 0.02 }, + Background::Blur { strength: 0.08 }, + Background::Colour { colour: Colour::rgb(0, 200, 0) }, + Background::Keep, + ] { + let change = + SourceChange { background: Some(background.clone()), ..Default::default() }; + let command = Command::UpdateSource { scene: 1, source: 1, change: Box::new(change) }; + studio.apply(command).await.unwrap(); + let graph = lock(&studio.graph); + assert_eq!(graph.inputs.len(), 1); + assert_eq!(graph.inputs[0].1.background(), &background); + } + } + #[tokio::test] async fn go_live_and_recording_change_the_status() { let studio = Studio::start(one_colour_scene()).await.unwrap();