diff --git a/gstreamer-video/src/video_event.rs b/gstreamer-video/src/video_event.rs index 87516336d..fb12ea8bb 100644 --- a/gstreamer-video/src/video_event.rs +++ b/gstreamer-video/src/video_event.rs @@ -138,6 +138,14 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> { } } + pub fn timestamp_if_some(self, timestamp: Option) -> Self { + if let Some(timestamp) = timestamp { + self.timestamp(timestamp) + } else { + self + } + } + pub fn stream_time(self, stream_time: impl Into>) -> Self { Self { stream_time: stream_time.into(), @@ -145,6 +153,14 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> { } } + pub fn stream_time_if_some(self, stream_time: Option) -> Self { + if let Some(stream_time) = stream_time { + self.stream_time(stream_time) + } else { + self + } + } + pub fn running_time(self, running_time: impl Into>) -> Self { Self { running_time: running_time.into(), @@ -152,6 +168,14 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> { } } + pub fn running_time_if_some(self, running_time: Option) -> Self { + if let Some(running_time) = running_time { + self.running_time(running_time) + } else { + self + } + } + pub fn all_headers(self, all_headers: bool) -> Self { Self { all_headers, @@ -268,6 +292,14 @@ impl<'a> UpstreamForceKeyUnitEventBuilder<'a> { } } + pub fn running_time_if_some(self, running_time: Option) -> Self { + if let Some(running_time) = running_time { + self.running_time(running_time) + } else { + self + } + } + pub fn all_headers(self, all_headers: bool) -> Self { Self { all_headers, diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index d818c340b..6cdfdd500 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -2634,6 +2634,14 @@ impl<'a> GapBuilder<'a> { self } + pub fn duration_if_some(self, duration: Option) -> Self { + if let Some(duration) = duration { + self.duration(duration) + } else { + self + } + } + event_builder_generic_impl!(|s: &Self| { #[allow(clippy::let_and_return)] let ev = ffi::gst_event_new_gap(s.timestamp.into_glib(), s.duration.into_glib()); @@ -2700,6 +2708,14 @@ impl<'a> QosBuilder<'a> { self } + pub fn timestamp_if_some(self, timestamp: Option) -> Self { + if let Some(timestamp) = timestamp { + self.timestamp(timestamp) + } else { + self + } + } + event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos( s.type_.into_glib(), s.proportion, diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index dec584945..639f4288b 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -3276,6 +3276,14 @@ impl<'a> AsyncDoneBuilder<'a> { self } + pub fn running_time_if_some(self, running_time: Option) -> Self { + if let Some(running_time) = running_time { + self.running_time(running_time) + } else { + self + } + } + message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_async_done( src, s.running_time.into_glib() @@ -3375,21 +3383,53 @@ impl<'a> QosBuilder<'a> { self } + pub fn running_time_if_some(self, running_time: Option) -> Self { + if let Some(running_time) = running_time { + self.running_time(running_time) + } else { + self + } + } + pub fn stream_time(mut self, stream_time: impl Into>) -> Self { self.stream_time = stream_time.into(); self } + pub fn stream_time_if_some(self, stream_time: Option) -> Self { + if let Some(stream_time) = stream_time { + self.stream_time(stream_time) + } else { + self + } + } + pub fn timestamp(mut self, timestamp: impl Into>) -> Self { self.timestamp = timestamp.into(); self } + pub fn timestamp_if_some(self, timestamp: Option) -> Self { + if let Some(timestamp) = timestamp { + self.timestamp(timestamp) + } else { + self + } + } + pub fn duration(mut self, duration: impl Into>) -> Self { self.duration = duration.into(); self } + pub fn duration_if_some(self, duration: Option) -> Self { + if let Some(duration) = duration { + self.duration(duration) + } else { + self + } + } + pub fn values(self, jitter: i64, proportion: f64, quality: i32) -> Self { Self { values: Some((jitter, proportion, quality)),