Merge pull request #178 from jb-alvarado/master

stop program when config from argument is not found
This commit is contained in:
jb-alvarado 2022-08-19 10:31:41 +02:00 committed by GitHub
commit d1ca6168b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 34 deletions

45
Cargo.lock generated
View File

@ -378,10 +378,11 @@ dependencies = [
[[package]]
name = "async-io"
version = "1.7.0"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5e18f61464ae81cde0a23e713ae8fd299580c54d697a35820cfd0625b8b0e07"
checksum = "0ab006897723d9352f63e2b13047177c3982d8d79709d713ce7747a8f19fd1b0"
dependencies = [
"autocfg",
"concurrent-queue",
"futures-lite",
"libc",
@ -575,9 +576,9 @@ dependencies = [
[[package]]
name = "bumpalo"
version = "3.10.0"
version = "3.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"
[[package]]
name = "byteorder"
@ -725,9 +726,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "cpufeatures"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b"
checksum = "1079fb8528d9f9c888b1e8aa651e6e079ade467323d58f75faf1d30b1808f540"
dependencies = [
"libc",
]
@ -873,9 +874,9 @@ dependencies = [
[[package]]
name = "either"
version = "1.7.0"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "email-encoding"
@ -1303,9 +1304,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57"
checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be"
dependencies = [
"bytes",
"fnv",
@ -1452,9 +1453,9 @@ dependencies = [
[[package]]
name = "iana-time-zone"
version = "0.1.44"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf7d67cf4a22adc5be66e75ebdf769b3f2ea032041437a7061f97a63dad4b"
checksum = "ad2bfd338099682614d3ee3fe0cd72e0b6a41ca6a87f6a74a3bd593c91650501"
dependencies = [
"android_system_properties",
"core-foundation-sys",
@ -1685,9 +1686,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.131"
version = "0.2.132"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04c3b4822ccebfa39c02fc03d1534441b22ead323fa0f48bb7ddd8e6ba076a40"
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
[[package]]
name = "libsqlite3-sys"
@ -1956,9 +1957,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.13.0"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e"
[[package]]
name = "openssl"
@ -2115,18 +2116,18 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pin-project"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78203e83c48cffbe01e4a2d35d566ca4de445d79a85372fc64e378bfc812a260"
checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.0.11"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "710faf75e1b33345361201d36d04e98ac1ed8909151a017ed384700836104c74"
checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
dependencies = [
"proc-macro2",
"quote",
@ -2416,9 +2417,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "security-framework"
version = "2.6.1"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc"
checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c"
dependencies = [
"bitflags",
"core-foundation",

View File

@ -459,6 +459,8 @@ fn gen_source(
mut node: Media,
filter_chain: &Arc<Mutex<Vec<String>>>,
) -> Media {
let duration = node.out - node.seek;
if valid_source(&node.source) {
node.add_probe();
@ -474,7 +476,6 @@ fn gen_source(
node.cmd = Some(seek_and_length(&node));
}
} else {
let duration = node.out - node.seek;
let probe = MediaProbe::new(&config.storage.filler_clip);
if node.source.is_empty() {
@ -501,7 +502,6 @@ fn gen_source(
.and_then(|d| d.parse::<f64>().ok())
{
// create placeholder from config filler.
node.source = config.storage.filler_clip.clone();
node.duration = length;
node.out = duration;
@ -517,9 +517,9 @@ fn gen_source(
node.add_filter(config, filter_chain);
if node.out - node.seek < 1.0 {
if duration < 1.0 {
warn!(
"Clip is less then 1 second long, skip: <b><magenta>{}</></b>",
"Clip is less then 1 second long (<yellow>{duration:.3}</>), skip: <b><magenta>{}</></b>",
node.source
);

View File

@ -3,10 +3,11 @@ use clap::Parser;
#[derive(Parser, Debug, Clone)]
#[clap(version,
about = "ffplayout, Rust based 24/7 playout solution.",
override_usage = "Run without any command to use config file only, or with commands to override parameters:\n\n ffplayout [OPTIONS]",
override_usage = "Run without any command to use config file only, or with commands to override parameters:
\n ffplayout (ARGS) [OPTIONS]\n\n Pass channel name only in multi channel environment!",
long_about = None)]
pub struct Args {
#[clap(index = 1, value_parser)]
#[clap(index = 1, value_parser, help = "Channel name")]
pub channel: Option<String>,
#[clap(short, long, help = "File path to ffplayout.yml")]

View File

@ -1,4 +1,7 @@
use std::path::{Path, PathBuf};
use std::{
path::{Path, PathBuf},
process::exit,
};
pub mod arg_parse;
@ -10,15 +13,18 @@ pub fn get_config(args: Args) -> PlayoutConfig {
Some(c) => {
let path = PathBuf::from(format!("/etc/ffplayout/{c}.yml"));
if path.is_file() {
Some(path.display().to_string())
} else {
println!("no file");
args.config
if !path.is_file() {
println!(
"Config file \"{c}\" under \"/etc/ffplayout/\" not found.\n\nCheck arguments!"
);
exit(1)
}
Some(path.display().to_string())
}
None => args.config,
};
let mut config = PlayoutConfig::new(cfg_path);
if let Some(gen) = args.generate {