Fix cosmic-player file launch and video playback
Some checks failed
Validate .desktop files / validate (push) Has been cancelled

This commit is contained in:
Lionel DARNIS 2026-07-09 11:51:07 +02:00
parent 4a1bfc975c
commit e7781986f5
5 changed files with 67 additions and 22 deletions

View file

@ -277,9 +277,21 @@ impl Video {
// wait for up to 5 seconds until the decoder gets the source capabilities
pipeline.state(gst::ClockTime::from_seconds(5)).0?;
let mut initial_sample = None;
let caps = pad.current_caps().or_else(|| {
let sample = video_sink
.try_pull_preroll(gst::ClockTime::from_seconds(2))
.or_else(|| video_sink.try_pull_sample(gst::ClockTime::from_seconds(2)))?;
let caps = sample.caps().map(|caps| caps.to_owned());
if sample.buffer().is_some() {
initial_sample = Some(sample);
}
caps
});
// extract resolution and framerate
// TODO(jazzfool): maybe we want to extract some other information too?
let (width, height, framerate, has_video) = if let Some(caps) = pad.current_caps() {
let (width, height, framerate, has_video) = if let Some(caps) = caps {
let s = caps.structure(0).ok_or(Error::Caps)?;
let width = s.get::<i32>("width").map_err(|_| Error::Caps)?;
let height = s.get::<i32>("height").map_err(|_| Error::Caps)?;
@ -313,8 +325,11 @@ impl Video {
let sync_av = pipeline.has_property("av-offset");
// NV12 = 12bpp
let frame = Arc::new(Mutex::new(Frame::new()));
let upload_frame = Arc::new(AtomicBool::new(false));
let has_initial_sample = initial_sample.is_some();
let frame = Arc::new(Mutex::new(
initial_sample.map(Frame).unwrap_or_else(Frame::new),
));
let upload_frame = Arc::new(AtomicBool::new(has_initial_sample));
let alive = Arc::new(AtomicBool::new(true));
let last_frame_time = Arc::new(Mutex::new(Instant::now()));