feat: add ffmpeg audio plugin and migrate verbosity to tracing levels
Release / check-release (push) Successful in 59s
Release / build_gnu (push) Skipped
Release / build_musl (push) Skipped
Release / build_windows (push) Skipped
Release / package_gnu (deb) (push) Skipped
Release / package_gnu (rpm) (push) Skipped
Release / package_musl (deb) (push) Skipped
Release / package_musl (rpm) (push) Skipped
Release / publish-release (push) Skipped
CI / Test (push) Successful in 1m44s
CI / Build Linux (push) Successful in 2m3s
Release / check-release (push) Successful in 59s
Release / build_gnu (push) Skipped
Release / build_musl (push) Skipped
Release / build_windows (push) Skipped
Release / package_gnu (deb) (push) Skipped
Release / package_gnu (rpm) (push) Skipped
Release / package_musl (deb) (push) Skipped
Release / package_musl (rpm) (push) Skipped
Release / publish-release (push) Skipped
CI / Test (push) Successful in 1m44s
CI / Build Linux (push) Successful in 2m3s
This commit is contained in:
+25
-42
@@ -19,48 +19,39 @@ use std::time::Instant;
|
||||
pub fn run_conversion(
|
||||
path: &[(&dyn Plugin, &str, &str)],
|
||||
input: &[u8],
|
||||
verbosity: u8,
|
||||
temp_dir: &Path,
|
||||
) -> Result<Vec<u8>, String> {
|
||||
if verbosity >= 1 {
|
||||
let path_str: Vec<_> = path.iter().map(|(p, _, _)| p.name()).collect();
|
||||
eprintln!("Path taken: {}", path_str.join(" -> "));
|
||||
}
|
||||
let path_str: Vec<_> = path.iter().map(|(p, _, _)| p.name()).collect();
|
||||
tracing::info!("Path taken: {}", path_str.join(" -> "));
|
||||
|
||||
let mut current_data = input.to_vec();
|
||||
|
||||
for (plugin, from_format, to_format) in path {
|
||||
if verbosity >= 2 {
|
||||
eprintln!(
|
||||
"Converting {} to {} using plugin {}...",
|
||||
from_format,
|
||||
to_format,
|
||||
plugin.name()
|
||||
);
|
||||
}
|
||||
tracing::info!(
|
||||
"Converting {} to {} using plugin {}...",
|
||||
from_format,
|
||||
to_format,
|
||||
plugin.name()
|
||||
);
|
||||
|
||||
if verbosity >= 4 {
|
||||
eprintln!("[Plugin Log] Running plugin: {}", plugin.name());
|
||||
eprintln!("[Plugin Log] Source format: {}", from_format);
|
||||
eprintln!("[Plugin Log] Target format: {}", to_format);
|
||||
eprintln!(
|
||||
"[Plugin Log] Metrics - Familiarity: {}, Quality: {}, Speed: {}",
|
||||
plugin.familiarity(*from_format, *to_format),
|
||||
plugin.quality(*from_format, *to_format),
|
||||
plugin.speed(*from_format, *to_format)
|
||||
);
|
||||
}
|
||||
tracing::debug!("[Plugin Log] Running plugin: {}", plugin.name());
|
||||
tracing::debug!("[Plugin Log] Source format: {}", from_format);
|
||||
tracing::debug!("[Plugin Log] Target format: {}", to_format);
|
||||
tracing::debug!(
|
||||
"[Plugin Log] Metrics - Familiarity: {}, Quality: {}, Speed: {}",
|
||||
plugin.familiarity(*from_format, *to_format),
|
||||
plugin.quality(*from_format, *to_format),
|
||||
plugin.speed(*from_format, *to_format)
|
||||
);
|
||||
|
||||
let start_time = Instant::now();
|
||||
current_data = plugin.convert(¤t_data, from_format, to_format, temp_dir)?;
|
||||
let elapsed = start_time.elapsed();
|
||||
|
||||
if verbosity >= 3 {
|
||||
eprintln!(
|
||||
"Step '{} -> {}' completed in {:.2?}",
|
||||
from_format, to_format, elapsed
|
||||
);
|
||||
}
|
||||
tracing::info!(
|
||||
"Step '{} -> {}' completed in {:?}",
|
||||
from_format, to_format, elapsed
|
||||
);
|
||||
}
|
||||
|
||||
Ok(current_data)
|
||||
@@ -114,7 +105,7 @@ mod tests {
|
||||
}
|
||||
|
||||
macro_rules! test_runner {
|
||||
($name:ident, $verbosity:expr, $fail:expr, $expected_res:expr, $expected_len:expr) => {
|
||||
($name:ident, $fail:expr, $expected_res:expr, $expected_len:expr) => {
|
||||
#[test]
|
||||
fn $name() {
|
||||
let plugin = MockPlugin {
|
||||
@@ -128,7 +119,7 @@ mod tests {
|
||||
let input = vec![0];
|
||||
|
||||
let result =
|
||||
run_conversion(&path, &input, $verbosity, std::path::Path::new("/dev/shm"));
|
||||
run_conversion(&path, &input, std::path::Path::new("/dev/shm"));
|
||||
assert_eq!(result.is_ok(), $expected_res);
|
||||
if let Ok(res) = result {
|
||||
assert_eq!(res.len(), $expected_len);
|
||||
@@ -137,14 +128,6 @@ mod tests {
|
||||
};
|
||||
}
|
||||
|
||||
test_runner!(test_runner_verb_0, 0, false, true, 2);
|
||||
test_runner!(test_runner_verb_1, 1, false, true, 2);
|
||||
test_runner!(test_runner_verb_2, 2, false, true, 2);
|
||||
test_runner!(test_runner_verb_3, 3, false, true, 2);
|
||||
test_runner!(test_runner_verb_4, 4, false, true, 2);
|
||||
test_runner!(test_runner_verb_5, 5, false, true, 2);
|
||||
test_runner!(test_runner_verb_0_fail, 0, true, false, 0);
|
||||
test_runner!(test_runner_verb_1_fail, 1, true, false, 0);
|
||||
test_runner!(test_runner_verb_4_fail, 4, true, false, 0);
|
||||
test_runner!(test_runner_verb_255, 255, false, true, 2);
|
||||
test_runner!(test_runner_verb_0, false, true, 2);
|
||||
test_runner!(test_runner_verb_0_fail, true, false, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user