mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
Add field_if_some setter for builder ClockTime fields
Optional `ClockTime` fields already implemented their setters in such a way that they could accept either `Option<ClockTime>` or `ClockTime`. This commit adds `field_if_some()` setter variants for builder `ClockTime` builder fields for consistency with other builder fields. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1424>
This commit is contained in:
parent
ea25c9262b
commit
db03c8edd1
3 changed files with 88 additions and 0 deletions
|
@ -138,6 +138,14 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn timestamp_if_some(self, timestamp: Option<gst::ClockTime>) -> Self {
|
||||||
|
if let Some(timestamp) = timestamp {
|
||||||
|
self.timestamp(timestamp)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn stream_time(self, stream_time: impl Into<Option<gst::ClockTime>>) -> Self {
|
pub fn stream_time(self, stream_time: impl Into<Option<gst::ClockTime>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
stream_time: stream_time.into(),
|
stream_time: stream_time.into(),
|
||||||
|
@ -145,6 +153,14 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn stream_time_if_some(self, stream_time: Option<gst::ClockTime>) -> Self {
|
||||||
|
if let Some(stream_time) = stream_time {
|
||||||
|
self.stream_time(stream_time)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn running_time(self, running_time: impl Into<Option<gst::ClockTime>>) -> Self {
|
pub fn running_time(self, running_time: impl Into<Option<gst::ClockTime>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
running_time: running_time.into(),
|
running_time: running_time.into(),
|
||||||
|
@ -152,6 +168,14 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn running_time_if_some(self, running_time: Option<gst::ClockTime>) -> Self {
|
||||||
|
if let Some(running_time) = running_time {
|
||||||
|
self.running_time(running_time)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn all_headers(self, all_headers: bool) -> Self {
|
pub fn all_headers(self, all_headers: bool) -> Self {
|
||||||
Self {
|
Self {
|
||||||
all_headers,
|
all_headers,
|
||||||
|
@ -268,6 +292,14 @@ impl<'a> UpstreamForceKeyUnitEventBuilder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn running_time_if_some(self, running_time: Option<gst::ClockTime>) -> Self {
|
||||||
|
if let Some(running_time) = running_time {
|
||||||
|
self.running_time(running_time)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn all_headers(self, all_headers: bool) -> Self {
|
pub fn all_headers(self, all_headers: bool) -> Self {
|
||||||
Self {
|
Self {
|
||||||
all_headers,
|
all_headers,
|
||||||
|
|
|
@ -2634,6 +2634,14 @@ impl<'a> GapBuilder<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn duration_if_some(self, duration: Option<ClockTime>) -> Self {
|
||||||
|
if let Some(duration) = duration {
|
||||||
|
self.duration(duration)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
event_builder_generic_impl!(|s: &Self| {
|
event_builder_generic_impl!(|s: &Self| {
|
||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return)]
|
||||||
let ev = ffi::gst_event_new_gap(s.timestamp.into_glib(), s.duration.into_glib());
|
let ev = ffi::gst_event_new_gap(s.timestamp.into_glib(), s.duration.into_glib());
|
||||||
|
@ -2700,6 +2708,14 @@ impl<'a> QosBuilder<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn timestamp_if_some(self, timestamp: Option<ClockTime>) -> Self {
|
||||||
|
if let Some(timestamp) = timestamp {
|
||||||
|
self.timestamp(timestamp)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos(
|
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos(
|
||||||
s.type_.into_glib(),
|
s.type_.into_glib(),
|
||||||
s.proportion,
|
s.proportion,
|
||||||
|
|
|
@ -3276,6 +3276,14 @@ impl<'a> AsyncDoneBuilder<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn running_time_if_some(self, running_time: Option<crate::ClockTime>) -> 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(
|
message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_async_done(
|
||||||
src,
|
src,
|
||||||
s.running_time.into_glib()
|
s.running_time.into_glib()
|
||||||
|
@ -3375,21 +3383,53 @@ impl<'a> QosBuilder<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn running_time_if_some(self, running_time: Option<crate::ClockTime>) -> 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<Option<crate::ClockTime>>) -> Self {
|
pub fn stream_time(mut self, stream_time: impl Into<Option<crate::ClockTime>>) -> Self {
|
||||||
self.stream_time = stream_time.into();
|
self.stream_time = stream_time.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn stream_time_if_some(self, stream_time: Option<crate::ClockTime>) -> Self {
|
||||||
|
if let Some(stream_time) = stream_time {
|
||||||
|
self.stream_time(stream_time)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn timestamp(mut self, timestamp: impl Into<Option<crate::ClockTime>>) -> Self {
|
pub fn timestamp(mut self, timestamp: impl Into<Option<crate::ClockTime>>) -> Self {
|
||||||
self.timestamp = timestamp.into();
|
self.timestamp = timestamp.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn timestamp_if_some(self, timestamp: Option<crate::ClockTime>) -> Self {
|
||||||
|
if let Some(timestamp) = timestamp {
|
||||||
|
self.timestamp(timestamp)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn duration(mut self, duration: impl Into<Option<crate::ClockTime>>) -> Self {
|
pub fn duration(mut self, duration: impl Into<Option<crate::ClockTime>>) -> Self {
|
||||||
self.duration = duration.into();
|
self.duration = duration.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn duration_if_some(self, duration: Option<crate::ClockTime>) -> Self {
|
||||||
|
if let Some(duration) = duration {
|
||||||
|
self.duration(duration)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn values(self, jitter: i64, proportion: f64, quality: i32) -> Self {
|
pub fn values(self, jitter: i64, proportion: f64, quality: i32) -> Self {
|
||||||
Self {
|
Self {
|
||||||
values: Some((jitter, proportion, quality)),
|
values: Some((jitter, proportion, quality)),
|
||||||
|
|
Loading…
Reference in a new issue