Commit 206e9809 authored by Zeeshan Ali's avatar Zeeshan Ali

Add gst-inspect

Same as the usual gst-inspect but written in Rust.
parent e47a3509
...@@ -17,4 +17,5 @@ members = [ ...@@ -17,4 +17,5 @@ members = [
"gstreamer-editing-services", "gstreamer-editing-services",
"examples", "examples",
"tutorials", "tutorials",
"tools",
] ]
[package]
name = "tools"
version = "0.12.0"
authors = ["Zeeshan Ali <zeeshanak@gnome.org>"]
[dependencies]
glib = { git = "https://github.com/gtk-rs/glib" }
glib-sys = { git = "https://github.com/gtk-rs/sys" }
gstreamer = { path = "../gstreamer" }
gstreamer-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys" }
[[bin]]
name = "gst-inspect"
path = "src/gst-inspect.rs"
extern crate gstreamer as gst;
extern crate gstreamer_sys as gst_ffi;
use gst::prelude::*;
extern crate glib;
extern crate glib_sys as glib_ffi;
fn main() {
if let Err(e) = gst::init() {
// FIXME: Color output
println!("Error initializing GStreamer: {}", e);
std::process::exit(-1);
}
print_element_list(false);
}
fn print_element_list(print_all: bool) {
let registry = gst::Registry::get();
let plugins = registry.get_plugin_list();
let mut n_blacklisted = 0;
let mut n_features = 0;
for ref plugin in &plugins {
if get_plugin_flags(&plugin).contains(gst::PluginFlags::BLACKLISTED) {
n_blacklisted = n_blacklisted + 1;
continue;
}
let name = plugin.get_plugin_name();
for feature in registry.get_feature_list_by_plugin(&name) {
n_features = n_features + 1;
if let Some(factory) = feature.downcast_ref::<gst::ElementFactory>() {
if print_all {
print_element_info(&feature, true);
} else if let Some(metadata) = factory.get_metadata(&gst::ELEMENT_METADATA_LONGNAME)
{
println!("{}: {}: {}", name, factory.get_name(), metadata);
}
} else if let Some(factory) = feature.downcast_ref::<gst::TypeFindFactory>() {
if print_all {
continue;
}
print!("{}: {}: ", name, factory.get_name());
let extensions = factory.get_extensions();
if extensions.len() != 0 {
let mut i = 0;
for extension in extensions {
if i != 0 {
print!(", ");
}
print!("{}", extension);
i = i + 1;
}
println!("");
} else {
println!("no extensions");
}
} else {
if !print_all {
println!("{}: {}: {}", name, feature.get_name(), feature.get_type());
}
}
}
}
print!("\nTotal count: {} plugins", plugins.len());
if n_blacklisted != 0 {
print!(
" ({} blacklisted {} not shown)",
n_blacklisted,
if n_blacklisted > 1 {
"entries"
} else {
"entry"
}
);
}
println!(
", {} {}",
n_features,
if n_features > 1 {
"features"
} else {
"feature"
}
);
}
fn print_element_info(_feature: &gst::PluginFeature, _print_names: bool) {
// FIXME: Implement.
}
fn get_plugin_flags(plugin: &gst::Plugin) -> gst::PluginFlags {
unsafe {
use glib::translate::{from_glib, ToGlibPtr};
use gst_ffi;
let ptr: *mut gst_ffi::GstObject = plugin.to_glib_none().0;
return from_glib((*ptr).flags);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment