mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
gst-pbutils: add IdStr builder setters
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1531>
This commit is contained in:
parent
0d28cbceac
commit
ebe3d72bae
1 changed files with 86 additions and 1 deletions
|
@ -183,6 +183,24 @@ impl ElementPropertiesGeneralBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn field_value_with_static(
|
||||||
|
mut self,
|
||||||
|
property_name: impl AsRef<glib::GStr> + '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<IdStr>,
|
||||||
|
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<glib::SendValue>) -> Self {
|
pub fn field_value_if_some(self, property_name: &str, value: Option<glib::SendValue>) -> Self {
|
||||||
if let Some(value) = value {
|
if let Some(value) = value {
|
||||||
self.field_value(property_name, 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<glib::GStr> + 'static,
|
||||||
|
value: Option<glib::SendValue>,
|
||||||
|
) -> 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<IdStr>,
|
||||||
|
value: Option<glib::SendValue>,
|
||||||
|
) -> Self {
|
||||||
|
if let Some(value) = value {
|
||||||
|
self.field_value_with_id(property_name, value)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build(self) -> ElementProperties {
|
pub fn build(self) -> ElementProperties {
|
||||||
ElementProperties(self.structure)
|
ElementProperties(self.structure)
|
||||||
}
|
}
|
||||||
|
@ -347,6 +389,24 @@ impl ElementPropertiesMapItemBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn field_value_with_static(
|
||||||
|
mut self,
|
||||||
|
property_name: impl AsRef<glib::GStr> + '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<IdStr>,
|
||||||
|
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<glib::SendValue>) -> Self {
|
pub fn field_value_if_some(self, property_name: &str, value: Option<glib::SendValue>) -> Self {
|
||||||
if let Some(value) = value {
|
if let Some(value) = value {
|
||||||
self.field_value(property_name, 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<glib::GStr> + 'static,
|
||||||
|
value: Option<glib::SendValue>,
|
||||||
|
) -> 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<IdStr>,
|
||||||
|
value: Option<glib::SendValue>,
|
||||||
|
) -> Self {
|
||||||
|
if let Some(value) = value {
|
||||||
|
self.field_value_with_id(property_name, value)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build(self) -> ElementPropertiesMapItem {
|
pub fn build(self) -> ElementPropertiesMapItem {
|
||||||
ElementPropertiesMapItem(self.structure)
|
ElementPropertiesMapItem(self.structure)
|
||||||
}
|
}
|
||||||
|
@ -363,6 +447,7 @@ impl ElementPropertiesMapItemBuilder {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use gst::idstr;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn element_properties_getters() {
|
fn element_properties_getters() {
|
||||||
|
@ -377,7 +462,7 @@ mod test {
|
||||||
assert_eq!(elem_props_general.map(), None);
|
assert_eq!(elem_props_general.map(), None);
|
||||||
|
|
||||||
let elem_factory_props_map = ElementPropertiesMapItem::builder("vp8enc")
|
let elem_factory_props_map = ElementPropertiesMapItem::builder("vp8enc")
|
||||||
.field("cq-level", 13)
|
.field_with_id(idstr!("cq-level"), 13)
|
||||||
.field("resize-allowed", false)
|
.field("resize-allowed", false)
|
||||||
.build();
|
.build();
|
||||||
let elem_props_map = ElementProperties::builder_map()
|
let elem_props_map = ElementProperties::builder_map()
|
||||||
|
|
Loading…
Reference in a new issue