diff --git a/gstreamer-pbutils/src/element_properties.rs b/gstreamer-pbutils/src/element_properties.rs index b52554752..3d57e2873 100644 --- a/gstreamer-pbutils/src/element_properties.rs +++ b/gstreamer-pbutils/src/element_properties.rs @@ -183,6 +183,24 @@ impl ElementPropertiesGeneralBuilder { self } + pub fn field_value_with_static( + mut self, + property_name: impl AsRef + 'static, + value: glib::SendValue, + ) -> Self { + self.structure.set_value_with_static(property_name, value); + self + } + + pub fn field_value_with_id( + mut self, + property_name: impl AsRef, + value: glib::SendValue, + ) -> Self { + self.structure.set_value_with_id(property_name, value); + self + } + pub fn field_value_if_some(self, property_name: &str, value: Option) -> Self { if let Some(value) = value { self.field_value(property_name, value) @@ -191,6 +209,30 @@ impl ElementPropertiesGeneralBuilder { } } + pub fn field_value_with_static_if_some( + self, + property_name: impl AsRef + 'static, + value: Option, + ) -> Self { + if let Some(value) = value { + self.field_value_with_static(property_name, value) + } else { + self + } + } + + pub fn field_value_with_id_if_some( + self, + property_name: impl AsRef, + value: Option, + ) -> Self { + if let Some(value) = value { + self.field_value_with_id(property_name, value) + } else { + self + } + } + pub fn build(self) -> ElementProperties { ElementProperties(self.structure) } @@ -347,6 +389,24 @@ impl ElementPropertiesMapItemBuilder { self } + pub fn field_value_with_static( + mut self, + property_name: impl AsRef + 'static, + value: glib::SendValue, + ) -> Self { + self.structure.set_value_with_static(property_name, value); + self + } + + pub fn field_value_with_id( + mut self, + property_name: impl AsRef, + value: glib::SendValue, + ) -> Self { + self.structure.set_value_with_id(property_name, value); + self + } + pub fn field_value_if_some(self, property_name: &str, value: Option) -> Self { if let Some(value) = value { self.field_value(property_name, value) @@ -355,6 +415,30 @@ impl ElementPropertiesMapItemBuilder { } } + pub fn field_value_with_static_if_some( + self, + property_name: impl AsRef + 'static, + value: Option, + ) -> Self { + if let Some(value) = value { + self.field_value_with_static(property_name, value) + } else { + self + } + } + + pub fn field_value_with_id_if_some( + self, + property_name: impl AsRef, + value: Option, + ) -> Self { + if let Some(value) = value { + self.field_value_with_id(property_name, value) + } else { + self + } + } + pub fn build(self) -> ElementPropertiesMapItem { ElementPropertiesMapItem(self.structure) } @@ -363,6 +447,7 @@ impl ElementPropertiesMapItemBuilder { #[cfg(test)] mod test { use super::*; + use gst::idstr; #[test] fn element_properties_getters() { @@ -377,7 +462,7 @@ mod test { assert_eq!(elem_props_general.map(), None); let elem_factory_props_map = ElementPropertiesMapItem::builder("vp8enc") - .field("cq-level", 13) + .field_with_id(idstr!("cq-level"), 13) .field("resize-allowed", false) .build(); let elem_props_map = ElementProperties::builder_map()