feat: Add keybinds to minimal example

This commit is contained in:
uttarayan21
2025-12-25 21:43:55 +05:30
parent a2491695b3
commit 4ed15c97f0
13 changed files with 156 additions and 113 deletions

View File

@@ -6,10 +6,10 @@ edition = "2024"
[dependencies]
# gst = { workspace = true }
wgpu = "*"
gstreamer = "*"
gstreamer-video = "*"
gstreamer-app = "*"
gstreamer-base = "*"
gstreamer = { version = "0.24.4", features = ["v1_26"] }
gstreamer-app = { version = "0.24.4", features = ["v1_26"] }
gstreamer-base = { version = "0.24.4", features = ["v1_26"] }
gstreamer-video = { version = "0.24.4", features = ["v1_26"] }
winit = { version = "*", features = ["wayland"] }
anyhow = "*"
pollster = "0.4.0"

View File

@@ -77,7 +77,7 @@ impl State {
.await
.context("Failed to request wgpu device")?;
let surface_caps = surface.get_capabilities(&adapter);
dbg!(&surface_caps);
tracing::info!("Caps: {:#?}", &surface_caps);
let surface_format = surface_caps
.formats
.iter()
@@ -85,6 +85,7 @@ impl State {
.find(|f| f.is_hdr_format())
.expect("HDR format not supported")
.clone();
tracing::info!("Using surface format: {:?}", surface_format);
let size = window.inner_size();
let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
@@ -411,9 +412,8 @@ impl State {
},
texture.size(),
);
drop(map);
// drop(buffer);
drop(frame);
// drop(map);
// drop(frame);
Ok(())
}
@@ -426,11 +426,11 @@ impl ApplicationHandler<State> for App {
let window = Arc::new(event_loop.create_window(window_attributes).unwrap());
let monitor = event_loop
.primary_monitor()
.or_else(|| window.current_monitor());
// let monitor = event_loop
// .primary_monitor()
// .or_else(|| window.current_monitor());
// window.set_fullscreen(None);
window.set_fullscreen(Some(winit::window::Fullscreen::Borderless(monitor)));
// window.set_fullscreen(Some(winit::window::Fullscreen::Borderless(monitor)));
self.state = Some(pollster::block_on(State::new(window)).expect("Failed to block"));
}
@@ -528,7 +528,7 @@ impl Video {
gst::init()?;
use gst::prelude::*;
let pipeline = gst::parse::launch(
r##"playbin3 uri=https://jellyfin.tsuba.darksailor.dev/Items/6010382cf25273e624d305907010d773/Download?api_key=036c140222464878862231ef66a2bc9c video-sink="videoconvert ! video/x-raw,format=RGB10A2_LE ! appsink name=appsink""##,
r##"playbin3 uri=https://jellyfin.tsuba.darksailor.dev/Items/6010382cf25273e624d305907010d773/Download?api_key=036c140222464878862231ef66a2bc9c video-sink="videoconvert ! video/x-raw,format=RGB10A2_LE ! appsink sync=true drop=true name=appsink""##
).context("Failed to parse gst pipeline")?;
let pipeline = pipeline
.downcast::<gst::Pipeline>()
@@ -544,11 +544,11 @@ impl Video {
})?;
// appsink.set_property("max-buffers", 2u32);
// appsink.set_property("emit-signals", true);
appsink.set_callbacks(
gst_app::AppSinkCallbacks::builder()
.new_sample(|_appsink| Ok(gst::FlowSuccess::Ok))
.build(),
);
// appsink.set_callbacks(
// gst_app::AppSinkCallbacks::builder()
// .new_sample(|_appsink| Ok(gst::FlowSuccess::Ok))
// .build(),
// );
let bus = pipeline.bus().context("Failed to get gst pipeline bus")?;
pipeline.set_state(gst::State::Playing)?;