Commit 2c949a9a authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Add Event bindings

And make Message bindings more consistent
parent 945d136a
......@@ -58,6 +58,7 @@ generate = [
"Gst.ChildProxy",
"Gst.Preset",
"Gst.TagSetter",
"Gst.QOSType",
]
manual = [
......
......@@ -88,7 +88,7 @@ fn main() {
};
match msg.view() {
MessageView::Eos => break,
MessageView::Eos(..) => break,
MessageView::Error(err) => {
println!(
"Error from {}: {} ({:?})",
......
......@@ -22,7 +22,7 @@ fn main() {
};
match msg.view() {
MessageView::Eos => break,
MessageView::Eos(..) => break,
MessageView::Error(err) => {
println!(
"Error from {}: {} ({:?})",
......
......@@ -26,7 +26,7 @@ fn main() {
bus.add_watch(move |_, msg| {
let main_loop = &main_loop_clone;
match msg.view() {
MessageView::Eos => main_loop.quit(),
MessageView::Eos(..) => main_loop.quit(),
MessageView::Error(err) => {
println!(
"Error from {}: {} ({:?})",
......
......@@ -41,7 +41,7 @@ fn main() {
};
match msg.view() {
MessageView::Eos => break,
MessageView::Eos(..) => break,
MessageView::Error(err) => {
println!(
"Error from {}: {} ({:?})",
......
......@@ -59,7 +59,7 @@ fn main() {
bus.add_watch(move |_, msg| {
let main_loop = &main_loop_clone;
match msg.view() {
MessageView::Eos => main_loop.quit(),
MessageView::Eos(..) => main_loop.quit(),
MessageView::Error(err) => {
println!(
"Error from {}: {} ({:?})",
......
......@@ -1205,6 +1205,66 @@ impl SetValue for ProgressType {
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum QOSType {
Overflow,
Underflow,
Throttle,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for QOSType {
type GlibType = ffi::GstQOSType;
fn to_glib(&self) -> ffi::GstQOSType {
match *self {
QOSType::Overflow => ffi::GST_QOS_TYPE_OVERFLOW,
QOSType::Underflow => ffi::GST_QOS_TYPE_UNDERFLOW,
QOSType::Throttle => ffi::GST_QOS_TYPE_THROTTLE,
QOSType::__Unknown(value) => unsafe{std::mem::transmute(value)}
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstQOSType> for QOSType {
fn from_glib(value: ffi::GstQOSType) -> Self {
skip_assert_initialized!();
match value as i32 {
0 => QOSType::Overflow,
1 => QOSType::Underflow,
2 => QOSType::Throttle,
value => QOSType::__Unknown(value),
}
}
}
impl StaticType for QOSType {
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_qos_type_get_type()) }
}
}
impl<'a> FromValueOptional<'a> for QOSType {
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
Some(FromValue::from_value(value))
}
}
impl<'a> FromValue<'a> for QOSType {
unsafe fn from_value(value: &Value) -> Self {
from_glib(std::mem::transmute::<i32, ffi::GstQOSType>(gobject_ffi::g_value_get_enum(value.to_glib_none().0)))
}
}
impl SetValue for QOSType {
unsafe fn set_value(value: &mut Value, this: &Self) {
gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib() as i32)
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum ResourceError {
Failed,
......
......@@ -115,6 +115,7 @@ pub use self::enums::PadProbeReturn;
pub use self::enums::ParseError;
pub use self::enums::PluginError;
pub use self::enums::ProgressType;
pub use self::enums::QOSType;
pub use self::enums::ResourceError;
pub use self::enums::SeekType;
pub use self::enums::State;
......
This diff is collapsed.
......@@ -64,6 +64,8 @@ pub mod bufferlist;
pub use bufferlist::{BufferList, BufferListRef};
pub mod query;
pub use query::{Query, QueryRef, QueryView};
pub mod event;
pub use event::{Event, EventRef, EventView};
mod element;
mod bin;
......
This diff is collapsed.
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