mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-10-31 22:59:14 +00:00
inspect: Print element class hierarchy
This commit is contained in:
parent
92ec3a6166
commit
dadf35f6aa
1 changed files with 31 additions and 0 deletions
|
@ -27,6 +27,8 @@ const PLUGIN_NAME_COLOR: Color = BRBLUE;
|
|||
const ELEMENT_NAME_COLOR: Color = Color::Green;
|
||||
const PROP_NAME_COLOR: Color = BRBLUE;
|
||||
const HEADING_COLOR: Color = Color::Yellow;
|
||||
const DATA_TYPE_COLOR: Color = Color::Green;
|
||||
const CHILD_LINK_COLOR: Color = Color::Purple;
|
||||
|
||||
fn print_element_list() {
|
||||
let registry = gst::Registry::get();
|
||||
|
@ -63,6 +65,7 @@ fn print_factory_details_info(factory: &gst::ElementFactory) {
|
|||
print_property("Klass", factory.klass());
|
||||
print_property("Description", factory.description());
|
||||
print_property("Author", factory.author());
|
||||
println!();
|
||||
}
|
||||
|
||||
fn print_plugin_info(plugin: &gst::Plugin) {
|
||||
|
@ -88,6 +91,33 @@ fn print_plugin_info(plugin: &gst::Plugin) {
|
|||
}
|
||||
print_property("Binary package", plugin.package().as_str());
|
||||
print_property("Origin URL", plugin.origin().as_str());
|
||||
println!();
|
||||
}
|
||||
|
||||
fn hierarchy_foreach<F>(type_: gst::glib::Type, foreach_func: &mut F)
|
||||
where
|
||||
F: FnMut(gst::glib::Type),
|
||||
{
|
||||
if let Some(parent) = type_.parent() {
|
||||
hierarchy_foreach(parent, foreach_func);
|
||||
}
|
||||
|
||||
foreach_func(type_);
|
||||
}
|
||||
|
||||
fn print_hierarchy(type_: gst::glib::Type) {
|
||||
let mut level = 0;
|
||||
let mut func = |cur_type: gst::glib::Type| {
|
||||
if level > 0 {
|
||||
print!("{}", " ".repeat(level - 1));
|
||||
print!(" {}", CHILD_LINK_COLOR.paint("+----"));
|
||||
}
|
||||
println!("{}", DATA_TYPE_COLOR.paint(cur_type.name()));
|
||||
level += 1;
|
||||
};
|
||||
|
||||
hierarchy_foreach(type_, &mut func);
|
||||
println!();
|
||||
}
|
||||
|
||||
fn print_element_info(feature: &gst::PluginFeature) -> Result<(), String> {
|
||||
|
@ -108,6 +138,7 @@ fn print_element_info(feature: &gst::PluginFeature) -> Result<(), String> {
|
|||
if let Some(plugin) = feature.plugin() {
|
||||
print_plugin_info(&plugin);
|
||||
}
|
||||
print_hierarchy(element.type_());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue