mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-12-18 14:06:30 +00:00
player: detect gtk4paintablesink with deep-element-added
Connect to the deep-element-added signal from the pipeline to detect the gtk4paintablesink presence.
This commit is contained in:
parent
25d856a360
commit
f118ef7db0
4 changed files with 38 additions and 12 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -478,9 +478,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gst-plugin-gtk4"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f70501fa85dfdbeebecea35d747791351d04266f5c2c4aa23014d9fe74132290"
|
||||
checksum = "e62e047edb1932887c20105c681203d138ebeb61b83b9e0b368cdec1d0fbc0cc"
|
||||
dependencies = [
|
||||
"fragile",
|
||||
"gst-plugin-version-helper",
|
||||
|
@ -502,10 +502,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gst_pipeline_studio"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"fragile",
|
||||
"futures-channel",
|
||||
"futures-executor",
|
||||
"gettext-rs",
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
[package]
|
||||
name = "gst_pipeline_studio"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
gtk = { version = "0.4.1", package = "gtk4" }
|
||||
gst = { package = "gstreamer", version = "0.18.1" }
|
||||
gst-plugin-gtk4 = { version = "0.1.1", optional=true }
|
||||
anyhow = "1"
|
||||
gettext-rs = {version = "0.7", features = ["gettext-system"]}
|
||||
gst = { package = "gstreamer", version = "0.18.1" }
|
||||
gst-plugin-gtk4 = { version = "0.1.0", optional=true }
|
||||
log = "0.4.11"
|
||||
once_cell = "1.7.2"
|
||||
xml-rs = "0.8.4"
|
||||
|
@ -19,7 +19,6 @@ serde = "1.0"
|
|||
serde_any = "0.5"
|
||||
simplelog = "0.11.2"
|
||||
futures-channel = "0.3"
|
||||
fragile = "1.0.0"
|
||||
|
||||
[dev-dependencies]
|
||||
futures-executor = "0.3"
|
||||
|
|
1
TODO.md
1
TODO.md
|
@ -93,6 +93,7 @@
|
|||
- [ ] Change TreeView to ListView
|
||||
- [ ] Implement zoom on the view (https://gitlab.gnome.org/World/obfuscate/-/blob/master/src/widgets/drawing_area.rs)
|
||||
- [ ] Settings: add a log level selection
|
||||
- [ ] reopen the last log on prematured exit (crash)
|
||||
|
||||
### CI/Infra
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ impl Player {
|
|||
|
||||
pub fn create_pipeline(&self, description: &str) -> anyhow::Result<gst::Pipeline> {
|
||||
GPS_INFO!("Creating pipeline {}", description);
|
||||
|
||||
self.n_video_sink.set(0);
|
||||
if settings::Settings::load_settings()
|
||||
.preferences
|
||||
.get("use_gtk4_sink")
|
||||
|
@ -122,7 +122,36 @@ impl Player {
|
|||
"Unable to create a pipeline from the given parse launch {"
|
||||
));
|
||||
}
|
||||
|
||||
self.check_for_gtk4sink(pipeline.as_ref().unwrap());
|
||||
// GPSApp is not Send(trait) ready , so we use a channel to exchange the given data with the main thread and use
|
||||
// GPSApp.
|
||||
let (ready_tx, ready_rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
|
||||
let player_weak = self.downgrade();
|
||||
let _ = ready_rx.attach(None, move |element: gst::Element| {
|
||||
let player = upgrade_weak!(player_weak, glib::Continue(false));
|
||||
let paintable = element.property::<gdk::Paintable>("paintable");
|
||||
let n_sink = player.n_video_sink.get();
|
||||
player
|
||||
.app
|
||||
.borrow()
|
||||
.as_ref()
|
||||
.expect("App should be available")
|
||||
.set_app_preview(&paintable, n_sink);
|
||||
player.n_video_sink.set(n_sink + 1);
|
||||
glib::Continue(true)
|
||||
});
|
||||
let bin = pipeline.unwrap().dynamic_cast::<gst::Bin>();
|
||||
if let Ok(bin) = bin.as_ref() {
|
||||
bin.connect_deep_element_added(move |_, _, element| {
|
||||
if let Some(factory) = element.factory() {
|
||||
GPS_INFO!("Received the signal deep element added {}", factory.name());
|
||||
if factory.name() == "gtk4paintablesink" {
|
||||
let _ = ready_tx.send(element.clone());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
let pipeline = bin.unwrap().dynamic_cast::<gst::Pipeline>();
|
||||
Ok(pipeline.unwrap())
|
||||
}
|
||||
|
||||
|
@ -160,8 +189,6 @@ impl Player {
|
|||
pipeline.on_pipeline_message(msg);
|
||||
glib::Continue(true)
|
||||
})?;
|
||||
pipeline.set_state(gst::State::Ready)?;
|
||||
self.check_for_gtk4sink(&pipeline);
|
||||
*self.pipeline.borrow_mut() = Some(pipeline);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue