Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3d9c200
feat(vision-mixer): stinger transitions: classic, track matte and mas…
srperens Oct 6, 2026
9c0a8aa
feat(stinger): widen the example blade
srperens Oct 6, 2026
9eb3651
fix(stinger): keep the example blade's trails out of its matte
srperens Oct 6, 2026
4b1c87f
feat(stinger): library API on the mixer, file guards, take ids
srperens Oct 6, 2026
e6aac42
fix(stinger): detect a clip's layout from the clip alone
srperens Oct 6, 2026
2db2645
test(stinger): render only the edge frames in the blade spill test
srperens Oct 6, 2026
2aa94f5
fix(stinger): warm the mixer up at cue; count late matte frames
srperens Oct 6, 2026
f2ca310
test(stinger): test clips in PNG, not FFV1
srperens Oct 6, 2026
def809b
test(stinger): show the mixer's pads mid-take when a matte frame is off
srperens Oct 6, 2026
5bb722d
test(stinger): add caps, geometry and shader uniforms to the mid-take…
srperens Oct 6, 2026
939f360
test(stinger): show the program's middle row half way through a matte…
srperens Oct 6, 2026
128b3cb
fix(stinger): keep the matte shader out of FX passthrough
srperens Oct 6, 2026
4f20bfa
fix(stinger): place step keyframes half a frame before their frame
srperens Oct 6, 2026
69afb01
refactor(stinger): plan a take from a start reported at runtime
wagenet Oct 6, 2026
bf77f97
feat(stinger): find where a stinger page starts from its first frame
wagenet Oct 6, 2026
9784e8a
feat(stinger): take a stinger from an HTML Input page
wagenet Oct 6, 2026
0a12385
feat(html_input): stinger page settings, and the panel's page source
wagenet Oct 6, 2026
f5d3d17
test(stinger): page stingers against a real cefsrc
wagenet Oct 6, 2026
31d4ab4
fix(stinger): finish a take whose request is dropped
wagenet Oct 6, 2026
db9b09e
fix(stinger): guard a stinger page's URL and first frame
wagenet Oct 6, 2026
967676f
fix(stinger): wait for one page frame; check paints at rest after a take
wagenet Oct 6, 2026
c6a894e
fix(stinger): refuse a take on a page showing a #fragment of its own
wagenet Oct 7, 2026
7913774
refactor(stinger): drop the paints-at-rest warning
wagenet Oct 7, 2026
b9d2b02
test(stinger): the API on a page stinger source
wagenet Oct 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions backend/src/api/flows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1808,16 +1808,46 @@ pub async fn trigger_transition(
ValidatedJson(req): ValidatedJson<TriggerTransitionRequest>,
) -> Result<Json<TransitionResponse>, (StatusCode, Json<ErrorResponse>)> {
debug!(
"Triggering {} transition on block {} in flow {} ({} -> {}, {}ms)",
"Triggering {} transition on block {} in flow {} ({:?} -> {:?}, {}ms)",
req.transition_type, block_id, flow_id, req.from_input, req.to_input, req.duration_ms
);

// A stinger runs from the clip on the mixer's stinger input, timed by the
// clip; PGM and PVW decide the inputs as for any take.
if req.transition_type.eq_ignore_ascii_case("stinger") {
let take = state
.stinger_take(&flow_id, &block_id, req.stinger_clip, None)
.await
.map_err(|e| {
error!("Failed to take stinger: {}", e);
crate::api::stinger::error_response("Failed to trigger transition", e)
})?;
return Ok(Json(TransitionResponse {
message: format!(
"Stinger clip {} ({:?}) on air in {:.0} ms",
take.index, take.variant, take.take_to_air_ms
),
transition_type: req.transition_type,
actual_transition_type: "stinger".to_string(),
duration_ms: take.duration_ms,
}));
}

let (Some(from_input), Some(to_input)) = (req.from_input, req.to_input) else {
return Err((
StatusCode::BAD_REQUEST,
Json(ErrorResponse::with_details(
"Failed to trigger transition",
"from_input and to_input are required (only a stinger may leave them out)",
)),
));
};
let actual_transition_type = state
.trigger_transition(
&flow_id,
&block_id,
req.from_input,
req.to_input,
from_input,
to_input,
&req.transition_type,
req.duration_ms,
)
Expand All @@ -1836,7 +1866,7 @@ pub async fn trigger_transition(
Ok(Json(TransitionResponse {
message: format!(
"Transition {} started: input {} -> {}",
req.transition_type, req.from_input, req.to_input
req.transition_type, from_input, to_input
),
transition_type: req.transition_type,
actual_transition_type,
Expand Down
10 changes: 8 additions & 2 deletions backend/src/api/mediaplayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,14 @@ pub async fn set_playlist(
let was_stopped = player.state() == strom_types::mediaplayer::PlayerState::Stopped;
player.set_playlist(req.files);

// Only auto-start from the beginning if the player was stopped
if was_stopped && player.playlist_len() > 0 {
// Only auto-start from the beginning if the player was stopped. A
// stinger clip source parks its first clip instead of playing it.
if player.stinger.enabled {
if player.playlist_len() > 0 && !player.is_parked_on(player.current_index()) {
let index = player.current_index();
let _ = control(move || player.cue(index).map(|_| ())).await;
}
} else if was_stopped && player.playlist_len() > 0 {
let _ = control(move || player.goto(0)).await;
}
}
Expand Down
1 change: 1 addition & 0 deletions backend/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod osc;
pub mod ports;
pub mod probes;
pub mod sdp_transform;
pub mod stinger;
pub mod system_clock;
pub mod version;
pub mod vision_mixer_page;
Expand Down
259 changes: 259 additions & 0 deletions backend/src/api/stinger.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
//! Stinger transitions on a vision mixer: the library (the stinger source's
//! playlist and per-clip settings), cueing, taking, and the example clips.
//!
//! A take is also available through the transition endpoint with
//! `transition_type` "stinger".

use axum::{
extract::{Path, Query, State},
http::StatusCode,
Json,
};
use strom_types::api::ErrorResponse;
use strom_types::stinger::{
StingerAddClipRequest, StingerClip, StingerClipSettings, StingerCueRequest,
StingerExamplesResponse, StingerFileGuard, StingerState, StingerTakeRequest,
StingerTakeResponse,
};
use strom_types::FlowId;
use tracing::info;

use crate::state::AppState;

type ApiError = (StatusCode, Json<ErrorResponse>);

/// 409 when the library changed under the request, 400 otherwise.
pub(crate) fn error_response(what: &str, e: crate::gst::pipeline::PipelineError) -> ApiError {
let status = match e {
crate::gst::pipeline::PipelineError::Conflict(_) => StatusCode::CONFLICT,
_ => StatusCode::BAD_REQUEST,
};
(
status,
Json(ErrorResponse::with_details(what, e.to_string())),
)
}

fn bad_request(what: &str) -> impl Fn(crate::gst::pipeline::PipelineError) -> ApiError + '_ {
move |e| error_response(what, e)
}

/// Stinger state of a vision mixer: its source, clips (with analysis and how
/// each plays here), the cued clip, and the last take's measurements.
#[utoipa::path(
get,
path = "/api/flows/{flow_id}/blocks/{block_id}/stinger",
tag = "flows",
params(
("flow_id" = String, Path, description = "Flow ID (UUID)"),
("block_id" = String, Path, description = "Vision mixer block instance ID")
),
responses(
(status = 200, description = "Stinger state", body = StingerState),
(status = 400, description = "Invalid request", body = ErrorResponse),
)
)]
pub async fn get_stinger_state(
State(state): State<AppState>,
Path((flow_id, block_id)): Path<(FlowId, String)>,
) -> Result<Json<StingerState>, ApiError> {
state
.stinger_state(&flow_id, &block_id)
.await
.map(Json)
.map_err(bad_request("Failed to read stinger state"))
}

/// Cue a stinger clip: load it and park it on its first frame, so a take
/// starts it without delay.
#[utoipa::path(
post,
path = "/api/flows/{flow_id}/blocks/{block_id}/stinger/cue",
tag = "flows",
params(
("flow_id" = String, Path, description = "Flow ID (UUID)"),
("block_id" = String, Path, description = "Vision mixer block instance ID")
),
request_body = StingerCueRequest,
responses(
(status = 200, description = "Clip cued; the stinger state after the cue", body = StingerState),
(status = 400, description = "The clip could not be cued", body = ErrorResponse),
(status = 409, description = "The library changed: `file` is no longer at `index`", body = ErrorResponse),
)
)]
pub async fn cue_stinger(
State(state): State<AppState>,
Path((flow_id, block_id)): Path<(FlowId, String)>,
Json(req): Json<StingerCueRequest>,
) -> Result<Json<StingerState>, ApiError> {
info!(
"Cueing stinger clip {} on vision mixer {} in flow {}",
req.index, block_id, flow_id
);
state
.stinger_cue(&flow_id, &block_id, req.index, req.file.as_deref())
.await
.map_err(bad_request("Failed to cue stinger"))?;
state
.stinger_state(&flow_id, &block_id)
.await
.map(Json)
.map_err(bad_request("Failed to read stinger state"))
}

/// Take a stinger from PGM to PVW.
#[utoipa::path(
post,
path = "/api/flows/{flow_id}/blocks/{block_id}/stinger/take",
tag = "flows",
params(
("flow_id" = String, Path, description = "Flow ID (UUID)"),
("block_id" = String, Path, description = "Vision mixer block instance ID")
),
request_body = StingerTakeRequest,
responses(
(status = 200, description = "Take started", body = StingerTakeResponse),
(status = 400, description = "The take could not start", body = ErrorResponse),
(status = 409, description = "The library changed: `file` is not the clip that would play", body = ErrorResponse),
)
)]
pub async fn take_stinger(
State(state): State<AppState>,
Path((flow_id, block_id)): Path<(FlowId, String)>,
Json(req): Json<StingerTakeRequest>,
) -> Result<Json<StingerTakeResponse>, ApiError> {
info!(
"Stinger take on vision mixer {} in flow {} (clip {:?})",
block_id, flow_id, req.index
);
state
.stinger_take(&flow_id, &block_id, req.index, req.file.as_deref())
.await
.map(Json)
.map_err(bad_request("Failed to take stinger"))
}

/// Store a stinger clip's settings (layout, cut point, mix, premultiplied
/// alpha, matte inversion) on the stinger source block.
#[utoipa::path(
put,
path = "/api/flows/{flow_id}/blocks/{block_id}/stinger/clips/{index}",
tag = "flows",
params(
("flow_id" = String, Path, description = "Flow ID (UUID)"),
("block_id" = String, Path, description = "Vision mixer block instance ID"),
("index" = usize, Path, description = "Playlist index on the stinger source"),
("file" = Option<String>, Query, description = "The file expected at `index`; 409 when the library has changed")
),
request_body = StingerClipSettings,
responses(
(status = 200, description = "Settings stored; the clip as it now plays", body = StingerClip),
(status = 400, description = "Invalid request", body = ErrorResponse),
(status = 409, description = "The library changed: `file` is no longer at `index`", body = ErrorResponse),
)
)]
pub async fn set_stinger_clip_settings(
State(state): State<AppState>,
Path((flow_id, block_id, index)): Path<(FlowId, String, usize)>,
Query(guard): Query<StingerFileGuard>,
Json(settings): Json<StingerClipSettings>,
) -> Result<Json<StingerClip>, ApiError> {
state
.stinger_set_clip_settings(&flow_id, &block_id, index, guard.file.as_deref(), settings)
.await
.map(Json)
.map_err(bad_request("Failed to store stinger clip settings"))
}

/// Render Strom's example stingers (classic, track matte, mask only) into the
/// media directory and add them to the stinger source's playlist.
#[utoipa::path(
post,
path = "/api/flows/{flow_id}/blocks/{block_id}/stinger/examples",
tag = "flows",
params(
("flow_id" = String, Path, description = "Flow ID (UUID)"),
("block_id" = String, Path, description = "Vision mixer block instance ID")
),
responses(
(status = 200, description = "Examples written", body = StingerExamplesResponse),
(status = 400, description = "Invalid request", body = ErrorResponse),
)
)]
pub async fn write_stinger_examples(
State(state): State<AppState>,
Path((flow_id, block_id)): Path<(FlowId, String)>,
) -> Result<Json<StingerExamplesResponse>, ApiError> {
state
.stinger_write_examples(&flow_id, &block_id)
.await
.map(Json)
.map_err(bad_request("Failed to write example stingers"))
}

/// Add a clip to the stinger library (the stinger source's playlist). Adding
/// a file already in the library returns it unchanged. Upload the file first
/// with the media API when it is not on the server yet.
#[utoipa::path(
post,
path = "/api/flows/{flow_id}/blocks/{block_id}/stinger/clips",
tag = "flows",
params(
("flow_id" = String, Path, description = "Flow ID (UUID)"),
("block_id" = String, Path, description = "Vision mixer block instance ID")
),
request_body = StingerAddClipRequest,
responses(
(status = 200, description = "The clip, as it plays here", body = StingerClip),
(status = 400, description = "Invalid request, or no such file", body = ErrorResponse),
)
)]
pub async fn add_stinger_clip(
State(state): State<AppState>,
Path((flow_id, block_id)): Path<(FlowId, String)>,
Json(req): Json<StingerAddClipRequest>,
) -> Result<Json<StingerClip>, ApiError> {
info!(
"Adding stinger clip {} on vision mixer {} in flow {}",
req.file, block_id, flow_id
);
state
.stinger_add_clip(&flow_id, &block_id, &req.file, req.settings)
.await
.map(Json)
.map_err(bad_request("Failed to add stinger clip"))
}

/// Remove a clip from the stinger library, with its settings. The file stays
/// in the media directory. Refused while a stinger is on air.
#[utoipa::path(
delete,
path = "/api/flows/{flow_id}/blocks/{block_id}/stinger/clips/{index}",
tag = "flows",
params(
("flow_id" = String, Path, description = "Flow ID (UUID)"),
("block_id" = String, Path, description = "Vision mixer block instance ID"),
("index" = usize, Path, description = "Playlist index on the stinger source"),
("file" = Option<String>, Query, description = "The file expected at `index`; 409 when the library has changed")
),
responses(
(status = 204, description = "Removed"),
(status = 400, description = "Invalid request", body = ErrorResponse),
(status = 409, description = "The library changed: `file` is no longer at `index`", body = ErrorResponse),
)
)]
pub async fn remove_stinger_clip(
State(state): State<AppState>,
Path((flow_id, block_id, index)): Path<(FlowId, String, usize)>,
Query(guard): Query<StingerFileGuard>,
) -> Result<StatusCode, ApiError> {
info!(
"Removing stinger clip {} on vision mixer {} in flow {}",
index, block_id, flow_id
);
state
.stinger_remove_clip(&flow_id, &block_id, index, guard.file.as_deref())
.await
.map(|()| StatusCode::NO_CONTENT)
.map_err(bad_request("Failed to remove stinger clip"))
}
5 changes: 5 additions & 0 deletions backend/src/api/vision_mixer_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ async fn render_vision_mixer_page(
"initial_pgm": initial_pgm,
"initial_pvw": initial_pvw,
"num_dsk_inputs": num_dsk_inputs,
"stinger_enabled": vm_props::parse_bool(
&vm_block.properties,
strom_types::stinger::ENABLE_STINGER_PROPERTY,
false,
),
"ftb_active": ftb_active,
"dsk_states": dsk_states,
"overlay_alpha": overlay_alpha,
Expand Down
Loading