diff --git a/Cargo.lock b/Cargo.lock index a62fcd1ea..e054e1f1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,17 +12,142 @@ dependencies = [ "num-rational 0.1.39 (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#af83826e0a31f68bcddee17d3791fb01453dc632" +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.28 (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#94c84e601857c1c1c39986c41907bf8f21a72a10" +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)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "libc 0.2.28 (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#94c84e601857c1c1c39986c41907bf8f21a72a10" +dependencies = [ + "libc 0.2.28 (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" dependencies = [ "glib 0.1.3 (git+https://github.com/gtk-rs/glib)", "gstreamer 0.1.0", + "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#049e8b74a2e1d47d3ce249b7793b4eef89334e05" +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.28 (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#cc1c9ab464bcf58624c3969cbe080292f98a43cf" +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)", + "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.28 (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#af83826e0a31f68bcddee17d3791fb01453dc632" +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.28 (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#af83826e0a31f68bcddee17d3791fb01453dc632" +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.28 (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#9a459203f6841936d0b43a00afa1b37c81d4cbf7" +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.28 (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#af83826e0a31f68bcddee17d3791fb01453dc632" +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.28 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -70,6 +195,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#65232501712337809bd6f3fb34bbea0ba30906ac" +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.28 (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#af83826e0a31f68bcddee17d3791fb01453dc632" +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.28 (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" @@ -102,20 +267,65 @@ name = "num-traits" version = "0.1.40" 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#25bdce1d786b492162b96a70d7f4594de322783c" +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)", + "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.28 (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#af83826e0a31f68bcddee17d3791fb01453dc632" +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.28 (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)" = "" "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)" = "" +"checksum cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)" = "" +"checksum gdk 0.5.3 (git+https://github.com/gtk-rs/gdk)" = "" +"checksum gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)" = "" +"checksum gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" +"checksum gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" +"checksum gio 0.1.3 (git+https://github.com/gtk-rs/gio)" = "" +"checksum gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" "checksum glib 0.1.3 (git+https://github.com/gtk-rs/glib)" = "" "checksum glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" "checksum gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" "checksum gstreamer-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)" = "" +"checksum gtk 0.1.3 (git+https://github.com/gtk-rs/gtk)" = "" +"checksum gtk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" "checksum libc 0.2.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb7b49972ee23d8aa1026c365a5b440ba08e35075f18c459980c7395c221ec48" "checksum num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "d1452e8b06e448a07f0e6ebb0bb1d92b8890eea63288c0b627331d53514d0fba" "checksum num-rational 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "288629c76fac4b33556f4b7ab57ba21ae202da65ba8b77466e6d598e31990790" "checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0" +"checksum pango 0.1.3 (git+https://github.com/gtk-rs/pango)" = "" +"checksum pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" "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" diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 9847cc49e..95e901cbf 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -6,4 +6,5 @@ authors = ["Sebastian Dröge "] [dependencies] glib = { version = "0.1.3", git = "https://github.com/gtk-rs/glib" } gstreamer = { path = "../gstreamer" } +gtk = { version = "0.1.3", git = "https://github.com/gtk-rs/gtk" } diff --git a/examples/src/bin/gtksink.rs b/examples/src/bin/gtksink.rs new file mode 100644 index 000000000..0709d0567 --- /dev/null +++ b/examples/src/bin/gtksink.rs @@ -0,0 +1,95 @@ +extern crate gstreamer as gst; +use gst::*; + +extern crate glib; +use glib::*; +use glib::ObjectExt; + +extern crate gtk; +use gtk::prelude::*; +use gtk::{Window, WindowType}; + +fn main() { + gst::init().unwrap(); + gtk::init().unwrap(); + + let pipeline = Pipeline::new(None); + let src = ElementFactory::make("videotestsrc", None).unwrap(); + let (sink, widget) = if let Some(gtkglsink) = ElementFactory::make("gtkglsink", None) { + let glsinkbin = ElementFactory::make("glsinkbin", None).unwrap(); + glsinkbin.set_property("sink", >kglsink.to_value()).unwrap(); + + let widget = gtkglsink.get_property("widget").unwrap(); + (glsinkbin, widget.get::().unwrap()) + } else { + let sink = ElementFactory::make("gtksink", None).unwrap(); + let widget = sink.get_property("widget").unwrap(); + (sink, widget.get::().unwrap()) + }; + + pipeline.add_many(&[&src, &sink]).unwrap(); + src.link(&sink).unwrap(); + + let window = Window::new(WindowType::Toplevel); + window.set_default_size(320, 240); + let vbox = gtk::Box::new(gtk::Orientation::Vertical, 0); + vbox.pack_start(&widget, true, true, 0); + let label = gtk::Label::new("Position: 00:00:00"); + vbox.pack_start(&label, true, true, 5); + window.add(&vbox); + window.show_all(); + + let pipeline_clone = pipeline.clone(); + gtk::timeout_add(500, move || { + let pipeline = &pipeline_clone; + let position = pipeline.query_position(Format::Time); + + if let Some(position) = position { + let mut seconds = position / 1_000_000_000; + let mut minutes = seconds / 60; + let hours = minutes / 60; + + seconds -= hours * 60 * 60 + minutes * 60; + minutes -= hours * 60; + + label.set_text(&format!("Position: {:02}:{:02}:{:02}", hours, minutes, seconds)); + } else { + label.set_text("Position: 00:00:00"); + } + + glib::Continue(true) + }); + + window.connect_delete_event(|_, _| { + gtk::main_quit(); + Inhibit(false) + }); + + let bus = pipeline.get_bus().unwrap(); + + let ret = pipeline.set_state(gst::State::Playing); + assert_ne!(ret, gst::StateChangeReturn::Failure); + + bus.add_watch(move |_, 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(); + } + _ => (), + }; + + glib::Continue(true) + }); + + gtk::main(); + + let ret = pipeline.set_state(gst::State::Null); + assert_ne!(ret, gst::StateChangeReturn::Failure); +}