voelin-core: stream the studio and keep its scenes in the settings

The studio composites, but nothing yet made its picture a stream or fed
its recording and replay buffer. Streamer::start_studio does both with the
smallest change to the streamer: the studio is one more capture backend,
and the packets the encoders already make are teed to the studio's outputs
where they are produced, with the frame size the recorder needs. Only the
stream codec's encoder is teed; a codec a viewer chose is never recorded.

Recording and the replay buffer must not need a live stream, so a studio's
streamer always has a sink: while no stream is attached it is one that
drops the frames after the tee. Its audio clock starts at the studio's
epoch, the clock the composite's timestamps already count from, so a
recording's audio and video start together (the test checks they do).

Outputs ask for keyframes of the layer they take only. The replay buffer
asks every two seconds while it is on: the encoders make keyframes only on
request, so without that the window could never move past the first one
and would grow for the whole session. WHIP asks once per need (start,
session up, the service's PLI) instead of on every frame until connected,
which would have made every frame a keyframe while ICE came up.

voelin_core::studio re-exports the studio, starts it from studio.scenes and
keeps the two in step both ways without echoes; studio.replay_seconds,
studio.replay_memory_mb and studio.recording_dir join the built-in keys
(with feature media). tests/studio.rs records a stream that switches scenes
live and saves a clip, and decodes both with ffmpeg: red before the switch,
blue after it, VP8 and Opus in sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 02:02:40 +03:00
1 parent 4e270576ce
commit abe5e4ef74
9 files changed
+614 -36

No files matched your search

+53 -2
View File
@@ -1224,9 +1224,52 @@ pub static STREAM_AUDIO_SOURCES: Key<Vec<AudioSourceSetting>> = Key::new(
)
.validated(valid_audio_sources);
/// The Stream Studio's scenes, their sources, and the size and frame rate
/// of its composite (`voelin_media::studio::scene::Scenes`); kept up to date
/// by `crate::studio::start` as the scenes are edited.
#[cfg(feature = "media")]
pub static STUDIO_SCENES: Key<voelin_media::studio::scene::Scenes> = Key::new(
"studio.scenes",
Kind::Json,
"Stream Studio scenes and sources, and the output size and frame rate.",
voelin_media::studio::scene::Scenes::default,
)
.validated(voelin_media::studio::scene::Scenes::check);
/// How many seconds the Stream Studio's replay buffer keeps, for saving a
/// clip after the fact. 0: off. No maximum (past
/// [`STUDIO_REPLAY_MEMORY_MB`] it spills to disk).
#[cfg(feature = "media")]
pub static STUDIO_REPLAY_SECONDS: Key<u32> = Key::new(
"studio.replay_seconds",
Kind::UInt { min: 0 },
"Seconds the Stream Studio's replay buffer keeps (0: off).",
|| 30,
);
/// MiB of the replay buffer kept in memory; older packets go to a
/// temporary file. 0: everything goes to the file.
#[cfg(feature = "media")]
pub static STUDIO_REPLAY_MEMORY_MB: Key<u64> = Key::new(
"studio.replay_memory_mb",
Kind::UInt { min: 0 },
"MiB of the replay buffer kept in memory before older packets go to disk.",
|| 256,
);
/// Where the Stream Studio puts recordings and clips; empty: a `Voelin`
/// folder in the user's videos folder (`crate::studio::recording_dir`).
#[cfg(feature = "media")]
pub static STUDIO_RECORDING_DIR: Key<String> = Key::new(
"studio.recording_dir",
Kind::Text { suggestions: &[] },
"Folder for Stream Studio recordings and clips (empty: Videos/Voelin).",
String::new,
);
/// The keys every [`Settings`] knows from the start.
pub fn builtin_keys() -> [&'static dyn Setting; 20] {
[
pub fn builtin_keys() -> Vec<&'static dyn Setting> {
vec![
&CRASH_REPORTS,
&AUDIO,
&STREAM_FPS,
@@ -1247,6 +1290,14 @@ pub fn builtin_keys() -> [&'static dyn Setting; 20] {
&CACHE_FETCH_IMAGES,
&FILES_PROGRESS_MS,
&PRIVACY_BLOCK_MODE,
#[cfg(feature = "media")]
&STUDIO_SCENES,
#[cfg(feature = "media")]
&STUDIO_REPLAY_SECONDS,
#[cfg(feature = "media")]
&STUDIO_REPLAY_MEMORY_MB,
#[cfg(feature = "media")]
&STUDIO_RECORDING_DIR,
]
}