mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 21:46:22 +00:00
devtools: Remove the gstdump binary as the 'dots' tracer replaces it
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7999>
This commit is contained in:
parent
174460770b
commit
fcfa668a27
5 changed files with 29 additions and 147 deletions
|
@ -175,7 +175,7 @@ def is_library_target_and_not_plugin(target, filename):
|
|||
|
||||
|
||||
def is_binary_target_and_in_path(target, filename, bindir):
|
||||
if target['name'] in ['gst-dots-viewer', 'gstdump']:
|
||||
if target['name'] in ['gst-dots-viewer']:
|
||||
return True
|
||||
|
||||
if target['type'] != 'executable':
|
||||
|
|
|
@ -30,12 +30,6 @@ windows = { version = "0.59", features = ["Win32_UI_Shell"] }
|
|||
[build-dependencies]
|
||||
static-files = "0.2.1"
|
||||
|
||||
# Binary target for gstdots
|
||||
[[bin]]
|
||||
name = "gst-dots-viewer"
|
||||
path = "src/main.rs"
|
||||
|
||||
# Binary target for gstdump
|
||||
[[bin]]
|
||||
name = "gstdump"
|
||||
path = "src/gstdump.rs"
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
# gst-dots-viewer
|
||||
|
||||
|
||||

|
||||
|
||||
Simple web server that watches a directory for GStreamer `*.dot` files in a local path and
|
||||
serves them as a web page allowing you to browse them easily. See
|
||||
Simple web server that watches a directory for GStreamer `*.dot` files in a
|
||||
local path and serves them as a web page allowing you to browse them easily. See
|
||||
`gst-dots-viewer --help` for more information.
|
||||
|
||||
## How to use it
|
||||
|
||||
This tool uses the `GST_DEBUG_DUMP_DOT_DIR` environment variable to locate the dot
|
||||
files generated by GStreamer and defaults to `$XDG_CACHE_DIR/gstreamer-dots/` if it is not set.
|
||||
This tool uses the `GST_DEBUG_DUMP_DOT_DIR` environment variable to locate the
|
||||
dot files generated by GStreamer and defaults to
|
||||
`$XDG_CACHE_DIR/gstreamer-dots/` if it is not set.
|
||||
|
||||
You can run it with:
|
||||
|
||||
|
@ -18,44 +18,44 @@ You can run it with:
|
|||
cargo run
|
||||
```
|
||||
|
||||
Then you can open your browser at `http://localhost:3000` and wait for the graphs to appear as you use your
|
||||
GStreamer application. The web page is updated every time a new `.dot` file is placed
|
||||
in the path pointed by the folder watched by the `gst-dots-viewer` server.
|
||||
Then you can open your browser at `http://localhost:3000` and wait for the
|
||||
graphs to appear as you use your GStreamer application. The web page is updated
|
||||
every time a new `.dot` file is placed in the path pointed by the folder watched
|
||||
by the `gst-dots-viewer` server.
|
||||
|
||||
## The `gstdump` utility
|
||||
## The `dots` tracer
|
||||
|
||||
In order to simplify generating the dot files when developing GStreamer applications,
|
||||
we provide the `gstdump` tool that can be used to **remove** old `.dot`
|
||||
files and setup the [`pipeline-snapshot`](tracer-pipeline-snapshot) tracer with the following parameters:
|
||||
In order to simplify generating the dot files when developing GStreamer
|
||||
applications, we provide the `dots` tracer that can be used to **remove** old
|
||||
`.dot` files and setup the [`pipeline-snapshot`](tracer-pipeline-snapshot)
|
||||
tracer with the following parameters:
|
||||
|
||||
- `xdg-cache=true`: Use the default 'cache' directory to store `.dot` files,
|
||||
the same as what `gst-dots-viewer` uses by default
|
||||
- `xdg-cache=true`: Use the default 'cache' directory to store `.dot` files, the
|
||||
same as what `gst-dots-viewer` uses by default
|
||||
- `folder-mode=numbered`: Use folders to store the `.dot` files, with
|
||||
incrementing number each time pipelines are dumped
|
||||
incrementing number each time pipelines are dumped
|
||||
|
||||
If you have already configured the `pipeline-snapshot` tracer using the
|
||||
`GST_TRACER` environment variable, `gstdump` will not override it.
|
||||
|
||||
`gstdump` also sets `GST_DEBUG_DUMP_DOT_DIR` to the path where `gst-dots-viewer` expects them
|
||||
so pipelines that are 'manually' dumped by the application are also dumped.
|
||||
The `dots` tracer also sets `GST_DEBUG_DUMP_DOT_DIR` to the path where
|
||||
`gst-dots-viewer` expects them so pipelines that are 'manually' dumped by the
|
||||
application are also dumped.
|
||||
|
||||
## Demo
|
||||
|
||||
How to use `gstdump`, gst-dots-viewer used in combination with the [tracer-pipeline-snapshot](tracer-pipeline-snapshot)
|
||||
How to use the `dots` tracer, gst-dots-viewer used in combination with the
|
||||
[tracer-pipeline-snapshot](tracer-pipeline-snapshot)
|
||||
|
||||
### Start gst-dots
|
||||
|
||||
``` sh
|
||||
```sh
|
||||
# Starts the `gst-dots-viewer` server with default parameters
|
||||
# You can open it in your browser at http://localhost:3000
|
||||
$ gst-dots-viewer
|
||||
```
|
||||
|
||||
### Start the GStreamer pipeline with `pipeline-snapshot` and `gstdump`
|
||||
### Start the GStreamer pipeline with `pipeline-snapshot` through the `dots` tracer
|
||||
|
||||
|
||||
``` sh
|
||||
# This runs the pipeline with `gstdump` which sets up:
|
||||
```sh
|
||||
# This runs the pipeline with the `dots` tracer which sets up:
|
||||
#
|
||||
# - the `pipeline-snapshot` tracer with the following parameters:
|
||||
# - `dots-viewer-ws-url=ws://127.0.0.1:3000/snapshot/`: Sets the URL
|
||||
|
@ -68,7 +68,7 @@ $ gst-dots-viewer
|
|||
# - `GST_DEBUG_DUMP_DOT_DIR` path so pipelines that are 'manually' dumped by
|
||||
# `gst-launch-1.0` are also dumped.
|
||||
|
||||
gstdump gst-launch-1.0 videotestsrc ! webrtcsink run-signalling-server=true0
|
||||
GST_TRACERS=dots gst-launch-1.0 videotestsrc ! webrtcsink run-signalling-server=true0
|
||||
```
|
||||
|
||||
### Dump pipelines from the web interface
|
||||
|
|
|
@ -34,7 +34,7 @@ if get_option('default_library') == 'static'
|
|||
}
|
||||
endif
|
||||
|
||||
foreach binname: ['gst-dots-viewer', 'gstdump']
|
||||
foreach binname: ['gst-dots-viewer']
|
||||
custom_target(binname,
|
||||
build_by_default: true,
|
||||
output: binname + exe_suffix,
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
use dirs::cache_dir;
|
||||
use glob::glob;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use tracing::{error, info};
|
||||
|
||||
fn main() {
|
||||
tracing_subscriber::fmt()
|
||||
.compact()
|
||||
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::CLOSE)
|
||||
.with_env_filter(
|
||||
tracing_subscriber::filter::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| tracing_subscriber::filter::EnvFilter::new("warn")),
|
||||
)
|
||||
.init();
|
||||
// Determine the directory to use for dumping GStreamer pipelines
|
||||
let gstdot_path = env::var("GST_DEBUG_DUMP_DOT_DIR")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|_| {
|
||||
let mut path = cache_dir().expect("Failed to find cache directory");
|
||||
path.push("gstreamer-dots");
|
||||
path
|
||||
});
|
||||
|
||||
let args: Vec<String> = env::args().skip(1).collect();
|
||||
let delete = args.first().map_or(true, |arg| {
|
||||
if ["--help", "-h"].contains(&arg.as_str()) {
|
||||
eprintln!("Usage: gstdump [-n | --no-delete] [command]");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
!["-n", "--no-delete"].contains(&arg.as_str())
|
||||
});
|
||||
|
||||
// Ensure the directory exists
|
||||
fs::create_dir_all(&gstdot_path).expect("Failed to create dot directory");
|
||||
|
||||
info!("Dumping GStreamer pipelines into {:?}", gstdot_path);
|
||||
let command_idx = if delete {
|
||||
// Build the glob pattern and remove existing .dot files
|
||||
let pattern = gstdot_path.join("**/*.dot").to_string_lossy().into_owned();
|
||||
info!("Removing existing .dot files matching {pattern}");
|
||||
for entry in glob(&pattern).expect("Failed to read glob pattern") {
|
||||
match entry {
|
||||
Ok(path) => {
|
||||
if path.is_file() {
|
||||
fs::remove_file(path).expect("Failed to remove file");
|
||||
}
|
||||
}
|
||||
Err(e) => error!("Error reading file: {}", e),
|
||||
}
|
||||
}
|
||||
0
|
||||
} else {
|
||||
1
|
||||
};
|
||||
|
||||
// Set the environment variable to use the determined directory
|
||||
env::set_var("GST_DEBUG_DUMP_DOT_DIR", &gstdot_path);
|
||||
match Command::new("gst-inspect-1.0")
|
||||
.args(["--exists", "pipeline-snapshot"])
|
||||
.status()
|
||||
{
|
||||
Ok(status) => {
|
||||
if !status.success() {
|
||||
error!(
|
||||
"WARNING: pipeline-snapshot tracer not found. \
|
||||
Please ensure that the `rstracers` plugin is installed."
|
||||
);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!(
|
||||
"WARNING: Could not run gst-inspect-1.0: {e} \
|
||||
to check the presence of the `pipeline-snapshot` tracer.\n\
|
||||
WARNING: Please ensure GStreamer is properly installed."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let default_pipeline_snapshot = "pipeline-snapshot(dots-viewer-ws-url=ws://127.0.0.1:3000/snapshot/,xdg-cache=true,folder-mode=numbered)";
|
||||
env::set_var(
|
||||
"GST_TRACERS",
|
||||
env::var("GST_TRACERS").map_or_else(
|
||||
|_| default_pipeline_snapshot.to_string(),
|
||||
|tracers| {
|
||||
if !tracers.contains("pipeline-snapshot") {
|
||||
info!("pipeline-snapshot already enabled");
|
||||
|
||||
tracers
|
||||
} else {
|
||||
format!("{tracers},{default_pipeline_snapshot}")
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Run the command provided in arguments
|
||||
info!("Running {:?}", &args[command_idx..]);
|
||||
if args.len() >= command_idx {
|
||||
let output = Command::new(&args[command_idx])
|
||||
.args(&args[command_idx + 1..])
|
||||
.status();
|
||||
|
||||
match output {
|
||||
Ok(_status) => (),
|
||||
Err(e) => error!("Error: {e:?}"),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue