From 1b7e99938febb0ed893175c5d3fb463a90132d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 17 May 2020 13:32:33 +0300 Subject: [PATCH] gstreamer/event: Add setter/getter for the gst::Stream in the stream-start event --- gstreamer/src/event.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 8fc6c8203..16c64d8e8 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -541,6 +541,15 @@ impl<'a> StreamStart<'a> { } } } + + #[cfg(any(feature = "v1_10", feature = "dox"))] + pub fn get_stream(&self) -> Option<::Stream> { + unsafe { + let mut stream = ptr::null_mut(); + gst_sys::gst_event_parse_stream(self.as_mut_ptr(), &mut stream); + from_glib_full(stream) + } + } } declare_concrete_event!(Caps); @@ -1050,6 +1059,8 @@ pub struct StreamStartBuilder<'a> { stream_id: &'a str, flags: Option<::StreamFlags>, group_id: Option, + #[cfg(any(feature = "v1_10", feature = "dox"))] + stream: Option<::Stream>, } impl<'a> StreamStartBuilder<'a> { fn new(stream_id: &'a str) -> Self { @@ -1059,6 +1070,8 @@ impl<'a> StreamStartBuilder<'a> { stream_id, flags: None, group_id: None, + #[cfg(any(feature = "v1_10", feature = "dox"))] + stream: None, } } @@ -1076,6 +1089,14 @@ impl<'a> StreamStartBuilder<'a> { } } + #[cfg(any(feature = "v1_10", feature = "dox"))] + pub fn stream(self, stream: ::Stream) -> Self { + Self { + stream: Some(stream), + ..self + } + } + event_builder_generic_impl!(|s: &Self| { let ev = gst_sys::gst_event_new_stream_start(s.stream_id.to_glib_none().0); if let Some(flags) = s.flags { @@ -1084,6 +1105,14 @@ impl<'a> StreamStartBuilder<'a> { if let Some(group_id) = s.group_id { gst_sys::gst_event_set_group_id(ev, group_id.0.get()); } + + #[cfg(any(feature = "v1_10", feature = "dox"))] + { + if let Some(ref stream) = s.stream { + gst_sys::gst_event_set_stream(ev, stream.to_glib_none().0); + } + } + ev }); }