Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(verify): macOS AVFoundation fixture encoder, keyframe seek cases, per-case failure collection
Richie McIlroy48357f05caaf
diff --git a/Cargo.lock b/Cargo.lockindex 62aee8779..1728a2195 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2156,12 +2156,14 @@ version = "0.1.0"dependencies = ["anyhow","cap-editor",+ "cap-enc-avfoundation","cap-export","cap-media-info","cap-project","cap-recording","cap-rendering","cap-timestamp",+ "cidre","ffmpeg-next","flume","futures",diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.tomlindex 63bbd780a..de97a2b66 100644--- a/crates/verify/Cargo.toml+++ b/crates/verify/Cargo.toml@@ -24,6 +24,10 @@ serde_json = "1"tokio = { workspace = true }workspace-hack = { version = "0.1", path = "../workspace-hack" }+[target.'cfg(target_os = "macos")'.dependencies]+cap-enc-avfoundation = { path = "../enc-avfoundation" }+cidre = { workspace = true }+[dev-dependencies]cap-editor = { path = "../editor" }cap-export = { path = "../export" }diff --git a/crates/verify/src/catalog.rs b/crates/verify/src/catalog.rsindex eb16e7a9c..f258844d0 100644--- a/crates/verify/src/catalog.rs+++ b/crates/verify/src/catalog.rs@@ -108,6 +108,27 @@ pub fn seek_gop(_tier: Tier) -> FixtureSpec {}}+/// The seek fixture written by the product's macOS encoder (AVAssetWriter+/// + VideoToolbox, its own GOP structure, 1/600 time base). Keyframes at+/// k/30 s are off the 10 ms grid for most k. Identical to `seek_gop`+/// elsewhere.+pub fn seek_gop_native(_tier: Tier) -> FixtureSpec {+ let duration = 12.0;+ let native = |mut track: VideoTrackSpec| {+ track.encoder = crate::fixture::TrackEncoder::AvFoundation;+ track+ };+ FixtureSpec {+ name: "seek-native".into(),+ segments: vec![SegmentSpec {+ display: native(screen(30, Timing::Constant { duration })),+ camera: Some(native(camera(Timing::Constant { duration }))),+ mic: None,+ system_audio: None,+ }],+ }+}+/// Camera that starts 1.5 s after the screen (it is the latest track).pub fn late_camera(_tier: Tier) -> FixtureSpec {let duration = 6.0;diff --git a/crates/verify/src/fixture.rs b/crates/verify/src/fixture.rsindex 1593a2947..6198121e2 100644--- a/crates/verify/src/fixture.rs+++ b/crates/verify/src/fixture.rs@@ -66,7 +66,10 @@ pub enum Timing {Constant { duration: f64 },/// Constant rate with no frames inside the given (start, length) holds,/// like a static screen under VFR capture.- Holds { duration: f64, holds: Vec<(f64, f64)> },+ Holds {+ duration: f64,+ holds: Vec<(f64, f64)>,+ },/// A source delivering below its nominal rate with jitter: consecutive/// frames are 1..=4 slots apart (mean ~2.4), with a rare 6..=12 slot/// stall, and no frames inside `holds`.@@ -82,7 +85,9 @@ pub enum Timing {impl Timing {pub fn slots(&self, fps: u32) -> Vec<u32> {match self {- Timing::Constant { duration } => (0..(duration * f64::from(fps)).round() as u32).collect(),+ Timing::Constant { duration } => {+ (0..(duration * f64::from(fps)).round() as u32).collect()+ }Timing::Holds { duration, holds } => (0..(duration * f64::from(fps)).round() as u32).filter(|&k| {let t = f64::from(k) / f64::from(fps);@@ -149,6 +154,19 @@ pub struct VideoTrackSpec {pub pts_offset: f64,/// `start_time` written to recording-meta.json.pub start_time: f64,+ /// Encoder used for the track.+ #[serde(default)]+ pub encoder: TrackEncoder,+}++#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]+pub enum TrackEncoder {+ /// libx264 with exact GOP control (all platforms).+ #[default]+ X264,+ /// The product's macOS AVAssetWriter/VideoToolbox encoder. Falls back to+ /// libx264 on other platforms.+ AvFoundation,}impl VideoTrackSpec {@@ -162,6 +180,7 @@ impl VideoTrackSpec {b_frames: 0,pts_offset: 0.0,start_time: 0.0,+ encoder: TrackEncoder::X264,}}}@@ -212,6 +231,28 @@ fn write_video_track(segment: u8,spec: &VideoTrackSpec,) -> anyhow::Result<()> {+ #[cfg(target_os = "macos")]+ if spec.encoder == TrackEncoder::AvFoundation {+ let times: Vec<(u32, f64)> = spec+ .timing+ .slots(spec.fps)+ .into_iter()+ .map(|slot| {+ (+ slot,+ spec.pts_offset + f64::from(slot) / f64::from(spec.fps),+ )+ })+ .collect();+ return crate::fixture_avf::write_video_track(+ path,+ |slot| FrameMarker::new(kind, segment, slot),+ spec.width,+ spec.height,+ spec.fps,+ ×,+ );+ }let mut config = VideoWriterConfig::new(spec.width, spec.height, spec.fps);config.gop = spec.gop;config.b_frames = spec.b_frames;@@ -219,7 +260,10 @@ fn write_video_track(for slot in spec.timing.slots(spec.fps) {let marker = FrameMarker::new(kind, segment, slot);let rgba = video_code::marker_rgba(marker, spec.width as usize, spec.height as usize);- writer.write_rgba(&rgba, spec.pts_offset + f64::from(slot) / f64::from(spec.fps))?;+ writer.write_rgba(+ &rgba,+ spec.pts_offset + f64::from(slot) / f64::from(spec.fps),+ )?;}writer.finish()?;Ok(())@@ -418,7 +462,17 @@ pub fn ensure_fixture(if done.exists() && dir.exists() {return Ok(dir);}- let staging = root.join(format!("{key}.{}.tmp.cap", std::process::id()));+ static GENERATING: std::sync::Mutex<()> = std::sync::Mutex::new(());+ let _serial = GENERATING.lock().unwrap_or_else(|e| e.into_inner());+ if done.exists() && dir.exists() {+ return Ok(dir);+ }+ static NEXT: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);+ let staging = root.join(format!(+ "{key}.{}-{}.tmp.cap",+ std::process::id(),+ NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed)+ ));generate(spec, &staging)?;// Paths inside recording-meta.json are relative, so the staged project// stays valid after the rename.diff --git a/crates/verify/src/fixture_avf.rs b/crates/verify/src/fixture_avf.rsnew file mode 100644index 000000000..048d595e2--- /dev/null+++ b/crates/verify/src/fixture_avf.rs@@ -0,0 +1,107 @@+//! macOS: writes a track through the product's AVFoundation encoder+//! (`cap-enc-avfoundation`, AVAssetWriter + VideoToolbox), the encoder Studio+//! recordings use on macOS, fed NV12 IOSurface buffers with exact times.++use std::{path::Path, time::Duration};++use anyhow::{anyhow, bail};+use cap_enc_avfoundation::{MP4Encoder, QueueFrameError};+use cap_media_info::{RawVideoFormat, VideoInfo};+use cidre::{arc, cf, cm, cv};++use crate::video_code::{self, FrameMarker};++fn pixel_buffer(width: usize, height: usize, rgba: &[u8]) -> anyhow::Result<arc::R<cv::PixelBuf>> {+ let io_surface_properties = cf::Dictionary::new();+ let keys: [&cf::Type; 1] = [cv::pixel_buffer::keys::io_surf_props().as_ref()];+ let values: [&cf::Type; 1] = [io_surface_properties.as_ref()];+ let attrs = cf::Dictionary::with_keys_values(&keys, &values)+ .ok_or_else(|| anyhow!("pixel buffer attributes"))?;+ let mut buf = cv::PixelBuf::new(width, height, cv::PixelFormat::_420V, Some(&attrs))+ .map_err(|e| anyhow!("pixel buffer: {e:?}"))?;+ unsafe {+ buf.lock_base_addr(cv::pixel_buffer::LockFlags::DEFAULT)+ .result()+ .map_err(|e| anyhow!("lock: {e:?}"))?;+ let y_stride = buf.plane_bytes_per_row(0);+ let uv_stride = buf.plane_bytes_per_row(1);+ let y_base = buf.plane_base_address(0).cast_mut();+ let uv_base = buf.plane_base_address(1).cast_mut();+ let ycc = |x: usize, y: usize| {+ let i = (y * width + x) * 4;+ video_code::rgb_to_ycbcr(rgba[i], rgba[i + 1], rgba[i + 2])+ };+ for y in 0..height {+ for x in 0..width {+ let (l, _, _) = ycc(x, y);+ *y_base.add(y * y_stride + x) = (16.0 + l * 219.0 / 255.0).round() as u8;+ }+ }+ for y in 0..height / 2 {+ for x in 0..width / 2 {+ let (_, cb, cr) = ycc(x * 2, y * 2);+ *uv_base.add(y * uv_stride + x * 2) = (128.0 + cb * 224.0 / 255.0).round() as u8;+ *uv_base.add(y * uv_stride + x * 2 + 1) =+ (128.0 + cr * 224.0 / 255.0).round() as u8;+ }+ }+ buf.unlock_lock_base_addr(cv::pixel_buffer::LockFlags::DEFAULT);+ }+ Ok(buf)+}++pub fn write_video_track(+ path: &Path,+ marker_for: impl Fn(u32) -> FrameMarker,+ width: u32,+ height: u32,+ fps: u32,+ times: &[(u32, f64)],+) -> anyhow::Result<()> {+ let info = VideoInfo::from_raw(RawVideoFormat::Nv12, width, height, fps);+ let mut encoder =+ MP4Encoder::init(path.to_path_buf(), info, None, None).map_err(|e| anyhow!("{e}"))?;+ let mut last = Duration::ZERO;+ for &(slot, pts) in times {+ let rgba = video_code::marker_rgba(marker_for(slot), width as usize, height as usize);+ let buf = pixel_buffer(width as usize, height as usize, &rgba)?;+ let format_desc = cm::VideoFormatDesc::with_image_buf(&buf)+ .map_err(|e| anyhow!("format description: {e:?}"))?;+ let timing = cm::SampleTimingInfo {+ duration: cm::Time::new(1_000_000 / i64::from(fps), 1_000_000),+ pts: cm::Time::new((pts * 1e6).round() as i64, 1_000_000),+ dts: cm::Time::invalid(),+ };+ let sample = cm::SampleBuf::with_image_buf(+ &buf,+ true,+ None,+ std::ptr::null(),+ &format_desc,+ &timing,+ )+ .map_err(|e| anyhow!("sample buffer: {e:?}"))?;+ let timestamp = Duration::from_secs_f64(pts);+ let mut queued = false;+ for _ in 0..20_000 {+ match encoder.queue_video_frame(sample.clone(), timestamp) {+ Ok(()) => {+ queued = true;+ break;+ }+ Err(QueueFrameError::NotReadyForMore) => {+ std::thread::sleep(Duration::from_micros(250));+ }+ Err(e) => bail!("queue frame at {pts}: {e}"),+ }+ }+ if !queued {+ bail!("encoder never became ready at {pts}");+ }+ last = timestamp;+ }+ encoder+ .finish(Some(last + Duration::from_secs_f64(1.0 / f64::from(fps))))+ .map_err(|e| anyhow!("finish: {e}"))?;+ Ok(())+}diff --git a/crates/verify/src/lib.rs b/crates/verify/src/lib.rsindex e2c643d8a..69ad33ae4 100644--- a/crates/verify/src/lib.rs+++ b/crates/verify/src/lib.rs@@ -2,10 +2,12 @@//! timeline model and oracle checkers. See `crates/verify/README.md`.pub mod audio_code;-pub mod media;-pub mod oracle;-pub mod video_code;pub mod catalog;pub mod fixture;+#[cfg(target_os = "macos")]+pub mod fixture_avf;+pub mod media;pub mod model;+pub mod oracle;pub mod report;+pub mod video_code;diff --git a/crates/verify/src/model.rs b/crates/verify/src/model.rsindex 830c82078..fd677c592 100644--- a/crates/verify/src/model.rs+++ b/crates/verify/src/model.rs@@ -316,7 +316,11 @@ impl ReferenceModel {let mut allowed = Vec::new();for slot in slots {let upto = numbers.partition_point(|&n| n <= slot);- let target = if upto == 0 { numbers[0] } else { numbers[upto - 1] };+ let target = if upto == 0 {+ numbers[0]+ } else {+ numbers[upto - 1]+ };for (frame, &n) in track.frames.iter().zip(&numbers) {if n == target && !allowed.contains(&frame.index) {allowed.push(frame.index);diff --git a/crates/verify/src/report.rs b/crates/verify/src/report.rsindex 820d169a1..b4b1bfb87 100644--- a/crates/verify/src/report.rs+++ b/crates/verify/src/report.rs@@ -155,10 +155,7 @@ pub fn load_expectations() -> Vec<Xfail> {pub fn lookup_xfail(id: &str) -> Option<Xfail> {let platform = platform();load_expectations().into_iter().find(|x| {- glob_match(&x.pattern, id)- && x.platforms- .iter()- .any(|p| p == "all" || p == platform)+ glob_match(&x.pattern, id) && x.platforms.iter().any(|p| p == "all" || p == platform)})}@@ -221,7 +218,10 @@ pub fn settle(case: Case) -> Result<CaseResult, String> {(Some(_), false) => "XPASS",};if let Some(x) = &xfail {- summary = format!("{summary}\n (expected failure, expectations.txt:{}: {})", x.line, x.reason);+ summary = format!(+ "{summary}\n (expected failure, expectations.txt:{}: {})",+ x.line, x.reason+ );}let result = CaseResult {id: case.id.clone(),diff --git a/crates/verify/tests/common/mod.rs b/crates/verify/tests/common/mod.rsindex a99ceeafe..9aba10e4c 100644--- a/crates/verify/tests/common/mod.rs+++ b/crates/verify/tests/common/mod.rs@@ -169,10 +169,18 @@ pub struct OutputFrame {fn picture_hash(frame: &ffmpeg::frame::Video) -> u64 {let mut hash: u64 = 0xcbf2_9ce4_8422_2325;- let planes = if frame.format() == ffmpeg::format::Pixel::NV12 { 2 } else { 3 };+ let planes = if frame.format() == ffmpeg::format::Pixel::NV12 {+ 2+ } else {+ 3+ };for plane in 0..planes.min(frame.planes()) {let width = frame.plane_width(plane) as usize- * if frame.format() == ffmpeg::format::Pixel::NV12 && plane == 1 { 2 } else { 1 };+ * if frame.format() == ffmpeg::format::Pixel::NV12 && plane == 1 {+ 2+ } else {+ 1+ };let stride = frame.stride(plane);let data = frame.data(plane);for row in 0..frame.plane_height(plane) as usize {@@ -224,14 +232,20 @@ pub fn check_sequence(.take(5).collect();if !off_grid.is_empty() {- case.problem(format!("output timestamps off the {fps} fps grid: {off_grid:?}"));+ case.problem(format!(+ "output timestamps off the {fps} fps grid: {off_grid:?}"+ ));}}let n = frames.len().min(expected_count as usize);let expectations: Vec<_> = (0..n as u32).map(|i| model.expect(i, fps)).collect();for kind in StreamKind::ALL {- let exp: Vec<StreamExpectation> = expectations.iter().map(|e| e.get(kind).clone()).collect();- let obs: Vec<_> = frames[..n].iter().map(|f| f.readout.get(kind).clone()).collect();+ let exp: Vec<StreamExpectation> =+ expectations.iter().map(|e| e.get(kind).clone()).collect();+ let obs: Vec<_> = frames[..n]+ .iter()+ .map(|f| f.readout.get(kind).clone())+ .collect();case.stream(oracle::check_stream(kind, &exp, &obs, fps));}}@@ -336,7 +350,12 @@ impl Player {/// Renders output frame `frame` and reads its markers. `None` when the/// timeline has no segment there or the decoders returned nothing.- pub async fn frame(&mut self, frame: u32, fps: u32, seek: bool) -> Result<FrameReadout, String> {+ pub async fn frame(+ &mut self,+ frame: u32,+ fps: u32,+ seek: bool,+ ) -> Result<FrameReadout, String> {let t = f64::from(frame) / f64::from(fps);let (segment_time, segment) = self.config@@ -412,8 +431,13 @@ pub fn check_requests() {let expectations: Vec<_> = frames.iter().map(|&f| model.expect(f, fps)).collect();for kind in StreamKind::ALL {- let exp: Vec<StreamExpectation> = expectations.iter().map(|e| e.get(kind).clone()).collect();+ let exp: Vec<StreamExpectation> =+ expectations.iter().map(|e| e.get(kind).clone()).collect();let obs: Vec<_> = readouts.iter().map(|r| r.get(kind).clone()).collect();case.stream(oracle::check_stream_at(kind, &exp, &obs, frames, fps));}}++pub fn assert_passed(failures: Vec<String>) {+ assert!(failures.is_empty(), "{}", failures.join("\n"));+}diff --git a/crates/verify/tests/export.rs b/crates/verify/tests/export.rsindex 384a08af8..b06799b18 100644--- a/crates/verify/tests/export.rs+++ b/crates/verify/tests/export.rs@@ -36,7 +36,7 @@ fn run(decoders: &[Decoder],resolution: (u32, u32),determinism: bool,-) {+) -> Vec<String> {let project = common::project(&spec);let rt = common::runtime();let mut failures = Vec::new();@@ -64,7 +64,13 @@ fn run(Err(e) => case.problem(format!("export failed: {e}")),Ok(path) => {let frames = common::read_output(&path);- common::check_sequence(&mut case, &model, &frames, fps, format == Format::Mp4);+ common::check_sequence(+ &mut case,+ &model,+ &frames,+ fps,+ format == Format::Mp4,+ );if determinism {let second = dir.path().join(format!("b.{ext}"));match rt.block_on(common::export(&project, config, &run, &second)) {@@ -97,7 +103,7 @@ fn run(}}}- assert!(failures.is_empty(), "{}", failures.join("\n"));+ failures}const RES: (u32, u32) = (480, 270);@@ -141,7 +147,8 @@ fn hide_camera_scene(config: &mut ProjectConfiguration) {#[test]fn basic() {- run(+ let mut failures: Vec<String> = Vec::new();+ failures.extend(run(catalog::basic(report::tier()),&[Variant {@@ -169,12 +176,14 @@ fn basic() {&Decoder::all(),RES,false,- );+ ));+ common::assert_passed(failures);}#[test]fn gif() {- run(+ let mut failures: Vec<String> = Vec::new();+ failures.extend(run(catalog::basic(report::tier()),&[Variant {edit: "cuts-speeds-reorder",@@ -184,12 +193,14 @@ fn gif() {&[Decoder::Default],(320, 180),false,- );+ ));+ common::assert_passed(failures);}#[test]fn vfr_holds() {- run(+ let mut failures: Vec<String> = Vec::new();+ failures.extend(run(catalog::vfr_holds(report::tier()),&[Variant {edit: "full",@@ -199,14 +210,16 @@ fn vfr_holds() {&Decoder::all(),RES,false,- );+ ));+ common::assert_passed(failures);}/// Long recordings with a jittery ~12 fps camera at 30 fps nominal exported/// at 60 fps: the camera must never run ahead of the screen.#[test]fn jitter_camera() {- run(+ let mut failures: Vec<String> = Vec::new();+ failures.extend(run(catalog::jitter_camera(report::tier()),&[Variant {edit: "full",@@ -216,17 +229,22 @@ fn jitter_camera() {&Decoder::all(),RES,report::tier() == Tier::Full,- );+ ));+ common::assert_passed(failures);}fn backward_jumps(config: &mut ProjectConfiguration) {- common::set_cuts(config, &[(5.0, 35.0, 1.0), (44.0, 50.0, 1.0), (28.0, 45.0, 1.0)]);+ common::set_cuts(+ config,+ &[(5.0, 35.0, 1.0), (44.0, 50.0, 1.0), (28.0, 45.0, 1.0)],+ );}/// Play past a long hold, elsewhere, then jump back into the hold.#[test]fn backward_hold() {- run(+ let mut failures: Vec<String> = Vec::new();+ failures.extend(run(catalog::backward_hold(report::tier()),&[Variant {edit: "backward-jumps",@@ -236,17 +254,19 @@ fn backward_hold() {&Decoder::all(),RES,false,- );+ ));+ common::assert_passed(failures);}#[test]fn start_offsets() {+ let mut failures: Vec<String> = Vec::new();for spec in [catalog::late_camera(report::tier()),catalog::early_camera(report::tier()),catalog::camera_pts_late(report::tier()),] {- run(+ failures.extend(run(spec,&[Variant {edit: "full",@@ -256,13 +276,15 @@ fn start_offsets() {&Decoder::all(),RES,false,- );+ ));}+ common::assert_passed(failures);}#[test]fn multi_segment() {- run(+ let mut failures: Vec<String> = Vec::new();+ failures.extend(run(catalog::multi_segment(report::tier()),&[Variant {edit: "full",@@ -272,5 +294,6 @@ fn multi_segment() {&Decoder::all(),RES,true,- );+ ));+ common::assert_passed(failures);}diff --git a/crates/verify/tests/playback.rs b/crates/verify/tests/playback.rsindex c6e73759d..72c52ca05 100644--- a/crates/verify/tests/playback.rs+++ b/crates/verify/tests/playback.rs@@ -20,12 +20,20 @@ fn no_edit(_: &mut ProjectConfiguration) {}fn cuts(config: &mut ProjectConfiguration) {common::set_cuts(config,- &[(0.5, 2.0, 1.0), (2.5, 4.0, 2.0), (1.0, 2.0, 0.5), (4.0, 5.8, 1.5)],+ &[+ (0.5, 2.0, 1.0),+ (2.5, 4.0, 2.0),+ (1.0, 2.0, 0.5),+ (4.0, 5.8, 1.5),+ ],);}fn backward_jumps(config: &mut ProjectConfiguration) {- common::set_cuts(config, &[(5.0, 35.0, 1.0), (44.0, 50.0, 1.0), (28.0, 45.0, 1.0)]);+ common::set_cuts(+ config,+ &[(5.0, 35.0, 1.0), (44.0, 50.0, 1.0), (28.0, 45.0, 1.0)],+ );}/// Plays `[start, end)` output frames sequentially (the first as a seek).@@ -34,7 +42,7 @@ fn sequential(edit: (&str, fn(&mut ProjectConfiguration)),fps: u32,start_fraction: f64,-) {+) -> Vec<String> {let project = common::project(&spec);let rt = common::runtime();let mut failures = Vec::new();@@ -72,44 +80,96 @@ fn sequential(failures.push(message);}}- assert!(failures.is_empty(), "{}", failures.join("\n"));+ failures}#[test]fn basic_sequential() {- sequential(catalog::basic(report::tier()), ("full", no_edit), 30, 0.0);- sequential(catalog::basic(report::tier()), ("cuts-speeds-reorder", cuts), 60, 0.0);+ let mut failures: Vec<String> = Vec::new();+ failures.extend(sequential(+ catalog::basic(report::tier()),+ ("full", no_edit),+ 30,+ 0.0,+ ));+ failures.extend(sequential(+ catalog::basic(report::tier()),+ ("cuts-speeds-reorder", cuts),+ 60,+ 0.0,+ ));+ common::assert_passed(failures);}#[test]fn play_from_middle() {+ let mut failures: Vec<String> = Vec::new();let seed = 0x9A1D_0001;let mut rng = Rng::new(seed);eprintln!("seed {seed:#x}");for _ in 0..2 {let start = 0.2 + rng.f64() * 0.6;- sequential(catalog::basic(report::tier()), ("full", no_edit), 30, start);+ failures.extend(sequential(+ catalog::basic(report::tier()),+ ("full", no_edit),+ 30,+ start,+ ));}- sequential(catalog::vfr_holds(report::tier()), ("full", no_edit), 60, 0.3);+ failures.extend(sequential(+ catalog::vfr_holds(report::tier()),+ ("full", no_edit),+ 60,+ 0.3,+ ));+ common::assert_passed(failures);}#[test]fn vfr_holds_sequential() {- sequential(catalog::vfr_holds(report::tier()), ("full", no_edit), 30, 0.0);+ let mut failures: Vec<String> = Vec::new();+ failures.extend(sequential(+ catalog::vfr_holds(report::tier()),+ ("full", no_edit),+ 30,+ 0.0,+ ));+ common::assert_passed(failures);}#[test]fn backward_jumps_sequential() {- sequential(catalog::backward_hold(report::tier()), ("backward-jumps", backward_jumps), 30, 0.0);+ let mut failures: Vec<String> = Vec::new();+ failures.extend(sequential(+ catalog::backward_hold(report::tier()),+ ("backward-jumps", backward_jumps),+ 30,+ 0.0,+ ));+ common::assert_passed(failures);}#[test]fn jitter_camera_sequential() {+ let mut failures: Vec<String> = Vec::new();let fps = if report::tier() == Tier::Full { 60 } else { 30 };- sequential(catalog::jitter_camera(report::tier()), ("full", no_edit), fps, 0.0);+ failures.extend(sequential(+ catalog::jitter_camera(report::tier()),+ ("full", no_edit),+ fps,+ 0.0,+ ));+ common::assert_passed(failures);}#[test]fn multi_segment_sequential() {- sequential(catalog::multi_segment(report::tier()), ("full", no_edit), 30, 0.0);+ let mut failures: Vec<String> = Vec::new();+ failures.extend(sequential(+ catalog::multi_segment(report::tier()),+ ("full", no_edit),+ 30,+ 0.0,+ ));+ common::assert_passed(failures);}diff --git a/crates/verify/tests/seek.rs b/crates/verify/tests/seek.rsindex 7be9c756b..8e749823b 100644--- a/crates/verify/tests/seek.rs+++ b/crates/verify/tests/seek.rs@@ -25,7 +25,7 @@ fn run(fps: u32,edit: fn(&mut ProjectConfiguration),make: &dyn Fn(u32, &common::Project) -> Vec<Request>,-) {+) -> Vec<String> {let project = common::project(&spec);let rt = common::runtime();let mut failures = Vec::new();@@ -57,7 +57,7 @@ fn run(failures.push(message);}}- assert!(failures.is_empty(), "{}", failures.join("\n"));+ failures}fn no_edit(_: &mut ProjectConfiguration) {}@@ -88,24 +88,47 @@ fn storm(seed: u64, count: usize) -> impl Fn(u32, &common::Project) -> Vec<Reque#[test]fn random_storm() {+ let mut failures: Vec<String> = Vec::new();let count = seek_count(150, 3000);- run(catalog::seek_gop(report::tier()), "storm", 30, no_edit, &storm(0x5EE4_0001, count));- run(catalog::vfr_holds(report::tier()), "storm", 60, no_edit, &storm(0x5EE4_0002, count));+ failures.extend(run(+ catalog::seek_gop(report::tier()),+ "storm",+ 30,+ no_edit,+ &storm(0x5EE4_0001, count),+ ));+ failures.extend(run(+ catalog::vfr_holds(report::tier()),+ "storm",+ 60,+ no_edit,+ &storm(0x5EE4_0002, count),+ ));+ failures.extend(run(+ catalog::seek_gop_native(report::tier()),+ "storm",+ 30,+ no_edit,+ &storm(0x5EE4_0004, count),+ ));+ common::assert_passed(failures);}-/// Seeks landing exactly on every source keyframe (and the frame before-/// it), in shuffled order: a reader started a hair before the keyframe-/// decodes the previous GOP and shows its last frame.+/// Seeks landing on and around every source keyframe, at 60 fps output so+/// requests also fall between the keyframe's pts and the next source slot,+/// in shuffled order: a reader started a hair before the keyframe decodes+/// the previous GOP and shows its last frame under the keyframe's number.#[test]fn keyframe_seeks() {+ let mut failures: Vec<String> = Vec::new();let keyframes = |total: u32, project: &common::Project| {let display = project.path.join("content/segments/segment-0/display.mp4");let times = media::keyframe_times(&display).expect("keyframes");let mut frames: Vec<u32> = times.iter().flat_map(|t| {- let f = (t * 30.0).round() as u32;- [f, f.saturating_sub(1), f + 1]+ let f = (t * 60.0).round() as u32;+ [f, f.saturating_sub(1), f + 1, f + 2]}).filter(|&f| f < total).collect();@@ -116,26 +139,55 @@ fn keyframe_seeks() {}frames.into_iter().map(|f| (f, true)).collect()};- run(catalog::seek_gop(report::tier()), "keyframes", 30, no_edit, &keyframes);+ failures.extend(run(+ catalog::seek_gop(report::tier()),+ "keyframes",+ 60,+ no_edit,+ &keyframes,+ ));+ failures.extend(run(+ catalog::seek_gop_native(report::tier()),+ "keyframes",+ 60,+ no_edit,+ &keyframes,+ ));+ common::assert_passed(failures);}/// Scrubbing: seek every 0.25 s forwards, then backwards.#[test]fn scrub() {+ let mut failures: Vec<String> = Vec::new();let scrub = |total: u32, _: &common::Project| {let step = 7;let mut out: Vec<Request> = (0..total).step_by(step).map(|f| (f, true)).collect();out.extend((0..total).rev().step_by(step).map(|f| (f, true)));out};- run(catalog::seek_gop(report::tier()), "scrub", 30, no_edit, &scrub);- run(catalog::vfr_holds(report::tier()), "scrub", 60, no_edit, &scrub);+ failures.extend(run(+ catalog::seek_gop(report::tier()),+ "scrub",+ 30,+ no_edit,+ &scrub,+ ));+ failures.extend(run(+ catalog::vfr_holds(report::tier()),+ "scrub",+ 60,+ no_edit,+ &scrub,+ ));+ common::assert_passed(failures);}/// Seeks into the middle of static holds and across them, then playback/// out of the hold.#[test]fn seek_into_holds() {+ let mut failures: Vec<String> = Vec::new();let into_holds = |total: u32, _: &common::Project| {let mut out = Vec::new();for t in [2.0, 3.5, 1.2, 9.0, 11.1, 5.2, 7.05, 2.3] {@@ -147,7 +199,14 @@ fn seek_into_holds() {}out};- run(catalog::vfr_holds(report::tier()), "into-holds", 60, no_edit, &into_holds);+ failures.extend(run(+ catalog::vfr_holds(report::tier()),+ "into-holds",+ 60,+ no_edit,+ &into_holds,+ ));+ common::assert_passed(failures);}/// The first frame after opening a project, at several positions.@@ -188,5 +247,5 @@ fn cold_open() {failures.push(message);}}- assert!(failures.is_empty(), "{}", failures.join("\n"));+ common::assert_passed(failures);}