diff --git a/Cargo.lock b/Cargo.lock index f20e0e4b..0ce08b0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -855,7 +855,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eebd66744a15ded14960ab4ccdbfb51ad3b81f51f3f04a80adac98c985396c9" dependencies = [ - "hashbrown", + "hashbrown 0.14.5", "stacker", ] @@ -1098,7 +1098,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -1122,6 +1122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -1292,7 +1293,7 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "ffplayout" -version = "0.23.0" +version = "0.23.1" dependencies = [ "chrono", "clap", @@ -1314,7 +1315,7 @@ dependencies = [ [[package]] name = "ffplayout-api" -version = "0.23.0" +version = "0.23.1" dependencies = [ "actix-files", "actix-multipart", @@ -1358,7 +1359,7 @@ dependencies = [ [[package]] name = "ffplayout-lib" -version = "0.23.0" +version = "0.23.1" dependencies = [ "chrono", "crossbeam-channel", @@ -1376,6 +1377,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "serde_with", "shlex", "signal-child", "simplelog", @@ -1664,13 +1666,19 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", "tracing", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.14.5" @@ -1687,7 +1695,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown", + "hashbrown 0.14.5", ] [[package]] @@ -1908,6 +1916,17 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -1915,7 +1934,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.14.5", + "serde", ] [[package]] @@ -3057,7 +3077,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de514ef58196f1fc96dcaef80fe6170a1ce6215df9687a93fe8300e773fefc5" dependencies = [ "form_urlencoded", - "indexmap", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -3104,6 +3124,36 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.2.6", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.63", +] + [[package]] name = "serial_test" version = "3.1.1" @@ -3311,7 +3361,7 @@ dependencies = [ "futures-util", "hashlink", "hex", - "indexmap", + "indexmap 2.2.6", "log", "memchr", "once_cell", @@ -3589,7 +3639,7 @@ dependencies = [ [[package]] name = "tests" -version = "0.23.0" +version = "0.23.1" dependencies = [ "chrono", "crossbeam-channel", @@ -3772,7 +3822,7 @@ version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ - "indexmap", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", diff --git a/Cargo.toml b/Cargo.toml index c619d299..32e7864e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["ffplayout-api", "ffplayout-engine", "tests"] resolver = "2" [workspace.package] -version = "0.23.0" +version = "0.23.1" license = "GPL-3.0" repository = "https://github.com/ffplayout/ffplayout" authors = ["Jonathan Baecker "] diff --git a/assets/advanced.toml b/assets/advanced.toml index 24152f40..6a6b0d72 100644 --- a/assets/advanced.toml +++ b/assets/advanced.toml @@ -6,7 +6,7 @@ input_param = "" # output_param get also applied to ingest instance. output_param = "" -[filters] +[decoder.filters] deinterlace = "" # yadif=0:-1:0 pad_scale_w = "" # scale={}:-1 pad_scale_h = "" # scale=-1:{} diff --git a/ffplayout-engine/Cargo.toml b/ffplayout-engine/Cargo.toml index f96a307a..019e59d9 100644 --- a/ffplayout-engine/Cargo.toml +++ b/ffplayout-engine/Cargo.toml @@ -45,7 +45,7 @@ depends = "" recommends = "sudo" suggests = "ffmpeg" copyright = "Copyright (c) 2022, Jonathan Baecker. All rights reserved." -conf-files = ["/etc/ffplayout/ffplayout.toml"] +conf-files = ["/etc/ffplayout/ffplayout.toml", "/etc/ffplayout/advanced.toml"] assets = [ [ "../target/x86_64-unknown-linux-musl/release/ffpapi", diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 48770847..e112e950 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -25,6 +25,7 @@ regex = "1" reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +serde_with = "3.8" shlex = "1.1" simplelog = { version = "0.12", features = ["paris"] } time = { version = "0.3", features = ["formatting", "macros"] } diff --git a/lib/src/utils/advanced_config.rs b/lib/src/utils/advanced_config.rs index fd5833cd..c5cb8018 100644 --- a/lib/src/utils/advanced_config.rs +++ b/lib/src/utils/advanced_config.rs @@ -1,6 +1,7 @@ use std::{fs::File, io::Read, path::PathBuf}; use serde::{Deserialize, Serialize}; +use serde_with::{serde_as, NoneAsEmptyString}; use shlex::split; #[derive(Debug, Default, Serialize, Deserialize, Clone)] @@ -10,9 +11,12 @@ pub struct AdvancedConfig { pub ingest: IngestConfig, } +#[serde_as] #[derive(Debug, Default, Serialize, Deserialize, Clone)] pub struct DecoderConfig { + #[serde_as(as = "NoneAsEmptyString")] pub input_param: Option, + #[serde_as(as = "NoneAsEmptyString")] pub output_param: Option, pub filters: Filters, #[serde(skip_serializing, skip_deserializing)] @@ -21,43 +25,70 @@ pub struct DecoderConfig { pub output_cmd: Option>, } +#[serde_as] #[derive(Debug, Default, Serialize, Deserialize, Clone)] pub struct EncoderConfig { + #[serde_as(as = "NoneAsEmptyString")] pub input_param: Option, #[serde(skip_serializing, skip_deserializing)] pub input_cmd: Option>, } +#[serde_as] #[derive(Debug, Default, Serialize, Deserialize, Clone)] pub struct IngestConfig { + #[serde_as(as = "NoneAsEmptyString")] pub input_param: Option, #[serde(skip_serializing, skip_deserializing)] pub input_cmd: Option>, } +#[serde_as] #[derive(Debug, Default, Serialize, Deserialize, Clone)] pub struct Filters { + #[serde_as(as = "NoneAsEmptyString")] pub deinterlace: Option, + #[serde_as(as = "NoneAsEmptyString")] pub pad_scale_w: Option, + #[serde_as(as = "NoneAsEmptyString")] pub pad_scale_h: Option, + #[serde_as(as = "NoneAsEmptyString")] pub pad_video: Option, + #[serde_as(as = "NoneAsEmptyString")] pub fps: Option, + #[serde_as(as = "NoneAsEmptyString")] pub scale: Option, + #[serde_as(as = "NoneAsEmptyString")] pub set_dar: Option, + #[serde_as(as = "NoneAsEmptyString")] pub fade_in: Option, + #[serde_as(as = "NoneAsEmptyString")] pub fade_out: Option, + #[serde_as(as = "NoneAsEmptyString")] pub overlay_logo_scale: Option, + #[serde_as(as = "NoneAsEmptyString")] pub overlay_logo_fade_in: Option, + #[serde_as(as = "NoneAsEmptyString")] pub overlay_logo_fade_out: Option, + #[serde_as(as = "NoneAsEmptyString")] pub overlay_logo: Option, + #[serde_as(as = "NoneAsEmptyString")] pub tpad: Option, + #[serde_as(as = "NoneAsEmptyString")] pub drawtext_from_file: Option, + #[serde_as(as = "NoneAsEmptyString")] pub drawtext_from_zmq: Option, + #[serde_as(as = "NoneAsEmptyString")] pub aevalsrc: Option, + #[serde_as(as = "NoneAsEmptyString")] pub afade_in: Option, + #[serde_as(as = "NoneAsEmptyString")] pub afade_out: Option, + #[serde_as(as = "NoneAsEmptyString")] pub apad: Option, + #[serde_as(as = "NoneAsEmptyString")] pub volume: Option, + #[serde_as(as = "NoneAsEmptyString")] pub split: Option, } @@ -72,8 +103,9 @@ impl AdvancedConfig { eprintln!("Read advanced config file: {e}") }; - if let Ok(tm) = toml_edit::de::from_str(&contents) { - config = tm + match toml_edit::de::from_str(&contents) { + Ok(tm) => config = tm, + Err(e) => eprintln!("Serialize advanced config file: {e}"), }; if let Some(input_parm) = &config.decoder.input_param {