Add launch example using the GTK main loop

This commit is contained in:
Sebastian Dröge 2017-07-05 19:10:58 +03:00
parent 8f8ba45588
commit 9ae4a4f862
3 changed files with 249 additions and 2 deletions

209
Cargo.lock generated
View file

@ -10,11 +10,50 @@ dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "atk-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#113444397b56ffda5214ffcc5a2ed80c25020fe5"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bitflags"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "c_vec"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cairo-rs"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/cairo#e1ca9ae0e81e970a87d9a7c0f73304da53bcabeb"
dependencies = [
"c_vec 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
"glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cairo-sys-rs"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/cairo#e1ca9ae0e81e970a87d9a7c0f73304da53bcabeb"
dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "examples"
version = "0.1.0"
@ -24,12 +63,95 @@ dependencies = [
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gstreamer 0.1.0",
"gstreamer-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)",
"gtk 0.1.3 (git+https://github.com/gtk-rs/gtk)",
]
[[package]]
name = "gdk"
version = "0.5.3"
source = "git+https://github.com/gtk-rs/gdk#6f6487a46874be4e96659f6697b480a8345d2690"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)",
"cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
"gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)",
"gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gio 0.1.3 (git+https://github.com/gtk-rs/gio)",
"glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pango 0.1.3 (git+https://github.com/gtk-rs/pango)",
]
[[package]]
name = "gdk-pixbuf"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/gdk-pixbuf#191812c0157e798dd680a34120bb1a5512bdb23f"
dependencies = [
"gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gdk-pixbuf-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#113444397b56ffda5214ffcc5a2ed80c25020fe5"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gdk-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#113444397b56ffda5214ffcc5a2ed80c25020fe5"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
"gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gio"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/gio#145ce6bb68d9078509c0f49934229b47dcb43700"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gio-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#113444397b56ffda5214ffcc5a2ed80c25020fe5"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "glib"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/glib#d3aed89e92d6162f385b699ccd546ee799612c93"
source = "git+https://github.com/gtk-rs/glib#3cc7d8ae4edcef23475f677064c2077097d34f83"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
@ -62,7 +184,7 @@ dependencies = [
[[package]]
name = "gstreamer-sys"
version = "0.1.1"
source = "git+https://github.com/sdroege/gstreamer-sys#0d5b1c60a6d74150a55de4b5f980e09dd67014f2"
source = "git+https://github.com/sdroege/gstreamer-sys#fbadb070c6f05a39dc68c9f7adaf07aa52909fd8"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
@ -71,6 +193,46 @@ dependencies = [
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gtk"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/gtk#4befceba101b9c9016ac54c2d56c95157de486b5"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)",
"cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
"gdk 0.5.3 (git+https://github.com/gtk-rs/gdk)",
"gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)",
"gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gio 0.1.3 (git+https://github.com/gtk-rs/gio)",
"gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gtk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pango 0.1.3 (git+https://github.com/gtk-rs/pango)",
]
[[package]]
name = "gtk-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#113444397b56ffda5214ffcc5a2ed80c25020fe5"
dependencies = [
"atk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)",
"gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lazy_static"
version = "0.2.8"
@ -81,17 +243,60 @@ name = "libc"
version = "0.2.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "pango"
version = "0.1.3"
source = "git+https://github.com/gtk-rs/pango#a931907e92e4e11a1cdad08aa86fddcdef6e76b0"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
]
[[package]]
name = "pango-sys"
version = "0.3.4"
source = "git+https://github.com/gtk-rs/sys#113444397b56ffda5214ffcc5a2ed80c25020fe5"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pkg-config"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum atk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
"checksum c_vec 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6237ac5a4b1e81c213c24c6437964c61e646df910a914b4ab1487b46df20bd13"
"checksum cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)" = "<none>"
"checksum cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)" = "<none>"
"checksum gdk 0.5.3 (git+https://github.com/gtk-rs/gdk)" = "<none>"
"checksum gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)" = "<none>"
"checksum gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum gio 0.1.3 (git+https://github.com/gtk-rs/gio)" = "<none>"
"checksum gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum glib 0.1.3 (git+https://github.com/gtk-rs/glib)" = "<none>"
"checksum glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum gstreamer-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)" = "<none>"
"checksum gtk 0.1.3 (git+https://github.com/gtk-rs/gtk)" = "<none>"
"checksum gtk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf"
"checksum libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)" = "38f5c2b18a287cf78b4097db62e20f43cace381dc76ae5c0a3073067f78b7ddc"
"checksum pango 0.1.3 (git+https://github.com/gtk-rs/pango)" = "<none>"
"checksum pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"

View file

@ -5,6 +5,7 @@ authors = ["Sebastian Dröge <sebastian@centricular.com>"]
[dependencies]
glib = { version = "0.1.3", git = "https://github.com/gtk-rs/glib" }
gtk = { version = "0.1.3", git = "https://github.com/gtk-rs/gtk" }
gstreamer = { path = "../gstreamer" }
glib-sys = { version = "0.3.4", git = "https://github.com/gtk-rs/sys" }
gobject-sys = { version = "0.3.4", git = "https://github.com/gtk-rs/sys" }
@ -13,5 +14,8 @@ gstreamer-sys = { version = "0.1.1", git = "https://github.com/sdroege/gstreamer
[[bin]]
name = "launch"
[[bin]]
name = "launch_glib_main"
[[bin]]
name = "decodebin"

View file

@ -0,0 +1,38 @@
extern crate gstreamer as gst;
use gst::*;
extern crate gtk;
use std::u64;
fn main() {
gst::init().unwrap();
// FIXME: Use glib crate once it has mainloop/etc bindings
// https://github.com/gtk-rs/glib/issues/168
gtk::init().unwrap();
let pipeline = gst::parse_launch("audiotestsrc ! autoaudiosink").unwrap();
let bus = pipeline.get_bus().unwrap();
let ret = pipeline.set_state(gst::State::Playing);
assert_ne!(ret, gst::StateChangeReturn::Failure);
bus.add_signal_watch();
bus.connect_message(|_, msg| {
match msg.view() {
MessageView::Eos => gtk::main_quit(),
MessageView::Error(err) => {
println!("Error from {}: {} ({:?})", msg.get_src().get_path_string(),
err.get_error(), err.get_debug());
gtk::main_quit();
},
_ => (),
}
});
gtk::main();
let ret = pipeline.set_state(gst::State::Null);
assert_ne!(ret, gst::StateChangeReturn::Failure);
}