Add bounded session playback, synced audio and frame thumbnails
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
//! Headless timing check against real segments; run inside the rig for device audio.
|
||||
use clipbin_core::store::Store;
|
||||
use clipbin_media::player::{Picture, Player};
|
||||
use std::{
|
||||
thread,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
fn main() {
|
||||
let directory = std::env::args().nth(1).expect("session root");
|
||||
let id = std::env::args()
|
||||
.nth(2)
|
||||
.unwrap_or_else(|| "1".into())
|
||||
.parse()
|
||||
.unwrap();
|
||||
let player = Player::new();
|
||||
player.resize((800, 450));
|
||||
player.open(
|
||||
Store {
|
||||
root: directory.into(),
|
||||
},
|
||||
id,
|
||||
Duration::ZERO,
|
||||
);
|
||||
thread::sleep(Duration::from_millis(250));
|
||||
player.play(true);
|
||||
let begin = Instant::now();
|
||||
let mut last = None;
|
||||
let mut frames = 0;
|
||||
for _ in 0..700 {
|
||||
thread::sleep(Duration::from_millis(10));
|
||||
let snapshot = player.snapshot();
|
||||
assert!(snapshot.audio_error.is_none(), "{:?}", snapshot.audio_error);
|
||||
if let Picture::Frame(frame) = snapshot.picture {
|
||||
if let Some(video_time) = snapshot.video_time {
|
||||
assert!(
|
||||
video_time.abs_diff(snapshot.time) <= Duration::from_millis(20),
|
||||
"video out of sync: {video_time:?} vs {:?}",
|
||||
snapshot.time
|
||||
);
|
||||
}
|
||||
if last
|
||||
.as_ref()
|
||||
.is_none_or(|previous| !std::sync::Arc::ptr_eq(previous, &frame))
|
||||
{
|
||||
frames += 1;
|
||||
}
|
||||
last = Some(frame);
|
||||
}
|
||||
}
|
||||
let snapshot = player.snapshot();
|
||||
println!(
|
||||
"playback_check wall={:.3} session={:.3} displayed_frames={frames}",
|
||||
begin.elapsed().as_secs_f64(),
|
||||
snapshot.time.as_secs_f64()
|
||||
);
|
||||
assert!(
|
||||
snapshot.time >= Duration::from_secs(6),
|
||||
"audio master clock stalled: {snapshot:?}"
|
||||
);
|
||||
player.audio(false, 0.5);
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
player.audio(true, 0.5);
|
||||
let before = snapshot.time;
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
assert!(player.snapshot().time > before, "muted wall clock stalled");
|
||||
player.close();
|
||||
}
|
||||
Reference in New Issue
Block a user