diff --git a/Gir_Gst.toml b/Gir_Gst.toml index ed7dd29f7..4a01601ef 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -59,6 +59,7 @@ generate = [ "Gst.Preset", "Gst.TagSetter", "Gst.QOSType", + "Gst.EventType", ] manual = [ @@ -134,6 +135,11 @@ name = "Gst.Message" status = "manual" ref_mode = "ref" +[[object]] +name = "Gst.Event" +status = "manual" +ref_mode = "ref" + [[object]] name = "Gst.TagList" status = "manual" diff --git a/gstreamer/src/auto/element.rs b/gstreamer/src/auto/element.rs index bafca1610..ccf25aaff 100644 --- a/gstreamer/src/auto/element.rs +++ b/gstreamer/src/auto/element.rs @@ -7,6 +7,7 @@ use Clock; use ClockTime; use ElementFactory; use Error; +use Event; use Format; use Iterator; use Message; @@ -180,7 +181,7 @@ pub trait ElementExt { fn seek_simple(&self, format: Format, seek_flags: SeekFlags, seek_pos: i64) -> Result<(), glib::error::BoolError>; - //fn send_event(&self, event: /*Ignored*/&mut Event) -> bool; + fn send_event(&self, event: &Event) -> bool; fn set_base_time(&self, time: ClockTime); @@ -508,9 +509,11 @@ impl + IsA> ElementExt for O { } } - //fn send_event(&self, event: /*Ignored*/&mut Event) -> bool { - // unsafe { TODO: call ffi::gst_element_send_event() } - //} + fn send_event(&self, event: &Event) -> bool { + unsafe { + from_glib(ffi::gst_element_send_event(self.to_glib_none().0, event.to_glib_full())) + } + } fn set_base_time(&self, time: ClockTime) { unsafe { diff --git a/gstreamer/src/auto/enums.rs b/gstreamer/src/auto/enums.rs index 0ecb32152..136acda74 100644 --- a/gstreamer/src/auto/enums.rs +++ b/gstreamer/src/auto/enums.rs @@ -320,6 +320,147 @@ impl SetValue for CoreError { } } +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum EventType { + Unknown, + FlushStart, + FlushStop, + StreamStart, + Caps, + Segment, + StreamCollection, + Tag, + Buffersize, + SinkMessage, + StreamGroupDone, + Eos, + Toc, + Protection, + SegmentDone, + Gap, + Qos, + Seek, + Navigation, + Latency, + Step, + Reconfigure, + TocSelect, + SelectStreams, + CustomUpstream, + CustomDownstream, + CustomDownstreamOob, + CustomDownstreamSticky, + CustomBoth, + CustomBothOob, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for EventType { + type GlibType = ffi::GstEventType; + + fn to_glib(&self) -> ffi::GstEventType { + match *self { + EventType::Unknown => ffi::GST_EVENT_UNKNOWN, + EventType::FlushStart => ffi::GST_EVENT_FLUSH_START, + EventType::FlushStop => ffi::GST_EVENT_FLUSH_STOP, + EventType::StreamStart => ffi::GST_EVENT_STREAM_START, + EventType::Caps => ffi::GST_EVENT_CAPS, + EventType::Segment => ffi::GST_EVENT_SEGMENT, + EventType::StreamCollection => ffi::GST_EVENT_STREAM_COLLECTION, + EventType::Tag => ffi::GST_EVENT_TAG, + EventType::Buffersize => ffi::GST_EVENT_BUFFERSIZE, + EventType::SinkMessage => ffi::GST_EVENT_SINK_MESSAGE, + EventType::StreamGroupDone => ffi::GST_EVENT_STREAM_GROUP_DONE, + EventType::Eos => ffi::GST_EVENT_EOS, + EventType::Toc => ffi::GST_EVENT_TOC, + EventType::Protection => ffi::GST_EVENT_PROTECTION, + EventType::SegmentDone => ffi::GST_EVENT_SEGMENT_DONE, + EventType::Gap => ffi::GST_EVENT_GAP, + EventType::Qos => ffi::GST_EVENT_QOS, + EventType::Seek => ffi::GST_EVENT_SEEK, + EventType::Navigation => ffi::GST_EVENT_NAVIGATION, + EventType::Latency => ffi::GST_EVENT_LATENCY, + EventType::Step => ffi::GST_EVENT_STEP, + EventType::Reconfigure => ffi::GST_EVENT_RECONFIGURE, + EventType::TocSelect => ffi::GST_EVENT_TOC_SELECT, + EventType::SelectStreams => ffi::GST_EVENT_SELECT_STREAMS, + EventType::CustomUpstream => ffi::GST_EVENT_CUSTOM_UPSTREAM, + EventType::CustomDownstream => ffi::GST_EVENT_CUSTOM_DOWNSTREAM, + EventType::CustomDownstreamOob => ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB, + EventType::CustomDownstreamSticky => ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, + EventType::CustomBoth => ffi::GST_EVENT_CUSTOM_BOTH, + EventType::CustomBothOob => ffi::GST_EVENT_CUSTOM_BOTH_OOB, + EventType::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for EventType { + fn from_glib(value: ffi::GstEventType) -> Self { + skip_assert_initialized!(); + match value as i32 { + 0 => EventType::Unknown, + 2563 => EventType::FlushStart, + 5127 => EventType::FlushStop, + 10254 => EventType::StreamStart, + 12814 => EventType::Caps, + 17934 => EventType::Segment, + 19230 => EventType::StreamCollection, + 20510 => EventType::Tag, + 23054 => EventType::Buffersize, + 25630 => EventType::SinkMessage, + 26894 => EventType::StreamGroupDone, + 28174 => EventType::Eos, + 30750 => EventType::Toc, + 33310 => EventType::Protection, + 38406 => EventType::SegmentDone, + 40966 => EventType::Gap, + 48641 => EventType::Qos, + 51201 => EventType::Seek, + 53761 => EventType::Navigation, + 56321 => EventType::Latency, + 58881 => EventType::Step, + 61441 => EventType::Reconfigure, + 64001 => EventType::TocSelect, + 66561 => EventType::SelectStreams, + 69121 => EventType::CustomUpstream, + 71686 => EventType::CustomDownstream, + 74242 => EventType::CustomDownstreamOob, + 76830 => EventType::CustomDownstreamSticky, + 79367 => EventType::CustomBoth, + 81923 => EventType::CustomBothOob, + value => EventType::__Unknown(value), + } + } +} + +impl StaticType for EventType { + fn static_type() -> Type { + unsafe { from_glib(ffi::gst_event_type_get_type()) } + } +} + +impl<'a> FromValueOptional<'a> for EventType { + unsafe fn from_value_optional(value: &Value) -> Option { + Some(FromValue::from_value(value)) + } +} + +impl<'a> FromValue<'a> for EventType { + unsafe fn from_value(value: &Value) -> Self { + from_glib(std::mem::transmute::(gobject_ffi::g_value_get_enum(value.to_glib_none().0))) + } +} + +impl SetValue for EventType { + 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 FlowReturn { CustomSuccess2, diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index 990a21d80..f43898dea 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -103,6 +103,7 @@ pub use self::enums::BufferingMode; pub use self::enums::BusSyncReply; pub use self::enums::CapsIntersectMode; pub use self::enums::CoreError; +pub use self::enums::EventType; pub use self::enums::FlowReturn; pub use self::enums::Format; pub use self::enums::IteratorResult; diff --git a/gstreamer/src/auto/pad.rs b/gstreamer/src/auto/pad.rs index de5a8799c..46d1f78dd 100644 --- a/gstreamer/src/auto/pad.rs +++ b/gstreamer/src/auto/pad.rs @@ -3,6 +3,8 @@ use Caps; use Element; +use Event; +use EventType; use FlowReturn; use Format; use Iterator; @@ -85,7 +87,7 @@ pub trait PadExt { //fn create_stream_id_printf_valist<'a, P: IsA, Q: Into>>(&self, parent: &P, stream_id: Q, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option; - //fn event_default<'a, P: IsA + 'a, Q: Into>>(&self, parent: Q, event: /*Ignored*/&mut Event) -> bool; + fn event_default<'a, P: IsA + 'a, Q: Into>>(&self, parent: Q, event: &Event) -> bool; //fn forward>>(&self, forward: /*Unknown conversion*//*Unimplemented*/PadForwardFunction, user_data: P) -> bool; @@ -109,7 +111,7 @@ pub trait PadExt { fn get_peer(&self) -> Option; - //fn get_sticky_event(&self, event_type: /*Ignored*/EventType, idx: u32) -> /*Ignored*/Option; + fn get_sticky_event(&self, event_type: EventType, idx: u32) -> Option; #[cfg(feature = "v1_10")] fn get_stream(&self) -> Option; @@ -159,7 +161,7 @@ pub trait PadExt { fn peer_query_position(&self, format: Format) -> Option; - //fn push_event(&self, event: /*Ignored*/&mut Event) -> bool; + fn push_event(&self, event: &Event) -> bool; //fn push_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn; @@ -173,7 +175,7 @@ pub trait PadExt { fn query_position(&self, format: Format) -> Option; - //fn send_event(&self, event: /*Ignored*/&mut Event) -> bool; + fn send_event(&self, event: &Event) -> bool; //fn set_activate_function_full>>(&self, activate: /*Unknown conversion*//*Unimplemented*/PadActivateFunction, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify); @@ -209,7 +211,7 @@ pub trait PadExt { fn stop_task(&self) -> Result<(), glib::error::BoolError>; - //fn store_sticky_event(&self, event: /*Ignored*/&mut Event) -> FlowReturn; + fn store_sticky_event(&self, event: &Event) -> FlowReturn; fn unlink>(&self, sinkpad: &P) -> Result<(), glib::error::BoolError>; @@ -263,9 +265,13 @@ impl + IsA> PadExt for O { // unsafe { TODO: call ffi::gst_pad_create_stream_id_printf_valist() } //} - //fn event_default<'a, P: IsA + 'a, Q: Into>>(&self, parent: Q, event: /*Ignored*/&mut Event) -> bool { - // unsafe { TODO: call ffi::gst_pad_event_default() } - //} + fn event_default<'a, P: IsA + 'a, Q: Into>>(&self, parent: Q, event: &Event) -> bool { + let parent = parent.into(); + let parent = parent.to_glib_none(); + unsafe { + from_glib(ffi::gst_pad_event_default(self.to_glib_none().0, parent.0, event.to_glib_full())) + } + } //fn forward>>(&self, forward: /*Unknown conversion*//*Unimplemented*/PadForwardFunction, user_data: P) -> bool { // unsafe { TODO: call ffi::gst_pad_forward() } @@ -329,9 +335,11 @@ impl + IsA> PadExt for O { } } - //fn get_sticky_event(&self, event_type: /*Ignored*/EventType, idx: u32) -> /*Ignored*/Option { - // unsafe { TODO: call ffi::gst_pad_get_sticky_event() } - //} + fn get_sticky_event(&self, event_type: EventType, idx: u32) -> Option { + unsafe { + from_glib_full(ffi::gst_pad_get_sticky_event(self.to_glib_none().0, event_type.to_glib(), idx)) + } + } #[cfg(feature = "v1_10")] fn get_stream(&self) -> Option { @@ -473,9 +481,11 @@ impl + IsA> PadExt for O { } } - //fn push_event(&self, event: /*Ignored*/&mut Event) -> bool { - // unsafe { TODO: call ffi::gst_pad_push_event() } - //} + fn push_event(&self, event: &Event) -> bool { + unsafe { + from_glib(ffi::gst_pad_push_event(self.to_glib_none().0, event.to_glib_full())) + } + } //fn push_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn { // unsafe { TODO: call ffi::gst_pad_push_list() } @@ -519,9 +529,11 @@ impl + IsA> PadExt for O { } } - //fn send_event(&self, event: /*Ignored*/&mut Event) -> bool { - // unsafe { TODO: call ffi::gst_pad_send_event() } - //} + fn send_event(&self, event: &Event) -> bool { + unsafe { + from_glib(ffi::gst_pad_send_event(self.to_glib_none().0, event.to_glib_full())) + } + } //fn set_activate_function_full>>(&self, activate: /*Unknown conversion*//*Unimplemented*/PadActivateFunction, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) { // unsafe { TODO: call ffi::gst_pad_set_activate_function_full() } @@ -597,9 +609,11 @@ impl + IsA> PadExt for O { } } - //fn store_sticky_event(&self, event: /*Ignored*/&mut Event) -> FlowReturn { - // unsafe { TODO: call ffi::gst_pad_store_sticky_event() } - //} + fn store_sticky_event(&self, event: &Event) -> FlowReturn { + unsafe { + from_glib(ffi::gst_pad_store_sticky_event(self.to_glib_none().0, event.to_glib_none().0)) + } + } fn unlink>(&self, sinkpad: &P) -> Result<(), glib::error::BoolError> { unsafe {