Commit 9cfb83d6 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Add Source support to GstBus, and the sync message handler

parent 71c08855
This diff is collapsed.
......@@ -47,10 +47,12 @@ generate = [
"Gst.StreamFlags",
"Gst.PadLinkReturn",
"Gst.ProgressType",
"Gst.BusSyncReply",
]
manual = [
"GLib.Error",
"GLib.Source",
"Gst.Message",
"Gst.Structure",
]
......@@ -100,6 +102,11 @@ trait = false
# Uses enum as flags
ignore = true
[[object.function]]
name = "create_watch"
# More convenient manual implementation
ignore = true
[[object]]
name = "Gst.Caps"
status = "manual"
......
......@@ -5,11 +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" }
gstreamer-sys = { version = "0.1.1", git = "https://github.com/sdroege/gstreamer-sys", features = ["v1_8"] }
[[bin]]
name = "launch"
......
extern crate gstreamer as gst;
use gst::*;
use gst::ObjectExt as GstObjectExt;
extern crate gtk;
extern crate glib;
use glib::*;
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 main_loop = MainLoop::new(None, false);
let pipeline = gst::parse_launch("audiotestsrc ! autoaudiosink").unwrap();
let bus = pipeline.get_bus().unwrap();
......@@ -18,22 +18,30 @@ fn main() {
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();
}
_ => (),
let main_loop_clone = main_loop.clone();
//bus.add_signal_watch();
//bus.connect_message(move |_, msg| {
bus.add_watch(move |_, msg| {
let main_loop = &main_loop_clone;
match msg.view() {
MessageView::Eos => main_loop.quit(),
MessageView::Error(err) => {
println!(
"Error from {}: {} ({:?})",
msg.get_src().get_path_string(),
err.get_error(),
err.get_debug()
);
main_loop.quit();
}
_ => (),
};
glib::Continue(true)
});
gtk::main();
main_loop.run();
let ret = pipeline.set_state(gst::State::Null);
assert_ne!(ret, gst::StateChangeReturn::Failure);
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
#[allow(unused_imports)]
use auto::*;
pub type ClockTime = u64;
pub type ElementFactoryListType = u64;
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Element;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use ClockTime;
......@@ -51,10 +51,6 @@ impl Bus {
// unsafe { TODO: call ffi::gst_bus_async_signal_func() }
//}
//pub fn create_watch(&self) -> /*Ignored*/Option<glib::Source> {
// unsafe { TODO: call ffi::gst_bus_create_watch() }
//}
pub fn disable_sync_message_emission(&self) {
unsafe {
ffi::gst_bus_disable_sync_message_emission(self.to_glib_none().0);
......@@ -107,7 +103,7 @@ impl Bus {
// unsafe { TODO: call ffi::gst_bus_set_sync_handler() }
//}
//pub fn sync_signal_handler<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, message: &mut Message, data: P) -> /*Ignored*/BusSyncReply {
//pub fn sync_signal_handler<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, message: &mut Message, data: P) -> BusSyncReply {
// unsafe { TODO: call ffi::gst_bus_sync_signal_handler() }
//}
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use ClockTime;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Caps;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Bus;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Bus;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use DeviceProvider;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Bus;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Caps;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use ffi;
......@@ -46,6 +46,42 @@ impl FromGlib<ffi::GstBufferingMode> for BufferingMode {
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum BusSyncReply {
Drop,
Pass,
Async,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for BusSyncReply {
type GlibType = ffi::GstBusSyncReply;
fn to_glib(&self) -> ffi::GstBusSyncReply {
match *self {
BusSyncReply::Drop => ffi::GST_BUS_DROP,
BusSyncReply::Pass => ffi::GST_BUS_PASS,
BusSyncReply::Async => ffi::GST_BUS_ASYNC,
BusSyncReply::__Unknown(value) => unsafe{std::mem::transmute(value)}
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstBusSyncReply> for BusSyncReply {
fn from_glib(value: ffi::GstBusSyncReply) -> Self {
skip_assert_initialized!();
match value as i32 {
0 => BusSyncReply::Drop,
1 => BusSyncReply::Pass,
2 => BusSyncReply::Async,
value => BusSyncReply::__Unknown(value),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum CoreError {
Failed,
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use ffi;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Bin;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
mod bin;
......@@ -74,6 +74,7 @@ pub use self::u_r_i_handler::URIHandlerExt;
mod enums;
pub use self::enums::BufferingMode;
pub use self::enums::BusSyncReply;
pub use self::enums::CoreError;
pub use self::enums::FlowReturn;
pub use self::enums::Format;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use ClockTime;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Caps;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Caps;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Bin;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Error;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
#[cfg(feature = "v1_10")]
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Object;
......
// This file was generated by gir (33e9567+) from gir-files (???)
// This file was generated by gir (7504fb6) from gir-files (???)
// DO NOT EDIT
use Error;
......
......@@ -230,7 +230,7 @@ mod tests {
fn test_simple() {
gst::init();
let caps = CapsRef::new_simple(
let caps = Caps::new_simple(
"foo/bar",
&[
("int", 12.into()),
......
......@@ -55,6 +55,7 @@ pub use caps::Caps;
mod element;
mod bin;
mod bus;
pub use bin::BinExtManual;
use std::ptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment