gstreamer: Add GstParamSpecBuilderExt trait to easily allow setting controllable, mutable-ready and other extension flags

This commit is contained in:
Sebastian Dröge 2022-08-10 12:10:43 +03:00
parent 446f09fec6
commit 2cb7fc8122
2 changed files with 51 additions and 0 deletions

View file

@ -342,6 +342,8 @@ pub mod prelude {
pub use crate::tags::{CustomTag, Tag}; pub use crate::tags::{CustomTag, Tag};
pub use crate::param_spec::GstParamSpecBuilderExt;
pub use muldiv::MulDiv; pub use muldiv::MulDiv;
pub use crate::format::{ pub use crate::format::{

View file

@ -306,6 +306,54 @@ impl<'a> glib::prelude::ParamSpecBuilderExt<'a> for ParamSpecArrayBuilder<'a> {
} }
} }
pub trait GstParamSpecBuilderExt<'a>: glib::prelude::ParamSpecBuilderExt<'a> {
// rustdoc-stripper-ignore-next
/// Mark the property as controllable
fn controllable(self) -> Self {
let flags = self.current_flags() | crate::PARAM_FLAG_CONTROLLABLE;
self.flags(flags)
}
// rustdoc-stripper-ignore-next
/// Mark the property as mutable in ready state
fn mutable_ready(self) -> Self {
let flags = self.current_flags() | crate::PARAM_FLAG_MUTABLE_READY;
self.flags(flags)
}
// rustdoc-stripper-ignore-next
/// Mark the property as mutable in paused state
fn mutable_paused(self) -> Self {
let flags = self.current_flags() | crate::PARAM_FLAG_MUTABLE_PAUSED;
self.flags(flags)
}
// rustdoc-stripper-ignore-next
/// Mark the property as mutable in playing state
fn mutable_playing(self) -> Self {
let flags = self.current_flags() | crate::PARAM_FLAG_MUTABLE_PLAYING;
self.flags(flags)
}
#[cfg(any(feature = "v1_18", feature = "dox"))]
// rustdoc-stripper-ignore-next
/// Mark the property for showing the default value in the docs
fn doc_show_default(self) -> Self {
let flags = self.current_flags() | crate::PARAM_FLAG_DOC_SHOW_DEFAULT;
self.flags(flags)
}
#[cfg(any(feature = "v1_18", feature = "dox"))]
// rustdoc-stripper-ignore-next
/// Mark the property for being only conditionally available
fn conditionally_available(self) -> Self {
let flags = self.current_flags() | crate::PARAM_FLAG_CONDITIONALLY_AVAILABLE;
self.flags(flags)
}
}
impl<'a, T: glib::prelude::ParamSpecBuilderExt<'a>> GstParamSpecBuilderExt<'a> for T {}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@ -332,6 +380,7 @@ mod tests {
.maximum((100, 1).into()) .maximum((100, 1).into())
.default_value((1, 1).into()) .default_value((1, 1).into())
.readwrite() .readwrite()
.mutable_playing()
.build(); .build();
} }
} }