Add Event bindings

And make Message bindings more consistent
This commit is contained in:
Sebastian Dröge 2017-07-30 15:06:44 +01:00
parent 945d136acb
commit 2c949a9a05
11 changed files with 1458 additions and 138 deletions

View file

@ -58,6 +58,7 @@ generate = [
"Gst.ChildProxy", "Gst.ChildProxy",
"Gst.Preset", "Gst.Preset",
"Gst.TagSetter", "Gst.TagSetter",
"Gst.QOSType",
] ]
manual = [ manual = [

View file

@ -88,7 +88,7 @@ fn main() {
}; };
match msg.view() { match msg.view() {
MessageView::Eos => break, MessageView::Eos(..) => break,
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {}: {} ({:?})", "Error from {}: {} ({:?})",

View file

@ -22,7 +22,7 @@ fn main() {
}; };
match msg.view() { match msg.view() {
MessageView::Eos => break, MessageView::Eos(..) => break,
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {}: {} ({:?})", "Error from {}: {} ({:?})",

View file

@ -26,7 +26,7 @@ fn main() {
bus.add_watch(move |_, msg| { bus.add_watch(move |_, msg| {
let main_loop = &main_loop_clone; let main_loop = &main_loop_clone;
match msg.view() { match msg.view() {
MessageView::Eos => main_loop.quit(), MessageView::Eos(..) => main_loop.quit(),
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {}: {} ({:?})", "Error from {}: {} ({:?})",

View file

@ -41,7 +41,7 @@ fn main() {
}; };
match msg.view() { match msg.view() {
MessageView::Eos => break, MessageView::Eos(..) => break,
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {}: {} ({:?})", "Error from {}: {} ({:?})",

View file

@ -59,7 +59,7 @@ fn main() {
bus.add_watch(move |_, msg| { bus.add_watch(move |_, msg| {
let main_loop = &main_loop_clone; let main_loop = &main_loop_clone;
match msg.view() { match msg.view() {
MessageView::Eos => main_loop.quit(), MessageView::Eos(..) => main_loop.quit(),
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {}: {} ({:?})", "Error from {}: {} ({:?})",

View file

@ -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)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum ResourceError { pub enum ResourceError {
Failed, Failed,

View file

@ -115,6 +115,7 @@ pub use self::enums::PadProbeReturn;
pub use self::enums::ParseError; pub use self::enums::ParseError;
pub use self::enums::PluginError; pub use self::enums::PluginError;
pub use self::enums::ProgressType; pub use self::enums::ProgressType;
pub use self::enums::QOSType;
pub use self::enums::ResourceError; pub use self::enums::ResourceError;
pub use self::enums::SeekType; pub use self::enums::SeekType;
pub use self::enums::State; pub use self::enums::State;

1237
gstreamer/src/event.rs Normal file

File diff suppressed because it is too large Load diff

View file

@ -64,6 +64,8 @@ pub mod bufferlist;
pub use bufferlist::{BufferList, BufferListRef}; pub use bufferlist::{BufferList, BufferListRef};
pub mod query; pub mod query;
pub use query::{Query, QueryRef, QueryView}; pub use query::{Query, QueryRef, QueryView};
pub mod event;
pub use event::{Event, EventRef, EventView};
mod element; mod element;
mod bin; mod bin;

View file

@ -8,7 +8,6 @@
use ffi; use ffi;
use Object; use Object;
use Element;
use miniobject::*; use miniobject::*;
use structure::*; use structure::*;
use TagList; use TagList;
@ -18,6 +17,8 @@ use std::mem;
use std::ffi::CStr; use std::ffi::CStr;
use glib; use glib;
use glib::Cast;
use glib::IsA;
use glib::translate::{from_glib, from_glib_none, from_glib_full, mut_override, ToGlibPtr, ToGlib}; use glib::translate::{from_glib, from_glib_none, from_glib_full, mut_override, ToGlibPtr, ToGlib};
#[repr(C)] #[repr(C)]
@ -49,7 +50,7 @@ impl MessageRef {
let type_ = unsafe { (*self.as_ptr()).type_ }; let type_ = unsafe { (*self.as_ptr()).type_ };
if type_ == ffi::GST_MESSAGE_EOS { if type_ == ffi::GST_MESSAGE_EOS {
MessageView::Eos MessageView::Eos(Eos(self))
} else if type_ == ffi::GST_MESSAGE_ERROR { } else if type_ == ffi::GST_MESSAGE_ERROR {
MessageView::Error(Error(self)) MessageView::Error(Error(self))
} else if type_ == ffi::GST_MESSAGE_WARNING { } else if type_ == ffi::GST_MESSAGE_WARNING {
@ -63,7 +64,7 @@ impl MessageRef {
} else if type_ == ffi::GST_MESSAGE_STATE_CHANGED { } else if type_ == ffi::GST_MESSAGE_STATE_CHANGED {
MessageView::StateChanged(StateChanged(self)) MessageView::StateChanged(StateChanged(self))
} else if type_ == ffi::GST_MESSAGE_STATE_DIRTY { } else if type_ == ffi::GST_MESSAGE_STATE_DIRTY {
MessageView::StateDirty MessageView::StateDirty(StateDirty(self))
} else if type_ == ffi::GST_MESSAGE_STEP_DONE { } else if type_ == ffi::GST_MESSAGE_STEP_DONE {
MessageView::StepDone(StepDone(self)) MessageView::StepDone(StepDone(self))
} else if type_ == ffi::GST_MESSAGE_CLOCK_PROVIDE { } else if type_ == ffi::GST_MESSAGE_CLOCK_PROVIDE {
@ -77,19 +78,19 @@ impl MessageRef {
} else if type_ == ffi::GST_MESSAGE_STREAM_STATUS { } else if type_ == ffi::GST_MESSAGE_STREAM_STATUS {
MessageView::StreamStatus(StreamStatus(self)) MessageView::StreamStatus(StreamStatus(self))
} else if type_ == ffi::GST_MESSAGE_APPLICATION { } else if type_ == ffi::GST_MESSAGE_APPLICATION {
MessageView::Application MessageView::Application(Application(self))
} else if type_ == ffi::GST_MESSAGE_ELEMENT { } else if type_ == ffi::GST_MESSAGE_ELEMENT {
MessageView::Element MessageView::Element(Element(self))
} else if type_ == ffi::GST_MESSAGE_SEGMENT_START { } else if type_ == ffi::GST_MESSAGE_SEGMENT_START {
MessageView::SegmentStart(SegmentStart(self)) MessageView::SegmentStart(SegmentStart(self))
} else if type_ == ffi::GST_MESSAGE_SEGMENT_DONE { } else if type_ == ffi::GST_MESSAGE_SEGMENT_DONE {
MessageView::SegmentDone(SegmentDone(self)) MessageView::SegmentDone(SegmentDone(self))
} else if type_ == ffi::GST_MESSAGE_DURATION_CHANGED { } else if type_ == ffi::GST_MESSAGE_DURATION_CHANGED {
MessageView::DurationChanged MessageView::DurationChanged(DurationChanged(self))
} else if type_ == ffi::GST_MESSAGE_LATENCY { } else if type_ == ffi::GST_MESSAGE_LATENCY {
MessageView::Latency MessageView::Latency(Latency(self))
} else if type_ == ffi::GST_MESSAGE_ASYNC_START { } else if type_ == ffi::GST_MESSAGE_ASYNC_START {
MessageView::AsyncStart MessageView::AsyncStart(AsyncStart(self))
} else if type_ == ffi::GST_MESSAGE_ASYNC_DONE { } else if type_ == ffi::GST_MESSAGE_ASYNC_DONE {
MessageView::AsyncDone(AsyncDone(self)) MessageView::AsyncDone(AsyncDone(self))
} else if type_ == ffi::GST_MESSAGE_REQUEST_STATE { } else if type_ == ffi::GST_MESSAGE_REQUEST_STATE {
@ -125,39 +126,39 @@ impl MessageRef {
} }
} }
pub fn new_eos<'a>() -> EosBuilder<'a> { pub fn new_eos() -> EosBuilder {
EosBuilder::new() EosBuilder::new()
} }
pub fn new_error<'a>(error: &'a glib::Error) -> ErrorBuilder<'a> { pub fn new_error(error: &glib::Error) -> ErrorBuilder {
ErrorBuilder::new(error) ErrorBuilder::new(error)
} }
pub fn new_warning<'a>(error: &'a glib::Error) -> WarningBuilder<'a> { pub fn new_warning(error: &glib::Error) -> WarningBuilder {
WarningBuilder::new(error) WarningBuilder::new(error)
} }
pub fn new_info<'a>(error: &'a glib::Error) -> InfoBuilder<'a> { pub fn new_info(error: &glib::Error) -> InfoBuilder {
InfoBuilder::new(error) InfoBuilder::new(error)
} }
pub fn new_tag<'a>(tags: &'a TagList) -> TagBuilder<'a> { pub fn new_tag(tags: &TagList) -> TagBuilder {
TagBuilder::new(tags) TagBuilder::new(tags)
} }
pub fn new_buffering<'a>(percent: i32) -> BufferingBuilder<'a> { pub fn new_buffering(percent: i32) -> BufferingBuilder {
BufferingBuilder::new(percent) BufferingBuilder::new(percent)
} }
pub fn new_state_changed<'a>(old: ::State, new: ::State, pending: ::State) -> StateChangedBuilder<'a> { pub fn new_state_changed(old: ::State, new: ::State, pending: ::State) -> StateChangedBuilder {
StateChangedBuilder::new(old, new, pending) StateChangedBuilder::new(old, new, pending)
} }
pub fn new_state_dirty<'a>() -> StateDirtyBuilder<'a> { pub fn new_state_dirty() -> StateDirtyBuilder {
StateDirtyBuilder::new() StateDirtyBuilder::new()
} }
pub fn new_step_done<'a>( pub fn new_step_done(
format: ::Format, format: ::Format,
amount: u64, amount: u64,
rate: f64, rate: f64,
@ -165,106 +166,106 @@ impl MessageRef {
intermediate: bool, intermediate: bool,
duration: u64, duration: u64,
eos: bool eos: bool
) -> StepDoneBuilder<'a> { ) -> StepDoneBuilder {
StepDoneBuilder::new(format, amount, rate, flush, intermediate, duration, eos) StepDoneBuilder::new(format, amount, rate, flush, intermediate, duration, eos)
} }
pub fn new_clock_provide<'a>(clock: &'a ::Clock, ready: bool) -> ClockProvideBuilder<'a> { pub fn new_clock_provide(clock: &::Clock, ready: bool) -> ClockProvideBuilder {
ClockProvideBuilder::new(clock, ready) ClockProvideBuilder::new(clock, ready)
} }
pub fn new_clock_lost<'a>(clock: &'a ::Clock) -> ClockLostBuilder<'a> { pub fn new_clock_lost(clock: &::Clock) -> ClockLostBuilder {
ClockLostBuilder::new(clock) ClockLostBuilder::new(clock)
} }
pub fn new_new_clock<'a>(clock: &'a ::Clock) -> NewClockBuilder<'a> { pub fn new_new_clock(clock: &::Clock) -> NewClockBuilder {
NewClockBuilder::new(clock) NewClockBuilder::new(clock)
} }
pub fn new_structure_change<'a>(type_: ::StructureChangeType, owner: &'a ::Element, busy: bool) -> StructureChangeBuilder<'a> { pub fn new_structure_change(type_: ::StructureChangeType, owner: &::Element, busy: bool) -> StructureChangeBuilder {
StructureChangeBuilder::new(type_, owner, busy) StructureChangeBuilder::new(type_, owner, busy)
} }
pub fn new_stream_status<'a>(type_: ::StreamStatusType, owner: &'a ::Element) -> StreamStatusBuilder<'a> { pub fn new_stream_status(type_: ::StreamStatusType, owner: &::Element) -> StreamStatusBuilder {
StreamStatusBuilder::new(type_, owner) StreamStatusBuilder::new(type_, owner)
} }
pub fn new_application<'a>(structure: ::Structure) -> ApplicationBuilder<'a> { pub fn new_application(structure: ::Structure) -> ApplicationBuilder {
ApplicationBuilder::new(structure) ApplicationBuilder::new(structure)
} }
pub fn new_element<'a>(structure: ::Structure) -> ElementBuilder<'a> { pub fn new_element(structure: ::Structure) -> ElementBuilder {
ElementBuilder::new(structure) ElementBuilder::new(structure)
} }
pub fn new_segment_start<'a>(format: ::Format, position: i64) -> SegmentStartBuilder<'a> { pub fn new_segment_start(format: ::Format, position: i64) -> SegmentStartBuilder {
SegmentStartBuilder::new(format, position) SegmentStartBuilder::new(format, position)
} }
pub fn new_segment_done<'a>(format: ::Format, position: i64) -> SegmentDoneBuilder<'a> { pub fn new_segment_done(format: ::Format, position: i64) -> SegmentDoneBuilder {
SegmentDoneBuilder::new(format, position) SegmentDoneBuilder::new(format, position)
} }
pub fn new_duration_changed<'a>() -> DurationChangedBuilder<'a> { pub fn new_duration_changed() -> DurationChangedBuilder {
DurationChangedBuilder::new() DurationChangedBuilder::new()
} }
pub fn new_latency<'a>() -> LatencyBuilder<'a> { pub fn new_latency() -> LatencyBuilder {
LatencyBuilder::new() LatencyBuilder::new()
} }
pub fn new_async_start<'a>() -> AsyncStartBuilder<'a> { pub fn new_async_start() -> AsyncStartBuilder {
AsyncStartBuilder::new() AsyncStartBuilder::new()
} }
pub fn new_async_done<'a>(running_time: u64) -> AsyncDoneBuilder<'a> { pub fn new_async_done(running_time: u64) -> AsyncDoneBuilder {
AsyncDoneBuilder::new(running_time) AsyncDoneBuilder::new(running_time)
} }
pub fn new_step_start<'a>(active: bool, pub fn new_step_start(active: bool,
format: ::Format, format: ::Format,
amount: u64, amount: u64,
rate: f64, rate: f64,
flush: bool, flush: bool,
intermediate: bool, intermediate: bool,
) -> StepStartBuilder<'a> { ) -> StepStartBuilder {
StepStartBuilder::new(active, format, amount, rate, flush, intermediate) StepStartBuilder::new(active, format, amount, rate, flush, intermediate)
} }
pub fn new_qos_builder<'a>(live: bool, pub fn new_qos_builder(live: bool,
running_time: u64, running_time: u64,
stream_time: u64, stream_time: u64,
timestamp: u64, timestamp: u64,
duration: u64, duration: u64,
) -> QosBuilder<'a> { ) -> QosBuilder {
QosBuilder::new(live, running_time, stream_time, timestamp, duration) QosBuilder::new(live, running_time, stream_time, timestamp, duration)
} }
pub fn new_toc<'a>(toc: (), updated: bool) -> TocBuilder<'a> { pub fn new_toc(toc: (), updated: bool) -> TocBuilder {
TocBuilder::new(toc, updated) TocBuilder::new(toc, updated)
} }
pub fn new_reset_time<'a>(running_time: u64) -> ResetTimeBuilder<'a> { pub fn new_reset_time(running_time: u64) -> ResetTimeBuilder {
ResetTimeBuilder::new(running_time) ResetTimeBuilder::new(running_time)
} }
pub fn new_stream_start<'a>() -> StreamStartBuilder<'a> { pub fn new_stream_start() -> StreamStartBuilder {
StreamStartBuilder::new() StreamStartBuilder::new()
} }
pub fn new_need_context<'a>(context_type: &'a str) -> NeedContextBuilder<'a> { pub fn new_need_context(context_type: &str) -> NeedContextBuilder {
NeedContextBuilder::new(context_type) NeedContextBuilder::new(context_type)
} }
pub fn new_have_context<'a>(context: ()) -> HaveContextBuilder<'a> { pub fn new_have_context(context: ()) -> HaveContextBuilder {
HaveContextBuilder::new(context) HaveContextBuilder::new(context)
} }
pub fn new_device_added<'a>(device: &'a ::Device) -> DeviceAddedBuilder<'a> { pub fn new_device_added(device: &::Device) -> DeviceAddedBuilder {
DeviceAddedBuilder::new(device) DeviceAddedBuilder::new(device)
} }
pub fn new_device_removed<'a>(device: &'a ::Device) -> DeviceRemovedBuilder<'a> { pub fn new_device_removed(device: &::Device) -> DeviceRemovedBuilder {
DeviceRemovedBuilder::new(device) DeviceRemovedBuilder::new(device)
} }
@ -274,12 +275,12 @@ impl MessageRef {
} }
#[cfg(feature = "v1_10")] #[cfg(feature = "v1_10")]
pub fn new_stream_collection<'a>(collection: &'a ::StreamCollection) -> StreamCollectionBuilder<'a> { pub fn new_stream_collection(collection: &::StreamCollection) -> StreamCollectionBuilder {
StreamCollectionBuilder::new(collection) StreamCollectionBuilder::new(collection)
} }
#[cfg(feature = "v1_10")] #[cfg(feature = "v1_10")]
pub fn new_streams_selected<'a>(collection: &'a ::StreamCollection) -> StreamsSelectedBuilder<'a> { pub fn new_streams_selected(collection: &::StreamCollection) -> StreamsSelectedBuilder {
StreamsSelectedBuilder::new(collection) StreamsSelectedBuilder::new(collection)
} }
@ -299,27 +300,27 @@ impl glib::types::StaticType for GstRc<MessageRef> {
} }
pub enum MessageView<'a> { pub enum MessageView<'a> {
Eos, Eos(Eos<'a>),
Error(Error<'a>), Error(Error<'a>),
Warning(Warning<'a>), Warning(Warning<'a>),
Info(Info<'a>), Info(Info<'a>),
Tag(Tag<'a>), Tag(Tag<'a>),
Buffering(Buffering<'a>), Buffering(Buffering<'a>),
StateChanged(StateChanged<'a>), StateChanged(StateChanged<'a>),
StateDirty, StateDirty(StateDirty<'a>),
StepDone(StepDone<'a>), StepDone(StepDone<'a>),
ClockProvide(ClockProvide<'a>), ClockProvide(ClockProvide<'a>),
ClockLost(ClockLost<'a>), ClockLost(ClockLost<'a>),
NewClock(NewClock<'a>), NewClock(NewClock<'a>),
StructureChange(StructureChange<'a>), StructureChange(StructureChange<'a>),
StreamStatus(StreamStatus<'a>), StreamStatus(StreamStatus<'a>),
Application, Application(Application<'a>),
Element, Element(Element<'a>),
SegmentStart(SegmentStart<'a>), SegmentStart(SegmentStart<'a>),
SegmentDone(SegmentDone<'a>), SegmentDone(SegmentDone<'a>),
DurationChanged, DurationChanged(DurationChanged<'a>),
Latency, Latency(Latency<'a>),
AsyncStart, AsyncStart(AsyncStart<'a>),
AsyncDone(AsyncDone<'a>), AsyncDone(AsyncDone<'a>),
RequestState(RequestState<'a>), RequestState(RequestState<'a>),
StepStart(StepStart<'a>), StepStart(StepStart<'a>),
@ -340,6 +341,8 @@ pub enum MessageView<'a> {
__NonExhaustive, __NonExhaustive,
} }
pub struct Eos<'a>(&'a MessageRef);
pub struct Error<'a>(&'a MessageRef); pub struct Error<'a>(&'a MessageRef);
impl<'a> Error<'a> { impl<'a> Error<'a> {
pub fn get_error(&self) -> glib::Error { pub fn get_error(&self) -> glib::Error {
@ -543,6 +546,8 @@ impl<'a> StateChanged<'a> {
} }
} }
pub struct StateDirty<'a>(&'a MessageRef);
pub struct StepDone<'a>(&'a MessageRef); pub struct StepDone<'a>(&'a MessageRef);
impl<'a> StepDone<'a> { impl<'a> StepDone<'a> {
pub fn get(&self) -> (::Format, u64, f64, bool, bool, u64, bool) { pub fn get(&self) -> (::Format, u64, f64, bool, bool, u64, bool) {
@ -631,7 +636,7 @@ impl<'a> NewClock<'a> {
pub struct StructureChange<'a>(&'a MessageRef); pub struct StructureChange<'a>(&'a MessageRef);
impl<'a> StructureChange<'a> { impl<'a> StructureChange<'a> {
pub fn get(&self) -> (::StructureChangeType, Option<Element>, bool) { pub fn get(&self) -> (::StructureChangeType, Option<::Element>, bool) {
unsafe { unsafe {
let mut type_ = mem::uninitialized(); let mut type_ = mem::uninitialized();
let mut owner = ptr::null_mut(); let mut owner = ptr::null_mut();
@ -651,7 +656,7 @@ impl<'a> StructureChange<'a> {
pub struct StreamStatus<'a>(&'a MessageRef); pub struct StreamStatus<'a>(&'a MessageRef);
impl<'a> StreamStatus<'a> { impl<'a> StreamStatus<'a> {
pub fn get(&self) -> (::StreamStatusType, Option<Element>) { pub fn get(&self) -> (::StreamStatusType, Option<::Element>) {
unsafe { unsafe {
let mut type_ = mem::uninitialized(); let mut type_ = mem::uninitialized();
let mut owner = ptr::null_mut(); let mut owner = ptr::null_mut();
@ -671,6 +676,10 @@ impl<'a> StreamStatus<'a> {
} }
} }
pub struct Application<'a>(&'a MessageRef);
pub struct Element<'a>(&'a MessageRef);
pub struct SegmentStart<'a>(&'a MessageRef); pub struct SegmentStart<'a>(&'a MessageRef);
impl<'a> SegmentStart<'a> { impl<'a> SegmentStart<'a> {
pub fn get(&self) -> (::Format, i64) { pub fn get(&self) -> (::Format, i64) {
@ -699,6 +708,12 @@ impl<'a> SegmentDone<'a> {
} }
} }
pub struct DurationChanged<'a>(&'a MessageRef);
pub struct Latency<'a>(&'a MessageRef);
pub struct AsyncStart<'a>(&'a MessageRef);
pub struct AsyncDone<'a>(&'a MessageRef); pub struct AsyncDone<'a>(&'a MessageRef);
impl<'a> AsyncDone<'a> { impl<'a> AsyncDone<'a> {
pub fn get_running_time(&self) -> u64 { pub fn get_running_time(&self) -> u64 {
@ -1043,9 +1058,12 @@ impl<'a> Redirect<'a> {
macro_rules! message_builder_generic_impl { macro_rules! message_builder_generic_impl {
($new_fn:expr) => { ($new_fn:expr) => {
pub fn src(self, src: Option<&'a Object>) -> Self { pub fn src<'b, T: IsA<Object> + Cast + Clone>(self, src: Option<&'b T>) -> Self {
Self { Self {
src: src, src: src.map(|o| {
let o = (*o).clone();
o.upcast::<Object>()
}),
.. self .. self
} }
} }
@ -1072,11 +1090,11 @@ macro_rules! message_builder_generic_impl {
} }
} }
pub struct EosBuilder<'a> { pub struct EosBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
} }
impl<'a> EosBuilder<'a> { impl EosBuilder {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
src: None, src: None,
@ -1088,7 +1106,7 @@ impl<'a> EosBuilder<'a> {
} }
pub struct ErrorBuilder<'a> { pub struct ErrorBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
error: &'a glib::Error, error: &'a glib::Error,
debug: Option<&'a str>, debug: Option<&'a str>,
@ -1147,7 +1165,7 @@ impl<'a> ErrorBuilder<'a> {
} }
pub struct WarningBuilder<'a> { pub struct WarningBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
error: &'a glib::Error, error: &'a glib::Error,
debug: Option<&'a str>, debug: Option<&'a str>,
@ -1206,7 +1224,7 @@ impl<'a> WarningBuilder<'a> {
} }
pub struct InfoBuilder<'a> { pub struct InfoBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
error: &'a glib::Error, error: &'a glib::Error,
debug: Option<&'a str>, debug: Option<&'a str>,
@ -1265,7 +1283,7 @@ impl<'a> InfoBuilder<'a> {
} }
pub struct TagBuilder<'a> { pub struct TagBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
tags: &'a TagList, tags: &'a TagList,
} }
@ -1283,13 +1301,13 @@ impl<'a> TagBuilder<'a> {
}); });
} }
pub struct BufferingBuilder<'a> { pub struct BufferingBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
percent: i32, percent: i32,
stats: Option<(::BufferingMode, i32, i32, i64)>, stats: Option<(::BufferingMode, i32, i32, i64)>,
} }
impl<'a> BufferingBuilder<'a> { impl BufferingBuilder {
pub fn new(percent: i32) -> Self { pub fn new(percent: i32) -> Self {
Self { Self {
src: None, src: None,
@ -1329,14 +1347,14 @@ impl<'a> BufferingBuilder<'a> {
}); });
} }
pub struct StateChangedBuilder<'a> { pub struct StateChangedBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
old: ::State, old: ::State,
new: ::State, new: ::State,
pending: ::State, pending: ::State,
} }
impl<'a> StateChangedBuilder<'a> { impl StateChangedBuilder {
pub fn new(old: ::State, new: ::State, pending: ::State) -> Self { pub fn new(old: ::State, new: ::State, pending: ::State) -> Self {
Self { Self {
src: None, src: None,
@ -1357,11 +1375,11 @@ impl<'a> StateChangedBuilder<'a> {
}); });
} }
pub struct StateDirtyBuilder<'a> { pub struct StateDirtyBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
} }
impl<'a> StateDirtyBuilder<'a> { impl StateDirtyBuilder {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
src: None, src: None,
@ -1372,8 +1390,8 @@ impl<'a> StateDirtyBuilder<'a> {
message_builder_generic_impl!(|_, src| ffi::gst_message_new_state_dirty(src)); message_builder_generic_impl!(|_, src| ffi::gst_message_new_state_dirty(src));
} }
pub struct StepDoneBuilder<'a> { pub struct StepDoneBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
format: ::Format, format: ::Format,
amount: u64, amount: u64,
@ -1383,7 +1401,7 @@ pub struct StepDoneBuilder<'a> {
duration: u64, duration: u64,
eos: bool, eos: bool,
} }
impl<'a> StepDoneBuilder<'a> { impl StepDoneBuilder {
pub fn new( pub fn new(
format: ::Format, format: ::Format,
amount: u64, amount: u64,
@ -1421,7 +1439,7 @@ impl<'a> StepDoneBuilder<'a> {
} }
pub struct ClockProvideBuilder<'a> { pub struct ClockProvideBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
clock: &'a ::Clock, clock: &'a ::Clock,
ready: bool, ready: bool,
@ -1442,7 +1460,7 @@ impl<'a> ClockProvideBuilder<'a> {
} }
pub struct ClockLostBuilder<'a> { pub struct ClockLostBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
clock: &'a ::Clock, clock: &'a ::Clock,
} }
@ -1461,7 +1479,7 @@ impl<'a> ClockLostBuilder<'a> {
} }
pub struct NewClockBuilder<'a> { pub struct NewClockBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
clock: &'a ::Clock, clock: &'a ::Clock,
} }
@ -1480,7 +1498,7 @@ impl<'a> NewClockBuilder<'a> {
} }
pub struct StructureChangeBuilder<'a> { pub struct StructureChangeBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
type_: ::StructureChangeType, type_: ::StructureChangeType,
owner: &'a ::Element, owner: &'a ::Element,
@ -1508,7 +1526,7 @@ impl<'a> StructureChangeBuilder<'a> {
} }
pub struct StreamStatusBuilder<'a> { pub struct StreamStatusBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
type_: ::StreamStatusType, type_: ::StreamStatusType,
owner: &'a ::Element, owner: &'a ::Element,
@ -1542,12 +1560,12 @@ impl<'a> StreamStatusBuilder<'a> {
}); });
} }
pub struct ApplicationBuilder<'a> { pub struct ApplicationBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
structure: Option<::Structure>, structure: Option<::Structure>,
} }
impl<'a> ApplicationBuilder<'a> { impl ApplicationBuilder {
pub fn new(structure: ::Structure) -> Self { pub fn new(structure: ::Structure) -> Self {
Self { Self {
src: None, src: None,
@ -1561,12 +1579,12 @@ impl<'a> ApplicationBuilder<'a> {
}); });
} }
pub struct ElementBuilder<'a> { pub struct ElementBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
structure: Option<::Structure>, structure: Option<::Structure>,
} }
impl<'a> ElementBuilder<'a> { impl ElementBuilder {
pub fn new(structure: ::Structure) -> Self { pub fn new(structure: ::Structure) -> Self {
Self { Self {
src: None, src: None,
@ -1580,13 +1598,13 @@ impl<'a> ElementBuilder<'a> {
}); });
} }
pub struct SegmentStartBuilder<'a> { pub struct SegmentStartBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
format: ::Format, format: ::Format,
position: i64, position: i64,
} }
impl<'a> SegmentStartBuilder<'a> { impl SegmentStartBuilder {
pub fn new(format: ::Format, position: i64) -> Self { pub fn new(format: ::Format, position: i64) -> Self {
Self { Self {
src: None, src: None,
@ -1601,13 +1619,13 @@ impl<'a> SegmentStartBuilder<'a> {
}); });
} }
pub struct SegmentDoneBuilder<'a> { pub struct SegmentDoneBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
format: ::Format, format: ::Format,
position: i64, position: i64,
} }
impl<'a> SegmentDoneBuilder<'a> { impl SegmentDoneBuilder {
pub fn new(format: ::Format, position: i64) -> Self { pub fn new(format: ::Format, position: i64) -> Self {
Self { Self {
src: None, src: None,
@ -1622,11 +1640,11 @@ impl<'a> SegmentDoneBuilder<'a> {
}); });
} }
pub struct DurationChangedBuilder<'a> { pub struct DurationChangedBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
} }
impl<'a> DurationChangedBuilder<'a> { impl DurationChangedBuilder {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
src: None, src: None,
@ -1637,11 +1655,11 @@ impl<'a> DurationChangedBuilder<'a> {
message_builder_generic_impl!(|_, src| ffi::gst_message_new_duration_changed(src)); message_builder_generic_impl!(|_, src| ffi::gst_message_new_duration_changed(src));
} }
pub struct LatencyBuilder<'a> { pub struct LatencyBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
} }
impl<'a> LatencyBuilder<'a> { impl LatencyBuilder {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
src: None, src: None,
@ -1652,11 +1670,11 @@ impl<'a> LatencyBuilder<'a> {
message_builder_generic_impl!(|_, src| ffi::gst_message_new_latency(src)); message_builder_generic_impl!(|_, src| ffi::gst_message_new_latency(src));
} }
pub struct AsyncStartBuilder<'a> { pub struct AsyncStartBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
} }
impl<'a> AsyncStartBuilder<'a> { impl AsyncStartBuilder {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
src: None, src: None,
@ -1667,12 +1685,12 @@ impl<'a> AsyncStartBuilder<'a> {
message_builder_generic_impl!(|_, src| ffi::gst_message_new_async_start(src)); message_builder_generic_impl!(|_, src| ffi::gst_message_new_async_start(src));
} }
pub struct AsyncDoneBuilder<'a> { pub struct AsyncDoneBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
running_time: u64, running_time: u64,
} }
impl<'a> AsyncDoneBuilder<'a> { impl AsyncDoneBuilder {
pub fn new(running_time: u64) -> Self { pub fn new(running_time: u64) -> Self {
Self { Self {
src: None, src: None,
@ -1686,12 +1704,12 @@ impl<'a> AsyncDoneBuilder<'a> {
}); });
} }
pub struct RequestStateBuilder<'a> { pub struct RequestStateBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
state: ::State, state: ::State,
} }
impl<'a> RequestStateBuilder<'a> { impl RequestStateBuilder {
pub fn new(state: ::State) -> Self { pub fn new(state: ::State) -> Self {
Self { Self {
src: None, src: None,
@ -1705,8 +1723,8 @@ impl<'a> RequestStateBuilder<'a> {
}); });
} }
pub struct StepStartBuilder<'a> { pub struct StepStartBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
active: bool, active: bool,
format: ::Format, format: ::Format,
@ -1715,7 +1733,7 @@ pub struct StepStartBuilder<'a> {
flush: bool, flush: bool,
intermediate: bool, intermediate: bool,
} }
impl<'a> StepStartBuilder<'a> { impl StepStartBuilder {
pub fn new( pub fn new(
active: bool, active: bool,
format: ::Format, format: ::Format,
@ -1749,8 +1767,8 @@ impl<'a> StepStartBuilder<'a> {
}); });
} }
pub struct QosBuilder<'a> { pub struct QosBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
live: bool, live: bool,
running_time: u64, running_time: u64,
@ -1760,7 +1778,7 @@ pub struct QosBuilder<'a> {
values: Option<(i64, f64, i32)>, values: Option<(i64, f64, i32)>,
stats: Option<(::Format, u64, u64)>, stats: Option<(::Format, u64, u64)>,
} }
impl<'a> QosBuilder<'a> { impl QosBuilder {
pub fn new( pub fn new(
live: bool, live: bool,
running_time: u64, running_time: u64,
@ -1815,7 +1833,7 @@ impl<'a> QosBuilder<'a> {
} }
pub struct ProgressBuilder<'a> { pub struct ProgressBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
type_: ::ProgressType, type_: ::ProgressType,
code: Option<&'a str>, code: Option<&'a str>,
@ -1857,13 +1875,13 @@ impl<'a> ProgressBuilder<'a> {
} }
// TODO Toc // TODO Toc
pub struct TocBuilder<'a> { pub struct TocBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
toc: (), toc: (),
updated: bool, updated: bool,
} }
impl<'a> TocBuilder<'a> { impl TocBuilder {
pub fn new(toc: () /* &'a Toc */, updated: bool) -> Self { pub fn new(toc: () /* &'a Toc */, updated: bool) -> Self {
Self { Self {
src: None, src: None,
@ -1882,12 +1900,12 @@ impl<'a> TocBuilder<'a> {
}); });
} }
pub struct ResetTimeBuilder<'a> { pub struct ResetTimeBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
running_time: u64, running_time: u64,
} }
impl<'a> ResetTimeBuilder<'a> { impl ResetTimeBuilder {
pub fn new(running_time: u64) -> Self { pub fn new(running_time: u64) -> Self {
Self { Self {
src: None, src: None,
@ -1901,12 +1919,12 @@ impl<'a> ResetTimeBuilder<'a> {
}); });
} }
pub struct StreamStartBuilder<'a> { pub struct StreamStartBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
group_id: Option<u32>, group_id: Option<u32>,
} }
impl<'a> StreamStartBuilder<'a> { impl StreamStartBuilder {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
src: None, src: None,
@ -1932,7 +1950,7 @@ impl<'a> StreamStartBuilder<'a> {
} }
pub struct NeedContextBuilder<'a> { pub struct NeedContextBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
context_type: &'a str, context_type: &'a str,
} }
@ -1951,12 +1969,12 @@ impl<'a> NeedContextBuilder<'a> {
} }
// TODO Context // TODO Context
pub struct HaveContextBuilder<'a> { pub struct HaveContextBuilder {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
context: (), context: (),
} }
impl<'a> HaveContextBuilder<'a> { impl HaveContextBuilder {
pub fn new(context: () /* ::Context */) -> Self { pub fn new(context: () /* ::Context */) -> Self {
Self { Self {
src: None, src: None,
@ -1971,7 +1989,7 @@ impl<'a> HaveContextBuilder<'a> {
} }
pub struct DeviceAddedBuilder<'a> { pub struct DeviceAddedBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
device: &'a ::Device, device: &'a ::Device,
} }
@ -1990,7 +2008,7 @@ impl<'a> DeviceAddedBuilder<'a> {
} }
pub struct DeviceRemovedBuilder<'a> { pub struct DeviceRemovedBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
device: &'a ::Device, device: &'a ::Device,
} }
@ -2009,7 +2027,7 @@ impl<'a> DeviceRemovedBuilder<'a> {
} }
pub struct PropertyNotifyBuilder<'a> { pub struct PropertyNotifyBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
property_name: &'a str, property_name: &'a str,
value: &'a glib::Value, value: &'a glib::Value,
@ -2034,10 +2052,10 @@ impl<'a> PropertyNotifyBuilder<'a> {
}); });
} }
#[cfg(feature = "v1_10")]
pub struct StreamCollectionBuilder<'a> { pub struct StreamCollectionBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
#[cfg(feature = "v1_10")]
collection: &'a ::StreamCollection, collection: &'a ::StreamCollection,
} }
#[cfg(feature = "v1_10")] #[cfg(feature = "v1_10")]
@ -2055,8 +2073,9 @@ impl<'a> StreamCollectionBuilder<'a> {
}); });
} }
#[cfg(feature = "v1_10")]
pub struct StreamsSelectedBuilder<'a> { pub struct StreamsSelectedBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
#[cfg(feature = "v1_10")] #[cfg(feature = "v1_10")]
collection: &'a ::StreamCollection, collection: &'a ::StreamCollection,
@ -2093,7 +2112,7 @@ impl<'a> StreamsSelectedBuilder<'a> {
} }
pub struct RedirectBuilder<'a> { pub struct RedirectBuilder<'a> {
src: Option<&'a Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
location: &'a str, location: &'a str,
tag_list: Option<&'a TagList>, tag_list: Option<&'a TagList>,