Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Major audio sync improvements with new timestamp system (#998)
Brendan Allan2823d316bc16
diff --git a/Cargo.lock b/Cargo.lockindex f86cdc3c6..1bae3f738 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -866,7 +866,7 @@ name = "cap-audio"version = "0.1.0"dependencies = ["cidre 0.11.0",- "cpal 0.15.3 (git+https://github.com/RustAudio/cpal?rev=f43d36e55494993bbbde3299af0c53e5cdf4d4cf)",+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca)","ffmpeg-next","tokio",]@@ -953,8 +953,7 @@ dependencies = [name = "cap-cpal-ffmpeg"version = "0.1.0"dependencies = [- "cap-ffmpeg-utils",- "cpal 0.15.3 (git+https://github.com/RustAudio/cpal?rev=f43d36e55494993bbbde3299af0c53e5cdf4d4cf)",+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca)","ffmpeg-next",]@@ -1006,7 +1005,7 @@ dependencies = ["cocoa 0.26.1","core-foundation 0.10.1","core-graphics 0.24.0",- "cpal 0.15.3 (git+https://github.com/RustAudio/cpal?rev=f43d36e55494993bbbde3299af0c53e5cdf4d4cf)",+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca)","device_query","dirs","dotenvy_macro",@@ -1083,7 +1082,7 @@ dependencies = ["cap-media-info","cap-project","cap-rendering",- "cpal 0.15.3 (git+https://github.com/RustAudio/cpal?rev=f43d36e55494993bbbde3299af0c53e5cdf4d4cf)",+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca)","ffmpeg-next","flume","futures",@@ -1100,7 +1099,6 @@ dependencies = [name = "cap-enc-avfoundation"version = "0.1.0"dependencies = [- "cap-ffmpeg-utils","cap-media-info","cidre 0.11.0","ffmpeg-next",@@ -1182,13 +1180,6 @@ dependencies = ["inventory",]-[[package]]-name = "cap-ffmpeg-utils"-version = "0.1.0"-dependencies = [- "ffmpeg-next",-]-[[package]]name = "cap-flags"version = "0.1.0"@@ -1220,8 +1211,7 @@ dependencies = [name = "cap-media-info"version = "0.1.0"dependencies = [- "cap-ffmpeg-utils",- "cpal 0.15.3 (git+https://github.com/RustAudio/cpal?rev=f43d36e55494993bbbde3299af0c53e5cdf4d4cf)",+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca)","ffmpeg-next","thiserror 1.0.69",]@@ -1275,18 +1265,18 @@ dependencies = ["cap-enc-ffmpeg","cap-enc-mediafoundation","cap-fail",- "cap-ffmpeg-utils","cap-flags","cap-media","cap-media-info","cap-mediafoundation-ffmpeg","cap-mediafoundation-utils","cap-project",+ "cap-timestamp","cap-utils","chrono","cidre 0.11.0","cocoa 0.26.1",- "cpal 0.15.3 (git+https://github.com/RustAudio/cpal?rev=f43d36e55494993bbbde3299af0c53e5cdf4d4cf)",+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca)","device_query","either","ffmpeg-next",@@ -1368,6 +1358,15 @@ dependencies = ["tracing-subscriber",]+[[package]]+name = "cap-timestamp"+version = "0.1.0"+dependencies = [+ "cidre 0.11.0",+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca)",+ "windows 0.60.0",+]+[[package]]name = "cap-utils"version = "0.1.0"@@ -2030,7 +2029,7 @@ dependencies = [[[package]]name = "cpal"version = "0.15.3"-source = "git+https://github.com/RustAudio/cpal?rev=f43d36e55494993bbbde3299af0c53e5cdf4d4cf#f43d36e55494993bbbde3299af0c53e5cdf4d4cf"+source = "git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca#3cc779a7b4ca51770211f1b7dc19f107978af707"dependencies = ["alsa","core-foundation-sys",@@ -2234,13 +2233,13 @@ checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a"[[package]]name = "dbus"-version = "0.9.7"+version = "0.9.9"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b"+checksum = "190b6255e8ab55a7b568df5a883e9497edc3e4821c06396612048b430e5ad1e9"dependencies = ["libc","libdbus-sys",- "winapi",+ "windows-sys 0.59.0",][[package]]@@ -3138,16 +3137,6 @@ dependencies = ["version_check",]-[[package]]-name = "gethostname"-version = "0.4.3"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818"-dependencies = [- "libc",- "windows-targets 0.48.5",-]-[[package]]name = "gethostname"version = "1.0.2"@@ -4410,9 +4399,9 @@ checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"[[package]]name = "libdbus-sys"-version = "0.2.5"+version = "0.2.6"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72"+checksum = "5cbe856efeb50e4681f010e9aaa2bf0a644e10139e54cde10fc83a307c23bd9f"dependencies = ["pkg-config",]@@ -4645,6 +4634,15 @@ dependencies = ["syn 2.0.104",]+[[package]]+name = "matchers"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"+dependencies = [+ "regex-automata 0.1.10",+]+[[package]]name = "matches"version = "0.1.10"@@ -6591,8 +6589,17 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"dependencies = ["aho-corasick","memchr",- "regex-automata",- "regex-syntax",+ "regex-automata 0.4.9",+ "regex-syntax 0.8.5",+]++[[package]]+name = "regex-automata"+version = "0.1.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"+dependencies = [+ "regex-syntax 0.6.29",][[package]]@@ -6603,9 +6610,15 @@ checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"dependencies = ["aho-corasick","memchr",- "regex-syntax",+ "regex-syntax 0.8.5",]+[[package]]+name = "regex-syntax"+version = "0.6.29"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"+[[package]]name = "regex-syntax"version = "0.8.5"@@ -6792,13 +6805,12 @@ checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97"[[package]]name = "rust-ini"-version = "0.21.1"+version = "0.21.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f"+checksum = "796e8d2b6696392a43bea58116b667fb4c29727dc5abd27d6acf338bb4f688c7"dependencies = ["cfg-if","ordered-multimap",- "trim-in-place",][[package]]@@ -6969,7 +6981,7 @@ dependencies = [name = "scap-cpal"version = "0.1.0"dependencies = [- "cpal 0.15.3 (git+https://github.com/RustAudio/cpal?rev=f43d36e55494993bbbde3299af0c53e5cdf4d4cf)",+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca)","thiserror 1.0.69",]@@ -6988,9 +7000,8 @@ dependencies = [name = "scap-ffmpeg"version = "0.1.0"dependencies = [- "cap-ffmpeg-utils","cidre 0.11.0",- "cpal 0.15.3 (git+https://github.com/RustAudio/cpal?rev=f43d36e55494993bbbde3299af0c53e5cdf4d4cf)",+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=3cc779a7b4ca)","ffmpeg-next","futures","scap-cpal",@@ -8076,9 +8087,9 @@ dependencies = [[[package]]name = "tao"-version = "0.34.2"+version = "0.34.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "4daa814018fecdfb977b59a094df4bd43b42e8e21f88fddfc05807e6f46efaaf"+checksum = "959469667dbcea91e5485fc48ba7dd6023face91bb0f1a14681a70f99847c3f7"dependencies = ["bitflags 2.9.1","block2 0.6.1",@@ -8144,9 +8155,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"[[package]]name = "tauri"-version = "2.8.4"+version = "2.8.5"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5d545ccf7b60dcd44e07c6fb5aeb09140966f0aabd5d2aa14a6821df7bc99348"+checksum = "d4d1d3b3dc4c101ac989fd7db77e045cc6d91a25349cd410455cb5c57d510c1c"dependencies = ["anyhow","bytes",@@ -8199,9 +8210,9 @@ dependencies = [[[package]]name = "tauri-build"-version = "2.4.0"+version = "2.4.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "67945dbaf8920dbe3a1e56721a419a0c3d085254ab24cff5b9ad55e2b0016e0b"+checksum = "9c432ccc9ff661803dab74c6cd78de11026a578a9307610bbc39d3c55be7943f"dependencies = ["anyhow","cargo_toml",@@ -8310,9 +8321,9 @@ dependencies = [[[package]]name = "tauri-plugin-deep-link"-version = "2.4.2"+version = "2.4.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6d430110d4ee102a9b673d3c03ff48098c80fe8ca71ba1ff52d8a5919538a1a6"+checksum = "cd67112fb1131834c2a7398ffcba520dbbf62c17de3b10329acd1a3554b1a9bb"dependencies = ["dunce","plist",@@ -8331,9 +8342,9 @@ dependencies = [[[package]]name = "tauri-plugin-dialog"-version = "2.3.3"+version = "2.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0ee5a3c416dc59d7d9aa0de5490a82d6e201c67ffe97388979d77b69b08cda40"+checksum = "0beee42a4002bc695550599b011728d9dfabf82f767f134754ed6655e434824e"dependencies = ["log","raw-window-handle",@@ -8469,7 +8480,7 @@ version = "2.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "77a1c77ebf6f20417ab2a74e8c310820ba52151406d0c80fbcea7df232e3f6ba"dependencies = [- "gethostname 1.0.2",+ "gethostname","log","os_info","serde",@@ -8529,9 +8540,9 @@ dependencies = [[[package]]name = "tauri-plugin-single-instance"-version = "2.3.3"+version = "2.3.4"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "236043404a4d1502ed7cce11a8ec88ea1e85597eec9887b4701bb10b66b13b6e"+checksum = "fb9cac815bf11c4a80fb498666bcdad66d65b89e3ae24669e47806febb76389c"dependencies = ["serde","serde_json",@@ -9228,10 +9239,14 @@ version = "0.3.19"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"dependencies = [+ "matchers","nu-ansi-term",+ "once_cell",+ "regex","sharded-slab","smallvec","thread_local",+ "tracing","tracing-core","tracing-log",]@@ -9270,12 +9285,6 @@ dependencies = ["petgraph",]-[[package]]-name = "trim-in-place"-version = "0.1.7"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc"-[[package]]name = "try-lock"version = "0.2.5"@@ -10970,20 +10979,20 @@ dependencies = [[[package]]name = "x11rb"-version = "0.13.1"+version = "0.13.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5d91ffca73ee7f68ce055750bf9f6eca0780b8c85eff9bc046a3b0da41755e12"+checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414"dependencies = [- "gethostname 0.4.3",- "rustix 0.38.44",+ "gethostname",+ "rustix 1.0.8","x11rb-protocol",][[package]]name = "x11rb-protocol"-version = "0.13.1"+version = "0.13.2"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d"+checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd"[[package]]name = "xattr"@@ -11223,9 +11232,9 @@ dependencies = [[[package]]name = "zip"-version = "4.5.0"+version = "4.6.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "8835eb39822904d39cb19465de1159e05d371973f0c6df3a365ad50565ddc8b9"+checksum = "caa8cd6af31c3b31c6631b8f483848b91589021b28fffe50adada48d4f4d2ed1"dependencies = ["arbitrary","crc32fast",diff --git a/Cargo.toml b/Cargo.tomlindex 46cd816ea..1d4c223b0 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -6,7 +6,7 @@ members = ["apps/cli", "apps/desktop/src-tauri", "crates/*"]anyhow = { version = "1.0.86" }# This includes a currently-unreleased fix that ensures the audio stream is actually# stopped and released on drop on macOS-cpal = { git = "https://github.com/RustAudio/cpal", rev = "f43d36e55494993bbbde3299af0c53e5cdf4d4cf" }+cpal = { git = "https://github.com/CapSoftware/cpal", rev = "3cc779a7b4ca" }ffmpeg = { package = "ffmpeg-next", git = "https://github.com/CapSoftware/rust-ffmpeg", rev = "49db1fede112" }tokio = { version = "1.39.3", features = ["macros",@@ -67,6 +67,7 @@ unexpected_cfgs = "allow"[workspace.lints.clippy]dbg_macro = "deny"let_underscore_future = "deny"+unchecked_duration_subtraction = "deny"# Optimize for smaller binary size[profile.release]diff --git a/apps/cli/src/record.rs b/apps/cli/src/record.rsindex f05d58886..73137dcb4 100644--- a/apps/cli/src/record.rs+++ b/apps/cli/src/record.rs@@ -1,4 +1,4 @@-use cap_recording::screen_capture::ScreenCaptureTarget;+use cap_recording::{screen_capture::ScreenCaptureTarget, studio_recording};use clap::Args;use scap_targets::{DisplayId, WindowId};use std::{env::current_dir, path::PathBuf};@@ -58,19 +58,12 @@ impl RecordStart {.path.unwrap_or_else(|| current_dir().unwrap().join(format!("{id}.cap")));- let actor = cap_recording::spawn_studio_recording_actor(- id,- path,- cap_recording::RecordingBaseInputs {- capture_target: target_info,- capture_system_audio: self.system_audio,- mic_feed: None,- camera_feed: None, // camera.map(|c| Arc::new(Mutex::new(c))),- },- false,- )- .await- .map_err(|e| e.to_string())?;+ let actor = studio_recording::Actor::builder(path, target_info)+ .with_system_audio(self.system_audio)+ .with_custom_cursor(false)+ .build()+ .await+ .map_err(|e| e.to_string())?;println!("Recording starting, press Enter to stop");diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex f7d299f51..ebeaf0d13 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -41,7 +41,7 @@"@tauri-apps/api": "2.5.0","@tauri-apps/plugin-clipboard-manager": "^2.3.0","@tauri-apps/plugin-deep-link": "^2.4.1",- "@tauri-apps/plugin-dialog": "^2.3.2",+ "@tauri-apps/plugin-dialog": "^2.4.0","@tauri-apps/plugin-fs": "^2.4.1","@tauri-apps/plugin-http": "^2.5.1","@tauri-apps/plugin-notification": "^2.3.0",diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex ad566014d..fc68098ff 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -5,10 +5,11 @@ use cap_project::{ZoomSegment, cursor::CursorEvents,};use cap_recording::{- CompletedStudioRecording, RecordingError, RecordingMode, StudioRecordingHandle,+ RecordingError, RecordingMode,feeds::{camera, microphone},- instant_recording::{CompletedInstantRecording, InstantRecordingHandle},+ instant_recording,sources::{CaptureDisplay, CaptureWindow, ScreenCaptureTarget, screen_capture},+ studio_recording,};use cap_rendering::ProjectRecordingsMeta;use cap_utils::{ensure_dir, spawn_actor};@@ -40,7 +41,7 @@ use crate::{pub enum InProgressRecording {Instant {target_name: String,- handle: InstantRecordingHandle,+ handle: instant_recording::ActorHandle,progressive_upload: Option<InstantMultipartUpload>,video_upload_info: VideoUploadInfo,inputs: StartRecordingInputs,@@ -48,7 +49,7 @@ pub enum InProgressRecording {},Studio {target_name: String,- handle: StudioRecordingHandle,+ handle: studio_recording::ActorHandle,inputs: StartRecordingInputs,recording_dir: PathBuf,},@@ -132,25 +133,18 @@ impl InProgressRecording {pub enum CompletedRecording {Instant {- recording: CompletedInstantRecording,+ recording: instant_recording::CompletedRecording,target_name: String,progressive_upload: Option<InstantMultipartUpload>,video_upload_info: VideoUploadInfo,},Studio {- recording: CompletedStudioRecording,+ recording: studio_recording::CompletedStudioRecording,target_name: String,},}impl CompletedRecording {- pub fn id(&self) -> &String {- match self {- Self::Instant { recording, .. } => &recording.id,- Self::Studio { recording, .. } => &recording.id,- }- }-pub fn project_path(&self) -> &PathBuf {match self {Self::Instant { recording, .. } => &recording.project_path,@@ -381,25 +375,28 @@ pub async fn start_recording(Err(e) => return Err(e.to_string()),};- let base_inputs = cap_recording::RecordingBaseInputs {- capture_target: inputs.capture_target.clone(),- capture_system_audio: inputs.capture_system_audio,- mic_feed,- camera_feed,- };-let (actor, actor_done_rx) = match inputs.mode {RecordingMode::Studio => {- let (handle, actor_done_rx) = cap_recording::spawn_studio_recording_actor(- id.clone(),+ let mut builder = studio_recording::Actor::builder(recording_dir.clone(),- base_inputs,+ inputs.capture_target.clone(),+ )+ .with_system_audio(inputs.capture_system_audio)+ .with_custom_cursor(general_settings.map(|s| s.custom_cursor_capture).unwrap_or_default(),- )- .await- .map_err(|e| {+ );++ if let Some(camera_feed) = camera_feed {+ builder = builder.with_camera_feed(camera_feed);+ }++ if let Some(mic_feed) = mic_feed {+ builder = builder.with_mic_feed(mic_feed);+ }++ let (handle, actor_done_rx) = builder.build().await.map_err(|e| {error!("Failed to spawn studio recording actor: {e}");e.to_string()})?;@@ -419,17 +416,20 @@ pub async fn start_recording(return Err("Video upload info not found".to_string());};- let (handle, actor_done_rx) =- cap_recording::instant_recording::spawn_instant_recording_actor(- id.clone(),- recording_dir.clone(),- base_inputs,- )- .await- .map_err(|e| {- error!("Failed to spawn studio recording actor: {e}");- e.to_string()- })?;+ let mut builder = instant_recording::Actor::builder(+ recording_dir.clone(),+ inputs.capture_target.clone(),+ )+ .with_system_audio(inputs.capture_system_audio);++ if let Some(mic_feed) = mic_feed {+ builder = builder.with_mic_feed(mic_feed);+ }++ let (handle, actor_done_rx) = builder.build().await.map_err(|e| {+ error!("Failed to spawn studio recording actor: {e}");+ e.to_string()+ })?;(InProgressRecording::Instant {@@ -945,7 +945,7 @@ fn generate_zoom_segments_from_clicks_impl(/// Generates zoom segments based on mouse click events during recording./// Used during the recording completion process.pub fn generate_zoom_segments_from_clicks(- recording: &CompletedStudioRecording,+ recording: &studio_recording::CompletedStudioRecording,recordings: &ProjectRecordingsMeta,) -> Vec<ZoomSegment> {// Build a temporary RecordingMeta so we can use the common implementation@@ -992,7 +992,7 @@ pub fn generate_zoom_segments_for_project(fn project_config_from_recording(app: &AppHandle,- completed_recording: &CompletedStudioRecording,+ completed_recording: &studio_recording::CompletedStudioRecording,recordings: &ProjectRecordingsMeta,default_config: Option<ProjectConfiguration>,) -> ProjectConfiguration {diff --git a/crates/camera-directshow/examples/cli.rs b/crates/camera-directshow/examples/cli.rsindex bad9b5761..d712c1a65 100644--- a/crates/camera-directshow/examples/cli.rs+++ b/crates/camera-directshow/examples/cli.rs@@ -115,8 +115,8 @@ mod windows {&selected_format.media_type,Box::new(|frame| {unsafe { dbg!(frame.sample.GetActualDataLength()) };- dbg!(frame.media_type.subtype_str());- dbg!(frame.reference_time);+ // dbg!(frame.media_type.subtype_str());+ // dbg!(frame.reference_time);dbg!(frame.timestamp);}),)diff --git a/crates/camera-directshow/src/lib.rs b/crates/camera-directshow/src/lib.rsindex bfb468667..41ce055c5 100644--- a/crates/camera-directshow/src/lib.rs+++ b/crates/camera-directshow/src/lib.rs@@ -21,6 +21,7 @@ use windows::{},System::{Com::{StructuredStorage::IPropertyBag, *},+ Performance::QueryPerformanceCounter,Variant::{VARIANT, VT_BSTR},},},@@ -790,8 +791,8 @@ impl<'a> IEnumPins_Impl for PinEnumerator_Impl<'a> {pub struct CallbackData<'a> {pub sample: &'a IMediaSample,pub media_type: &'a AMMediaType,- pub reference_time: Instant,pub timestamp: Duration,+ pub perf_counter: i64,}pub type SinkCallback = Box<dyn FnMut(CallbackData)>;@@ -994,6 +995,9 @@ impl IMemInputPin_Impl for SinkInputPin_Impl {&self,psample: windows_core::Ref<'_, windows::Win32::Media::DirectShow::IMediaSample>,) -> windows_core::Result<()> {+ let mut perf_counter = 0;+ unsafe { QueryPerformanceCounter(&mut perf_counter)? };+let Some(psample) = psample.as_ref() else {return Ok(());};@@ -1022,20 +1026,13 @@ impl IMemInputPin_Impl for SinkInputPin_Impl {let mut start_time = 0;let mut end_time = 0;- let mut timestamp = unsafe { psample.GetTime(&mut start_time, &mut end_time) }- .ok()- .map(|_| Duration::from_micros(start_time as u64 / 10));-- let mut first_ref_time = self.first_ref_time.borrow_mut();- let first_ref_time = first_ref_time.get_or_insert(Instant::now());-- let timestamp = timestamp.get_or_insert(Instant::now() - *first_ref_time);+ unsafe { psample.GetTime(&mut start_time, &mut end_time) }?;(self.callback.borrow_mut())(CallbackData {sample: psample,media_type: &media_type,- reference_time: *first_ref_time,- timestamp: *timestamp,+ timestamp: Duration::from_micros(start_time as u64 / 10),+ perf_counter,});Ok(())diff --git a/crates/camera-mediafoundation/Cargo.toml b/crates/camera-mediafoundation/Cargo.tomlindex db4970a4f..239ce520c 100644--- a/crates/camera-mediafoundation/Cargo.toml+++ b/crates/camera-mediafoundation/Cargo.toml@@ -15,6 +15,8 @@ windows = { workspace = true, features = ["Win32_Media_MediaFoundation","Win32_Media_DirectShow","Win32_System_Com",+ "Win32_System_WinRT",+ "Win32_System_Performance",] }[dev-dependencies]diff --git a/crates/camera-mediafoundation/src/lib.rs b/crates/camera-mediafoundation/src/lib.rsindex 175120a5c..e4335d963 100644--- a/crates/camera-mediafoundation/src/lib.rs+++ b/crates/camera-mediafoundation/src/lib.rs@@ -13,13 +13,16 @@ use std::{Mutex,mpsc::{Receiver, Sender, channel},},- time::{Duration, Instant},+ time::Duration,};use tracing::error;use windows::Win32::{Foundation::{S_FALSE, *},Media::MediaFoundation::*,- System::Com::{CLSCTX_INPROC_SERVER, CoCreateInstance, CoInitialize},+ System::{+ Com::{CLSCTX_INPROC_SERVER, CoCreateInstance, CoInitialize},+ Performance::QueryPerformanceCounter,+ },};use windows_core::{ComObjectInner, Interface, PWSTR, implement};@@ -542,9 +545,8 @@ fn get_device_model_id(device_id: &str) -> Option<String> {pub struct CallbackData {pub sample: IMFSample,- pub reference_time: Instant,pub timestamp: Duration,- pub capture_begin_time: Instant,+ pub perf_counter: i64,}#[implement(IMFCaptureEngineOnSampleCallback, IMFCaptureEngineOnEventCallback)]@@ -555,6 +557,9 @@ struct VideoCallback {impl IMFCaptureEngineOnSampleCallback_Impl for VideoCallback_Impl {fn OnSample(&self, psample: windows_core::Ref<'_, IMFSample>) -> windows_core::Result<()> {+ let mut perf_counter = 0;+ unsafe { QueryPerformanceCounter(&mut perf_counter)? };+let Some(sample) = psample.as_ref() else {return Ok(());};@@ -563,28 +568,12 @@ impl IMFCaptureEngineOnSampleCallback_Impl for VideoCallback_Impl {return Ok(());};- let reference_time = Instant::now();- let mf_time_now = Duration::from_micros(unsafe { MFGetSystemTime() / 10 } as u64);-- let raw_time_stamp = unsafe { sample.GetSampleTime() }.unwrap_or(0);- let timestamp = Duration::from_micros((raw_time_stamp / 10) as u64);-- let raw_capture_begin_time =- unsafe { sample.GetUINT64(&MFSampleExtension_DeviceReferenceSystemTime) }- .or_else(- // retry, it's what chromium does /shrug- |_| unsafe { sample.GetUINT64(&MFSampleExtension_DeviceReferenceSystemTime) },- )- .unwrap_or(unsafe { MFGetSystemTime() } as u64);-- let capture_begin_time =- reference_time + Duration::from_micros(raw_capture_begin_time / 10) - mf_time_now;+ let sample_time = unsafe { sample.GetSampleTime() }?;(callback)(CallbackData {sample: sample.clone(),- reference_time,- timestamp,- capture_begin_time,+ timestamp: Duration::from_micros(sample_time as u64 / 10),+ perf_counter,});Ok(())diff --git a/crates/camera-windows/examples/cli.rs b/crates/camera-windows/examples/cli.rsindex cf73abca5..76b241bb7 100644--- a/crates/camera-windows/examples/cli.rs+++ b/crates/camera-windows/examples/cli.rs@@ -32,7 +32,12 @@ mod windows {let Ok(bytes) = frame.bytes() else {return;};- dbg!(bytes.len(), frame.pixel_format);+ dbg!(+ bytes.len(),+ frame.pixel_format,+ frame.timestamp,+ frame.perf_counter+ );}).unwrap();diff --git a/crates/camera-windows/src/lib.rs b/crates/camera-windows/src/lib.rsindex 9214e1097..51500743f 100644--- a/crates/camera-windows/src/lib.rs+++ b/crates/camera-windows/src/lib.rs@@ -98,8 +98,8 @@ impl VideoDeviceInfo {height: format.height() as usize,pixel_format: format.pixel_format,timestamp: data.timestamp,- reference_time: data.reference_time,- capture_begin_time: Some(data.capture_begin_time),+ perf_counter: data.perf_counter,+ // capture_begin_time: Some(data.capture_begin_time),})}}),@@ -128,8 +128,8 @@ impl VideoDeviceInfo {width: video_info.bmiHeader.biWidth as usize,height: video_info.bmiHeader.biHeight as usize,timestamp: data.timestamp,- reference_time: data.reference_time,- capture_begin_time: None,+ perf_counter: data.perf_counter,+ // capture_begin_time: None,});}),)?;@@ -178,9 +178,9 @@ pub struct Frame {pub pixel_format: PixelFormat,pub width: usize,pub height: usize,- pub reference_time: Instant,+ // pub reference_time: Instant,pub timestamp: Duration,- pub capture_begin_time: Option<Instant>,+ pub perf_counter: i64,inner: FrameInner,}diff --git a/crates/camera/src/lib.rs b/crates/camera/src/lib.rsindex a1af62c6f..cec0e0496 100644--- a/crates/camera/src/lib.rs+++ b/crates/camera/src/lib.rs@@ -3,7 +3,7 @@use std::{fmt::{Debug, Display},ops::Deref,- time::{Duration, Instant},+ time::Duration,};#[cfg(target_os = "macos")]@@ -190,9 +190,9 @@ pub enum StartCapturingError {#[derive(Debug)]pub struct CapturedFrame {native: NativeCapturedFrame,- pub reference_time: Instant,+ // pub reference_time: Instant,pub timestamp: Duration,- pub capture_begin_time: Option<Instant>,+ // pub capture_begin_time: Option<Instant>,}impl CapturedFrame {diff --git a/crates/camera/src/macos.rs b/crates/camera/src/macos.rsindex bf81e186e..cb2035030 100644--- a/crates/camera/src/macos.rs+++ b/crates/camera/src/macos.rs@@ -105,9 +105,9 @@ pub(super) fn start_capturing_impl(callback(CapturedFrame {native: NativeCapturedFrame(image_buf.retained(), data.sample_buf.retained()),- reference_time: Instant::now(),+ // reference_time: Instant::now(),timestamp: data.timestamp,- capture_begin_time: Some(data.capture_begin_time),+ // capture_begin_time: Some(data.capture_begin_time),});})));diff --git a/crates/camera/src/windows.rs b/crates/camera/src/windows.rsindex 9b7771efd..d76909a5d 100644--- a/crates/camera/src/windows.rs+++ b/crates/camera/src/windows.rs@@ -73,8 +73,8 @@ pub(super) fn start_capturing_impl(Ok(WindowsCaptureHandle {inner: device.start_capturing(format.native(), move |frame| {callback(CapturedFrame {- reference_time: frame.reference_time,- capture_begin_time: frame.capture_begin_time,+ // reference_time: frame.reference_time,+ // capture_begin_time: frame.capture_begin_time,timestamp: frame.timestamp,native: NativeCapturedFrame(frame),});diff --git a/crates/cpal-ffmpeg/Cargo.toml b/crates/cpal-ffmpeg/Cargo.tomlindex f0931bd38..4ea431bd5 100644--- a/crates/cpal-ffmpeg/Cargo.toml+++ b/crates/cpal-ffmpeg/Cargo.toml@@ -6,7 +6,6 @@ edition = "2024"[dependencies]cpal.workspace = trueffmpeg.workspace = true-cap-ffmpeg-utils = { path = "../ffmpeg-utils" }[lints]workspace = truediff --git a/crates/cpal-ffmpeg/src/lib.rs b/crates/cpal-ffmpeg/src/lib.rsindex 80f90a232..b09aab297 100644--- a/crates/cpal-ffmpeg/src/lib.rs+++ b/crates/cpal-ffmpeg/src/lib.rs@@ -1,4 +1,3 @@-use cap_ffmpeg_utils::PlanarData;use cpal::{SampleFormat, StreamConfig};use ffmpeg::format::{Sample, sample};@@ -32,7 +31,7 @@ impl DataExt for ::cpal::Data {let base = (i as usize) * plane_size;ffmpeg_frame- .plane_data_mut(i as usize)+ .data_mut(i as usize).copy_from_slice(&self.bytes()[base..base + plane_size]);}} else {diff --git a/crates/enc-avfoundation/Cargo.toml b/crates/enc-avfoundation/Cargo.tomlindex e352610e0..244a3e41a 100644--- a/crates/enc-avfoundation/Cargo.toml+++ b/crates/enc-avfoundation/Cargo.toml@@ -5,7 +5,6 @@ edition = "2024"[dependencies]cap-media-info = { path = "../media-info" }-cap-ffmpeg-utils = { path = "../ffmpeg-utils" }ffmpeg.workspace = truethiserror.workspace = truediff --git a/crates/enc-avfoundation/src/mp4.rs b/crates/enc-avfoundation/src/mp4.rsindex 2092c7efb..c56b56b46 100644--- a/crates/enc-avfoundation/src/mp4.rs+++ b/crates/enc-avfoundation/src/mp4.rs@@ -1,7 +1,6 @@-use cap_ffmpeg_utils::PlanarData;use cap_media_info::{AudioInfo, VideoInfo};use cidre::{cm::SampleTimingInfo, objc::Obj, *};-use ffmpeg::{ffi::AV_TIME_BASE_Q, frame};+use ffmpeg::frame;use std::path::PathBuf;use tracing::{debug, info};@@ -195,6 +194,8 @@ impl MP4Encoder {})}+ /// Expects frames with whatever pts values you like+ /// They will be made relative when encodingpub fn queue_video_frame(&mut self,frame: &cidre::cm::SampleBuf,@@ -205,17 +206,16 @@ impl MP4Encoder {let time = frame.pts();+ let new_pts = self+ .elapsed_duration+ .add(time.sub(self.segment_first_timestamp.unwrap_or(time)));+if !self.is_writing {self.is_writing = true;- self.asset_writer.start_session_at_src_time(time);+ self.asset_writer.start_session_at_src_time(new_pts);self.start_time = time;}- let new_pts = self- .start_time- .add(self.elapsed_duration)- .add(time.sub(self.segment_first_timestamp.unwrap_or(time)));-let mut timing = frame.timing_info(0).unwrap();timing.pts = new_pts;let frame = frame.copy_with_new_timing(&[timing]).unwrap();@@ -234,8 +234,10 @@ impl MP4Encoder {Ok(())}+ /// Expects frames with pts values relative to the first frame's pts+ /// in the timebase of 1 / sample ratepub fn queue_audio_frame(&mut self, frame: frame::Audio) -> Result<(), QueueAudioFrameError> {- if self.is_paused {+ if self.is_paused || !self.is_writing {return Ok(());}@@ -244,7 +246,7 @@ impl MP4Encoder {};if !audio_input.is_ready_for_more_media_data() {- return Err(QueueAudioFrameError::NotReady);+ return Ok(());}let audio_desc = cat::audio::StreamBasicDesc::common_f32(@@ -265,7 +267,7 @@ impl MP4Encoder {if frame.is_planar() {let mut offset = 0;for plane_i in 0..frame.planes() {- let data = frame.plane_data(plane_i);+ let data = frame.data(plane_i);block_buf_slice[offset..offset + data.len()].copy_from_slice(&data[0..frame.samples() * frame.format().bytes()]);offset += data.len();@@ -277,7 +279,7 @@ impl MP4Encoder {let format_desc =cm::AudioFormatDesc::with_asbd(&audio_desc).map_err(QueueAudioFrameError::Setup)?;- let time = cm::Time::new(frame.pts().unwrap_or(0), AV_TIME_BASE_Q.den);+ let time = cm::Time::new(frame.pts().unwrap_or(0), frame.rate() as i32);let pts = self.start_timediff --git a/crates/enc-ffmpeg/src/audio/aac.rs b/crates/enc-ffmpeg/src/audio/aac.rsindex 3df667a38..2f9765790 100644--- a/crates/enc-ffmpeg/src/audio/aac.rs+++ b/crates/enc-ffmpeg/src/audio/aac.rs@@ -5,9 +5,8 @@ use ffmpeg::{frame,threading::Config,};-use std::collections::VecDeque;-use crate::AudioEncoder;+use crate::{AudioEncoder, audio::buffered_resampler::BufferedResampler};#[derive(thiserror::Error, Debug)]pub enum AACEncoderError {@@ -24,9 +23,7 @@ pub struct AACEncoder {tag: &'static str,encoder: encoder::Audio,packet: ffmpeg::Packet,- resampler: Option<ffmpeg::software::resampling::Context>,- resampled_frame: frame::Audio,- buffer: Vec<VecDeque<u8>>,+ resampler: BufferedResampler,stream_index: usize,}@@ -75,39 +72,26 @@ impl AACEncoder {output_config.sample_format = Self::SAMPLE_FORMAT;output_config.sample_rate = rate as u32;- let resampler = if (- input_config.sample_format,- input_config.channel_layout(),- input_config.sample_rate,- ) != (- output_config.sample_format,- output_config.channel_layout(),- output_config.sample_rate,- ) {- Some(- ffmpeg::software::resampler(- (- input_config.sample_format,- input_config.channel_layout(),- input_config.sample_rate,- ),- (- output_config.sample_format,- output_config.channel_layout(),- output_config.sample_rate,- ),- )- .unwrap(),- )- } else {- None- };+ let resampler = ffmpeg::software::resampler(+ (+ input_config.sample_format,+ input_config.channel_layout(),+ input_config.sample_rate,+ ),+ (+ output_config.sample_format,+ output_config.channel_layout(),+ output_config.sample_rate,+ ),+ )+ .unwrap();+ let resampler = BufferedResampler::new(resampler);encoder.set_bit_rate(Self::OUTPUT_BITRATE);encoder.set_rate(rate);encoder.set_format(output_config.sample_format);encoder.set_channel_layout(output_config.channel_layout());- encoder.set_time_base(output_config.time_base);+ encoder.set_time_base(FFRational(1, output_config.rate()));let encoder = encoder.open()?;@@ -118,50 +102,19 @@ impl AACEncoder {Ok(Self {tag,- buffer: vec![VecDeque::new(); 2],encoder,stream_index,packet: ffmpeg::Packet::empty(),- resampled_frame: frame::Audio::empty(),resampler,})}pub fn queue_frame(&mut self, frame: frame::Audio, output: &mut format::context::Output) {- let frame = if let Some(resampler) = &mut self.resampler {- resampler.run(&frame, &mut self.resampled_frame).unwrap();- &self.resampled_frame- } else {- &frame- };-- for i in 0..frame.planes() {- self.buffer[i]- .extend(&frame.data(i)[0..frame_size_bytes(frame) / frame.channels() as usize]);- }+ self.resampler.add_frame(frame);- let channel_size_bytes = self.encoder.frame_size() as usize * self.encoder.format().bytes();-- loop {- if self.buffer[0].len() < channel_size_bytes {- break;- }-- let mut frame = frame::Audio::new(- self.encoder.format(),- self.encoder.frame_size() as usize,- self.encoder.channel_layout(),- );-- for i in 0..frame.planes() {- let bytes = self.buffer[i]- .drain(0..channel_size_bytes)- .collect::<Vec<_>>();-- frame.data_mut(i)[0..channel_size_bytes]- .copy_from_slice(&bytes[0..channel_size_bytes]);- }+ let frame_size = self.encoder.frame_size() as usize;+ while let Some(frame) = self.resampler.get_frame(frame_size) {self.encoder.send_frame(&frame).unwrap();self.process_packets(output);@@ -180,69 +133,10 @@ impl AACEncoder {}pub fn finish(&mut self, output: &mut format::context::Output) {- let frame_size_bytes = self.encoder.frame_size() as usize- * self.encoder.channels() as usize- * self.encoder.format().bytes();-- if let Some(mut resampler) = self.resampler.take() {- while resampler.delay().is_some() {- resampler.flush(&mut self.resampled_frame).unwrap();- if self.resampled_frame.samples() == 0 {- break;- }-- for i in 0..self.resampled_frame.planes() {- self.buffer[i].extend(- &self.resampled_frame.data(0)[0..self.resampled_frame.samples()- * self.resampled_frame.format().bytes()],- );- }-- while self.buffer.len() >= frame_size_bytes {- let mut frame = frame::Audio::new(- self.encoder.format(),- self.encoder.frame_size() as usize,- self.encoder.channel_layout(),- );-- for i in 0..frame.planes() {- let bytes = self.buffer[i]- .drain(0..frame_size_bytes)- .collect::<Vec<_>>();-- frame.data_mut(0)[0..frame_size_bytes].copy_from_slice(&bytes);- }-- self.encoder.send_frame(&frame).unwrap();-- self.process_packets(output);- }- }-- while !self.buffer[0].is_empty() {- let channel_size_bytes =- (frame_size_bytes / self.encoder.channels() as usize).min(self.buffer[0].len());- let frame_size = channel_size_bytes / self.encoder.format().bytes();-- let mut frame = frame::Audio::new(- self.encoder.format(),- frame_size,- self.encoder.channel_layout(),- );-- for i in 0..frame.planes() {- let bytes = self.buffer[i]- .drain(0..channel_size_bytes)- .collect::<Vec<_>>();-- frame.data_mut(i)[0..channel_size_bytes]- .copy_from_slice(&bytes[0..channel_size_bytes]);- }-- self.encoder.send_frame(&frame).unwrap();+ while let Some(frame) = self.resampler.flush(self.encoder.frame_size() as usize) {+ self.encoder.send_frame(&frame).unwrap();- self.process_packets(output);- }+ self.process_packets(output);}self.encoder.send_eof().unwrap();@@ -260,7 +154,3 @@ impl AudioEncoder for AACEncoder {self.finish(output);}}--fn frame_size_bytes(frame: &frame::Audio) -> usize {- frame.samples() * frame.format().bytes() * frame.channels() as usize-}diff --git a/crates/enc-ffmpeg/src/audio/buffered_resampler.rs b/crates/enc-ffmpeg/src/audio/buffered_resampler.rsnew file mode 100644index 000000000..c7706011d--- /dev/null+++ b/crates/enc-ffmpeg/src/audio/buffered_resampler.rs@@ -0,0 +1,597 @@+use std::collections::VecDeque;++use ffmpeg::software::resampling;++/// Consumes audio frames, resmaples them, buffers the results,+/// and allows retrieving new frames of any size.+/// When retrieving new frames via `get_frame`, silence will be accounted+/// for if the requested frame size is larger than the latest buffered frame,+/// ensuring that the resulting frame's PTS is always accurate.+pub struct BufferedResampler {+ resampler: ffmpeg::software::resampling::Context,+ buffer: VecDeque<(ffmpeg::frame::Audio, i64)>,+ sample_index: usize,+ // used to account for cases where pts is rounded down instead of up+ min_next_pts: Option<i64>,+}++impl BufferedResampler {+ pub fn new(resampler: ffmpeg::software::resampling::Context) -> Self {+ Self {+ resampler,+ buffer: VecDeque::new(),+ sample_index: 0,+ min_next_pts: None,+ }+ }++ fn remaining_samples(&self) -> usize {+ let (mut pts, mut remaining_samples) = if let Some(front) = self.buffer.front() {+ (+ front.1 + front.0.samples() as i64,+ front.0.samples() - self.sample_index,+ )+ } else {+ return 0;+ };++ for buffer in self.buffer.iter().skip(1) {+ // fill in gap+ remaining_samples += (buffer.1 - pts) as usize;+ remaining_samples += buffer.0.samples();+ pts += buffer.0.samples() as i64;+ }++ return remaining_samples;+ }++ pub fn output(&self) -> resampling::context::Definition {+ *self.resampler.output()+ }++ pub fn add_frame(&mut self, mut frame: ffmpeg::frame::Audio) {+ if let Some(min_next_pts) = self.min_next_pts {+ if let Some(pts) = frame.pts() {+ frame.set_pts(Some(pts.max(min_next_pts)));+ }+ }++ let pts = frame.pts().unwrap();++ let mut resampled_frame = ffmpeg::frame::Audio::empty();++ self.resampler.run(&frame, &mut resampled_frame).unwrap();++ let resampled_pts =+ (pts as f64 * (resampled_frame.rate() as f64 / frame.rate() as f64)) as i64;++ let mut next_pts = resampled_pts + resampled_frame.samples() as i64;++ self.buffer.push_back((resampled_frame, resampled_pts));++ while let Some(_) = self.resampler.delay() {+ let mut resampled_frame = ffmpeg::frame::Audio::new(+ self.resampler.output().format,+ 0,+ self.resampler.output().channel_layout,+ );+ self.resampler.flush(&mut resampled_frame).unwrap();+ let samples = resampled_frame.samples();+ if samples == 0 {+ break;+ }++ self.buffer.push_back((resampled_frame, next_pts));++ next_pts = next_pts + samples as i64;+ }++ self.min_next_pts = Some(pts + frame.samples() as i64);+ }++ fn get_frame_inner(&mut self, samples: usize) -> Option<ffmpeg::frame::Audio> {+ let output = self.output();++ let mut out_frame =+ ffmpeg::frame::Audio::new(output.format, samples, output.channel_layout);++ let mut samples_already_written = 0;+ let mut current_pts = 0;++ if output.format.is_packed() {+ let bytes_per_sample =+ output.format.bytes() * output.channel_layout.channels() as usize;++ while let Some((frame, pts)) = self.buffer.pop_front() {+ if out_frame.pts().is_none() {+ current_pts = pts + self.sample_index as i64;+ out_frame.set_pts(Some(current_pts));+ }++ if pts >= current_pts + samples as i64 {+ self.buffer.push_front((frame, pts));++ let dest_range_start_samples = samples_already_written;+ let dest_range_end_samples =+ dest_range_start_samples + (samples - samples_already_written);+ out_frame.data_mut(0)[dest_range_start_samples * bytes_per_sample+ ..dest_range_end_samples * bytes_per_sample]+ .fill(0);++ break;+ }++ if current_pts < pts {+ let silence_needed =+ ((pts - current_pts) as usize).min(samples - samples_already_written);++ out_frame.data_mut(0)[samples_already_written * bytes_per_sample+ ..(samples_already_written + silence_needed) * bytes_per_sample]+ .fill(0);++ samples_already_written += silence_needed;+ current_pts += silence_needed as i64;++ if samples_already_written >= samples {+ self.buffer.push_front((frame, pts));+ break;+ }+ }++ let sample_index = self.sample_index;++ let src_samples_remaining = frame.samples() - sample_index;++ let samples_to_write =+ usize::min(src_samples_remaining, samples - samples_already_written);++ let dest_range_start = samples_already_written * bytes_per_sample;+ let dest_range_end = dest_range_start + samples_to_write * bytes_per_sample;++ let src_range_start = sample_index * bytes_per_sample;+ let src_range_end = src_range_start + samples_to_write * bytes_per_sample;++ out_frame.data_mut(0)[dest_range_start..dest_range_end]+ .copy_from_slice(&frame.data(0)[src_range_start..src_range_end]);++ samples_already_written += samples_to_write;++ self.sample_index += samples_to_write;++ current_pts += samples_to_write as i64;++ if samples_to_write < src_samples_remaining {+ self.buffer.push_front((frame, pts));+ break;+ } else if samples_to_write >= src_samples_remaining {+ self.sample_index -= frame.samples();+ }+ }+ } else {+ let channels = output.channel_layout.channels() as usize;+ let bytes_per_sample = output.format.bytes();++ while let Some((frame, pts)) = self.buffer.pop_front() {+ if out_frame.pts().is_none() {+ current_pts = pts + self.sample_index as i64;+ out_frame.set_pts(Some(current_pts));+ }++ if pts >= current_pts + samples as i64 {+ self.buffer.push_front((frame, pts));++ for i in 0..channels {+ let dest_range_start_samples = samples_already_written;+ let dest_range_end_samples =+ dest_range_start_samples + (samples - samples_already_written);+ out_frame.data_mut(i)[dest_range_start_samples * bytes_per_sample+ ..dest_range_end_samples * bytes_per_sample]+ .fill(0);+ }++ break;+ }++ if current_pts < pts {+ let silence_needed =+ ((pts - current_pts) as usize).min(samples - samples_already_written);++ for i in 0..channels {+ out_frame.data_mut(i)[samples_already_written * bytes_per_sample+ ..(samples_already_written + silence_needed) * bytes_per_sample]+ .fill(0);+ }++ samples_already_written += silence_needed;+ current_pts += silence_needed as i64;++ if samples_already_written >= samples {+ self.buffer.push_front((frame, pts));+ break;+ }+ }++ let sample_index = self.sample_index;++ let src_samples_remaining = frame.samples() - sample_index;++ let samples_to_write =+ usize::min(src_samples_remaining, samples - samples_already_written);++ let dest_range_start = samples_already_written * bytes_per_sample;+ let dest_range_end = dest_range_start + samples_to_write * bytes_per_sample;++ let src_range_start = sample_index * bytes_per_sample;+ let src_range_end = src_range_start + samples_to_write * bytes_per_sample;++ for i in 0..channels {+ out_frame.data_mut(i)[dest_range_start..dest_range_end]+ .copy_from_slice(&frame.data(i)[src_range_start..src_range_end]);+ }++ samples_already_written += samples_to_write;++ self.sample_index += samples_to_write;++ current_pts += samples_to_write as i64;++ if samples_to_write < src_samples_remaining {+ self.buffer.push_front((frame, pts));+ break;+ } else if samples_to_write >= src_samples_remaining {+ self.sample_index -= frame.samples();+ }+ }+ }++ Some(out_frame)+ }++ pub fn get_frame(&mut self, samples: usize) -> Option<ffmpeg::frame::Audio> {+ if self.remaining_samples() < samples {+ return None;+ }++ self.get_frame_inner(samples)+ }++ pub fn flush(&mut self, max_samples: usize) -> Option<ffmpeg::frame::Audio> {+ let remaining_samples = self.remaining_samples();+ if remaining_samples == 0 {+ return None;+ }++ self.get_frame_inner(remaining_samples.min(max_samples))+ }+}++#[cfg(test)]+mod test {+ use super::*;+ use ffmpeg::{ChannelLayout, format};++ const IN_RATE: u32 = 100;++ fn create_resampler(out_rate: u32) -> BufferedResampler {+ let resampler = ffmpeg::software::resampler(+ (+ format::Sample::U8(cap_media_info::Type::Packed),+ ChannelLayout::MONO,+ IN_RATE,+ ),+ (+ format::Sample::U8(cap_media_info::Type::Packed),+ ChannelLayout::MONO,+ out_rate,+ ),+ )+ .unwrap();++ BufferedResampler::new(resampler)+ }++ fn make_input_frame(samples: usize, pts: i64) -> ffmpeg::frame::Audio {+ let mut frame = ffmpeg::frame::Audio::new(+ cap_media_info::Sample::U8(cap_media_info::Type::Packed),+ samples,+ ChannelLayout::MONO,+ );++ frame.data_mut(0).fill(69);++ frame.set_rate(IN_RATE);+ frame.set_pts(Some(pts));+ frame+ }++ mod resampler {+ use super::*;++ #[test]+ fn sequential_frames() {+ let mut bufferer = create_resampler(200);++ bufferer.add_frame(make_input_frame(100, 0));+ bufferer.add_frame(make_input_frame(100, 100));++ let sample_sum = bufferer.buffer.iter().map(|f| f.0.samples()).sum::<usize>();+ assert_eq!(sample_sum, 400);++ let first = bufferer.buffer.front().unwrap();+ assert_eq!(first.1, 0);++ let last = bufferer.buffer.back().unwrap();+ assert_eq!(last.1 + last.0.samples() as i64, 400);+ }++ #[test]+ fn start_gap() {+ let mut bufferer = create_resampler(200);++ bufferer.add_frame(make_input_frame(100, 100));+ bufferer.add_frame(make_input_frame(100, 200));++ let first = bufferer.buffer.front().unwrap();+ assert_eq!(first.1, 200);++ let last = bufferer.buffer.back().unwrap();+ assert_eq!(last.1 + last.0.samples() as i64, 600);+ }++ #[test]+ fn middle_gap() {+ let mut bufferer = create_resampler(200);++ bufferer.add_frame(make_input_frame(100, 0));+ bufferer.add_frame(make_input_frame(100, 200));++ let first = bufferer.buffer.front().unwrap();+ assert_eq!(first.1, 0);++ let last = bufferer.buffer.back().unwrap();+ assert_eq!(last.1 + last.0.samples() as i64, 600);+ }+ }++ mod get_frame {+ use super::*;++ #[test]+ fn same_format() {+ // Tests getting 50 then 50 then 50++ let mut bufferer = create_resampler(IN_RATE);++ bufferer.add_frame(make_input_frame(100, 0));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 50);+ assert_eq!(bufferer.sample_index, 50);+ assert_eq!(out_frame.pts(), Some(0));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 50);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(50));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_none());++ // Tests getting 75 then 75 (should fail) then 25 (should succeed)++ let mut bufferer = create_resampler(IN_RATE);++ bufferer.add_frame(make_input_frame(100, 0));++ let out_frame = bufferer.get_frame(75);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 75);+ assert_eq!(bufferer.sample_index, 75);+ assert_eq!(out_frame.pts(), Some(0));++ let out_frame = bufferer.get_frame(75);+ assert!(out_frame.is_none());++ let out_frame = bufferer.get_frame(25);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 25);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(75));+ }++ #[test]+ fn different_format() {+ let mut bufferer = create_resampler(200);++ bufferer.add_frame(make_input_frame(100, 0));++ let out_frame = bufferer.get_frame(125);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 125);+ assert_eq!(bufferer.sample_index, 25);+ assert_eq!(out_frame.pts(), Some(0));++ let out_frame = bufferer.get_frame(100);+ assert!(out_frame.is_none());++ let out_frame = bufferer.get_frame(75);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 75);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(125));+ }++ // start gap will never have silence+ #[test]+ fn start_gap() {+ let mut bufferer = create_resampler(IN_RATE);++ bufferer.add_frame(make_input_frame(100, 100));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 50);+ assert_eq!(bufferer.sample_index, 50);+ assert_eq!(out_frame.pts(), Some(100));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 50);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(150));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_none());+ }++ #[test]+ fn middle_gap_no_silence() {+ let mut bufferer = create_resampler(IN_RATE);++ bufferer.add_frame(make_input_frame(100, 0));+ bufferer.add_frame(make_input_frame(100, 200));++ let out_frame = bufferer.get_frame(100);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 100);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(0));++ let out_frame = bufferer.get_frame(100);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 100);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(200));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_none());+ }++ #[test]+ fn middle_gap_expect_silence() {+ let mut bufferer = create_resampler(IN_RATE);++ bufferer.add_frame(make_input_frame(100, 0));+ bufferer.add_frame(make_input_frame(100, 200));++ let out_frame = bufferer.get_frame(150);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 150);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(0));++ let out_frame = bufferer.get_frame(100);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 100);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(200));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_none());+ }++ #[test]+ fn middle_gap_start_offset() {+ let mut bufferer = create_resampler(IN_RATE);++ bufferer.add_frame(make_input_frame(100, 0));+ bufferer.add_frame(make_input_frame(100, 200));++ let out_frame = bufferer.get_frame(25);+ assert!(out_frame.is_some());++ let out_frame = bufferer.get_frame(175);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 175);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(25));++ let out_frame = bufferer.get_frame(100);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 100);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(200));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_none());+ }++ #[test]+ fn middle_gap_overlap() {+ let mut bufferer = create_resampler(IN_RATE);++ bufferer.add_frame(make_input_frame(100, 0));+ bufferer.add_frame(make_input_frame(100, 200));++ let out_frame = bufferer.get_frame(75);+ assert!(out_frame.is_some());++ let out_frame = bufferer.get_frame(175);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 175);+ assert_eq!(bufferer.sample_index, 50);+ assert_eq!(out_frame.pts(), Some(75));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 50);+ assert_eq!(bufferer.sample_index, 0);+ assert_eq!(out_frame.pts(), Some(250));++ let out_frame = bufferer.get_frame(50);+ assert!(out_frame.is_none());+ }++ #[test]+ fn many_small_frames() {+ let mut bufferer = create_resampler(IN_RATE);++ bufferer.add_frame(make_input_frame(100, 0));+ bufferer.add_frame(make_input_frame(100, 200));++ for i in 0..8 {+ let out_frame = bufferer.get_frame(25);+ assert!(out_frame.is_some());+ let out_frame = out_frame.unwrap();++ assert_eq!(out_frame.samples(), 25);+ assert_eq!(out_frame.pts(), Some(i % 4 * 25 + 200 * (i / 4)));+ assert_eq!(bufferer.sample_index, ((i as usize + 1) % 4) * 25 % 100);+ }+ }+ }+}diff --git a/crates/enc-ffmpeg/src/audio/mod.rs b/crates/enc-ffmpeg/src/audio/mod.rsindex 529c8c28f..184b460cd 100644--- a/crates/enc-ffmpeg/src/audio/mod.rs+++ b/crates/enc-ffmpeg/src/audio/mod.rs@@ -1,4 +1,5 @@mod audio_encoder;+mod buffered_resampler;pub use audio_encoder::*;mod opus;diff --git a/crates/enc-ffmpeg/src/audio/opus.rs b/crates/enc-ffmpeg/src/audio/opus.rsindex aa6265a06..70dde56cc 100644--- a/crates/enc-ffmpeg/src/audio/opus.rs+++ b/crates/enc-ffmpeg/src/audio/opus.rs@@ -5,7 +5,8 @@ use ffmpeg::{frame,threading::Config,};-use std::collections::VecDeque;++use crate::audio::buffered_resampler::BufferedResampler;use super::AudioEncoder;@@ -14,9 +15,7 @@ pub struct OpusEncoder {tag: &'static str,encoder: encoder::Audio,packet: ffmpeg::Packet,- resampler: Option<ffmpeg::software::resampling::Context>,- resampled_frame: frame::Audio,- buffer: VecDeque<u8>,+ resampler: BufferedResampler,stream_index: usize,}@@ -75,39 +74,26 @@ impl OpusEncoder {output_config.sample_format = Self::SAMPLE_FORMAT;output_config.sample_rate = rate as u32;- let resampler = if (- input_config.sample_format,- input_config.channel_layout(),- input_config.sample_rate,- ) != (- output_config.sample_format,- output_config.channel_layout(),- output_config.sample_rate,- ) {- Some(- ffmpeg::software::resampler(- (- input_config.sample_format,- input_config.channel_layout(),- input_config.sample_rate,- ),- (- output_config.sample_format,- output_config.channel_layout(),- output_config.sample_rate,- ),- )- .unwrap(),- )- } else {- None- };+ let resampler = ffmpeg::software::resampler(+ (+ input_config.sample_format,+ input_config.channel_layout(),+ input_config.sample_rate,+ ),+ (+ output_config.sample_format,+ output_config.channel_layout(),+ output_config.sample_rate,+ ),+ )+ .unwrap();+ let resampler = BufferedResampler::new(resampler);encoder.set_bit_rate(Self::OUTPUT_BITRATE);encoder.set_rate(rate);encoder.set_format(output_config.sample_format);encoder.set_channel_layout(output_config.channel_layout());- encoder.set_time_base(output_config.time_base);+ encoder.set_time_base(FFRational(1, output_config.rate()));let encoder = encoder.open()?;@@ -118,68 +104,26 @@ impl OpusEncoder {Ok(Self {tag,- buffer: VecDeque::new(),encoder,stream_index,packet: ffmpeg::Packet::empty(),- resampled_frame: frame::Audio::empty(),resampler,})}- pub fn queue_frame(&mut self, frame: frame::Audio, output: &mut format::context::Output) {- if let Some(resampler) = &mut self.resampler {- resampler.run(&frame, &mut self.resampled_frame).unwrap();-- self.buffer- .extend(&self.resampled_frame.data(0)[0..frame_size_bytes(&self.resampled_frame)]);-- loop {- let frame_size_bytes = self.encoder.frame_size() as usize- * self.encoder.channels() as usize- * self.encoder.format().bytes();- if self.buffer.len() < frame_size_bytes {- break;- }-- let bytes = self.buffer.drain(0..frame_size_bytes).collect::<Vec<_>>();- let mut frame = frame::Audio::new(- self.encoder.format(),- self.encoder.frame_size() as usize,- self.encoder.channel_layout(),- );-- frame.data_mut(0)[0..frame_size_bytes].copy_from_slice(&bytes);-- self.encoder.send_frame(&frame).unwrap();-- self.process_packets(output);- }- } else {- self.buffer- .extend(&frame.data(0)[0..frame_size_bytes(&frame)]);-- loop {- let frame_size_bytes = self.encoder.frame_size() as usize- * self.encoder.channels() as usize- * self.encoder.format().bytes();- if self.buffer.len() < frame_size_bytes {- break;- }+ pub fn input_time_base(&self) -> FFRational {+ self.encoder.time_base()+ }- let bytes = self.buffer.drain(0..frame_size_bytes).collect::<Vec<_>>();- let mut frame = frame::Audio::new(- self.encoder.format(),- self.encoder.frame_size() as usize,- self.encoder.channel_layout(),- );+ pub fn queue_frame(&mut self, frame: frame::Audio, output: &mut format::context::Output) {+ self.resampler.add_frame(frame);- frame.data_mut(0)[0..frame_size_bytes].copy_from_slice(&bytes);+ let frame_size = self.encoder.frame_size() as usize;- self.encoder.send_frame(&frame).unwrap();+ while let Some(frame) = self.resampler.get_frame(frame_size) {+ self.encoder.send_frame(&frame).unwrap();- self.process_packets(output);- }+ self.process_packets(output);}}@@ -195,60 +139,10 @@ impl OpusEncoder {}pub fn finish(&mut self, output: &mut format::context::Output) {- let frame_size_bytes = self.encoder.frame_size() as usize- * self.encoder.channels() as usize- * self.encoder.format().bytes();-- if let Some(mut resampler) = self.resampler.take() {- while resampler.delay().is_some() {- resampler.flush(&mut self.resampled_frame).unwrap();- if self.resampled_frame.samples() == 0 {- break;- }+ while let Some(frame) = self.resampler.flush(self.encoder.frame_size() as usize) {+ self.encoder.send_frame(&frame).unwrap();- self.buffer.extend(- &self.resampled_frame.data(0)[0..self.resampled_frame.samples()- * self.resampled_frame.channels() as usize- * self.resampled_frame.format().bytes()],- );-- while self.buffer.len() >= frame_size_bytes {- let bytes = self.buffer.drain(0..frame_size_bytes).collect::<Vec<_>>();-- let mut frame = frame::Audio::new(- self.encoder.format(),- self.encoder.frame_size() as usize,- self.encoder.channel_layout(),- );-- frame.data_mut(0)[0..frame_size_bytes].copy_from_slice(&bytes);-- self.encoder.send_frame(&frame).unwrap();-- self.process_packets(output);- }- }-- while !self.buffer.is_empty() {- let frame_size_bytes = frame_size_bytes.min(self.buffer.len());- let frame_size = frame_size_bytes- / self.encoder.channels() as usize- / self.encoder.format().bytes();-- let bytes = self.buffer.drain(0..frame_size_bytes).collect::<Vec<_>>();-- let mut frame = frame::Audio::new(- self.encoder.format(),- frame_size,- self.encoder.channel_layout(),- );-- frame.data_mut(0)[0..frame_size_bytes].copy_from_slice(&bytes);-- self.encoder.send_frame(&frame).unwrap();-- self.process_packets(output);- }+ self.process_packets(output);}self.encoder.send_eof().unwrap();@@ -266,7 +160,3 @@ impl AudioEncoder for OpusEncoder {self.finish(output);}}--fn frame_size_bytes(frame: &frame::Audio) -> usize {- frame.samples() * frame.format().bytes() * frame.channels() as usize-}diff --git a/crates/enc-ffmpeg/src/mux/ogg.rs b/crates/enc-ffmpeg/src/mux/ogg.rsindex d45b6b813..1f63a92e5 100644--- a/crates/enc-ffmpeg/src/mux/ogg.rs+++ b/crates/enc-ffmpeg/src/mux/ogg.rs@@ -24,6 +24,10 @@ impl OggFile {Ok(Self { encoder, output })}+ pub fn encoder(&self) -> &OpusEncoder {+ &self.encoder+ }+pub fn queue_frame(&mut self, frame: frame::Audio) {self.encoder.queue_frame(frame, &mut self.output);}diff --git a/crates/ffmpeg-utils/Cargo.toml b/crates/ffmpeg-utils/Cargo.tomldeleted file mode 100644index b1225b5f2..000000000--- a/crates/ffmpeg-utils/Cargo.toml+++ /dev/null@@ -1,10 +0,0 @@-[package]-name = "cap-ffmpeg-utils"-version = "0.1.0"-edition = "2024"--[dependencies]-ffmpeg.workspace = true--[lints]-workspace = truediff --git a/crates/ffmpeg-utils/src/lib.rs b/crates/ffmpeg-utils/src/lib.rsdeleted file mode 100644index 00a2b0405..000000000--- a/crates/ffmpeg-utils/src/lib.rs+++ /dev/null@@ -1,34 +0,0 @@-pub trait PlanarData {- fn plane_data(&self, index: usize) -> &[u8];- fn plane_data_mut(&mut self, index: usize) -> &mut [u8];-}--impl PlanarData for ffmpeg::frame::Audio {- #[inline]- fn plane_data(&self, index: usize) -> &[u8] {- if index >= self.planes() {- panic!("out of bounds");- }-- unsafe {- std::slice::from_raw_parts(- (*self.as_ptr()).data[index],- (*self.as_ptr()).linesize[0] as usize,- )- }- }-- #[inline]- fn plane_data_mut(&mut self, index: usize) -> &mut [u8] {- if index >= self.planes() {- panic!("out of bounds");- }-- unsafe {- std::slice::from_raw_parts_mut(- (*self.as_mut_ptr()).data[index],- (*self.as_ptr()).linesize[0] as usize,- )- }- }-}diff --git a/crates/media-info/Cargo.toml b/crates/media-info/Cargo.tomlindex f16081663..b3eb8a691 100644--- a/crates/media-info/Cargo.toml+++ b/crates/media-info/Cargo.toml@@ -8,7 +8,6 @@ ffmpeg.workspace = truethiserror.workspace = truecpal.workspace = true-cap-ffmpeg-utils = { path = "../ffmpeg-utils" }[lints]workspace = truediff --git a/crates/media-info/src/lib.rs b/crates/media-info/src/lib.rsindex 9ea1d1b1f..a4274ab80 100644--- a/crates/media-info/src/lib.rs+++ b/crates/media-info/src/lib.rs@@ -1,4 +1,3 @@-use cap_ffmpeg_utils::*;use cpal::{SampleFormat, SupportedBufferSize, SupportedStreamConfig};use ffmpeg::frame;pub use ffmpeg::{@@ -27,23 +26,34 @@ pub enum AudioInfoError {impl AudioInfo {pub const MAX_AUDIO_CHANNELS: u16 = 2;- pub fn new(+ pub const fn new(sample_format: Sample,sample_rate: u32,channel_count: u16,) -> Result<Self, AudioInfoError> {- Self::channel_layout_raw(channel_count)- .ok_or(AudioInfoError::ChannelLayout(channel_count))?;+ if Self::channel_layout_raw(channel_count).is_none() {+ return Err(AudioInfoError::ChannelLayout(channel_count));+ }Ok(Self {sample_format,sample_rate,- channels: channel_count.into(),+ channels: channel_count as usize,time_base: FFRational(1, 1_000_000),buffer_size: 1024,})}+ pub const fn new_raw(sample_format: Sample, sample_rate: u32, channel_count: u16) -> Self {+ Self {+ sample_format,+ sample_rate,+ channels: channel_count as usize,+ time_base: FFRational(1, 1_000_000),+ buffer_size: 1024,+ }+ }+pub fn from_stream_config(config: &SupportedStreamConfig) -> Self {let sample_format = ffmpeg_sample_format_for(config.sample_format()).unwrap();let buffer_size = match config.buffer_size() {@@ -78,7 +88,7 @@ impl AudioInfo {})}- fn channel_layout_raw(channels: u16) -> Option<ChannelLayout> {+ const fn channel_layout_raw(channels: u16) -> Option<ChannelLayout> {Some(match channels {1 => ChannelLayout::MONO,2 => ChannelLayout::STEREO,@@ -94,8 +104,8 @@ impl AudioInfo {self.sample_format.bytes()}- pub fn rate(&self) -> i32 {- self.sample_rate.try_into().unwrap()+ pub const fn rate(&self) -> i32 {+ self.sample_rate as i32}pub fn empty_frame(&self, sample_count: usize) -> frame::Audio {@@ -105,13 +115,12 @@ impl AudioInfo {frame}- pub fn wrap_frame(&self, data: &[u8], timestamp: i64) -> frame::Audio {+ pub fn wrap_frame(&self, data: &[u8]) -> frame::Audio {let sample_size = self.sample_size();let interleaved_chunk_size = sample_size * self.channels;let samples = data.len() / interleaved_chunk_size;let mut frame = frame::Audio::new(self.sample_format, samples, self.channel_layout());- frame.set_pts(Some(timestamp));frame.set_rate(self.sample_rate);if self.channels == 0 {@@ -131,7 +140,7 @@ impl AudioInfo {for channel in 0..self.channels {let channel_start = channel * sample_size;let channel_end = channel_start + sample_size;- frame.plane_data_mut(channel)[start..end]+ frame.data_mut(channel)[start..end].copy_from_slice(&interleaved_chunk[channel_start..channel_end]);}}diff --git a/crates/recording/Cargo.toml b/crates/recording/Cargo.tomlindex 52ac8672a..746448c12 100644--- a/crates/recording/Cargo.toml+++ b/crates/recording/Cargo.toml@@ -20,7 +20,7 @@ cap-cursor-info = { path = "../cursor-info" }cap-camera = { path = "../camera", features = ["serde", "specta"] }cap-camera-ffmpeg = { path = "../camera-ffmpeg" }cap-enc-ffmpeg = { path = "../enc-ffmpeg" }-cap-ffmpeg-utils = { path = "../ffmpeg-utils" }+cap-timestamp = { path = "../timestamp" }specta.workspace = truetokio.workspace = true@@ -65,6 +65,7 @@ windows = { workspace = true, features = ["Win32_Foundation","Win32_Graphics_Gdi","Win32_UI_WindowsAndMessaging",+ "Win32_System_Performance",] }scap-direct3d = { path = "../scap-direct3d" }scap-ffmpeg = { path = "../scap-ffmpeg" }@@ -72,4 +73,4 @@ scap-cpal = { path = "../scap-cpal" }[dev-dependencies]tempfile = "3.20.0"-tracing-subscriber = { version = "0.3.19", default-features = false }+tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }diff --git a/crates/recording/examples/recording-cli.rs b/crates/recording/examples/recording-cli.rsindex fc1c126b2..26200723a 100644--- a/crates/recording/examples/recording-cli.rs+++ b/crates/recording/examples/recording-cli.rs@@ -1,11 +1,14 @@-use std::time::Duration;--use cap_recording::{RecordingBaseInputs, screen_capture::ScreenCaptureTarget};+use cap_recording::{feeds::microphone, screen_capture::ScreenCaptureTarget, *};+use kameo::Actor;use scap_targets::Display;+use std::time::Duration;use tracing::info;#[tokio::main]pub async fn main() {+ unsafe { std::env::set_var("RUST_LOG", "trace") };+ unsafe { std::env::set_var("RUST_BACKTRACE", "1") };+#[cfg(windows)]{use windows::Win32::UI::HiDpi::{PROCESS_PER_MONITOR_DPI_AWARE, SetProcessDpiAwareness};@@ -22,20 +25,48 @@ pub async fn main() {info!("Recording to directory '{}'", dir.path().display());- let (handle, _ready_rx) = cap_recording::spawn_studio_recording_actor(- "test".to_string(),+ // let camera_feed = CameraFeed::spawn(CameraFeed::default());++ // camera_feed+ // .ask(camera::SetInput {+ // id: DeviceOrModelID::from_info(&cap_camera::list_cameras().next().unwrap()),+ // })+ // .await+ // .unwrap()+ // .await+ // .unwrap();++ let (error_tx, _) = flume::bounded(1);+ let mic_feed = MicrophoneFeed::spawn(MicrophoneFeed::new(error_tx));++ mic_feed+ .ask(microphone::SetInput {+ label:+ // MicrophoneFeed::list()+ // .into_iter()+ // .find(|(k, _)| k.contains("Focusrite"))+ MicrophoneFeed::default()+ .map(|v| v.0)+ .unwrap(),+ })+ .await+ .unwrap()+ .await+ .unwrap();++ tokio::time::sleep(Duration::from_millis(10)).await;++ let (handle, _ready_rx) = instant_recording::Actor::builder(dir.path().into(),- RecordingBaseInputs {- capture_target: ScreenCaptureTarget::Display {- id: Display::primary().id(),- },- capture_system_audio: true,- camera_feed: None,- mic_feed: None,+ ScreenCaptureTarget::Display {+ id: Display::primary().id(),},- false,- // true,)+ .with_system_audio(true)+ // .with_mic_feed(std::sync::Arc::new(+ // mic_feed.ask(microphone::Lock).await.unwrap(),+ // ))+ .build().await.unwrap();diff --git a/crates/recording/src/capture_pipeline.rs b/crates/recording/src/capture_pipeline.rsindex 30fc96f14..f34b6e913 100644--- a/crates/recording/src/capture_pipeline.rs+++ b/crates/recording/src/capture_pipeline.rs@@ -3,12 +3,13 @@ use crate::{feeds::microphone::MicrophoneFeedLock,pipeline::builder::PipelineBuilder,sources::{- AudioInputSource, AudioMixer, ScreenCaptureFormat, ScreenCaptureSource,- ScreenCaptureTarget, screen_capture,+ AudioInputSource, ScreenCaptureFormat, ScreenCaptureSource, ScreenCaptureTarget,+ audio_mixer::AudioMixer, screen_capture,},};use cap_media::MediaError;use cap_media_info::AudioInfo;+use cap_timestamp::{Timestamp, Timestamps};use flume::{Receiver, Sender};use std::{future::Future,@@ -22,10 +23,10 @@ pub trait MakeCapturePipeline: ScreenCaptureFormat + std::fmt::Debug + 'static {builder: PipelineBuilder,source: (ScreenCaptureSource<Self>,- flume::Receiver<(Self::VideoFormat, f64)>,+ flume::Receiver<(Self::VideoFormat, Timestamp)>,),output_path: PathBuf,- ) -> Result<(PipelineBuilder, flume::Receiver<f64>), MediaError>+ ) -> Result<(PipelineBuilder, flume::Receiver<Timestamp>), MediaError>whereSelf: Sized;@@ -33,10 +34,10 @@ pub trait MakeCapturePipeline: ScreenCaptureFormat + std::fmt::Debug + 'static {builder: PipelineBuilder,source: (ScreenCaptureSource<Self>,- flume::Receiver<(Self::VideoFormat, f64)>,+ flume::Receiver<(Self::VideoFormat, Timestamp)>,),audio: Option<Arc<MicrophoneFeedLock>>,- system_audio: Option<(Receiver<(ffmpeg::frame::Audio, f64)>, AudioInfo)>,+ system_audio: Option<(Receiver<(ffmpeg::frame::Audio, Timestamp)>, AudioInfo)>,output_path: PathBuf,pause_flag: Arc<AtomicBool>,) -> impl Future<Output = Result<PipelineBuilder, MediaError>> + Send@@ -50,10 +51,10 @@ impl MakeCapturePipeline for screen_capture::CMSampleBufferCapture {mut builder: PipelineBuilder,source: (ScreenCaptureSource<Self>,- flume::Receiver<(Self::VideoFormat, f64)>,+ flume::Receiver<(Self::VideoFormat, Timestamp)>,),output_path: PathBuf,- ) -> Result<(PipelineBuilder, flume::Receiver<f64>), MediaError> {+ ) -> Result<(PipelineBuilder, flume::Receiver<Timestamp>), MediaError> {let screen_config = source.0.info();tracing::info!("screen config: {:?}", screen_config);@@ -74,18 +75,19 @@ impl MakeCapturePipeline for screen_capture::CMSampleBufferCapture {let mut timestamp_tx = Some(timestamp_tx);let _ = ready.send(Ok(()));- let Ok(frame) = source.1.recv() else {+ let Ok((frame, timestamp)) = source.1.recv() else {return Ok(());};if let Some(timestamp_tx) = timestamp_tx.take() {- let _ = timestamp_tx.send(frame.1);+ let _ = timestamp_tx.send(timestamp);+ let _ = screen_encoder.queue_video_frame(frame.as_ref());}let result = loop {match source.1.recv() {- Ok(frame) => {- let _ = screen_encoder.queue_video_frame(frame.0.as_ref());+ Ok((frame, _)) => {+ let _ = screen_encoder.queue_video_frame(frame.as_ref());}// Err(RecvTimeoutError::Timeout) => {// break Err("Frame receive timeout".to_string());@@ -108,23 +110,26 @@ impl MakeCapturePipeline for screen_capture::CMSampleBufferCapture {mut builder: PipelineBuilder,source: (ScreenCaptureSource<Self>,- flume::Receiver<(Self::VideoFormat, f64)>,+ flume::Receiver<(Self::VideoFormat, Timestamp)>,),audio: Option<Arc<MicrophoneFeedLock>>,- system_audio: Option<(Receiver<(ffmpeg::frame::Audio, f64)>, AudioInfo)>,+ system_audio: Option<(Receiver<(ffmpeg::frame::Audio, Timestamp)>, AudioInfo)>,output_path: PathBuf,pause_flag: Arc<AtomicBool>,) -> Result<PipelineBuilder, MediaError> {+ let start_time = Timestamps::now();+let (audio_tx, audio_rx) = flume::bounded(64);- let mut audio_mixer = AudioMixer::new(audio_tx);+ let mut audio_mixer = AudioMixer::builder(audio_tx);if let Some(system_audio) = system_audio {audio_mixer.add_source(system_audio.1, system_audio.0);}if let Some(audio) = audio {- let sink = audio_mixer.sink(*audio.audio_info());- let source = AudioInputSource::init(audio, sink.tx, SystemTime::now());+ let (tx, rx) = flume::bounded(32);+ audio_mixer.add_source(*audio.audio_info(), rx);+ let source = AudioInputSource::init(audio, tx);builder.spawn_source("microphone_capture", source);}@@ -135,7 +140,7 @@ impl MakeCapturePipeline for screen_capture::CMSampleBufferCapture {cap_enc_avfoundation::MP4Encoder::init("mp4",source.0.info(),- has_audio_sources.then_some(AudioMixer::info()),+ has_audio_sources.then_some(AudioMixer::INFO),output_path,Some(1080),)@@ -143,11 +148,10 @@ impl MakeCapturePipeline for screen_capture::CMSampleBufferCapture {));use cidre::cm;- use ffmpeg::ffi::AV_TIME_BASE_Q;use tracing::error;let (first_frame_tx, mut first_frame_rx) =- tokio::sync::oneshot::channel::<(cm::Time, f64)>();+ tokio::sync::oneshot::channel::<(cm::Time, Timestamp)>();if has_audio_sources {builder.spawn_source("audio_mixer", audio_mixer);@@ -157,9 +161,7 @@ impl MakeCapturePipeline for screen_capture::CMSampleBufferCapture {let _ = ready.send(Ok(()));let mut time = None;- while let Ok(mut frame) = audio_rx.recv() {- let pts = frame.pts().unwrap();-+ while let Ok((mut frame, timestamp)) = audio_rx.recv() {if let Ok(first_time) = first_frame_rx.try_recv() {time = Some(first_time);};@@ -168,14 +170,15 @@ impl MakeCapturePipeline for screen_capture::CMSampleBufferCapture {continue;};- let elapsed = (pts as f64 / AV_TIME_BASE_Q.den as f64) - time.1;+ let ts_offset = timestamp.duration_since(start_time);+ let screen_first_offset = time.1.duration_since(start_time);- let time = time.0.add(cm::Time::new(- (elapsed * time.0.scale as f64 + time.1 * time.0.scale as f64) as i64,- time.0.scale,- ));+ let Some(ts_offset) = ts_offset.checked_sub(screen_first_offset) else {+ continue;+ };- frame.set_pts(Some(time.value / (time.scale / AV_TIME_BASE_Q.den) as i64));+ let pts = (ts_offset.as_secs_f64() * frame.rate() as f64) as i64;+ frame.set_pts(Some(pts));if let Ok(mut mp4) = mp4.lock()&& let Err(e) = mp4.queue_audio_frame(frame)@@ -192,7 +195,7 @@ impl MakeCapturePipeline for screen_capture::CMSampleBufferCapture {let mut first_frame_tx = Some(first_frame_tx);builder.spawn_task("screen_capture_encoder", move |ready| {let _ = ready.send(Ok(()));- while let Ok((frame, unix_time)) = source.1.recv() {+ while let Ok((frame, timestamp)) = source.1.recv() {if let Ok(mut mp4) = mp4.lock() {if pause_flag.load(std::sync::atomic::Ordering::Relaxed) {mp4.pause();@@ -201,7 +204,7 @@ impl MakeCapturePipeline for screen_capture::CMSampleBufferCapture {}if let Some(first_frame_tx) = first_frame_tx.take() {- let _ = first_frame_tx.send((frame.pts(), unix_time));+ let _ = first_frame_tx.send((frame.pts(), timestamp));}mp4.queue_video_frame(frame.as_ref())@@ -228,10 +231,10 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {mut builder: PipelineBuilder,source: (ScreenCaptureSource<Self>,- flume::Receiver<(Self::VideoFormat, f64)>,+ flume::Receiver<(Self::VideoFormat, Timestamp)>,),output_path: PathBuf,- ) -> Result<(PipelineBuilder, flume::Receiver<f64>), MediaError>+ ) -> Result<(PipelineBuilder, flume::Receiver<Timestamp>), MediaError>whereSelf: Sized,{@@ -258,7 +261,7 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {match native_encoder {Ok(encoder) => {- let mut muxer = cap_mediafoundation_ffmpeg::H264StreamMuxer::new(+ let muxer = cap_mediafoundation_ffmpeg::H264StreamMuxer::new(&mut output,cap_mediafoundation_ffmpeg::MuxerConfig {width: screen_config.width,@@ -382,10 +385,10 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {mut builder: PipelineBuilder,source: (ScreenCaptureSource<Self>,- flume::Receiver<(Self::VideoFormat, f64)>,+ flume::Receiver<(Self::VideoFormat, Timestamp)>,),audio: Option<Arc<MicrophoneFeedLock>>,- system_audio: Option<(Receiver<(ffmpeg::frame::Audio, f64)>, AudioInfo)>,+ system_audio: Option<(Receiver<(ffmpeg::frame::Audio, Timestamp)>, AudioInfo)>,output_path: PathBuf,_pause_flag: Arc<AtomicBool>,) -> Result<PipelineBuilder, MediaError>@@ -397,16 +400,19 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {cap_mediafoundation_utils::thread_init();+ let start_time = Timestamps::now();+let (audio_tx, audio_rx) = flume::bounded(64);- let mut audio_mixer = AudioMixer::new(audio_tx);+ let mut audio_mixer = AudioMixer::builder(audio_tx);if let Some(system_audio) = system_audio {audio_mixer.add_source(system_audio.1, system_audio.0);}if let Some(audio) = audio {- let sink = audio_mixer.sink(*audio.audio_info());- let source = AudioInputSource::init(audio, sink.tx, SystemTime::now());+ let (tx, rx) = flume::bounded(32);+ audio_mixer.add_source(*audio.audio_info(), rx);+ let source = AudioInputSource::init(audio, tx);builder.spawn_source("microphone_capture", source);}@@ -469,7 +475,7 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {let audio_encoder = has_audio_sources.then(|| {- AACEncoder::init("mic_audio", AudioMixer::info(), &mut output)+ AACEncoder::init("mic_audio", AudioMixer::INFO, &mut output).map(|v| v.boxed()).map_err(|e| MediaError::Any(e.to_string().into()))})@@ -482,18 +488,33 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {let output = Arc::new(std::sync::Mutex::new(output));+ let (first_frame_tx, first_frame_rx) = tokio::sync::oneshot::channel::<Timestamp>();+if let Some(mut audio_encoder) = audio_encoder {builder.spawn_source("audio_mixer", audio_mixer);- // let is_done = is_done.clone();let output = output.clone();builder.spawn_task("audio_encoding", move |ready| {let _ = ready.send(Ok(()));- while let Ok(frame) = audio_rx.recv() {++ let time = first_frame_rx.blocking_recv().unwrap();+ let screen_first_offset = time.duration_since(start_time);++ while let Ok((mut frame, timestamp)) = audio_rx.recv() {+ let ts_offset = timestamp.duration_since(start_time);++ let Some(ts_offset) = ts_offset.checked_sub(screen_first_offset) else {+ continue;+ };++ let pts = (ts_offset.as_secs_f64() * frame.rate() as f64) as i64;+ frame.set_pts(Some(pts));+if let Ok(mut output) = output.lock() {- audio_encoder.queue_frame(frame, &mut *output);+ audio_encoder.queue_frame(frame, &mut output)}}+Ok(())});}@@ -509,9 +530,13 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {let _ = ready.send(Ok(()));+ let mut first_frame_tx = Some(first_frame_tx);+while let Ok(e) = encoder.get_event() {match e {MediaFoundation::METransformNeedInput => {+ use cap_timestamp::PerformanceCounterTimestamp;+let Ok((frame, _)) = source.1.recv() else {break;};@@ -521,6 +546,14 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {.SystemRelativeTime().map_err(|e| format!("Frame Time: {e}"))?;+ let timestamp = Timestamp::PerformanceCounter(+ PerformanceCounterTimestamp::new(frame_time.Duration),+ );++ if let Some(first_frame_tx) = first_frame_tx.take() {+ let _ = first_frame_tx.send(timestamp);+ }+encoder.handle_needs_input(frame.texture(), frame_time).map_err(|e| format!("NeedsInput: {e}"))?;@@ -588,7 +621,7 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {type ScreenCaptureReturn<T> = (ScreenCaptureSource<T>,- Receiver<(<T as ScreenCaptureFormat>::VideoFormat, f64)>,+ Receiver<(<T as ScreenCaptureFormat>::VideoFormat, Timestamp)>,);#[cfg(target_os = "macos")]@@ -601,7 +634,7 @@ pub async fn create_screen_capture(capture_target: &ScreenCaptureTarget,force_show_cursor: bool,max_fps: u32,- audio_tx: Option<Sender<(ffmpeg::frame::Audio, f64)>>,+ audio_tx: Option<Sender<(ffmpeg::frame::Audio, Timestamp)>>,start_time: SystemTime,#[cfg(windows)] d3d_device: ::windows::Win32::Graphics::Direct3D11::ID3D11Device,) -> Result<ScreenCaptureReturn<ScreenCaptureMethod>, RecordingError> {diff --git a/crates/recording/src/cursor.rs b/crates/recording/src/cursor.rsindex 7c42933db..c17e1c186 100644--- a/crates/recording/src/cursor.rs+++ b/crates/recording/src/cursor.rs@@ -1,7 +1,8 @@use cap_cursor_capture::CursorCropBounds;use cap_cursor_info::CursorShape;use cap_project::{CursorClickEvent, CursorMoveEvent, XY};-use std::{collections::HashMap, path::PathBuf, time::SystemTime};+use cap_timestamp::Timestamps;+use std::{collections::HashMap, path::PathBuf};use tokio::sync::oneshot;use tokio_util::sync::CancellationToken;@@ -41,7 +42,7 @@ pub fn spawn_cursor_recorder(cursors_dir: PathBuf,prev_cursors: Cursors,next_cursor_id: u32,- start_time: SystemTime,+ start_time: Timestamps,) -> CursorActor {use cap_utils::spawn_actor;use device_query::{DeviceQuery, DeviceState};@@ -81,10 +82,7 @@ pub fn spawn_cursor_recorder(break;};- let Ok(elapsed) = start_time.elapsed() else {- continue;- };- let elapsed = elapsed.as_secs_f64() * 1000.0;+ let elapsed = start_time.instant().elapsed().as_secs_f64() * 1000.0;let mouse_state = device_state.get_mouse();let cursor_data = get_cursor_data();diff --git a/crates/recording/src/feeds/camera.rs b/crates/recording/src/feeds/camera.rsindex 16660407f..b805497a8 100644--- a/crates/recording/src/feeds/camera.rs+++ b/crates/recording/src/feeds/camera.rs@@ -1,6 +1,10 @@use cap_camera::CameraInfo;+use cap_camera_ffmpeg::*;use cap_fail::fail_err;use cap_media_info::VideoInfo;+#[cfg(windows)]+use cap_timestamp::PerformanceCounterTimestamp;+use cap_timestamp::Timestamp;use ffmpeg::frame;use futures::{FutureExt, future::BoxFuture};use kameo::prelude::*;@@ -9,20 +13,17 @@ use std::{cmp::Ordering,ops::Deref,sync::mpsc::{self, SyncSender},- time::{Duration, Instant},+ time::Duration,};use tokio::{runtime::Runtime, sync::oneshot, task::LocalSet};use tracing::{debug, error, trace, warn};-use cap_camera_ffmpeg::*;-const CAMERA_INIT_TIMEOUT: Duration = Duration::from_secs(4);#[derive(Clone)]pub struct RawCameraFrame {pub frame: frame::Video,- pub timestamp: Duration,- pub reference_time: Instant,+ pub timestamp: Timestamp,}#[derive(Actor)]@@ -282,8 +283,18 @@ async fn setup_camera(let _ = recipient.tell(NewFrame(RawCameraFrame {frame: ff_frame,- timestamp: frame.timestamp,- reference_time: frame.reference_time,+ #[cfg(windows)]+ timestamp: Timestamp::PerformanceCounter(PerformanceCounterTimestamp::new(+ frame.native().perf_counter,+ )),+ #[cfg(target_os = "macos")]+ timestamp: Timestamp::MachAbsoluteTime(+ cap_timestamp::MachAbsoluteTimestamp::new(+ cidre::cm::Clock::convert_host_time_to_sys_units(+ frame.native().sample_buf().pts(),+ ),+ ),+ ),})).try_send();})diff --git a/crates/recording/src/feeds/microphone.rs b/crates/recording/src/feeds/microphone.rsindex d20b90092..7701a5eca 100644--- a/crates/recording/src/feeds/microphone.rs+++ b/crates/recording/src/feeds/microphone.rs@@ -1,4 +1,5 @@use cap_media_info::{AudioInfo, ffmpeg_sample_format_for};+use cap_timestamp::Timestamp;use cpal::{Device, InputCallbackInfo, SampleFormat, StreamError, SupportedStreamConfig,traits::{DeviceTrait, HostTrait, StreamTrait},@@ -21,6 +22,7 @@ pub struct MicrophoneSamples {pub data: Vec<u8>,pub format: SampleFormat,pub info: InputCallbackInfo,+ pub timestamp: Timestamp,}#[derive(Actor)]@@ -91,44 +93,15 @@ impl MicrophoneFeed {}}+ pub fn default() -> Option<(String, Device, SupportedStreamConfig)> {+ let host = cpal::default_host();+ host.default_input_device().and_then(get_usable_device)+ }+pub fn list() -> MicrophonesMap {let host = cpal::default_host();let mut device_map = IndexMap::new();- let get_usable_device = |device: Device| {- device- .supported_input_configs()- .map_err(|error| {- error!(- "Error getting supported input configs for device: {}",- error- );- error- })- .ok()- .and_then(|configs| {- let mut configs = configs.collect::<Vec<_>>();- configs.sort_by(|a, b| {- b.sample_format()- .sample_size()- .cmp(&a.sample_format().sample_size())- .then(b.max_sample_rate().cmp(&a.max_sample_rate()))- });- configs- .into_iter()- .filter(|c| {- c.min_sample_rate().0 <= 48000 && c.max_sample_rate().0 <= 48000- })- .find(|c| ffmpeg_sample_format_for(c.sample_format()).is_some())- })- .and_then(|config| {- device- .name()- .ok()- .map(|name| (name, device, config.with_max_sample_rate()))- })- };-if let Some((name, device, config)) =host.default_input_device().and_then(get_usable_device){@@ -152,6 +125,38 @@ impl MicrophoneFeed {}}+fn get_usable_device(device: Device) -> Option<(String, Device, SupportedStreamConfig)> {+ device+ .supported_input_configs()+ .map_err(|error| {+ error!(+ "Error getting supported input configs for device: {}",+ error+ );+ error+ })+ .ok()+ .and_then(|configs| {+ let mut configs = configs.collect::<Vec<_>>();+ configs.sort_by(|a, b| {+ b.sample_format()+ .sample_size()+ .cmp(&a.sample_format().sample_size())+ .then(b.max_sample_rate().cmp(&a.max_sample_rate()))+ });+ configs+ .into_iter()+ .filter(|c| c.min_sample_rate().0 <= 48000 && c.max_sample_rate().0 <= 48000)+ .find(|c| ffmpeg_sample_format_for(c.sample_format()).is_some())+ })+ .and_then(|config| {+ device+ .name()+ .ok()+ .map(|name| (name, device, config.with_max_sample_rate()))+ })+}+#[derive(Reply)]pub struct MicrophoneFeedLock {actor: ActorRef<MicrophoneFeed>,@@ -297,6 +302,7 @@ impl Message<SetInput> for MicrophoneFeed {data: data.bytes().to_vec(),format: data.sample_format(),info: info.clone(),+ timestamp: Timestamp::from_cpal(info.timestamp().capture),}).try_send();}diff --git a/crates/recording/src/instant_recording.rs b/crates/recording/src/instant_recording.rsindex bcd10c60f..187546257 100644--- a/crates/recording/src/instant_recording.rs+++ b/crates/recording/src/instant_recording.rs@@ -1,6 +1,14 @@+use crate::{+ ActorError, RecordingBaseInputs, RecordingError,+ capture_pipeline::{MakeCapturePipeline, create_screen_capture},+ feeds::microphone::MicrophoneFeedLock,+ pipeline::RecordingPipeline,+ sources::{ScreenCaptureSource, ScreenCaptureTarget},+};use cap_media::MediaError;use cap_media_info::{AudioInfo, VideoInfo};use cap_project::InstantRecordingMeta;+use cap_timestamp::Timestamp;use cap_utils::{ensure_dir, spawn_actor};use flume::Receiver;use std::{@@ -11,37 +19,29 @@ use std::{use tokio::sync::oneshot;use tracing::{Instrument, debug, error, info, trace};-use crate::{- ActorError, RecordingBaseInputs, RecordingError,- capture_pipeline::{MakeCapturePipeline, create_screen_capture},- feeds::microphone::MicrophoneFeedLock,- pipeline::Pipeline,- sources::{ScreenCaptureSource, ScreenCaptureTarget},-};--struct InstantRecordingPipeline {- pub inner: Pipeline,+struct Pipeline {+ pub inner: RecordingPipeline,#[allow(unused)]pub output_path: PathBuf,pub pause_flag: Arc<AtomicBool>,}-enum InstantRecordingActorState {+enum ActorState {Recording {- pipeline: InstantRecordingPipeline,+ pipeline: Pipeline,pipeline_done_rx: oneshot::Receiver<Result<(), String>>,segment_start_time: f64,},Paused {- pipeline: InstantRecordingPipeline,+ pipeline: Pipeline,pipeline_done_rx: oneshot::Receiver<Result<(), String>>,segment_start_time: f64,},}#[derive(Clone)]-pub struct InstantRecordingHandle {- ctrl_tx: flume::Sender<InstantRecordingActorControlMessage>,+pub struct ActorHandle {+ ctrl_tx: flume::Sender<ActorControlMessage>,pub capture_target: ScreenCaptureTarget,// pub bounds: Bounds,}@@ -57,32 +57,32 @@ macro_rules! send_message {}};}-impl InstantRecordingHandle {- pub async fn stop(&self) -> Result<CompletedInstantRecording, RecordingError> {- send_message!(self.ctrl_tx, InstantRecordingActorControlMessage::Stop)+impl ActorHandle {+ pub async fn stop(&self) -> Result<CompletedRecording, RecordingError> {+ send_message!(self.ctrl_tx, ActorControlMessage::Stop)}pub async fn pause(&self) -> Result<(), RecordingError> {- send_message!(self.ctrl_tx, InstantRecordingActorControlMessage::Pause)+ send_message!(self.ctrl_tx, ActorControlMessage::Pause)}pub async fn resume(&self) -> Result<(), RecordingError> {- send_message!(self.ctrl_tx, InstantRecordingActorControlMessage::Resume)+ send_message!(self.ctrl_tx, ActorControlMessage::Resume)}pub async fn cancel(&self) -> Result<(), RecordingError> {- send_message!(self.ctrl_tx, InstantRecordingActorControlMessage::Cancel)+ send_message!(self.ctrl_tx, ActorControlMessage::Cancel)}}-pub enum InstantRecordingActorControlMessage {+pub enum ActorControlMessage {Pause(oneshot::Sender<Result<(), RecordingError>>),Resume(oneshot::Sender<Result<(), RecordingError>>),- Stop(oneshot::Sender<Result<CompletedInstantRecording, RecordingError>>),+ Stop(oneshot::Sender<Result<CompletedRecording, RecordingError>>),Cancel(oneshot::Sender<Result<(), RecordingError>>),}-impl std::fmt::Debug for InstantRecordingActorControlMessage {+impl std::fmt::Debug for ActorControlMessage {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {match self {Self::Pause(_) => write!(f, "Pause"),@@ -93,15 +93,13 @@ impl std::fmt::Debug for InstantRecordingActorControlMessage {}}-pub struct InstantRecordingActor {- id: String,+pub struct Actor {recording_dir: PathBuf,capture_target: ScreenCaptureTarget,video_info: VideoInfo,}-pub struct CompletedInstantRecording {- pub id: String,+pub struct CompletedRecording {pub project_path: PathBuf,pub display_source: ScreenCaptureTarget,pub meta: InstantRecordingMeta,@@ -112,17 +110,11 @@ async fn create_pipeline<TCaptureFormat: MakeCapturePipeline>(output_path: PathBuf,screen_source: (ScreenCaptureSource<TCaptureFormat>,- flume::Receiver<(TCaptureFormat::VideoFormat, f64)>,+ flume::Receiver<(TCaptureFormat::VideoFormat, Timestamp)>,),mic_feed: Option<Arc<MicrophoneFeedLock>>,- system_audio: Option<Receiver<(ffmpeg::frame::Audio, f64)>>,-) -> Result<- (- InstantRecordingPipeline,- oneshot::Receiver<Result<(), String>>,- ),- MediaError,-> {+ system_audio: Option<Receiver<(ffmpeg::frame::Audio, Timestamp)>>,+) -> Result<(Pipeline, oneshot::Receiver<Result<(), String>>), MediaError> {if let Some(mic_feed) = &mic_feed {debug!("mic audio info: {:#?}",@@ -130,7 +122,7 @@ async fn create_pipeline<TCaptureFormat: MakeCapturePipeline>();};- let pipeline_builder = Pipeline::builder();+ let pipeline_builder = RecordingPipeline::builder();let pause_flag = Arc::new(AtomicBool::new(false));let system_audio = system_audio.map(|v| (v, screen_source.0.audio_info()));@@ -149,7 +141,7 @@ async fn create_pipeline<TCaptureFormat: MakeCapturePipeline>(pipeline.play().await?;Ok((- InstantRecordingPipeline {+ Pipeline {inner: pipeline,output_path,pause_flag,@@ -158,13 +150,61 @@ async fn create_pipeline<TCaptureFormat: MakeCapturePipeline>())}+impl Actor {+ pub fn builder(output: PathBuf, capture_target: ScreenCaptureTarget) -> ActorBuilder {+ ActorBuilder::new(output, capture_target)+ }+}++pub struct ActorBuilder {+ output_path: PathBuf,+ capture_target: ScreenCaptureTarget,+ system_audio: bool,+ mic_feed: Option<Arc<MicrophoneFeedLock>>,+}++impl ActorBuilder {+ pub fn new(output: PathBuf, capture_target: ScreenCaptureTarget) -> Self {+ Self {+ output_path: output,+ capture_target,+ system_audio: false,+ mic_feed: None,+ }+ }++ pub fn with_system_audio(mut self, system_audio: bool) -> Self {+ self.system_audio = system_audio;+ self+ }++ pub fn with_mic_feed(mut self, mic_feed: Arc<MicrophoneFeedLock>) -> Self {+ self.mic_feed = Some(mic_feed);+ self+ }++ pub async fn build(+ self,+ ) -> Result<(ActorHandle, oneshot::Receiver<Result<(), String>>), RecordingError> {+ spawn_instant_recording_actor(+ self.output_path,+ RecordingBaseInputs {+ capture_target: self.capture_target,+ capture_system_audio: self.system_audio,+ mic_feed: self.mic_feed,+ camera_feed: None,+ },+ )+ .await+ }+}+pub async fn spawn_instant_recording_actor(- id: String,recording_dir: PathBuf,inputs: RecordingBaseInputs,) -> Result<(- InstantRecordingHandle,+ ActorHandle,tokio::sync::oneshot::Receiver<Result<(), String>>,),RecordingError,@@ -221,14 +261,13 @@ pub async fn spawn_instant_recording_actor(let inputs = inputs.clone();let video_info = screen_source.info();async move {- let mut actor = InstantRecordingActor {- id,+ let mut actor = Actor {recording_dir,capture_target: inputs.capture_target,video_info,};- let mut state = InstantRecordingActorState::Recording {+ let mut state = ActorState::Recording {pipeline,pipeline_done_rx,segment_start_time,@@ -253,7 +292,7 @@ pub async fn spawn_instant_recording_actor(});Ok((- InstantRecordingHandle {+ ActorHandle {ctrl_tx,capture_target: inputs.capture_target,// bounds: *screen_source.get_bounds(),@@ -280,16 +319,15 @@ macro_rules! send_response {}async fn run_actor_iteration(- state: InstantRecordingActorState,- ctrl_rx: &Receiver<InstantRecordingActorControlMessage>,- actor: InstantRecordingActor,-) -> Result<Option<(InstantRecordingActorState, InstantRecordingActor)>, InstantRecordingActorError>-{- use InstantRecordingActorControlMessage as Msg;- use InstantRecordingActorState as State;+ state: ActorState,+ ctrl_rx: &Receiver<ActorControlMessage>,+ actor: Actor,+) -> Result<Option<(ActorState, Actor)>, InstantRecordingActorError> {+ use ActorControlMessage as Msg;+ use ActorState as State;// Helper function to shutdown pipeline- async fn shutdown(mut pipeline: InstantRecordingPipeline) -> Result<(), RecordingError> {+ async fn shutdown(mut pipeline: Pipeline) -> Result<(), RecordingError> {pipeline.inner.shutdown().await?;Ok(())}@@ -374,7 +412,7 @@ async fn run_actor_iteration(let res = shutdown(pipeline).await;let res = match res {- Ok(_) => stop_recording(actor).await,+ Ok(_) => Ok(stop_recording(actor).await),Err(e) => Err(e),};@@ -431,20 +469,17 @@ async fn run_actor_iteration(})}-async fn stop_recording(- actor: InstantRecordingActor,-) -> Result<CompletedInstantRecording, RecordingError> {+async fn stop_recording(actor: Actor) -> CompletedRecording {use cap_project::*;- Ok(CompletedInstantRecording {- id: actor.id,+ CompletedRecording {project_path: actor.recording_dir.clone(),meta: InstantRecordingMeta {fps: actor.video_info.fps(),sample_rate: None,},display_source: actor.capture_target,- })+ }}fn current_time_f64() -> f64 {diff --git a/crates/recording/src/lib.rs b/crates/recording/src/lib.rsindex 007599dda..5842be671 100644--- a/crates/recording/src/lib.rs+++ b/crates/recording/src/lib.rs@@ -6,13 +6,8 @@ pub mod pipeline;pub mod sources;pub mod studio_recording;-pub use instant_recording::{- CompletedInstantRecording, InstantRecordingActor, spawn_instant_recording_actor,-};+pub use feeds::{camera::CameraFeed, microphone::MicrophoneFeed};pub use sources::{camera, screen_capture};-pub use studio_recording::{- CompletedStudioRecording, StudioRecordingHandle, spawn_studio_recording_actor,-};use cap_media::MediaError;use feeds::microphone::MicrophoneFeedLock;diff --git a/crates/recording/src/pipeline/audio_buffer.rs b/crates/recording/src/pipeline/audio_buffer.rsindex 39045e5cb..fd3e6442f 100644--- a/crates/recording/src/pipeline/audio_buffer.rs+++ b/crates/recording/src/pipeline/audio_buffer.rs@@ -1,5 +1,4 @@use cap_audio::cast_bytes_to_f32_slice;-use cap_ffmpeg_utils::*;use cap_media_info::AudioInfo;use ffmpeg::encoder;pub use ffmpeg::util::frame::Audio as FFAudio;@@ -47,8 +46,7 @@ impl AudioBuffer {if frame.is_planar() {for channel in 0..self.config.channels {- self.data[channel]- .extend(unsafe { cast_bytes_to_f32_slice(frame.plane_data(channel)) });+ self.data[channel].extend(unsafe { cast_bytes_to_f32_slice(frame.data(channel)) });}} else {self.data[0].extend(unsafe {@@ -80,7 +78,7 @@ impl AudioBuffer {.drain(0..actual_samples_per_channel).enumerate(){- self.frame.plane_data_mut(channel)[index * 4..(index + 1) * 4]+ self.frame.data_mut(channel)[index * 4..(index + 1) * 4].copy_from_slice(&byte.to_ne_bytes());}}@@ -89,7 +87,7 @@ impl AudioBuffer {.drain(0..actual_samples_per_channel * self.config.channels).enumerate(){- self.frame.plane_data_mut(0)[index * 4..(index + 1) * 4]+ self.frame.data_mut(0)[index * 4..(index + 1) * 4].copy_from_slice(&byte.to_ne_bytes());}}diff --git a/crates/recording/src/pipeline/builder.rs b/crates/recording/src/pipeline/builder.rsindex a1b8f5319..cb3972b1b 100644--- a/crates/recording/src/pipeline/builder.rs+++ b/crates/recording/src/pipeline/builder.rs@@ -8,7 +8,7 @@ use tokio::sync::oneshot;use tracing::{error, info};use crate::pipeline::{- MediaError, Pipeline,+ MediaError, RecordingPipeline,control::ControlBroadcast,task::{PipelineReadySignal, PipelineSourceTask},};@@ -107,7 +107,7 @@ impl PipelineBuilder {impl PipelineBuilder {pub async fn build(self,- ) -> Result<(Pipeline, oneshot::Receiver<Result<(), String>>), MediaError> {+ ) -> Result<(RecordingPipeline, oneshot::Receiver<Result<(), String>>), MediaError> {let Self { control, tasks } = self;if tasks.is_empty() {@@ -154,7 +154,7 @@ impl PipelineBuilder {});Ok((- Pipeline {+ RecordingPipeline {control,task_handles,is_shutdown: false,diff --git a/crates/recording/src/pipeline/mod.rs b/crates/recording/src/pipeline/mod.rsindex 4d2e16c23..f0050b794 100644--- a/crates/recording/src/pipeline/mod.rs+++ b/crates/recording/src/pipeline/mod.rs@@ -12,13 +12,13 @@ use crate::MediaError;use builder::PipelineBuilder;use control::{Control, ControlBroadcast, PipelineControlSignal};-pub struct Pipeline {+pub struct RecordingPipeline {control: ControlBroadcast,task_handles: IndexMap<String, JoinHandle<()>>,is_shutdown: bool,}-impl Pipeline {+impl RecordingPipeline {pub fn builder() -> PipelineBuilder {PipelineBuilder::default()}diff --git a/crates/recording/src/sources/audio_input.rs b/crates/recording/src/sources/audio_input.rsindex 67416adc9..af10294e8 100644--- a/crates/recording/src/sources/audio_input.rs+++ b/crates/recording/src/sources/audio_input.rs@@ -5,11 +5,12 @@ use crate::{use cap_fail::fail;use cap_media::MediaError;use cap_media_info::AudioInfo;-use cpal::{Device, StreamInstant, SupportedStreamConfig};-use ffmpeg::{frame::Audio as FFAudio, sys::AV_TIME_BASE_Q};+use cap_timestamp::Timestamp;+use cpal::{Device, SupportedStreamConfig};+use ffmpeg::frame::Audio as FFAudio;use flume::{Receiver, Sender};use indexmap::IndexMap;-use std::{sync::Arc, time::SystemTime};+use std::sync::Arc;use tracing::{error, info};pub type AudioInputDeviceMap = IndexMap<String, (Device, SupportedStreamConfig)>;@@ -17,26 +18,15 @@ pub type AudioInputDeviceMap = IndexMap<String, (Device, SupportedStreamConfig)>pub struct AudioInputSource {feed: Arc<MicrophoneFeedLock>,audio_info: AudioInfo,- tx: Sender<(FFAudio, f64)>,- start_timestamp: Option<(StreamInstant, SystemTime)>,- start_time: f64,+ tx: Sender<(FFAudio, Timestamp)>,}impl AudioInputSource {- pub fn init(- feed: Arc<MicrophoneFeedLock>,- tx: Sender<(FFAudio, f64)>,- start_time: SystemTime,- ) -> Self {+ pub fn init(feed: Arc<MicrophoneFeedLock>, tx: Sender<(FFAudio, Timestamp)>) -> Self {Self {audio_info: *feed.audio_info(),feed,tx,- start_timestamp: None,- start_time: start_time- .duration_since(SystemTime::UNIX_EPOCH)- .unwrap()- .as_secs_f64(),}}@@ -45,33 +35,9 @@ impl AudioInputSource {}fn process_frame(&mut self, samples: MicrophoneSamples) -> Result<(), MediaError> {- let start_timestamp = match self.start_timestamp {- None => *self- .start_timestamp- .insert((samples.info.timestamp().capture, SystemTime::now())),- Some(v) => v,- };-- let elapsed = samples- .info- .timestamp()- .capture- .duration_since(&start_timestamp.0)- .unwrap();-- let timestamp = start_timestamp- .1- .checked_add(elapsed)- .unwrap()- .duration_since(SystemTime::UNIX_EPOCH)- .unwrap()- .as_secs_f64()- - self.start_time;+ let timestamp = Timestamp::from_cpal(samples.info.timestamp().capture);- let frame = self.audio_info.wrap_frame(- &samples.data,- (elapsed.as_secs_f64() * AV_TIME_BASE_Q.den as f64) as i64,- );+ let frame = self.audio_info.wrap_frame(&samples.data);if self.tx.send((frame, timestamp)).is_err() {return Err(MediaError::Any("Pipeline is unreachable! Stopping capture".into(),diff --git a/crates/recording/src/sources/audio_mixer.rs b/crates/recording/src/sources/audio_mixer.rsindex 57f8d509e..8e28e8855 100644--- a/crates/recording/src/sources/audio_mixer.rs+++ b/crates/recording/src/sources/audio_mixer.rs@@ -1,50 +1,53 @@+use crate::pipeline::task::PipelineSourceTask;use cap_media_info::AudioInfo;-use ffmpeg::sys::AV_TIME_BASE_Q;+use cap_timestamp::{Timestamp, Timestamps};use flume::{Receiver, Sender};-use std::time::Duration;-use tracing::{debug, warn};+use std::{+ collections::VecDeque,+ time::{Duration, Instant},+};+use tracing::debug;-use crate::pipeline::task::PipelineSourceTask;+// Wait TICK_MS for frames to arrive+// Assume all sources' frames for that tick have arrived after TICK_MS+// Insert silence where necessary for sources with no frames+//+// Current problem is generating an output timestamp that lines up with the input's timestamp-pub struct AudioMixer {- sources: Vec<AudioMixerSource>,- output: Sender<ffmpeg::frame::Audio>,+struct MixerSource {+ rx: Receiver<(ffmpeg::frame::Audio, Timestamp)>,+ info: AudioInfo,+ buffer: VecDeque<(ffmpeg::frame::Audio, Timestamp)>,+ buffer_last: Option<(Timestamp, Duration)>,}-impl AudioMixer {- pub fn new(output: Sender<ffmpeg::frame::Audio>) -> Self {+pub struct AudioMixerBuilder {+ sources: Vec<MixerSource>,+ output: Sender<(ffmpeg::frame::Audio, Timestamp)>,+}++impl AudioMixerBuilder {+ pub fn new(output: Sender<(ffmpeg::frame::Audio, Timestamp)>) -> Self {Self {sources: Vec::new(),output,}}- pub fn sink(&mut self, info: AudioInfo) -> AudioMixerSink {- let (tx, rx) = flume::bounded(32);-- self.sources.push(AudioMixerSource { rx, info });-- AudioMixerSink { tx }- }-- pub fn add_source(&mut self, info: AudioInfo, rx: Receiver<(ffmpeg::frame::Audio, f64)>) {- self.sources.push(AudioMixerSource { rx, info })- }-pub fn has_sources(&self) -> bool {!self.sources.is_empty()}- pub fn info() -> AudioInfo {- AudioInfo::new(- ffmpeg::format::Sample::F32(ffmpeg::format::sample::Type::Packed),- 48000,- 2,- )- .unwrap()+ pub fn add_source(&mut self, info: AudioInfo, rx: Receiver<(ffmpeg::frame::Audio, Timestamp)>) {+ self.sources.push(MixerSource {+ info,+ rx,+ buffer: VecDeque::new(),+ buffer_last: None,+ });}- pub fn run(&mut self, mut get_is_stopped: impl FnMut() -> bool, on_ready: impl FnOnce()) {+ pub fn build(self) -> Result<AudioMixer, ffmpeg::Error> {let mut filter_graph = ffmpeg::filter::Graph::new();let mut abuffers = self@@ -63,45 +66,36 @@ impl AudioMixer {debug!("audio mixer input {i}: {args}");- filter_graph- .add(- &ffmpeg::filter::find("abuffer").expect("Failed to find abuffer filter"),- &format!("src{i}"),- &args,- )- .unwrap()+ filter_graph.add(+ &ffmpeg::filter::find("abuffer").expect("Failed to find abuffer filter"),+ &format!("src{i}"),+ &args,+ )})- .collect::<Vec<_>>();-- let mut amix = filter_graph- .add(- &ffmpeg::filter::find("amix").expect("Failed to find amix filter"),- "amix",- &format!(- "inputs={}:duration=first:dropout_transition=0",- abuffers.len()- ),- )- .unwrap();+ .collect::<Result<Vec<_>, _>>()?;++ let mut amix = filter_graph.add(+ &ffmpeg::filter::find("amix").expect("Failed to find amix filter"),+ "amix",+ &format!(+ "inputs={}:duration=first:dropout_transition=0",+ abuffers.len()+ ),+ )?;let aformat_args = "sample_fmts=flt:sample_rates=48000:channel_layouts=stereo";- debug!("aformat args: {aformat_args}");-- let mut aformat = filter_graph- .add(- &ffmpeg::filter::find("aformat").expect("Failed to find aformat filter"),- "aformat",- aformat_args,- )- .expect("Failed to add aformat filter");-- let mut abuffersink = filter_graph- .add(- &ffmpeg::filter::find("abuffersink").expect("Failed to find abuffersink filter"),- "sink",- "",- )- .expect("Failed to add abuffersink filter");++ let mut aformat = filter_graph.add(+ &ffmpeg::filter::find("aformat").expect("Failed to find aformat filter"),+ "aformat",+ aformat_args,+ )?;++ let mut abuffersink = filter_graph.add(+ &ffmpeg::filter::find("abuffersink").expect("Failed to find abuffersink filter"),+ "sink",+ "",+ )?;for (i, abuffer) in abuffers.iter_mut().enumerate() {abuffer.link(0, &mut amix, i as u32);@@ -110,74 +104,454 @@ impl AudioMixer {amix.link(0, &mut aformat, 0);aformat.link(0, &mut abuffersink, 0);- filter_graph- .validate()- .expect("Failed to validate filter graph");+ filter_graph.validate()?;++ Ok(AudioMixer {+ sources: self.sources,+ samples_out: 0,+ output: self.output,+ last_tick: None,+ abuffers,+ abuffersink,+ _filter_graph: filter_graph,+ _amix: amix,+ _aformat: aformat,+ start_timestamp: None,+ timestamps: Timestamps::now(),+ })+ }+}- on_ready();+pub struct AudioMixer {+ sources: Vec<MixerSource>,+ samples_out: usize,+ output: Sender<(ffmpeg::frame::Audio, Timestamp)>,+ last_tick: Option<Timestamp>,+ // sample_timestamps: VecDeque<(usize, Timestamp)>,+ abuffers: Vec<ffmpeg::filter::Context>,+ abuffersink: ffmpeg::filter::Context,+ _filter_graph: ffmpeg::filter::Graph,+ _amix: ffmpeg::filter::Context,+ _aformat: ffmpeg::filter::Context,+ timestamps: Timestamps,+ start_timestamp: Option<Timestamp>,+}- let mut filtered = ffmpeg::frame::Audio::empty();- loop {- if get_is_stopped() {- return;- }+impl AudioMixer {+ pub const INFO: AudioInfo = AudioInfo::new_raw(+ cap_media_info::Sample::F32(cap_media_info::Type::Packed),+ 48_000,+ 2,+ );+ pub const BUFFER_TIMEOUT: Duration = Duration::from_millis(200);++ fn buffer_sources(&mut self, now: Timestamp) {+ for source in &mut self.sources {+ let rate = source.info.rate();- for (i, source) in self.sources.iter().enumerate() {- loop {- let value = match source.rx.try_recv() {- Ok(v) => v,- Err(flume::TryRecvError::Disconnected) => return,- Err(flume::TryRecvError::Empty) => break,- };- let frame = &value.0;+ if let Some(last) = source.buffer_last {+ let last_end = last.0 + last.1;+ if let Some(elapsed_since_last) = now+ .duration_since(self.timestamps)+ .checked_sub(last_end.duration_since(self.timestamps))+ {+ let mut remaining = elapsed_since_last;- abuffers[i].source().add(frame).unwrap();+ while remaining > Self::BUFFER_TIMEOUT {+ let chunk_samples =+ (Self::BUFFER_TIMEOUT.as_secs_f64() * rate as f64) as usize;++ let mut frame = ffmpeg::frame::Audio::new(+ source.info.sample_format,+ chunk_samples,+ source.info.channel_layout(),+ );+ frame.set_rate(source.info.rate() as u32);++ for i in 0..frame.planes() {+ frame.data_mut(i).fill(0);+ }++ let timestamp = last_end + (elapsed_since_last - remaining);+ source.buffer_last = Some((timestamp, Self::BUFFER_TIMEOUT));+ source.buffer.push_back((frame, timestamp));++ remaining -= Self::BUFFER_TIMEOUT;+ }}}- while abuffersink.sink().frame(&mut filtered).is_ok() {- let adjusted_pts =- filtered.pts().unwrap() as f64 / 48000.0 * AV_TIME_BASE_Q.den as f64;- filtered.set_pts(Some(adjusted_pts as i64));- if self.output.send(filtered).is_err() {- warn!("Mixer unable to send output");- return;+ while let Ok((frame, timestamp)) = source.rx.try_recv() {+ // if gap between incoming and last, insert silence+ if let Some((buffer_last_timestamp, buffer_last_duration)) = source.buffer_last {+ let timestamp_elapsed = timestamp.duration_since(self.timestamps);+ let buffer_last_elapsed = buffer_last_timestamp.duration_since(self.timestamps);++ if timestamp_elapsed > buffer_last_elapsed {+ let elapsed_since_last_frame = timestamp_elapsed - buffer_last_elapsed;++ if let Some(diff) =+ elapsed_since_last_frame.checked_sub(buffer_last_duration)+ && diff >= Duration::from_millis(1)+ {+ let gap = diff;++ print!("Gap between last buffer frame, inserting {gap:?} of silence");++ let silence_samples_needed = (gap.as_secs_f64()) * rate as f64;+ let silence_samples_count = silence_samples_needed.ceil() as usize;++ let mut frame = ffmpeg::frame::Audio::new(+ source.info.sample_format,+ silence_samples_count,+ source.info.channel_layout(),+ );++ for i in 0..frame.planes() {+ frame.data_mut(i).fill(0);+ }++ frame.set_rate(source.info.rate() as u32);++ let timestamp = buffer_last_timestamp + gap;+ source.buffer_last = Some((+ timestamp,+ Duration::from_secs_f64(silence_samples_count as f64 / rate as f64),+ ));+ source.buffer.push_back((frame, timestamp));+ }+ }}- filtered = ffmpeg::frame::Audio::empty()++ source.buffer_last = Some((+ timestamp,+ Duration::from_secs_f64(frame.samples() as f64 / frame.rate() as f64),+ ));+ source.buffer.push_back((frame, timestamp));}+ }++ if self.start_timestamp.is_none() {+ self.start_timestamp = self+ .sources+ .iter()+ .filter_map(|s| s.buffer.get(0))+ .min_by(|a, b| {+ a.1.duration_since(self.timestamps)+ .cmp(&b.1.duration_since(self.timestamps))+ })+ .map(|v| v.1);+ }++ if let Some(start_timestamp) = self.start_timestamp {+ if let Some(elapsed_since_start) = now+ .duration_since(self.timestamps)+ .checked_sub(start_timestamp.duration_since(self.timestamps))+ && elapsed_since_start > Self::BUFFER_TIMEOUT+ {+ for source in &mut self.sources {+ if source.buffer_last.is_none() {+ let rate = source.info.rate();++ let mut remaining = elapsed_since_start;+ while remaining > Self::BUFFER_TIMEOUT {+ let chunk_samples =+ (Self::BUFFER_TIMEOUT.as_secs_f64() * rate as f64) as usize;- std::thread::sleep(Duration::from_millis(2))+ let mut frame = ffmpeg::frame::Audio::new(+ source.info.sample_format,+ chunk_samples,+ source.info.channel_layout(),+ );++ for i in 0..frame.planes() {+ frame.data_mut(i).fill(0);+ }++ frame.set_rate(source.info.rate() as u32);++ let timestamp = start_timestamp + (elapsed_since_start - remaining);+ source.buffer_last = Some((+ timestamp,+ Duration::from_secs_f64(chunk_samples as f64 / rate as f64),+ ));+ source.buffer.push_front((frame, timestamp));++ remaining -= Self::BUFFER_TIMEOUT;+ }+ }+ }+ }}}-}-pub struct AudioMixerSink {- pub tx: flume::Sender<(ffmpeg::frame::Audio, f64)>,-}+ fn tick(&mut self, start: Timestamps, now: Timestamp) -> Result<(), ()> {+ self.buffer_sources(now);-pub struct AudioMixerSource {- rx: flume::Receiver<(ffmpeg::frame::Audio, f64)>,- info: AudioInfo,+ let Some(start_timestamp) = self.start_timestamp else {+ return Ok(());+ };++ for (i, source) in self.sources.iter_mut().enumerate() {+ for buffer in source.buffer.drain(..) {+ let _ = self.abuffers[i].source().add(&buffer.0);+ }+ }++ let mut filtered = ffmpeg::frame::Audio::empty();+ while self.abuffersink.sink().frame(&mut filtered).is_ok() {+ let elapsed = Duration::from_secs_f64(self.samples_out as f64 / filtered.rate() as f64);+ let timestamp = start.instant() + start_timestamp.duration_since(start) + elapsed;++ self.samples_out += filtered.samples();++ if self+ .output+ .send((filtered, Timestamp::Instant(timestamp)))+ .is_err()+ {+ return Err(());+ }++ filtered = ffmpeg::frame::Audio::empty();+ }++ self.last_tick = Some(now);++ Ok(())+ }++ pub fn builder(output: Sender<(ffmpeg::frame::Audio, Timestamp)>) -> AudioMixerBuilder {+ AudioMixerBuilder::new(output)+ }}-impl PipelineSourceTask for AudioMixer {+impl PipelineSourceTask for AudioMixerBuilder {fn run(&mut self,ready_signal: crate::pipeline::task::PipelineReadySignal,mut control_signal: crate::pipeline::control::PipelineControlSignal,) -> Result<(), String> {- self.run(- || {- control_signal- .last()- .map(|v| matches!(v, crate::pipeline::control::Control::Shutdown))- .unwrap_or(false)- },- || {- let _ = ready_signal.send(Ok(()));- },- );+ let start = Timestamps::now();++ let this = std::mem::replace(self, AudioMixerBuilder::new(self.output.clone()));++ let mut mixer = this.build().map_err(|e| format!("BuildMixer: {e}"))?;++ let _ = ready_signal.send(Ok(()));++ loop {+ if control_signal+ .last()+ .map(|v| matches!(v, crate::pipeline::control::Control::Shutdown))+ .unwrap_or(false)+ {+ break;+ }++ mixer+ .tick(start, Timestamp::Instant(Instant::now()))+ .map_err(|()| format!("Audio mixer tick failed"))?;++ std::thread::sleep(Duration::from_millis(5));+ }Ok(())}}++#[cfg(test)]+mod test {+ use super::*;++ const SAMPLE_RATE: u32 = 48_000;+ const SOURCE_INFO: AudioInfo = AudioInfo::new_raw(+ cap_media_info::Sample::U8(cap_media_info::Type::Packed),+ SAMPLE_RATE,+ 1,+ );+ const ONE_SECOND: Duration = Duration::from_secs(1);+ const SAMPLES_SECOND: usize = SOURCE_INFO.rate() as usize;++ #[test]+ fn mix_sources() {+ let (tx, output_rx) = flume::bounded(4);+ let mut mixer = AudioMixerBuilder::new(tx);++ let (tx1, rx) = flume::bounded(4);+ mixer.add_source(SOURCE_INFO, rx);++ let (tx2, rx) = flume::bounded(4);+ mixer.add_source(SOURCE_INFO, rx);++ let mut mixer = mixer.build().unwrap();+ let start = mixer.timestamps;++ tx1.send((+ SOURCE_INFO.wrap_frame(&vec![128, 255, 255, 255]),+ Timestamp::Instant(start.instant()),+ ))+ .unwrap();+ tx2.send((+ SOURCE_INFO.wrap_frame(&vec![128, 128, 1, 255]),+ Timestamp::Instant(start.instant()),+ ))+ .unwrap();++ let _ = mixer.tick(+ start,+ Timestamp::Instant(start.instant() + Duration::from_secs_f64(4.0 / SAMPLE_RATE as f64)),+ );++ let (frame, _) = output_rx.recv().expect("No output frame");++ let byte_count = frame.samples() * frame.channels() as usize;+ let samples: &[f32] = unsafe { std::mem::transmute(&frame.data(0)[0..byte_count]) };++ assert_eq!(samples[0], 0.0);+ assert_eq!(samples[0], samples[1]);++ assert_eq!(samples[4], 0.0);+ assert_eq!(samples[4], samples[5]);+ }++ mod source_buffer {+ use super::*;++ #[test]+ fn single_frame() {+ let (output_tx, _) = flume::bounded(4);+ let mut mixer = AudioMixerBuilder::new(output_tx);+ let start = Timestamps::now();++ let (tx, rx) = flume::bounded(4);+ mixer.add_source(SOURCE_INFO, rx);++ let mut mixer = mixer.build().unwrap();++ tx.send((+ SOURCE_INFO.wrap_frame(&vec![0; SAMPLES_SECOND / 2]),+ Timestamp::Instant(start.instant()),+ ))+ .unwrap();++ mixer.buffer_sources(Timestamp::Instant(start.instant()));++ assert_eq!(mixer.sources[0].buffer.len(), 1);+ assert!(mixer.sources[0].rx.is_empty());+ }++ #[test]+ fn frame_gap() {+ let (output_tx, _) = flume::bounded(4);+ let mut mixer = AudioMixerBuilder::new(output_tx);++ let (tx, rx) = flume::bounded(4);+ mixer.add_source(SOURCE_INFO, rx);++ let mut mixer = mixer.build().unwrap();++ tx.send((+ SOURCE_INFO.wrap_frame(&vec![0; SAMPLES_SECOND / 2]),+ Timestamp::Instant(mixer.timestamps.instant()),+ ))+ .unwrap();++ tx.send((+ SOURCE_INFO.wrap_frame(&vec![0; SAMPLES_SECOND / 2]),+ Timestamp::Instant(mixer.timestamps.instant() + ONE_SECOND),+ ))+ .unwrap();++ mixer.buffer_sources(Timestamp::Instant(mixer.timestamps.instant()));++ let source = &mixer.sources[0];++ assert_eq!(source.buffer.len(), 3);+ assert!(source.rx.is_empty());++ assert_eq!(+ source.buffer[1].1.duration_since(mixer.timestamps),+ ONE_SECOND / 2+ );+ assert_eq!(+ source.buffer[1].0.samples(),+ SOURCE_INFO.rate() as usize / 2+ );+ }++ #[test]+ fn start_gap() {+ let (output_tx, _) = flume::bounded(4);+ let mut mixer = AudioMixerBuilder::new(output_tx);++ let (tx, rx) = flume::bounded(4);+ mixer.add_source(SOURCE_INFO, rx);++ let mut mixer = mixer.build().unwrap();+ let start = mixer.timestamps;++ tx.send((+ SOURCE_INFO.wrap_frame(&vec![0; SAMPLES_SECOND / 2]),+ Timestamp::Instant(start.instant() + ONE_SECOND / 2),+ ))+ .unwrap();++ mixer.buffer_sources(Timestamp::Instant(start.instant()));++ let source = &mixer.sources[0];++ assert_eq!(source.buffer.len(), 1);+ assert!(source.rx.is_empty());++ assert_eq!(source.buffer[0].1.duration_since(start), ONE_SECOND / 2);+ assert_eq!(+ source.buffer[0].0.samples(),+ SOURCE_INFO.rate() as usize / 2+ );+ }++ #[test]+ fn after_draining() {+ let (output_tx, _) = flume::bounded(4);+ let mut mixer = AudioMixerBuilder::new(output_tx);++ let (tx, rx) = flume::bounded(4);+ mixer.add_source(SOURCE_INFO, rx);++ let mut mixer = mixer.build().unwrap();+ let start = mixer.timestamps;++ tx.send((+ SOURCE_INFO.wrap_frame(&vec![0; SAMPLES_SECOND / 2]),+ Timestamp::Instant(start.instant()),+ ))+ .unwrap();++ mixer.buffer_sources(Timestamp::Instant(start.instant()));++ mixer.sources[0].buffer.clear();++ tx.send((+ SOURCE_INFO.wrap_frame(&vec![0; SAMPLES_SECOND / 2]),+ Timestamp::Instant(start.instant() + ONE_SECOND),+ ))+ .unwrap();++ mixer.buffer_sources(Timestamp::Instant(start.instant() + ONE_SECOND));++ let source = &mixer.sources[0];++ assert_eq!(source.buffer.len(), 2);+ assert!(source.rx.is_empty());++ let item = &source.buffer[0];+ assert_eq!(item.1.duration_since(start), ONE_SECOND / 2);+ assert_eq!(item.0.samples(), SOURCE_INFO.rate() as usize / 2);++ let item = &source.buffer[1];+ assert_eq!(item.1.duration_since(start), ONE_SECOND);+ assert_eq!(item.0.samples(), SOURCE_INFO.rate() as usize / 2);+ }+ }+}diff --git a/crates/recording/src/sources/camera.rs b/crates/recording/src/sources/camera.rsindex 058042852..f9da4beb3 100644--- a/crates/recording/src/sources/camera.rs+++ b/crates/recording/src/sources/camera.rs@@ -1,40 +1,27 @@-use cap_media_info::VideoInfo;-use ffmpeg::frame;-use flume::{Receiver, Sender};-use std::{- sync::Arc,- time::{Duration, Instant},-};-use tracing::{error, info};-use crate::{MediaError,feeds::camera::{self, CameraFeedLock, RawCameraFrame},pipeline::{control::Control, task::PipelineSourceTask},};+use cap_media_info::VideoInfo;+use cap_timestamp::Timestamp;+use ffmpeg::frame;+use flume::{Receiver, Sender};+use std::sync::Arc;+use tracing::{error, info};pub struct CameraSource {feed: Arc<CameraFeedLock>,video_info: VideoInfo,- output: Sender<(frame::Video, f64)>,- first_frame_instant: Option<Instant>,- first_frame_timestamp: Option<Duration>,- start_instant: Instant,+ output: Sender<(frame::Video, Timestamp)>,}impl CameraSource {- pub fn init(- feed: Arc<CameraFeedLock>,- output: Sender<(frame::Video, f64)>,- start_instant: Instant,- ) -> Self {+ pub fn init(feed: Arc<CameraFeedLock>, output: Sender<(frame::Video, Timestamp)>) -> Self {Self {video_info: *feed.video_info(),feed,output,- first_frame_instant: None,- first_frame_timestamp: None,- start_instant,}}@@ -45,8 +32,8 @@ impl CameraSource {fn process_frame(&self,camera_frame: RawCameraFrame,- first_frame_instant: Instant,- first_frame_timestamp: Duration,+ // first_frame_instant: Instant,+ // first_frame_timestamp: Duration,) -> Result<(), MediaError> {let check_skip_send = || {cap_fail::fail_err!("media::sources::camera::skip_send", ());@@ -58,13 +45,13 @@ impl CameraSource {return Ok(());}- let relative_timestamp = camera_frame.timestamp - first_frame_timestamp;+ // let relative_timestamp = camera_frame.timestamp - first_frame_timestamp;if self.output.send((camera_frame.frame,- (first_frame_instant + relative_timestamp - self.start_instant).as_secs_f64(),+ camera_frame.timestamp, // (first_frame_instant + relative_timestamp - self.start_instant).as_secs_f64(),)).is_err(){@@ -81,12 +68,10 @@ impl CameraSource {drop(frames_rx);for frame in frames {- let first_frame_instant = *self.first_frame_instant.get_or_insert(frame.reference_time);- let first_frame_timestamp = *self.first_frame_timestamp.get_or_insert(frame.timestamp);+ // let first_frame_instant = *self.first_frame_instant.get_or_insert(frame.reference_time);+ // let first_frame_timestamp = *self.first_frame_timestamp.get_or_insert(frame.timestamp);- if let Err(error) =- self.process_frame(frame, first_frame_instant, first_frame_timestamp)- {+ if let Err(error) = self.process_frame(frame) {eprintln!("{error}");break;}@@ -116,14 +101,12 @@ impl PipelineSourceTask for CameraSource {match control_signal.last() {Some(Control::Play) => match frames.drain().last().or_else(|| frames.recv().ok()) {Some(frame) => {- let first_frame_instant =- *self.first_frame_instant.get_or_insert(frame.reference_time);- let first_frame_timestamp =- *self.first_frame_timestamp.get_or_insert(frame.timestamp);-- if let Err(error) =- self.process_frame(frame, first_frame_instant, first_frame_timestamp)- {+ // let first_frame_instant =+ // *self.first_frame_instant.get_or_insert(frame.reference_time);+ // let first_frame_timestamp =+ // *self.first_frame_timestamp.get_or_insert(frame.timestamp);++ if let Err(error) = self.process_frame(frame) {eprintln!("{error}");break;}diff --git a/crates/recording/src/sources/mod.rs b/crates/recording/src/sources/mod.rsindex d83b75911..7dcc47b78 100644--- a/crates/recording/src/sources/mod.rs+++ b/crates/recording/src/sources/mod.rs@@ -4,6 +4,5 @@ pub mod camera;pub mod screen_capture;pub use audio_input::*;-pub use audio_mixer::*;pub use camera::*;pub use screen_capture::*;diff --git a/crates/recording/src/sources/screen_capture/macos.rs b/crates/recording/src/sources/screen_capture/macos.rsindex cca201792..476e45dd4 100644--- a/crates/recording/src/sources/screen_capture/macos.rs+++ b/crates/recording/src/sources/screen_capture/macos.rs@@ -1,5 +1,4 @@use super::*;-use cap_ffmpeg_utils::PlanarData;use cidre::*;use kameo::prelude::*;@@ -25,11 +24,8 @@ impl ScreenCaptureFormat for CMSampleBufferCapture {#[derive(Actor)]struct FrameHandler {- start_time_unix: f64,- start_cmtime: f64,- start_time_f64: f64,- video_tx: Sender<(arc::R<cm::SampleBuf>, f64)>,- audio_tx: Option<Sender<(ffmpeg::frame::Audio, f64)>>,+ video_tx: Sender<(arc::R<cm::SampleBuf>, Timestamp)>,+ audio_tx: Option<Sender<(ffmpeg::frame::Audio, Timestamp)>>,}impl Message<NewFrame> for FrameHandler {@@ -43,9 +39,9 @@ impl Message<NewFrame> for FrameHandler {let frame = msg.0;let sample_buffer = frame.sample_buf();- let frame_time = sample_buffer.pts().value as f64 / sample_buffer.pts().scale as f64;- let unix_timestamp = self.start_time_unix + frame_time - self.start_cmtime;- let relative_time = unix_timestamp - self.start_time_f64;+ let mach_timestamp = cm::Clock::convert_host_time_to_sys_units(sample_buffer.pts());+ let timestamp =+ Timestamp::MachAbsoluteTime(cap_timestamp::MachAbsoluteTimestamp::new(mach_timestamp));match &frame {scap_screencapturekit::Frame::Screen(frame) => {@@ -62,7 +58,7 @@ impl Message<NewFrame> for FrameHandler {if check_skip_send().is_ok()&& self.video_tx- .send((sample_buffer.retained(), relative_time))+ .send((sample_buffer.retained(), timestamp)).is_err(){warn!("Pipeline is unreachable");@@ -94,14 +90,12 @@ impl Message<NewFrame> for FrameHandler {frame.set_rate(48_000);let data_bytes_size = buf_list.list().buffers[0].data_bytes_size;for i in 0..frame.planes() {- frame.plane_data_mut(i).copy_from_slice(+ frame.data_mut(i).copy_from_slice(&slice[i * data_bytes_size as usize..(i + 1) * data_bytes_size as usize],);}- frame.set_pts(Some((relative_time * AV_TIME_BASE_Q.den as f64) as i64));-- let _ = audio_tx.send((frame, relative_time));+ let _ = audio_tx.send((frame, timestamp));}_ => {}}@@ -128,20 +122,6 @@ impl PipelineSourceTask for ScreenCaptureSource<CMSampleBufferCapture> {ready_signal: crate::pipeline::task::PipelineReadySignal,control_signal: crate::pipeline::control::PipelineControlSignal,) -> Result<(), String> {- let start = std::time::SystemTime::now();- let start_time_unix = start- .duration_since(std::time::UNIX_EPOCH)- .expect("Time went backwards")- .as_secs_f64();- let start_cmtime = cidre::cm::Clock::host_time_clock().time();- let start_cmtime = start_cmtime.value as f64 / start_cmtime.scale as f64;-- let start_time_f64 = self- .start_time- .duration_since(SystemTime::UNIX_EPOCH)- .unwrap()- .as_secs_f64();-let video_tx = self.video_tx.clone();let audio_tx = self.audio_tx.clone();let config = self.config.clone();@@ -149,13 +129,7 @@ impl PipelineSourceTask for ScreenCaptureSource<CMSampleBufferCapture> {self.tokio_handle.block_on(async move {let captures_audio = audio_tx.is_some();- let frame_handler = FrameHandler::spawn(FrameHandler {- video_tx,- audio_tx,- start_time_unix,- start_cmtime,- start_time_f64,- });+ let frame_handler = FrameHandler::spawn(FrameHandler { video_tx, audio_tx });let display = Display::from_id(&config.display).ok_or_else(|| SourceError::NoDisplay(config.display))?;@@ -190,6 +164,7 @@ impl PipelineSourceTask for ScreenCaptureSource<CMSampleBufferCapture> {.build();settings.set_pixel_format(cv::PixelFormat::_32_BGRA);+ settings.set_color_space_name(cg::color_space::names::srgb());if let Some(crop_bounds) = config.crop_bounds {tracing::info!("crop bounds: {:?}", crop_bounds);diff --git a/crates/recording/src/sources/screen_capture/mod.rs b/crates/recording/src/sources/screen_capture/mod.rsindex 27075375e..b0a95525b 100644--- a/crates/recording/src/sources/screen_capture/mod.rs+++ b/crates/recording/src/sources/screen_capture/mod.rs@@ -1,6 +1,7 @@+use crate::pipeline::{control::Control, task::PipelineSourceTask};use cap_cursor_capture::CursorCropBounds;use cap_media_info::{AudioInfo, VideoInfo};-use ffmpeg::sys::AV_TIME_BASE_Q;+use cap_timestamp::Timestamp;use flume::Sender;use scap_targets::{Display, DisplayId, Window, WindowId, bounds::*};use serde::{Deserialize, Serialize};@@ -8,8 +9,6 @@ use specta::Type;use std::time::SystemTime;use tracing::{error, warn};-use crate::pipeline::{control::Control, task::PipelineSourceTask};-#[cfg(windows)]mod windows;#[cfg(windows)]@@ -194,8 +193,8 @@ pub struct ScreenCaptureSource<TCaptureFormat: ScreenCaptureFormat> {config: Config,video_info: VideoInfo,tokio_handle: tokio::runtime::Handle,- video_tx: Sender<(TCaptureFormat::VideoFormat, f64)>,- audio_tx: Option<Sender<(ffmpeg::frame::Audio, f64)>>,+ video_tx: Sender<(TCaptureFormat::VideoFormat, Timestamp)>,+ audio_tx: Option<Sender<(ffmpeg::frame::Audio, Timestamp)>>,start_time: SystemTime,_phantom: std::marker::PhantomData<TCaptureFormat>,#[cfg(windows)]@@ -277,8 +276,8 @@ impl<TCaptureFormat: ScreenCaptureFormat> ScreenCaptureSource<TCaptureFormat> {target: &ScreenCaptureTarget,show_cursor: bool,max_fps: u32,- video_tx: Sender<(TCaptureFormat::VideoFormat, f64)>,- audio_tx: Option<Sender<(ffmpeg::frame::Audio, f64)>>,+ video_tx: Sender<(TCaptureFormat::VideoFormat, Timestamp)>,+ audio_tx: Option<Sender<(ffmpeg::frame::Audio, Timestamp)>>,start_time: SystemTime,tokio_handle: tokio::runtime::Handle,#[cfg(windows)] d3d_device: ::windows::Win32::Graphics::Direct3D11::ID3D11Device,diff --git a/crates/recording/src/sources/screen_capture/windows.rs b/crates/recording/src/sources/screen_capture/windows.rsindex 1bed88387..ea8dbaa38 100644--- a/crates/recording/src/sources/screen_capture/windows.rs+++ b/crates/recording/src/sources/screen_capture/windows.rs@@ -1,10 +1,10 @@use super::*;use ::windows::{- Foundation::TimeSpan,Graphics::Capture::GraphicsCaptureItem,Win32::Graphics::Direct3D11::{D3D11_BOX, ID3D11Device},};use cap_fail::fail_err;+use cap_timestamp::PerformanceCounterTimestamp;use cpal::traits::{DeviceTrait, HostTrait};use kameo::prelude::*;use scap_ffmpeg::*;@@ -47,12 +47,11 @@ impl ScreenCaptureFormat for Direct3DCapture {struct FrameHandler {capturer: WeakActorRef<ScreenCaptureActor>,- start_time: SystemTime,frames_dropped: u32,last_cleanup: Instant,last_log: Instant,frame_events: VecDeque<(Instant, bool)>,- video_tx: Sender<(scap_direct3d::Frame, f64)>,+ video_tx: Sender<(scap_direct3d::Frame, Timestamp)>,}impl Actor for FrameHandler {@@ -127,12 +126,14 @@ impl Message<NewFrame> for FrameHandler {msg: NewFrame,ctx: &mut kameo::prelude::Context<Self, Self::Reply>,) -> Self::Reply {- let Ok(elapsed) = msg.display_time.duration_since(self.start_time) else {+ let Ok(timestamp) = msg.frame.inner().SystemRelativeTime() else {return;};- let now = Instant::now();- let frame_dropped = match self.video_tx.try_send((msg.frame, elapsed.as_secs_f64())) {+ let frame_dropped = match self.video_tx.try_send((+ msg.frame,+ Timestamp::PerformanceCounter(PerformanceCounterTimestamp::new(timestamp.Duration)),+ )) {Err(flume::TrySendError::Disconnected(_)) => {warn!("Pipeline disconnected");let _ = ctx.actor_ref().stop_gracefully().await;@@ -146,6 +147,8 @@ impl Message<NewFrame> for FrameHandler {_ => false,};+ let now = Instant::now();+self.frame_events.push_back((now, frame_dropped));if now.duration_since(self.last_cleanup) > Duration::from_millis(100) {@@ -211,7 +214,6 @@ impl PipelineSourceTask for ScreenCaptureSource<Direct3DCapture> {let video_tx = self.video_tx.clone();let audio_tx = self.audio_tx.clone();- let start_time = self.start_time;let d3d_device = self.d3d_device.clone();// Frame drop rate tracking state@@ -226,7 +228,6 @@ impl PipelineSourceTask for ScreenCaptureSource<Direct3DCapture> {let frame_handler = FrameHandler::spawn(FrameHandler {capturer: capturer.downgrade(),video_tx,- start_time,frame_events: Default::default(),frames_dropped: Default::default(),last_cleanup: Instant::now(),@@ -284,7 +285,7 @@ impl PipelineSourceTask for ScreenCaptureSource<Direct3DCapture> {let audio_capture = if let Some(audio_tx) = audio_tx {let audio_capture = WindowsAudioCapture::spawn(- WindowsAudioCapture::new(audio_tx, start_time)+ WindowsAudioCapture::new(audio_tx).map_err(SourceError::CreateAudioCapture)?,);@@ -478,28 +479,15 @@ pub mod audio {impl WindowsAudioCapture {pub fn new(- audio_tx: Sender<(ffmpeg::frame::Audio, f64)>,- start_time: SystemTime,+ audio_tx: Sender<(ffmpeg::frame::Audio, Timestamp)>,) -> Result<Self, scap_cpal::CapturerError> {- let mut i = 0;let capturer = scap_cpal::create_capturer(- move |data, _: &cpal::InputCallbackInfo, config| {+ move |data, info, config| {use scap_ffmpeg::*;- let timestamp = SystemTime::now();- let mut ff_frame = data.as_ffmpeg(config);-- let Ok(elapsed) = timestamp.duration_since(start_time) else {- warn!("Skipping audio frame {i} as elapsed time is invalid");- return;- };-- let rate = ff_frame.rate();-- ff_frame.set_pts(Some((elapsed.as_secs_f64() * rate as f64) as i64));+ let timestamp = Timestamp::from_cpal(info.timestamp().capture);- let _ = audio_tx.send((ff_frame, elapsed.as_secs_f64()));- i += 1;+ let _ = audio_tx.send((data.as_ffmpeg(config), timestamp));},move |e| {dbg!(e);diff --git a/crates/recording/src/studio_recording.rs b/crates/recording/src/studio_recording.rsindex 404289709..082168c95 100644--- a/crates/recording/src/studio_recording.rs+++ b/crates/recording/src/studio_recording.rs@@ -3,12 +3,13 @@ use crate::{capture_pipeline::{MakeCapturePipeline, ScreenCaptureMethod, create_screen_capture},cursor::{CursorActor, Cursors, spawn_cursor_recorder},feeds::{camera::CameraFeedLock, microphone::MicrophoneFeedLock},- pipeline::Pipeline,+ pipeline::RecordingPipeline,sources::{AudioInputSource, CameraSource, ScreenCaptureFormat, ScreenCaptureTarget},};use cap_enc_ffmpeg::{H264Encoder, MP4File, OggFile, OpusEncoder};use cap_media_info::VideoInfo;use cap_project::{CursorEvents, StudioRecordingMeta};+use cap_timestamp::{Timestamp, Timestamps};use cap_utils::spawn_actor;use flume::Receiver;use relative_path::RelativePathBuf;@@ -22,9 +23,9 @@ use tokio::sync::oneshot;use tracing::{debug, info, trace};#[allow(clippy::large_enum_variant)]-enum StudioRecordingActorState {+enum ActorState {Recording {- pipeline: StudioRecordingPipeline,+ pipeline: Pipeline,pipeline_done_rx: oneshot::Receiver<Result<(), String>>,index: u32,segment_start_time: f64,@@ -37,31 +38,28 @@ enum StudioRecordingActorState {},}-pub enum StudioRecordingActorControlMessage {+pub enum ActorControlMessage {Pause(oneshot::Sender<Result<(), RecordingError>>),Resume(oneshot::Sender<Result<(), CreateSegmentPipelineError>>),Stop(oneshot::Sender<Result<CompletedStudioRecording, RecordingError>>),Cancel(oneshot::Sender<Result<(), RecordingError>>),}-pub struct StudioRecordingActor {- id: String,+pub struct Actor {recording_dir: PathBuf,fps: u32,- segments: Vec<StudioRecordingSegment>,- #[allow(unused)]- start_instant: Instant,+ segments: Vec<RecordingSegment>,}-pub struct StudioRecordingSegment {+pub struct RecordingSegment {pub start: f64,pub end: f64,- pipeline: StudioRecordingPipeline,+ pipeline: Pipeline,}pub struct PipelineOutput {pub path: PathBuf,- pub first_timestamp_rx: flume::Receiver<f64>,+ pub first_timestamp_rx: flume::Receiver<Timestamp>,}pub struct ScreenPipelineOutput {@@ -69,8 +67,9 @@ pub struct ScreenPipelineOutput {pub video_info: VideoInfo,}-struct StudioRecordingPipeline {- pub inner: Pipeline,+struct Pipeline {+ pub start_time: Timestamps,+ pub inner: RecordingPipeline,pub screen: ScreenPipelineOutput,pub microphone: Option<PipelineOutput>,pub camera: Option<CameraPipelineInfo>,@@ -84,8 +83,8 @@ struct CursorPipeline {}#[derive(Clone)]-pub struct StudioRecordingHandle {- ctrl_tx: flume::Sender<StudioRecordingActorControlMessage>,+pub struct ActorHandle {+ ctrl_tx: flume::Sender<ActorControlMessage>,pub capture_target: ScreenCaptureTarget,}@@ -100,39 +99,101 @@ macro_rules! send_message {}};}-impl StudioRecordingHandle {+impl ActorHandle {pub async fn stop(&self) -> Result<CompletedStudioRecording, RecordingError> {- send_message!(self.ctrl_tx, StudioRecordingActorControlMessage::Stop)+ send_message!(self.ctrl_tx, ActorControlMessage::Stop)}pub async fn pause(&self) -> Result<(), RecordingError> {- send_message!(self.ctrl_tx, StudioRecordingActorControlMessage::Pause)+ send_message!(self.ctrl_tx, ActorControlMessage::Pause)}pub async fn resume(&self) -> Result<(), CreateSegmentPipelineError> {- send_message!(self.ctrl_tx, StudioRecordingActorControlMessage::Resume)+ send_message!(self.ctrl_tx, ActorControlMessage::Resume)}pub async fn cancel(&self) -> Result<(), RecordingError> {- send_message!(self.ctrl_tx, StudioRecordingActorControlMessage::Cancel)+ send_message!(self.ctrl_tx, ActorControlMessage::Cancel)}}#[derive(Debug, thiserror::Error)]-pub enum SpawnStudioRecordingError {+pub enum SpawnError {#[error("{0}")]Media(#[from] MediaError),#[error("{0}")]PipelineCreationError(#[from] CreateSegmentPipelineError),}-pub async fn spawn_studio_recording_actor(- id: String,+impl Actor {+ pub fn builder(output: PathBuf, capture_target: ScreenCaptureTarget) -> ActorBuilder {+ ActorBuilder::new(output, capture_target)+ }+}++pub struct ActorBuilder {+ output_path: PathBuf,+ capture_target: ScreenCaptureTarget,+ system_audio: bool,+ mic_feed: Option<Arc<MicrophoneFeedLock>>,+ camera_feed: Option<Arc<CameraFeedLock>>,+ custom_cursor: bool,+}++impl ActorBuilder {+ pub fn new(output: PathBuf, capture_target: ScreenCaptureTarget) -> Self {+ Self {+ output_path: output,+ capture_target,+ system_audio: false,+ mic_feed: None,+ camera_feed: None,+ custom_cursor: false,+ }+ }++ pub fn with_system_audio(mut self, system_audio: bool) -> Self {+ self.system_audio = system_audio;+ self+ }++ pub fn with_mic_feed(mut self, mic_feed: Arc<MicrophoneFeedLock>) -> Self {+ self.mic_feed = Some(mic_feed);+ self+ }++ pub fn with_camera_feed(mut self, camera_feed: Arc<CameraFeedLock>) -> Self {+ self.camera_feed = Some(camera_feed);+ self+ }++ pub fn with_custom_cursor(mut self, custom_cursor: bool) -> Self {+ self.custom_cursor = custom_cursor;+ self+ }++ pub async fn build(+ self,+ ) -> Result<(ActorHandle, oneshot::Receiver<Result<(), String>>), SpawnError> {+ spawn_studio_recording_actor(+ self.output_path,+ RecordingBaseInputs {+ capture_target: self.capture_target,+ capture_system_audio: self.system_audio,+ mic_feed: self.mic_feed,+ camera_feed: self.camera_feed,+ },+ self.custom_cursor,+ )+ .await+ }+}++async fn spawn_studio_recording_actor(recording_dir: PathBuf,base_inputs: RecordingBaseInputs,custom_cursor_capture: bool,-) -> Result<(StudioRecordingHandle, oneshot::Receiver<Result<(), String>>), SpawnStudioRecordingError>-{+) -> Result<(ActorHandle, oneshot::Receiver<Result<(), String>>), SpawnError> {ensure_dir(&recording_dir)?;let (done_tx, done_rx) = oneshot::channel();@@ -144,9 +205,7 @@ pub async fn spawn_studio_recording_actor(let segments_dir = ensure_dir(&content_dir.join("segments"))?;let cursors_dir = ensure_dir(&content_dir.join("cursors"))?;- // TODO: move everything to start_instant- let start_time = SystemTime::now();- let start_instant = Instant::now();+ let start_time = Timestamps::now();if let Some(camera_feed) = &base_inputs.camera_feed {debug!("camera device info: {:#?}", camera_feed.camera_info());@@ -163,7 +222,6 @@ pub async fn spawn_studio_recording_actor(base_inputs.clone(),custom_cursor_capture,start_time,- start_instant,);let index = 0;@@ -181,15 +239,13 @@ pub async fn spawn_studio_recording_actor(let fps = pipeline.screen.video_info.fps();spawn_actor(async move {- let mut actor = StudioRecordingActor {- id,+ let mut actor = Actor {recording_dir,fps,segments: Vec::new(),- start_instant,};- let mut state = StudioRecordingActorState::Recording {+ let mut state = ActorState::Recording {pipeline,pipeline_done_rx,index,@@ -214,7 +270,7 @@ pub async fn spawn_studio_recording_actor(});Ok((- StudioRecordingHandle {+ ActorHandle {ctrl_tx,capture_target: base_inputs.capture_target,},@@ -240,18 +296,18 @@ macro_rules! send_response {}async fn run_actor_iteration(- state: StudioRecordingActorState,- ctrl_rx: &Receiver<StudioRecordingActorControlMessage>,- mut actor: StudioRecordingActor,+ state: ActorState,+ ctrl_rx: &Receiver<ActorControlMessage>,+ mut actor: Actor,segment_pipeline_factory: &mut SegmentPipelineFactory,-) -> Result<Option<(StudioRecordingActorState, StudioRecordingActor)>, StudioRecordingActorError> {- use StudioRecordingActorControlMessage as Msg;- use StudioRecordingActorState as State;+) -> Result<Option<(ActorState, Actor)>, StudioRecordingActorError> {+ use ActorControlMessage as Msg;+ use ActorState as State;// Helper function to shutdown pipeline and save cursor dataasync fn shutdown(- mut pipeline: StudioRecordingPipeline,- actor: &mut StudioRecordingActor,+ mut pipeline: Pipeline,+ actor: &mut Actor,segment_start_time: f64,) -> Result<(Cursors, u32), RecordingError> {tracing::info!("pipeline shuting down");@@ -282,7 +338,7 @@ async fn run_actor_iteration((Default::default(), 0)};- actor.segments.push(StudioRecordingSegment {+ actor.segments.push(RecordingSegment {start: segment_start_time,end: segment_stop_time,pipeline,@@ -472,15 +528,14 @@ async fn run_actor_iteration(}pub struct CompletedStudioRecording {- pub id: String,pub project_path: PathBuf,pub meta: StudioRecordingMeta,pub cursor_data: cap_project::CursorImages,- pub segments: Vec<StudioRecordingSegment>,+ pub segments: Vec<RecordingSegment>,}async fn stop_recording(- actor: StudioRecordingActor,+ actor: Actor,cursors: Cursors,) -> Result<CompletedStudioRecording, RecordingError> {use cap_project::*;@@ -489,38 +544,46 @@ async fn stop_recording(RelativePathBuf::from_path(path.strip_prefix(&actor.recording_dir).unwrap()).unwrap()};- let recv_timestamp = |pipeline: &PipelineOutput| pipeline.first_timestamp_rx.try_recv().ok();-let meta = StudioRecordingMeta::MultipleSegments {inner: MultipleSegments {segments: {actor.segments.iter()- .map(|s| MultipleSegment {- display: VideoMeta {- path: make_relative(&s.pipeline.screen.inner.path),- fps: actor.fps,- start_time: recv_timestamp(&s.pipeline.screen.inner),- },- camera: s.pipeline.camera.as_ref().map(|camera| VideoMeta {- path: make_relative(&camera.inner.path),- fps: camera.fps,- start_time: recv_timestamp(&camera.inner),- }),- mic: s.pipeline.microphone.as_ref().map(|mic| AudioMeta {- path: make_relative(&mic.path),- start_time: recv_timestamp(mic),- }),- cursor: s- .pipeline- .cursor- .as_ref()- .map(|cursor| make_relative(&cursor.output_path)),- system_audio: s.pipeline.system_audio.as_ref().map(|audio| AudioMeta {- path: make_relative(&audio.path),- start_time: recv_timestamp(audio),- }),+ .map(|s| {+ let recv_timestamp = |pipeline: &PipelineOutput| {+ pipeline+ .first_timestamp_rx+ .try_recv()+ .ok()+ .map(|v| v.duration_since(s.pipeline.start_time).as_secs_f64())+ };++ MultipleSegment {+ display: VideoMeta {+ path: make_relative(&s.pipeline.screen.inner.path),+ fps: actor.fps,+ start_time: recv_timestamp(&s.pipeline.screen.inner),+ },+ camera: s.pipeline.camera.as_ref().map(|camera| VideoMeta {+ path: make_relative(&camera.inner.path),+ fps: camera.fps,+ start_time: recv_timestamp(&camera.inner),+ }),+ mic: s.pipeline.microphone.as_ref().map(|mic| AudioMeta {+ path: make_relative(&mic.path),+ start_time: recv_timestamp(mic),+ }),+ cursor: s+ .pipeline+ .cursor+ .as_ref()+ .map(|cursor| make_relative(&cursor.output_path)),+ system_audio: s.pipeline.system_audio.as_ref().map(|audio| AudioMeta {+ path: make_relative(&audio.path),+ start_time: recv_timestamp(audio),+ }),+ }}).collect()},@@ -549,7 +612,6 @@ async fn stop_recording(.map_err(RecordingError::from)?;Ok(CompletedStudioRecording {- id: actor.id,project_path: actor.recording_dir.clone(),meta,cursor_data: Default::default(),@@ -563,8 +625,7 @@ struct SegmentPipelineFactory {cursors_dir: PathBuf,base_inputs: RecordingBaseInputs,custom_cursor_capture: bool,- start_time: SystemTime,- start_instant: Instant,+ start_time: Timestamps,index: u32,}@@ -575,8 +636,7 @@ impl SegmentPipelineFactory {cursors_dir: PathBuf,base_inputs: RecordingBaseInputs,custom_cursor_capture: bool,- start_time: SystemTime,- start_instant: Instant,+ start_time: Timestamps,) -> Self {Self {segments_dir,@@ -584,7 +644,6 @@ impl SegmentPipelineFactory {base_inputs,custom_cursor_capture,start_time,- start_instant,index: 0,}}@@ -593,13 +652,7 @@ impl SegmentPipelineFactory {&mut self,cursors: Cursors,next_cursors_id: u32,- ) -> Result<- (- StudioRecordingPipeline,- oneshot::Receiver<Result<(), String>>,- ),- CreateSegmentPipelineError,- > {+ ) -> Result<(Pipeline, oneshot::Receiver<Result<(), String>>), CreateSegmentPipelineError> {let result = create_segment_pipeline(&self.segments_dir,&self.cursors_dir,@@ -612,7 +665,6 @@ impl SegmentPipelineFactory {next_cursors_id,self.custom_cursor_capture,self.start_time,- self.start_instant,).await?;@@ -653,15 +705,8 @@ async fn create_segment_pipeline(prev_cursors: Cursors,next_cursors_id: u32,custom_cursor_capture: bool,- start_time: SystemTime,- start_instant: Instant,-) -> Result<- (- StudioRecordingPipeline,- oneshot::Receiver<Result<(), String>>,- ),- CreateSegmentPipelineError,-> {+ start_time: Timestamps,+) -> Result<(Pipeline, oneshot::Receiver<Result<(), String>>), CreateSegmentPipelineError> {let system_audio = if capture_system_audio {let (tx, rx) = flume::bounded(64);(Some(tx), Some(rx))@@ -684,7 +729,7 @@ async fn create_segment_pipeline(!custom_cursor_capture,120,system_audio.0,- start_time,+ start_time.system_time(),#[cfg(windows)]d3d_device,)@@ -693,7 +738,7 @@ async fn create_segment_pipeline(let dir = ensure_dir(&segments_dir.join(format!("segment-{index}")))?;- let mut pipeline_builder = Pipeline::builder();+ let mut pipeline_builder = RecordingPipeline::builder();let screen_output_path = dir.join("display.mp4");@@ -729,35 +774,46 @@ async fn create_segment_pipeline(};let microphone = if let Some(mic_feed) = mic_feed {- let (tx, rx) = flume::bounded(8);+ let (tx, channel) = flume::bounded(8);- let mic_source = AudioInputSource::init(mic_feed, tx, start_time);+ let mic_source = AudioInputSource::init(mic_feed, tx);let mic_config = mic_source.info();let output_path = dir.join("audio-input.ogg");- let mut mic_encoder = OggFile::init(+ let mut output = OggFile::init(output_path.clone(),OpusEncoder::factory("microphone", mic_config),).map_err(|e| MediaError::Any(e.to_string().into()))?;+ let time_base = output.encoder().input_time_base();pipeline_builder.spawn_source("microphone_capture", mic_source);- let (timestamp_tx, timestamp_rx) = flume::bounded(1);+ let (timestamp_tx, first_timestamp_rx) = flume::bounded(1);pipeline_builder.spawn_task("microphone_encoder", move |ready| {+ let mut first_timestamp = None;let mut timestamp_tx = Some(timestamp_tx);let _ = ready.send(Ok(()));- while let Ok(frame) = rx.recv() {+ let rate = time_base.denominator() as f64 / time_base.numerator() as f64;++ while let Ok((mut frame, timestamp)) = channel.recv() {if let Some(timestamp_tx) = timestamp_tx.take() {- timestamp_tx.send(frame.1).unwrap();+ let _ = timestamp_tx.send(timestamp);}- mic_encoder.queue_frame(frame.0);+ let first_timestamp = first_timestamp.get_or_insert(timestamp);++ let elapsed = timestamp.duration_since(start_time)+ - first_timestamp.duration_since(start_time);+ frame.set_pts(Some((elapsed.as_secs_f64() * rate) as i64));++ output.queue_frame(frame);}- mic_encoder.finish();++ output.finish();Ok(())});@@ -768,7 +824,7 @@ async fn create_segment_pipeline(Some(PipelineOutput {path: output_path,- first_timestamp_rx: timestamp_rx,+ first_timestamp_rx,})} else {None@@ -779,26 +835,38 @@ async fn create_segment_pipeline({let output_path = dir.join("system_audio.ogg");- let mut system_audio_encoder = OggFile::init(+ let mut output = OggFile::init(output_path.clone(),OpusEncoder::factory("system_audio", config),).map_err(|e| MediaError::Any(e.to_string().into()))?;+ let time_base = output.encoder().input_time_base();+let (timestamp_tx, timestamp_rx) = flume::bounded(1);pipeline_builder.spawn_task("system_audio_encoder", move |ready| {+ let mut first_timestamp = None;let mut timestamp_tx = Some(timestamp_tx);let _ = ready.send(Ok(()));- while let Ok(frame) = channel.recv() {+ let rate = time_base.denominator() as f64 / time_base.numerator() as f64;++ while let Ok((mut frame, timestamp)) = channel.recv() {if let Some(timestamp_tx) = timestamp_tx.take() {- timestamp_tx.send(frame.1).unwrap();+ let _ = timestamp_tx.send(timestamp);}- system_audio_encoder.queue_frame(frame.0);+ let first_timestamp = first_timestamp.get_or_insert(timestamp);++ let elapsed = timestamp.duration_since(start_time)+ - first_timestamp.duration_since(start_time);+ frame.set_pts(Some((elapsed.as_secs_f64() * rate).round() as i64));++ output.queue_frame(frame);}- system_audio_encoder.finish();++ output.finish();Ok(())});@@ -811,10 +879,11 @@ async fn create_segment_pipeline(};let camera = if let Some(camera_feed) = camera_feed {- let (tx, rx) = flume::bounded(8);+ let (tx, channel) = flume::bounded(8);- let camera_source = CameraSource::init(camera_feed, tx, start_instant);+ let camera_source = CameraSource::init(camera_feed, tx);let camera_config = camera_source.info();+ let time_base = camera_config.time_base;let output_path = dir.join("camera.mp4");let mut camera_encoder = MP4File::init(@@ -830,27 +899,24 @@ async fn create_segment_pipeline(let (timestamp_tx, timestamp_rx) = flume::bounded(1);pipeline_builder.spawn_task("camera_encoder", move |ready| {+ let mut first_timestamp = None;let mut timestamp_tx = Some(timestamp_tx);let _ = ready.send(Ok(()));- let mut start = None;- while let Ok(mut frame) = rx.recv() {+ let rate = time_base.denominator() as f64 / time_base.numerator() as f64;++ while let Ok((mut frame, timestamp)) = channel.recv() {if let Some(timestamp_tx) = timestamp_tx.take() {- timestamp_tx.send(frame.1).unwrap();+ let _ = timestamp_tx.send(timestamp);}- if let Some(start) = start {- frame.0.set_pts(Some(- ((camera_config.time_base.denominator() as f64- / camera_config.time_base.numerator() as f64)- * (frame.1 - start)) as i64,- ));- } else {- start = Some(frame.1);- frame.0.set_pts(Some(0));- }+ let first_timestamp = first_timestamp.get_or_insert(timestamp);- camera_encoder.queue_video_frame(frame.0);+ let elapsed = timestamp.duration_since(start_time)+ - first_timestamp.duration_since(start_time);+ frame.set_pts(Some((elapsed.as_secs_f64() * rate) as i64));++ camera_encoder.queue_video_frame(frame);}camera_encoder.finish();Ok(())@@ -901,8 +967,9 @@ async fn create_segment_pipeline(info!("pipeline playing");Ok((- StudioRecordingPipeline {+ Pipeline {inner: pipeline,+ start_time,screen,microphone,camera,diff --git a/crates/scap-direct3d/src/lib.rs b/crates/scap-direct3d/src/lib.rsindex 73edb47a6..57f594d58 100644--- a/crates/scap-direct3d/src/lib.rs+++ b/crates/scap-direct3d/src/lib.rs@@ -3,16 +3,13 @@#![cfg(windows)]use std::{- os::windows::io::AsRawHandle,sync::{Arc,atomic::{AtomicBool, Ordering},mpsc::RecvError,},- thread::JoinHandle,time::Duration,};-use windows::{Foundation::{Metadata::ApiInformation, TypedEventHandler},Graphics::{@@ -23,7 +20,7 @@ use windows::{DirectX::{Direct3D11::IDirect3DDevice, DirectXPixelFormat},},Win32::{- Foundation::{HANDLE, HMODULE, LPARAM, S_FALSE, WPARAM},+ Foundation::HMODULE,Graphics::{Direct3D::D3D_DRIVER_TYPE_HARDWARE,Direct3D11::{@@ -41,16 +38,8 @@ use windows::{IDXGIDevice,},},- System::{- Threading::GetThreadId,- WinRT::{- CreateDispatcherQueueController, DQTAT_COM_NONE, DQTYPE_THREAD_CURRENT,- Direct3D11::{CreateDirect3D11DeviceFromDXGIDevice, IDirect3DDxgiInterfaceAccess},- DispatcherQueueOptions, RO_INIT_MULTITHREADED, RoInitialize,- },- },- UI::WindowsAndMessaging::{- DispatchMessageW, GetMessageW, MSG, PostThreadMessageW, TranslateMessage, WM_QUIT,+ System::WinRT::Direct3D11::{+ CreateDirect3D11DeviceFromDXGIDevice, IDirect3DDxgiInterfaceAccess,},},core::{HSTRING, IInspectable, Interface},diff --git a/crates/scap-ffmpeg/Cargo.toml b/crates/scap-ffmpeg/Cargo.tomlindex 4cfee27bd..0c90dba2a 100644--- a/crates/scap-ffmpeg/Cargo.toml+++ b/crates/scap-ffmpeg/Cargo.toml@@ -8,7 +8,6 @@ license = "MIT"ffmpeg = { workspace = true }cpal = { workspace = true }scap-cpal = { optional = true, path = "../scap-cpal" }-cap-ffmpeg-utils = { path = "../ffmpeg-utils" }[target.'cfg(windows)'.dependencies]scap-direct3d = { path = "../scap-direct3d" }diff --git a/crates/scap-ffmpeg/src/cpal.rs b/crates/scap-ffmpeg/src/cpal.rsindex 1da8a8b1b..0ef265db1 100644--- a/crates/scap-ffmpeg/src/cpal.rs+++ b/crates/scap-ffmpeg/src/cpal.rs@@ -1,4 +1,3 @@-use cap_ffmpeg_utils::PlanarData;use cpal::{SampleFormat, StreamConfig};use ffmpeg::format::{Sample, sample};@@ -32,7 +31,7 @@ impl DataExt for ::cpal::Data {let base = (i as usize) * plane_size;ffmpeg_frame- .plane_data_mut(i as usize)+ .data_mut(i as usize).copy_from_slice(&self.bytes()[base..base + plane_size]);}} else {diff --git a/crates/timestamp/Cargo.toml b/crates/timestamp/Cargo.tomlnew file mode 100644index 000000000..ea0642582--- /dev/null+++ b/crates/timestamp/Cargo.toml@@ -0,0 +1,20 @@+[package]+name = "cap-timestamp"+version = "0.1.0"+edition = "2024"++[features]++[dependencies]+cpal = { workspace = true }++[target.'cfg(target_os = "macos")'.dependencies]+cidre = { workspace = true }++[target.'cfg(target_os = "windows")'.dependencies]+windows = { workspace = true, features = [+ "Win32_System_Performance",+] }++[lints]+workspace = truediff --git a/crates/timestamp/src/lib.rs b/crates/timestamp/src/lib.rsnew file mode 100644index 000000000..c5f3ffb7c--- /dev/null+++ b/crates/timestamp/src/lib.rs@@ -0,0 +1,126 @@+use std::time::{Duration, Instant, SystemTime};++#[cfg(windows)]+mod win;+#[cfg(windows)]+pub use win::*;++#[cfg(target_os = "macos")]+mod macos;+#[cfg(target_os = "macos")]+pub use macos::*;++#[derive(Clone, Copy, Debug)]+pub enum Timestamp {+ Instant(Instant),+ SystemTime(SystemTime),+ #[cfg(windows)]+ PerformanceCounter(PerformanceCounterTimestamp),+ #[cfg(target_os = "macos")]+ MachAbsoluteTime(MachAbsoluteTimestamp),+}++impl Timestamp {+ pub fn duration_since(&self, start: Timestamps) -> Duration {+ match self {+ Self::Instant(instant) => instant.duration_since(start.instant),+ Self::SystemTime(time) => time.duration_since(start.system_time).unwrap(),+ #[cfg(windows)]+ Self::PerformanceCounter(counter) => counter.duration_since(start.performance_counter),+ #[cfg(target_os = "macos")]+ Self::MachAbsoluteTime(time) => time.duration_since(start.mach_absolute_time),+ }+ }++ pub fn from_cpal(instant: cpal::StreamInstant) -> Self {+ #[cfg(windows)]+ {+ Self::PerformanceCounter(PerformanceCounterTimestamp::from_cpal(instant))+ }+ #[cfg(target_os = "macos")]+ {+ Self::MachAbsoluteTime(MachAbsoluteTimestamp::from_cpal(instant))+ }+ }+}++impl std::ops::Add<Duration> for &Timestamp {+ type Output = Timestamp;++ fn add(self, rhs: Duration) -> Self::Output {+ match *self {+ Timestamp::Instant(i) => Timestamp::Instant(i + rhs),+ Timestamp::SystemTime(t) => Timestamp::SystemTime(t + rhs),+ #[cfg(windows)]+ Timestamp::PerformanceCounter(c) => Timestamp::PerformanceCounter(c + rhs),+ #[cfg(target_os = "macos")]+ Timestamp::MachAbsoluteTime(c) => Timestamp::MachAbsoluteTime(c + rhs),+ }+ }+}++impl std::ops::Add<Duration> for Timestamp {+ type Output = Timestamp;++ fn add(self, rhs: Duration) -> Self::Output {+ match self {+ Timestamp::Instant(i) => Timestamp::Instant(i + rhs),+ Timestamp::SystemTime(t) => Timestamp::SystemTime(t + rhs),+ #[cfg(windows)]+ Timestamp::PerformanceCounter(c) => Timestamp::PerformanceCounter(c + rhs),+ #[cfg(target_os = "macos")]+ Timestamp::MachAbsoluteTime(c) => Timestamp::MachAbsoluteTime(c + rhs),+ }+ }+}++impl std::ops::Sub<Duration> for Timestamp {+ type Output = Timestamp;++ fn sub(self, rhs: Duration) -> Self::Output {+ match self {+ Timestamp::Instant(i) => Timestamp::Instant(i.checked_sub(rhs).unwrap()),+ Timestamp::SystemTime(t) => Timestamp::SystemTime(t - rhs),+ #[cfg(windows)]+ Timestamp::PerformanceCounter(c) => Timestamp::PerformanceCounter(c - rhs),+ #[cfg(target_os = "macos")]+ Timestamp::MachAbsoluteTime(c) => Timestamp::MachAbsoluteTime(c - rhs),+ }+ }+}++#[derive(Clone, Copy, Debug)]+pub struct Timestamps {+ instant: Instant,+ system_time: SystemTime,+ #[cfg(windows)]+ performance_counter: PerformanceCounterTimestamp,+ #[cfg(target_os = "macos")]+ mach_absolute_time: MachAbsoluteTimestamp,+}++impl Timestamps {+ pub fn now() -> Self {+ Self {+ instant: Instant::now(),+ system_time: SystemTime::now(),+ #[cfg(windows)]+ performance_counter: PerformanceCounterTimestamp::now(),+ #[cfg(target_os = "macos")]+ mach_absolute_time: MachAbsoluteTimestamp::now(),+ }+ }++ pub fn instant(&self) -> Instant {+ self.instant+ }++ pub fn system_time(&self) -> SystemTime {+ self.system_time+ }++ #[cfg(target_os = "macos")]+ pub fn mach_absolute_time(&self) -> MachAbsoluteTimestamp {+ self.mach_absolute_time+ }+}diff --git a/crates/timestamp/src/macos.rs b/crates/timestamp/src/macos.rsnew file mode 100644index 000000000..fd1065ec4--- /dev/null+++ b/crates/timestamp/src/macos.rs@@ -0,0 +1,73 @@+use cidre::mach::TimeBaseInfo;+use std::{+ ops::{Add, Sub},+ time::Duration,+};++#[derive(Clone, Copy, Debug)]+pub struct MachAbsoluteTimestamp(+ // Nanoseconds+ u64,+);++impl MachAbsoluteTimestamp {+ pub fn new(nanos: u64) -> Self {+ Self(nanos)+ }++ pub fn now() -> Self {+ Self(cidre::mach::abs_time())+ }++ pub fn duration_since(&self, other: Self) -> Duration {+ let info = TimeBaseInfo::new();+ let freq = info.numer as f64 / info.denom as f64;++ let Some(diff) = self.0.checked_sub(other.0) else {+ return Duration::ZERO;+ };++ Duration::from_nanos((diff as f64 * freq) as u64)+ }++ pub fn from_cpal(instant: cpal::StreamInstant) -> Self {+ use cpal::host::coreaudio::StreamInstantExt;++ Self(instant.as_host_time())+ }+}++impl Add<Duration> for MachAbsoluteTimestamp {+ type Output = Self;++ fn add(self, rhs: Duration) -> Self::Output {+ let info = TimeBaseInfo::new();+ let freq = info.numer as f64 / info.denom as f64;++ Self((self.0 as f64 + rhs.as_nanos() as f64 * freq) as u64)+ }+}++impl Sub<Duration> for MachAbsoluteTimestamp {+ type Output = Self;++ fn sub(self, rhs: Duration) -> Self::Output {+ let info = TimeBaseInfo::new();+ let freq = info.numer as f64 / info.denom as f64;++ Self((self.0 as f64 - rhs.as_nanos() as f64 * freq) as u64)+ }+}++#[cfg(test)]+mod test {+ use super::*;++ #[test]+ fn test() {+ let a = MachAbsoluteTimestamp::new(0);++ dbg!(MachAbsoluteTimestamp::now());+ dbg!(a + Duration::from_secs(1));+ }+}diff --git a/crates/timestamp/src/win.rs b/crates/timestamp/src/win.rsnew file mode 100644index 000000000..119616e0e--- /dev/null+++ b/crates/timestamp/src/win.rs@@ -0,0 +1,64 @@+use cpal::StreamInstant;+use std::{+ ops::{Add, Sub},+ sync::OnceLock,+ time::Duration,+};+use windows::Win32::System::Performance::{QueryPerformanceCounter, QueryPerformanceFrequency};++#[derive(Clone, Copy, Debug)]+pub struct PerformanceCounterTimestamp(i64);++static PERF_FREQ: OnceLock<i64> = OnceLock::new();++#[inline]+fn perf_freq() -> i64 {+ *PERF_FREQ.get_or_init(|| {+ let mut freq: i64 = 0;+ // SAFETY: According to the Windows API docs, QueryPerformanceFrequency+ // will succeed on all Windows XP and later systems.+ unsafe { QueryPerformanceFrequency(&mut freq) }.unwrap();+ freq+ })+}++impl PerformanceCounterTimestamp {+ pub fn new(value: i64) -> Self {+ Self(value)+ }++ pub fn duration_since(&self, other: Self) -> Duration {+ let freq = perf_freq();+ Duration::from_secs_f64((self.0 - other.0) as f64 / freq as f64)+ }++ pub fn now() -> Self {+ let mut value = 0;+ unsafe { QueryPerformanceCounter(&mut value).unwrap() };+ Self(value)+ }++ pub fn from_cpal(instant: StreamInstant) -> Self {+ use cpal::host::wasapi::StreamInstantExt;++ Self(instant.as_performance_counter())+ }+}++impl Add<Duration> for PerformanceCounterTimestamp {+ type Output = Self;++ fn add(self, rhs: Duration) -> Self::Output {+ let freq = perf_freq();+ Self(self.0 + (rhs.as_secs_f64() * freq as f64) as i64)+ }+}++impl Sub<Duration> for PerformanceCounterTimestamp {+ type Output = Self;++ fn sub(self, rhs: Duration) -> Self::Output {+ let freq = perf_freq();+ Self(self.0 - (rhs.as_secs_f64() * freq as f64) as i64)+ }+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 7811110fb..fdd639470 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -123,8 +123,8 @@ importers:specifier: ^2.4.1version: 2.4.1'@tauri-apps/plugin-dialog':- specifier: ^2.3.2- version: 2.3.2+ specifier: ^2.4.0+ version: 2.4.0'@tauri-apps/plugin-fs':specifier: ^2.4.1version: 2.4.1@@ -921,7 +921,7 @@ importers:version: 18.3.21'@types/react-dom':specifier: latest- version: 19.1.7(@types/[email protected])+ version: 19.1.9(@types/[email protected])dotenv-cli:specifier: latestversion: 10.0.0@@ -974,28 +974,28 @@ importers:'@radix-ui/react-dialog':specifier: ^1.0.5- version: 1.1.13(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ version: 1.1.13(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-dropdown-menu':specifier: ^2.0.6- version: 2.1.14(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ version: 2.1.14(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-label':specifier: ^2.0.2- version: 2.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ version: 2.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-navigation-menu':specifier: ^1.1.4- version: 1.2.12(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ version: 1.2.12(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-popover':specifier: ^1.0.7- version: 1.1.13(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ version: 1.1.13(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-select':specifier: ^2.2.5- version: 2.2.5(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ version: 2.2.5(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-slot':specifier: ^1.0.2version: 1.2.2(@types/[email protected])([email protected])'@radix-ui/react-switch':specifier: ^1.1.0- version: 1.2.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ version: 1.2.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@tailwindcss/typography':specifier: ^0.5.9@@ -1032,7 +1032,7 @@ importers:version: 18.3.21'@types/react-dom':specifier: latest- version: 19.1.7(@types/[email protected])+ version: 19.1.9(@types/[email protected])'@vitejs/plugin-react':specifier: ^4.0.3version: 4.4.1([email protected](@types/[email protected])([email protected])([email protected])([email protected]))@@ -5831,10 +5831,10 @@ packages:react-dom:optional: true- '@storybook/[email protected]':- resolution: {integrity: sha512-IGd75RO4YR7ofOZWqND2dYHrKLjwN05+mM1xfrucb2SoQzjbNXvFNVVxtOCBmqsarjmrMKLKHuRgFzU41vs43g==}+ '@storybook/[email protected]':+ resolution: {integrity: sha512-H4U+LXXrxXFezTzPc0pfvZA/qjyg9XmgPCGSXa0Q41LH+8UrW9uP42TDVarQkD77jS4Trd7QIFCN64xe34XAoQ==}peerDependencies:- storybook: ^10.0.0-beta.0+ storybook: ^10.0.0-beta.2vite: ^5.0.0 || ^6.0.0 || ^7.0.0'@storybook/[email protected]':@@ -5845,12 +5845,12 @@ packages:prettier:optional: true- '@storybook/[email protected]':- resolution: {integrity: sha512-2vFHbbnp/yGWt4p53OO5swDVZzmOp3HkJEbhc1zE9BW3YcX0mG8Gh2sd7K0+Io04uoupwJpawTz8VDdKfYkJUA==}+ '@storybook/[email protected]':+ resolution: {integrity: sha512-OBjwaEdG3OrgsvUncu0AptCOH9u9BDQeIlMChj/QxnlNCy4yTUdPYNJ140mYzl51a20IKi6OTRverLopP7RNUg==}peerDependencies:esbuild: '*'rollup: '*'- storybook: ^10.0.0-beta.0+ storybook: ^10.0.0-beta.2vite: '*'webpack: '*'peerDependenciesMeta:@@ -6175,8 +6175,8 @@ packages:'@tauri-apps/[email protected]':resolution: {integrity: sha512-I8Bo+spcAKGhIIJ1qN/gapp/Ot3mosQL98znxr975Zn2ODAkUZ++BQ9FnTpR7PDwfIl5ANSGdIW/YU01zVTcJw==}- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-cNLo9YeQSC0MF4IgXnotHsqEgJk72MBZLXmQPrLA95qTaaWiiaFQ38hIMdZ6YbGUNkr3oni3EhU+AD5jLHcdUA==}+ '@tauri-apps/[email protected]':+ resolution: {integrity: sha512-OvXkrEBfWwtd8tzVCEXIvRfNEX87qs2jv6SqmVPiHcJjBhSF/GUvjqUNIDmKByb5N8nvDqVUM7+g1sXwdC/S9w==}'@tauri-apps/[email protected]':resolution: {integrity: sha512-vJlKZVGF3UAFGoIEVT6Oq5L4HGDCD78WmA4uhzitToqYiBKWAvZR61M6zAyQzHqLs0ADemkE4RSy/5sCmZm6ZQ==}@@ -6463,8 +6463,8 @@ packages:peerDependencies:'@types/react': ^18.0.0- '@types/[email protected]':- resolution: {integrity: sha512-i5ZzwYpqjmrKenzkoLM2Ibzt6mAsM7pxB6BCIouEVVmgiqaMj1TjaK7hnA36hbW5aZv20kx7Lw6hWzPWg0Rurw==}+ '@types/[email protected]':+ resolution: {integrity: sha512-qXRuZaOsAdXKFyOhRBg6Lqqc0yay13vN7KrIg4L7N4aaHN68ma9OK3NE1BoDFgFOTfM7zg+3/8+2n8rLUH3OKQ==}peerDependencies:'@types/react': ^19.0.0@@ -12602,7 +12602,7 @@ packages:resolution: {integrity: sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA==}engines: {node: '>=6.4.0 <13 || >=14'}- deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net+ deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.netresolution: {integrity: sha512-erY3HFDG0dPnhw4U+udPfrzXa4xhSG+n4rxfRuZWCUvjFWwKl+OxWf/7zk50s84/fAAs7vf5QAb9uRa0cCykxw==}@@ -17388,14 +17388,14 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17406,14 +17406,14 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:- '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17427,17 +17427,17 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-slot': 1.2.2(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17451,17 +17451,17 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-slot': 1.2.3(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected]([email protected])':dependencies:@@ -17507,18 +17507,18 @@ snapshots:transitivePeerDependencies:- '@types/react'- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.2'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-dismissable-layer': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-dismissable-layer': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-focus-guards': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-focus-scope': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-focus-scope': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-portal': 1.1.8(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-presence': 1.1.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-portal': 1.1.8(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-presence': 1.1.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-slot': 1.2.2(@types/[email protected])([email protected])'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])aria-hidden: 1.2.4@@ -17527,7 +17527,7 @@ snapshots:react-remove-scroll: 2.6.3(@types/[email protected])([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])dependencies:@@ -17559,18 +17559,18 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.2'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-escape-keydown': 1.1.1(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17585,18 +17585,18 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.2'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-escape-keydown': 1.1.1(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17613,20 +17613,20 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.2'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-menu': 2.1.14(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-menu': 2.1.14(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected]([email protected])':dependencies:@@ -17659,16 +17659,16 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17681,16 +17681,16 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected]([email protected])':dependencies:@@ -17705,14 +17705,14 @@ snapshots:optionalDependencies:'@types/react': 18.3.21- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17740,22 +17740,22 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.2- '@radix-ui/react-collection': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-collection': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-direction': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-dismissable-layer': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-dismissable-layer': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-focus-guards': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-focus-scope': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-focus-scope': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-popper': 1.2.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-portal': 1.1.8(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-presence': 1.1.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-roving-focus': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-popper': 1.2.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-portal': 1.1.8(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-presence': 1.1.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-roving-focus': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-slot': 1.2.2(@types/[email protected])([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])aria-hidden: 1.2.4@@ -17764,43 +17764,43 @@ snapshots:react-remove-scroll: 2.6.3(@types/[email protected])([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.2- '@radix-ui/react-collection': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-collection': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-direction': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-dismissable-layer': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-dismissable-layer': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-presence': 1.1.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-presence': 1.1.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])'@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-previous': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-visually-hidden': 1.2.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-visually-hidden': 1.2.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.2'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-dismissable-layer': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-dismissable-layer': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-focus-guards': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-focus-scope': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-focus-scope': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-popper': 1.2.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-portal': 1.1.8(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-presence': 1.1.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-popper': 1.2.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-portal': 1.1.8(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-presence': 1.1.4(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-slot': 1.2.2(@types/[email protected])([email protected])'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])aria-hidden: 1.2.4@@ -17809,7 +17809,7 @@ snapshots:react-remove-scroll: 2.6.3(@types/[email protected])([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17829,13 +17829,13 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:- '@radix-ui/react-arrow': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-arrow': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-rect': 1.1.1(@types/[email protected])([email protected])@@ -17845,7 +17845,7 @@ snapshots:react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17865,13 +17865,13 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:- '@radix-ui/react-arrow': 1.1.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-arrow': 1.1.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-rect': 1.1.1(@types/[email protected])([email protected])@@ -17881,7 +17881,7 @@ snapshots:react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])dependencies:@@ -17900,15 +17900,15 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17920,15 +17920,15 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:- '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])dependencies:@@ -17948,7 +17948,7 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])@@ -17956,7 +17956,7 @@ snapshots:react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])dependencies:@@ -17974,14 +17974,14 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/react-slot': 1.2.2(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -17992,14 +17992,14 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/react-slot': 1.2.3(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -18018,22 +18018,22 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.2- '@radix-ui/react-collection': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-collection': 1.1.6(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-direction': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -18064,34 +18064,34 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/number': 1.1.1'@radix-ui/primitive': 1.1.2- '@radix-ui/react-collection': 1.1.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-collection': 1.1.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-direction': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-dismissable-layer': 1.1.10(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-dismissable-layer': 1.1.10(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-focus-guards': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-focus-scope': 1.1.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-focus-scope': 1.1.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-popper': 1.2.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-portal': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-popper': 1.2.7(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-portal': 1.1.9(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-slot': 1.2.3(@types/[email protected])([email protected])'@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])'@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-previous': 1.1.1(@types/[email protected])([email protected])- '@radix-ui/react-visually-hidden': 1.2.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-visually-hidden': 1.2.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])aria-hidden: 1.2.4react: 19.1.0react-dom: 19.1.0([email protected])react-remove-scroll: 2.6.3(@types/[email protected])([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -18132,12 +18132,12 @@ snapshots:optionalDependencies:'@types/react': 18.3.21- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:'@radix-ui/primitive': 1.1.2'@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])'@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])'@radix-ui/react-use-previous': 1.1.1(@types/[email protected])([email protected])'@radix-ui/react-use-size': 1.1.1(@types/[email protected])([email protected])@@ -18145,7 +18145,7 @@ snapshots:react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -18252,14 +18252,14 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:- '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:@@ -18270,14 +18270,14 @@ snapshots:'@types/react': 18.3.21'@types/react-dom': 18.3.7(@types/[email protected])- '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ '@radix-ui/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':dependencies:- '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])+ '@radix-ui/react-primitive': 2.1.3(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])react: 19.1.0react-dom: 19.1.0([email protected])optionalDependencies:'@types/react': 18.3.21- '@types/react-dom': 19.1.7(@types/[email protected])+ '@types/react-dom': 19.1.9(@types/[email protected])'@radix-ui/[email protected]': {}@@ -19271,9 +19271,9 @@ snapshots:react: 19.1.0react-dom: 19.1.0([email protected])- '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':+ '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':dependencies:- '@storybook/csf-plugin': 10.0.0-beta.0([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ '@storybook/csf-plugin': 10.0.0-beta.2([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))storybook: 8.6.12([email protected])ts-dedent: 2.2.0@@ -19303,7 +19303,7 @@ snapshots:- supports-color- utf-8-validate- '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':+ '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':dependencies:storybook: 8.6.12([email protected])unplugin: 2.3.8@@ -19625,9 +19625,9 @@ snapshots:dependencies:'@tauri-apps/api': 2.7.0- '@tauri-apps/[email protected]':+ '@tauri-apps/[email protected]':dependencies:- '@tauri-apps/api': 2.7.0+ '@tauri-apps/api': 2.8.0'@tauri-apps/[email protected]':dependencies:@@ -19965,7 +19965,7 @@ snapshots:dependencies:'@types/react': 18.3.21- '@types/[email protected](@types/[email protected])':+ '@types/[email protected](@types/[email protected])':dependencies:'@types/react': 18.3.21@@ -22278,8 +22278,8 @@ snapshots:'@typescript-eslint/parser': 5.62.0([email protected])([email protected])eslint: 8.57.1eslint-import-resolver-node: 0.3.9- eslint-import-resolver-typescript: 3.10.1([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected])- eslint-plugin-import: 2.31.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected]))([email protected])+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected])+ eslint-plugin-import: 2.31.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])eslint-plugin-jsx-a11y: 6.10.2([email protected])eslint-plugin-react: 7.37.5([email protected])eslint-plugin-react-hooks: 4.6.2([email protected])@@ -22298,7 +22298,7 @@ snapshots:eslint: 9.30.1([email protected])eslint-import-resolver-node: 0.3.9eslint-import-resolver-typescript: 3.10.1([email protected]([email protected]([email protected])))([email protected]([email protected]))- eslint-plugin-import: 2.31.0(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])))([email protected]([email protected]))+ eslint-plugin-import: 2.31.0(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))eslint-plugin-jsx-a11y: 6.10.2([email protected]([email protected]))eslint-plugin-react: 7.37.5([email protected]([email protected]))eslint-plugin-react-hooks: 4.6.2([email protected]([email protected]))@@ -22326,21 +22326,6 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected]):- dependencies:- '@nolyfill/is-core-module': 1.0.39- debug: 4.4.0([email protected])- eslint: 8.57.1- get-tsconfig: 4.10.0- is-bun-module: 2.0.0- stable-hash: 0.0.5- tinyglobby: 0.2.13- unrs-resolver: 1.7.2- optionalDependencies:- eslint-plugin-import: 2.31.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected]))([email protected])- transitivePeerDependencies:- - supports-color-[email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])):dependencies:'@nolyfill/is-core-module': 1.0.39@@ -22352,7 +22337,7 @@ snapshots:tinyglobby: 0.2.13unrs-resolver: 1.7.2optionalDependencies:- eslint-plugin-import: 2.31.0(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])))([email protected]([email protected]))+ eslint-plugin-import: 2.31.0(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))transitivePeerDependencies:- supports-color@@ -22371,14 +22356,14 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected]))([email protected]):+ [email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]):dependencies:debug: 3.2.7optionalDependencies:'@typescript-eslint/parser': 5.62.0([email protected])([email protected])eslint: 8.57.1eslint-import-resolver-node: 0.3.9- eslint-import-resolver-typescript: 3.10.1([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected])+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected])transitivePeerDependencies:- supports-color@@ -22404,7 +22389,7 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected]))([email protected]):+ [email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]):dependencies:'@rtsao/scc': 1.1.0array-includes: 3.1.8@@ -22415,7 +22400,7 @@ snapshots:doctrine: 2.1.0eslint: 8.57.1eslint-import-resolver-node: 0.3.9- eslint-module-utils: 2.12.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected]))([email protected])+ eslint-module-utils: 2.12.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected])hasown: 2.0.2is-core-module: 2.16.1is-glob: 4.0.3@@ -22433,7 +22418,7 @@ snapshots:- eslint-import-resolver-webpack- supports-color- [email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]([email protected]([email protected])))([email protected]([email protected])))([email protected]([email protected])):+ [email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected])):dependencies:'@rtsao/scc': 1.1.0array-includes: 3.1.8@@ -27514,7 +27499,7 @@ snapshots:[email protected](@storybook/[email protected]([email protected]([email protected])))([email protected])([email protected])([email protected])([email protected]([email protected]))([email protected](@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected](@types/[email protected])([email protected])([email protected])([email protected])):dependencies:- '@storybook/builder-vite': 10.0.0-beta.0([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ '@storybook/builder-vite': 10.0.0-beta.2([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))'@storybook/types': 9.0.0-alpha.1([email protected]([email protected]))magic-string: 0.30.17solid-js: 1.9.6