mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-12-21 07:26:28 +00:00
element: element property special convert for enum and flags
In element_property, add special case enum and flags property to use a better value such as nick or the proper u32 flags
This commit is contained in:
parent
bed8d6a58e
commit
a6f03db8f6
1 changed files with 19 additions and 8 deletions
|
@ -156,13 +156,24 @@ impl ElementInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn element_property(element: &gst::Element, property_name: &str) -> anyhow::Result<String> {
|
pub fn element_property(element: &gst::Element, property_name: &str) -> anyhow::Result<String> {
|
||||||
let value = element
|
let value = element.property_value(property_name);
|
||||||
.property_value(property_name)
|
if value.type_().is_a(glib::Type::ENUM) {
|
||||||
.transform::<String>()
|
let value = value.get::<&glib::EnumValue>().unwrap().nick().to_string();
|
||||||
.expect("Unable to transform to string")
|
Ok(value)
|
||||||
.get::<String>()
|
} else if value.type_().is_a(glib::Type::FLAGS) {
|
||||||
.unwrap_or_default();
|
let value = value.get::<Vec<&glib::FlagsValue>>().unwrap();
|
||||||
Ok(value)
|
let flags = value.iter().copied().fold(0, |acc, val| acc | val.value());
|
||||||
|
|
||||||
|
Ok(flags.to_string())
|
||||||
|
} else {
|
||||||
|
let value = value
|
||||||
|
.transform::<String>()
|
||||||
|
.expect("Unable to transform to string")
|
||||||
|
.get::<String>()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_lowercase();
|
||||||
|
Ok(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn element_property_by_feature_name(
|
pub fn element_property_by_feature_name(
|
||||||
|
@ -181,7 +192,7 @@ impl ElementInfo {
|
||||||
element: &gst::Element,
|
element: &gst::Element,
|
||||||
) -> anyhow::Result<HashMap<String, glib::ParamSpec>> {
|
) -> anyhow::Result<HashMap<String, glib::ParamSpec>> {
|
||||||
let mut properties_list = HashMap::new();
|
let mut properties_list = HashMap::new();
|
||||||
let params = element.class().list_properties();
|
let params = element.list_properties();
|
||||||
|
|
||||||
for param in params.iter() {
|
for param in params.iter() {
|
||||||
GPS_INFO!("Property_name {}", param.name());
|
GPS_INFO!("Property_name {}", param.name());
|
||||||
|
|
Loading…
Reference in a new issue