prepare engine for multi channel support

This commit is contained in:
jb-alvarado 2022-07-18 16:39:22 +02:00
parent 2a7a3621e4
commit 01a464dce5
6 changed files with 68 additions and 33 deletions

59
Cargo.lock generated
View File

@ -626,7 +626,7 @@ dependencies = [
[[package]]
name = "chrono"
version = "0.4.20-beta.1"
source = "git+https://github.com/chronotope/chrono.git#051e1170c41477ce162301c8711110a4577c1a23"
source = "git+https://github.com/chronotope/chrono.git#187819ff43e0e4da351b3ea4ac2d3076e06e8251"
dependencies = [
"num-integer",
"num-traits",
@ -636,9 +636,9 @@ dependencies = [
[[package]]
name = "clap"
version = "3.2.8"
version = "3.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83"
checksum = "ab8b79fe3946ceb4a0b1c080b4018992b8d27e9ff363644c1c9b6387c854614d"
dependencies = [
"atty",
"bitflags",
@ -675,9 +675,9 @@ dependencies = [
[[package]]
name = "concurrent-queue"
version = "1.2.2"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3"
checksum = "83827793632c72fa4f73c2edb31e7a997527dd8ffe7077344621fc62c5478157"
dependencies = [
"cache-padded",
]
@ -880,9 +880,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "crypto-common"
version = "0.1.5"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ccfd8c0ee4cce11e45b3fd6f9d5e69e0cc62912aa6a0cb1bf4617b0eba5a12f"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
@ -1009,7 +1009,7 @@ dependencies = [
[[package]]
name = "ffplayout"
version = "0.10.5"
version = "0.10.6"
dependencies = [
"clap",
"crossbeam-channel 0.5.5",
@ -1135,7 +1135,7 @@ dependencies = [
"futures-core",
"futures-sink",
"pin-project",
"spin 0.9.3",
"spin 0.9.4",
]
[[package]]
@ -1406,9 +1406,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.12.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashlink"
@ -1543,7 +1543,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown 0.12.2",
"hashbrown 0.12.3",
]
[[package]]
@ -2084,9 +2084,9 @@ dependencies = [
[[package]]
name = "os_str_bytes"
version = "6.1.0"
version = "6.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4"
[[package]]
name = "paris"
@ -2167,9 +2167,9 @@ checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc"
[[package]]
name = "pem"
version = "1.0.2"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9a3b09a20e374558580a4914d3b7d89bd61b954a5a5e1dcbea98753addb1947"
checksum = "03c64931a1a212348ec4f3b4362585eca7159d0d09cbdf4a7f74f02173596fd4"
dependencies = [
"base64",
]
@ -2548,18 +2548,18 @@ checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1"
[[package]]
name = "serde"
version = "1.0.138"
version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47"
checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.138"
version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c"
checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb"
dependencies = [
"proc-macro2",
"quote",
@ -2591,9 +2591,9 @@ dependencies = [
[[package]]
name = "serde_yaml"
version = "0.8.25"
version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ec0091e1f5aa338283ce049bd9dfefd55e1f168ac233e85c1ffe0038fb48cbe"
checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b"
dependencies = [
"indexmap",
"ryu",
@ -2692,9 +2692,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "spin"
version = "0.9.3"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c530c2b0d0bf8b69304b39fe2001993e267461948b890cd037d8ad4293fa1a0d"
checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09"
dependencies = [
"lock_api",
]
@ -2932,10 +2932,11 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.19.2"
version = "1.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439"
checksum = "57aec3cfa4c296db7255446efb4928a6be304b431a806216105542a67b6ca82e"
dependencies = [
"autocfg",
"bytes",
"libc",
"memchr",
@ -3070,9 +3071,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]]
name = "unicode-ident"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
[[package]]
name = "unicode-normalization"
@ -3391,7 +3392,7 @@ dependencies = [
[[package]]
name = "zeromq"
version = "0.3.3"
source = "git+https://github.com/zeromq/zmq.rs.git#9e0eb7c16950146d285d952939ea8d5a5fc812c9"
source = "git+https://github.com/zeromq/zmq.rs.git#c7cbd1c0d589c9d671626c7fa5ba26843c0ab219"
dependencies = [
"async-std",
"async-trait",

View File

@ -1,3 +1,5 @@
# give user www-data permission to control the ffplayout systemd service
www-data ALL = NOPASSWD: /bin/systemctl start ffplayout.service, /bin/systemctl stop ffplayout.service, /bin/systemctl reload ffplayout.service, /bin/systemctl restart ffplayout.service, /bin/systemctl status ffplayout.service, /bin/systemctl is-active ffplayout.service
www-data ALL = NOPASSWD: /bin/systemctl start ffplayout@*, /bin/systemctl stop ffplayout@*, /bin/systemctl reload ffplayout@*, /bin/systemctl restart ffplayout@*, /bin/systemctl status ffplayout@*, /bin/systemctl is-active ffplayout@*, /bin/systemctl enable ffplayout@*, /bin/systemctl disable ffplayout@*

14
assets/ffplayout@.service Normal file
View File

@ -0,0 +1,14 @@
[Unit]
Description=Rust and ffmpeg based multi channel playout solution
After=network.target remote-fs.target
[Service]
ExecStart=/usr/bin/ffplayout %I
Restart=always
RestartSec=1
KillMode=mixed
User=www-data
Group=www-data
[Install]
WantedBy=multi-user.target

View File

@ -4,7 +4,7 @@ description = "24/7 playout based on rust and ffmpeg"
license = "GPL-3.0"
authors = ["Jonathan Baecker jonbae77@gmail.com"]
readme = "README.md"
version = "0.10.5"
version = "0.10.6"
edition = "2021"
[dependencies]
@ -48,6 +48,7 @@ assets = [
"755"
],
["../assets/ffpapi.service", "/lib/systemd/system/", "644"],
["../assets/ffplayout@.service", "/lib/systemd/system/", "644"],
["../assets/11-ffplayout", "/etc/sudoers.d/", "644"],
["../assets/ffplayout.yml", "/etc/ffplayout/", "644"],
["../assets/logo.png", "/usr/share/ffplayout/", "644"],
@ -66,6 +67,7 @@ assets = [
{ source = "../assets/ffplayout.yml", dest = "/etc/ffplayout/ffplayout.yml", mode = "644", config = true },
{ source = "../assets/ffpapi.service", dest = "/lib/systemd/system/ffpapi.service", mode = "644" },
{ source = "../assets/ffplayout.service", dest = "/lib/systemd/system/ffplayout.service", mode = "644" },
{ source = "../assets/ffplayout@.service", dest = "/lib/systemd/system/ffplayout@.service", mode = "644" },
{ source = "../assets/11-ffplayout", dest = "/etc/sudoers.d/11-ffplayout", mode = "644" },
{ source = "../README.md", dest = "/usr/share/doc/ffplayout/README", mode = "644", doc = true },
{ source = "../LICENSE", dest = "/usr/share/doc/ffplayout/LICENSE", mode = "644" },

View File

@ -6,6 +6,9 @@ use clap::Parser;
override_usage = "Run without any command to use config file only, or with commands to override parameters:\n\n ffplayout [OPTIONS]",
long_about = None)]
pub struct Args {
#[clap(index = 1, value_parser)]
pub channel: Option<String>,
#[clap(short, long, help = "File path to ffplayout.yml")]
pub config: Option<String>,
@ -15,7 +18,7 @@ pub struct Args {
#[clap(
short,
long,
help = "Generate playlist for date or date-range, like: 2022-01-01 - 2022-01-10",
help = "Generate playlist for dates, like: 2022-01-01 - 2022-01-10",
name = "YYYY-MM-DD",
multiple_values = true
)]

View File

@ -1,4 +1,4 @@
use std::path::Path;
use std::path::{Path, PathBuf};
pub mod arg_parse;
@ -6,7 +6,20 @@ pub use arg_parse::Args;
use ffplayout_lib::utils::{time_to_sec, PlayoutConfig};
pub fn get_config(args: Args) -> PlayoutConfig {
let mut config = PlayoutConfig::new(args.config);
let cfg_path = match args.channel {
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
}
}
None => args.config,
};
let mut config = PlayoutConfig::new(cfg_path);
if let Some(gen) = args.generate {
config.general.generate = Some(gen);