Enable functions working on Events

This commit is contained in:
Sebastian Dröge 2017-07-30 15:09:51 +01:00
parent 2c949a9a05
commit 421e648a27
5 changed files with 189 additions and 24 deletions

View file

@ -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"

View file

@ -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<O: IsA<Element> + IsA<glib::object::Object>> 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 {

View file

@ -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<ffi::GstEventType> 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<Self> {
Some(FromValue::from_value(value))
}
}
impl<'a> FromValue<'a> for EventType {
unsafe fn from_value(value: &Value) -> Self {
from_glib(std::mem::transmute::<i32, ffi::GstEventType>(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,

View file

@ -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;

View file

@ -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<Element>, Q: Into<Option<&'a str>>>(&self, parent: &P, stream_id: Q, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option<String>;
//fn event_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q, event: /*Ignored*/&mut Event) -> bool;
fn event_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q, event: &Event) -> bool;
//fn forward<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, forward: /*Unknown conversion*//*Unimplemented*/PadForwardFunction, user_data: P) -> bool;
@ -109,7 +111,7 @@ pub trait PadExt {
fn get_peer(&self) -> Option<Pad>;
//fn get_sticky_event(&self, event_type: /*Ignored*/EventType, idx: u32) -> /*Ignored*/Option<Event>;
fn get_sticky_event(&self, event_type: EventType, idx: u32) -> Option<Event>;
#[cfg(feature = "v1_10")]
fn get_stream(&self) -> Option<Stream>;
@ -159,7 +161,7 @@ pub trait PadExt {
fn peer_query_position(&self, format: Format) -> Option<i64>;
//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<i64>;
//fn send_event(&self, event: /*Ignored*/&mut Event) -> bool;
fn send_event(&self, event: &Event) -> bool;
//fn set_activate_function_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&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<P: IsA<Pad>>(&self, sinkpad: &P) -> Result<(), glib::error::BoolError>;
@ -263,9 +265,13 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
// unsafe { TODO: call ffi::gst_pad_create_stream_id_printf_valist() }
//}
//fn event_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q, event: /*Ignored*/&mut Event) -> bool {
// unsafe { TODO: call ffi::gst_pad_event_default() }
//}
fn event_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&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<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, forward: /*Unknown conversion*//*Unimplemented*/PadForwardFunction, user_data: P) -> bool {
// unsafe { TODO: call ffi::gst_pad_forward() }
@ -329,9 +335,11 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
}
}
//fn get_sticky_event(&self, event_type: /*Ignored*/EventType, idx: u32) -> /*Ignored*/Option<Event> {
// unsafe { TODO: call ffi::gst_pad_get_sticky_event() }
//}
fn get_sticky_event(&self, event_type: EventType, idx: u32) -> Option<Event> {
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<Stream> {
@ -473,9 +481,11 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> 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<O: IsA<Pad> + IsA<glib::object::Object>> 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<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&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<O: IsA<Pad> + IsA<glib::object::Object>> 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<P: IsA<Pad>>(&self, sinkpad: &P) -> Result<(), glib::error::BoolError> {
unsafe {