From 0dbdd1f46ef0cb86527d30e93d8273eca214fba0 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Tue, 11 Jun 2024 17:30:53 +0200 Subject: [PATCH] remove engine and ffpapi, fix tests and dependencies, handle start/stop/restart channel --- Cargo.lock | 444 +++++--- Cargo.toml | 6 +- debian/postinst | 1 - debian/postrm | 2 +- ffplayout-api/Cargo.toml | 60 - ffplayout-api/README.md | 63 -- ffplayout-api/build.rs | 15 - ffplayout-api/src/api/auth.rs | 46 - ffplayout-api/src/api/mod.rs | 2 - ffplayout-api/src/api/routes.rs | 1230 --------------------- ffplayout-api/src/db/handles.rs | 352 ------ ffplayout-api/src/db/mod.rs | 13 - ffplayout-api/src/db/models.rs | 118 -- ffplayout-api/src/lib.rs | 21 - ffplayout-api/src/main.rs | 194 ---- ffplayout-api/src/sse/broadcast.rs | 160 --- ffplayout-api/src/sse/mod.rs | 55 - ffplayout-api/src/sse/routes.rs | 82 -- ffplayout-api/src/utils/args_parse.rs | 36 - ffplayout-api/src/utils/channels.rs | 74 -- ffplayout-api/src/utils/control.rs | 345 ------ ffplayout-api/src/utils/errors.rs | 105 -- ffplayout-api/src/utils/files.rs | 456 -------- ffplayout-api/src/utils/mod.rs | 390 ------- ffplayout-api/src/utils/playlist.rs | 152 --- ffplayout-api/src/utils/system.rs | 176 --- ffplayout-engine/Cargo.toml | 221 ---- ffplayout-engine/README.md | 34 - ffplayout-engine/src/input/folder.rs | 102 -- ffplayout-engine/src/input/ingest.rs | 167 --- ffplayout-engine/src/input/mod.rs | 51 - ffplayout-engine/src/input/playlist.rs | 848 -------------- ffplayout-engine/src/lib.rs | 4 - ffplayout-engine/src/main.rs | 236 ---- ffplayout-engine/src/output/desktop.rs | 88 -- ffplayout-engine/src/output/hls.rs | 275 ----- ffplayout-engine/src/output/mod.rs | 263 ----- ffplayout-engine/src/output/null.rs | 52 - ffplayout-engine/src/output/stream.rs | 52 - ffplayout-engine/src/rpc/mod.rs | 5 - ffplayout-engine/src/rpc/server.rs | 587 ---------- ffplayout-engine/src/rpc/zmq_cmd.rs | 13 - ffplayout-engine/src/utils/arg_parse.rs | 109 -- ffplayout-engine/src/utils/mod.rs | 298 ----- ffplayout-engine/src/utils/task_runner.rs | 25 - ffplayout/Cargo.toml | 103 +- ffplayout/src/api/routes.rs | 31 +- ffplayout/src/db/handles.rs | 10 + ffplayout/src/main.rs | 20 +- ffplayout/src/player/controller.rs | 70 +- ffplayout/src/player/input/mod.rs | 10 +- ffplayout/src/player/input/playlist.rs | 14 +- ffplayout/src/player/output/hls.rs | 5 +- ffplayout/src/player/output/mod.rs | 5 +- ffplayout/src/utils/control.rs | 38 +- ffplayout/src/utils/playlist.rs | 2 +- lib/Cargo.toml | 39 - lib/README.md | 4 - lib/src/filter/custom.rs | 39 - lib/src/filter/mod.rs | 793 ------------- lib/src/filter/v_drawtext.rs | 78 -- lib/src/lib.rs | 8 - lib/src/macros/mod.rs | 6 - lib/src/utils/advanced_config.rs | 98 -- lib/src/utils/config.rs | 585 ---------- lib/src/utils/controller.rs | 226 ---- lib/src/utils/errors.rs | 56 - lib/src/utils/folder.rs | 235 ---- lib/src/utils/generator.rs | 317 ------ lib/src/utils/import.rs | 80 -- lib/src/utils/json_serializer.rs | 205 ---- lib/src/utils/json_validate.rs | 260 ----- lib/src/utils/logging.rs | 281 ----- lib/src/utils/mod.rs | 1018 ----------------- tests/Cargo.toml | 7 +- tests/src/engine_cmd.rs | 355 ++++-- tests/src/engine_generator.rs | 64 +- tests/src/engine_playlist.rs | 331 +++--- tests/src/lib_utils.rs | 19 +- 79 files changed, 959 insertions(+), 12481 deletions(-) delete mode 100644 ffplayout-api/Cargo.toml delete mode 100644 ffplayout-api/README.md delete mode 100644 ffplayout-api/build.rs delete mode 100644 ffplayout-api/src/api/auth.rs delete mode 100644 ffplayout-api/src/api/mod.rs delete mode 100644 ffplayout-api/src/api/routes.rs delete mode 100644 ffplayout-api/src/db/handles.rs delete mode 100644 ffplayout-api/src/db/mod.rs delete mode 100644 ffplayout-api/src/db/models.rs delete mode 100644 ffplayout-api/src/lib.rs delete mode 100644 ffplayout-api/src/main.rs delete mode 100644 ffplayout-api/src/sse/broadcast.rs delete mode 100644 ffplayout-api/src/sse/mod.rs delete mode 100644 ffplayout-api/src/sse/routes.rs delete mode 100644 ffplayout-api/src/utils/args_parse.rs delete mode 100644 ffplayout-api/src/utils/channels.rs delete mode 100644 ffplayout-api/src/utils/control.rs delete mode 100644 ffplayout-api/src/utils/errors.rs delete mode 100644 ffplayout-api/src/utils/files.rs delete mode 100644 ffplayout-api/src/utils/mod.rs delete mode 100644 ffplayout-api/src/utils/playlist.rs delete mode 100644 ffplayout-api/src/utils/system.rs delete mode 100644 ffplayout-engine/Cargo.toml delete mode 100644 ffplayout-engine/README.md delete mode 100644 ffplayout-engine/src/input/folder.rs delete mode 100644 ffplayout-engine/src/input/ingest.rs delete mode 100644 ffplayout-engine/src/input/mod.rs delete mode 100644 ffplayout-engine/src/input/playlist.rs delete mode 100644 ffplayout-engine/src/lib.rs delete mode 100644 ffplayout-engine/src/main.rs delete mode 100644 ffplayout-engine/src/output/desktop.rs delete mode 100644 ffplayout-engine/src/output/hls.rs delete mode 100644 ffplayout-engine/src/output/mod.rs delete mode 100644 ffplayout-engine/src/output/null.rs delete mode 100644 ffplayout-engine/src/output/stream.rs delete mode 100644 ffplayout-engine/src/rpc/mod.rs delete mode 100644 ffplayout-engine/src/rpc/server.rs delete mode 100644 ffplayout-engine/src/rpc/zmq_cmd.rs delete mode 100644 ffplayout-engine/src/utils/arg_parse.rs delete mode 100644 ffplayout-engine/src/utils/mod.rs delete mode 100644 ffplayout-engine/src/utils/task_runner.rs delete mode 100644 lib/Cargo.toml delete mode 100644 lib/README.md delete mode 100644 lib/src/filter/custom.rs delete mode 100644 lib/src/filter/mod.rs delete mode 100644 lib/src/filter/v_drawtext.rs delete mode 100644 lib/src/lib.rs delete mode 100644 lib/src/macros/mod.rs delete mode 100644 lib/src/utils/advanced_config.rs delete mode 100644 lib/src/utils/config.rs delete mode 100644 lib/src/utils/controller.rs delete mode 100644 lib/src/utils/errors.rs delete mode 100644 lib/src/utils/folder.rs delete mode 100644 lib/src/utils/generator.rs delete mode 100644 lib/src/utils/import.rs delete mode 100644 lib/src/utils/json_serializer.rs delete mode 100644 lib/src/utils/json_validate.rs delete mode 100644 lib/src/utils/logging.rs delete mode 100644 lib/src/utils/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 1b296cd1..eebdcfd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -258,13 +258,13 @@ dependencies = [ [[package]] name = "actix-web-httpauth" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d613edf08a42ccc6864c941d30fe14e1b676a77d16f1dbadc1174d065a0a775" +checksum = "456348ed9dcd72a13a1f4a660449fafdecee9ac8205552e286809eb5b0b29bd3" dependencies = [ "actix-utils", "actix-web", - "base64 0.21.7", + "base64 0.22.1", "futures-core", "futures-util", "log", @@ -294,7 +294,7 @@ dependencies = [ "futures-util", "http 0.2.12", "impl-more", - "itertools 0.12.1", + "itertools", "local-channel", "mediatype", "mime", @@ -320,18 +320,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "actix-web-static-files" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adf6d1ef6d7a60e084f9e0595e2a5234abda14e76c105ecf8e2d0e8800c41a1f" -dependencies = [ - "actix-web", - "derive_more", - "futures-util", - "static-files", -] - [[package]] name = "addr2line" version = "0.22.0" @@ -478,12 +466,6 @@ dependencies = [ "password-hash", ] -[[package]] -name = "ascii" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" - [[package]] name = "async-trait" version = "0.1.80" @@ -689,17 +671,11 @@ dependencies = [ "stacker", ] -[[package]] -name = "chunked_transfer" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901" - [[package]] name = "clap" -version = "4.5.6" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", "clap_derive", @@ -707,9 +683,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.6" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", @@ -970,6 +946,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -1072,7 +1059,7 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "ffplayout" -version = "0.23.0" +version = "0.24.0" dependencies = [ "actix-files", "actix-multipart", @@ -1080,19 +1067,16 @@ dependencies = [ "actix-web-grants", "actix-web-httpauth", "actix-web-lab", - "actix-web-static-files", "argon2", "chrono", "clap", "crossbeam-channel", "derive_more", "faccess", - "ffplayout-lib", "ffprobe", "flexi_logger", "futures-util", "home", - "itertools 0.13.0", "jsonwebtoken", "lazy_static", "lettre", @@ -1129,101 +1113,6 @@ dependencies = [ "zeromq", ] -[[package]] -name = "ffplayout-api" -version = "0.23.0" -dependencies = [ - "actix-files", - "actix-multipart", - "actix-web", - "actix-web-grants", - "actix-web-httpauth", - "actix-web-lab", - "actix-web-static-files", - "argon2", - "chrono", - "clap", - "derive_more", - "faccess", - "ffplayout-lib", - "futures-util", - "home", - "jsonwebtoken", - "lazy_static", - "lexical-sort", - "local-ip-address", - "once_cell", - "parking_lot", - "path-clean", - "rand", - "regex", - "relative-path", - "reqwest", - "rpassword", - "sanitize-filename", - "serde", - "serde_json", - "simplelog", - "sqlx", - "static-files", - "sysinfo", - "tokio", - "tokio-stream", - "toml_edit", - "uuid", -] - -[[package]] -name = "ffplayout-engine" -version = "0.23.0" -dependencies = [ - "chrono", - "clap", - "crossbeam-channel", - "ffplayout-lib", - "futures", - "itertools 0.13.0", - "notify", - "notify-debouncer-full", - "rand", - "regex", - "reqwest", - "serde", - "serde_json", - "simplelog", - "tiny_http", - "zeromq", -] - -[[package]] -name = "ffplayout-lib" -version = "0.23.0" -dependencies = [ - "chrono", - "crossbeam-channel", - "derive_more", - "ffprobe", - "file-rotate", - "home", - "lazy_static", - "lettre", - "lexical-sort", - "log", - "num-traits", - "rand", - "regex", - "reqwest", - "serde", - "serde_json", - "shlex", - "signal-child", - "simplelog", - "time", - "toml_edit", - "walkdir", - "winapi", -] - [[package]] name = "ffprobe" version = "0.4.0" @@ -1586,12 +1475,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", + "futures-util", "http 1.1.0", "http-body", "pin-project-lite", @@ -1605,9 +1494,9 @@ checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "9f3935c160d00ac752e09787e6e6bfc26494c2183cc922f1bc678a60d4733bc2" [[package]] name = "httpdate" @@ -1694,6 +1583,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1710,6 +1717,18 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" +dependencies = [ + "icu_normalizer", + "icu_properties", + "smallvec", + "utf8_iter", +] + [[package]] name = "impl-more" version = "0.1.6" @@ -1778,15 +1797,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.11" @@ -1876,7 +1886,7 @@ dependencies = [ "futures-io", "futures-util", "httpdate", - "idna", + "idna 0.5.0", "mime", "nom", "percent-encoding", @@ -1928,6 +1938,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "local-channel" version = "0.1.5" @@ -3024,7 +3040,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" dependencies = [ - "itertools 0.12.1", + "itertools", "nom", "unicode_categories", ] @@ -3222,6 +3238,12 @@ dependencies = [ "urlencoding", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "stacker" version = "0.1.15" @@ -3375,6 +3397,17 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "sysinfo" version = "0.30.12" @@ -3413,12 +3446,11 @@ dependencies = [ [[package]] name = "tests" -version = "0.23.0" +version = "0.24.0" dependencies = [ "chrono", "crossbeam-channel", - "ffplayout-engine", - "ffplayout-lib", + "ffplayout", "ffprobe", "file-rotate", "lettre", @@ -3430,8 +3462,9 @@ dependencies = [ "serde_json", "serial_test", "shlex", - "simplelog", + "sqlx", "time", + "tokio", "toml_edit", "walkdir", ] @@ -3490,15 +3523,13 @@ dependencies = [ ] [[package]] -name = "tiny_http" -version = "0.12.0" +name = "tinystr" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389915df6413a2e74fb181895f933386023c71110878cd0825588928e64cdc82" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" dependencies = [ - "ascii", - "chunked_transfer", - "httpdate", - "log", + "displaydoc", + "zerovec", ] [[package]] @@ -3748,12 +3779,12 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" dependencies = [ "form_urlencoded", - "idna", + "idna 1.0.0", "percent-encoding", ] @@ -3763,6 +3794,18 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -4166,6 +4209,42 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.34" @@ -4186,6 +4265,27 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" @@ -4219,6 +4319,28 @@ dependencies = [ "uuid", ] +[[package]] +name = "zerovec" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "zstd" version = "0.13.1" diff --git a/Cargo.toml b/Cargo.toml index a8a56b57..d98266e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [workspace] -members = ["ffplayout", "ffplayout-api", "ffplayout-engine", "lib", "tests"] -default-members = ["ffplayout", "ffplayout-api", "ffplayout-engine", "tests"] +members = ["ffplayout", "tests"] +default-members = ["ffplayout", "tests"] resolver = "2" [workspace.package] -version = "0.23.0" +version = "0.24.0" license = "GPL-3.0" repository = "https://github.com/ffplayout/ffplayout" authors = ["Jonathan Baecker "] diff --git a/debian/postinst b/debian/postinst index b93fb820..b8614c43 100644 --- a/debian/postinst +++ b/debian/postinst @@ -23,7 +23,6 @@ if [ ! -d "/usr/share/ffplayout/db" ]; then chown -R ${sysUser}: "/usr/share/ffplayout" chown -R ${sysUser}: "/var/lib/ffplayout" - chown -R ${sysUser}: "/etc/ffplayout" fi if [ ! -d "/var/log/ffplayout" ]; then diff --git a/debian/postrm b/debian/postrm index f5053657..0a7655f1 100644 --- a/debian/postrm +++ b/debian/postrm @@ -6,7 +6,7 @@ sysUser="ffpu" case "$1" in abort-install|purge) deluser $sysUser - rm -rf /usr/share/ffplayout /var/log/ffplayout /etc/ffplayout /var/lib/ffplayout /home/$sysUser + rm -rf /usr/share/ffplayout /var/log/ffplayout /var/lib/ffplayout /home/$sysUser ;; remove) diff --git a/ffplayout-api/Cargo.toml b/ffplayout-api/Cargo.toml deleted file mode 100644 index ef2c9855..00000000 --- a/ffplayout-api/Cargo.toml +++ /dev/null @@ -1,60 +0,0 @@ -[package] -name = "ffplayout-api" -description = "Rest API for ffplayout" -readme = "README.md" -version.workspace = true -license.workspace = true -authors.workspace = true -repository.workspace = true -edition.workspace = true - -[features] -default = ["embed_frontend"] -embed_frontend = [] - -[dependencies] -ffplayout-lib = { path = "../lib" } -actix-files = "0.6" -actix-multipart = "0.6" -actix-web = "4" -actix-web-grants = "4" -actix-web-httpauth = "0.8" -actix-web-lab = "0.20" -actix-web-static-files = "4.0" -argon2 = "0.5" -chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } -clap = { version = "4.3", features = ["derive"] } -derive_more = "0.99" -faccess = "0.2" -futures-util = { version = "0.3", default-features = false, features = ["std"] } -home = "0.5" -jsonwebtoken = "9" -lazy_static = "1.4" -lexical-sort = "0.3" -local-ip-address = "0.6" -once_cell = "1.18" -parking_lot = "0.12" -path-clean = "1.0" -rand = "0.8" -regex = "1" -relative-path = "1.8" -reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] } -rpassword = "7.2" -sanitize-filename = "0.5" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -simplelog = { version = "0.12", features = ["paris"] } -static-files = "0.2" -sysinfo ={ version = "0.30", features = ["linux-netdevs"] } -sqlx = { version = "0.7", features = ["runtime-tokio", "sqlite"] } -tokio = { version = "1.29", features = ["full"] } -tokio-stream = "0.1" -toml_edit = {version ="0.22", features = ["serde"]} -uuid = "1.8" - -[build-dependencies] -static-files = "0.2" - -[[bin]] -name = "ffpapi" -path = "src/main.rs" diff --git a/ffplayout-api/README.md b/ffplayout-api/README.md deleted file mode 100644 index b62ce785..00000000 --- a/ffplayout-api/README.md +++ /dev/null @@ -1,63 +0,0 @@ -**ffplayout-api** -================ - -ffplayout-api (ffpapi) is a non strict REST API for ffplayout. It makes it possible to control the engine, read and manipulate the config, save playlist, etc. - -To be able to use the API it is necessary to initialize the settings database first. To do that, run: - -```BASH -ffpapi -i -``` - -Then add an admin user: - -```BASH -ffpapi -u -p -m -``` - -Then run the API thru the systemd service, or like: - -```BASH -ffpapi -l 127.0.0.1:8787 -``` - -Possible Arguments ------ - -```BASH -OPTIONS: - -a, --ask ask for user credentials - -d, --domain domain name for initialization - -h, --help Print help information - -i, --init Initialize Database - -l, --listen Listen on IP:PORT, like: 127.0.0.1:8787 - -m, --mail Admin mail address - -p, --password Admin password - -u, --username Create admin user - -V, --version Print version information -``` - -If you plan to run ffpapi with systemd set permission from **/usr/share/ffplayout** and content to user **ffpu:ffpu**. User **ffpu** has to be created. - -**For possible endpoints read: [api endpoints](/docs/api.md)** - -ffpapi can also serve the browser based frontend, just run in your browser `127.0.0.1:8787`. - -"Piggyback" Mode ------ - -ffplayout was originally planned to run under Linux as a SystemD service. It is also designed so that the engine and ffpapi run completely independently of each other. This is to increase flexibility and stability. - -Nevertheless, programs compiled in Rust can basically run on all systems supported by the language. And so this repo also offers binaries for other platforms. - -In the past, however, it was only possible under Linux to start/stop/restart the ffplayout engine process through ffpapi. This limit no longer exists since v0.17.0, because the "piggyback" mode was introduced here. This means that ffpapi recognizes which platform it is running on, and if it is not on Linux, it starts the engine as a child process. Thus it is now possible to control ffplayout engine completely on all platforms. The disadvantage here is that the engine process is dependent on ffpapi; if it closes or crashes, the engine also closes. - -Under Linux, this mode can be simulated by starting ffpapi with the environment variable `PIGGYBACK_MODE=true`. This scenario is also conceivable in container operation, for example. - -**Run in piggyback mode:** - -```BASH -PIGGYBACK_MODE=True ffpapi -l 127.0.0.1:8787 -``` - -This function is experimental, use it with caution. diff --git a/ffplayout-api/build.rs b/ffplayout-api/build.rs deleted file mode 100644 index df50d511..00000000 --- a/ffplayout-api/build.rs +++ /dev/null @@ -1,15 +0,0 @@ -use static_files::NpmBuild; - -fn main() -> std::io::Result<()> { - if !cfg!(debug_assertions) && cfg!(feature = "embed_frontend") { - NpmBuild::new("../ffplayout-frontend") - .install()? - .run("generate")? - .target("../ffplayout-frontend/.output/public") - .change_detection() - .to_resource_dir() - .build() - } else { - Ok(()) - } -} diff --git a/ffplayout-api/src/api/auth.rs b/ffplayout-api/src/api/auth.rs deleted file mode 100644 index 9c933a68..00000000 --- a/ffplayout-api/src/api/auth.rs +++ /dev/null @@ -1,46 +0,0 @@ -use actix_web::error::ErrorUnauthorized; -use actix_web::Error; -use chrono::{TimeDelta, Utc}; -use jsonwebtoken::{self, DecodingKey, EncodingKey, Header, Validation}; -use serde::{Deserialize, Serialize}; - -use crate::utils::{GlobalSettings, Role}; - -// Token lifetime -const JWT_EXPIRATION_DAYS: i64 = 7; - -#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)] -pub struct Claims { - pub id: i32, - pub username: String, - pub role: Role, - exp: i64, -} - -impl Claims { - pub fn new(id: i32, username: String, role: Role) -> Self { - Self { - id, - username, - role, - exp: (Utc::now() + TimeDelta::try_days(JWT_EXPIRATION_DAYS).unwrap()).timestamp(), - } - } -} - -/// Create a json web token (JWT) -pub fn create_jwt(claims: Claims) -> Result { - let config = GlobalSettings::global(); - let encoding_key = EncodingKey::from_secret(config.secret.as_bytes()); - jsonwebtoken::encode(&Header::default(), &claims, &encoding_key) - .map_err(|e| ErrorUnauthorized(e.to_string())) -} - -/// Decode a json web token (JWT) -pub async fn decode_jwt(token: &str) -> Result { - let config = GlobalSettings::global(); - let decoding_key = DecodingKey::from_secret(config.secret.as_bytes()); - jsonwebtoken::decode::(token, &decoding_key, &Validation::default()) - .map(|data| data.claims) - .map_err(|e| ErrorUnauthorized(e.to_string())) -} diff --git a/ffplayout-api/src/api/mod.rs b/ffplayout-api/src/api/mod.rs deleted file mode 100644 index 474f258a..00000000 --- a/ffplayout-api/src/api/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod auth; -pub mod routes; diff --git a/ffplayout-api/src/api/routes.rs b/ffplayout-api/src/api/routes.rs deleted file mode 100644 index 3eab3073..00000000 --- a/ffplayout-api/src/api/routes.rs +++ /dev/null @@ -1,1230 +0,0 @@ -/// ### Possible endpoints -/// -/// Run the API thru the systemd service, or like: -/// -/// ```BASH -/// ffpapi -l 127.0.0.1:8787 -/// ``` -/// -/// For all endpoints an (Bearer) authentication is required.\ -/// `{id}` represent the channel id, and at default is 1. -use std::{collections::HashMap, env, path::PathBuf}; - -use actix_files; -use actix_multipart::Multipart; -use actix_web::{ - delete, get, - http::{ - header::{ContentDisposition, DispositionType}, - StatusCode, - }, - patch, post, put, web, HttpRequest, HttpResponse, Responder, -}; -use actix_web_grants::{authorities::AuthDetails, proc_macro::protect}; - -use argon2::{ - password_hash::{rand_core::OsRng, PasswordHash, SaltString}, - Argon2, PasswordHasher, PasswordVerifier, -}; -use chrono::{DateTime, Datelike, Local, NaiveDateTime, TimeDelta, TimeZone, Utc}; -use path_clean::PathClean; -use regex::Regex; -use serde::{Deserialize, Serialize}; -use simplelog::*; -use sqlx::{Pool, Sqlite}; -use tokio::{fs, task}; - -use crate::db::{ - handles, - models::{Channel, LoginUser, TextPreset, User}, -}; -use crate::utils::{ - channels::{create_channel, delete_channel}, - control::{control_service, control_state, media_info, send_message, ControlParams, Process}, - errors::ServiceError, - files::{ - browser, create_directory, norm_abs_path, remove_file_or_folder, rename_file, upload, - MoveObject, PathObject, - }, - naive_date_time_from_str, - playlist::{delete_playlist, generate_playlist, read_playlist, write_playlist}, - playout_config, public_path, read_log_file, read_playout_config, system, Role, -}; -use crate::{ - api::auth::{create_jwt, Claims}, - utils::control::ProcessControl, -}; -use ffplayout_lib::{ - utils::{ - get_date_range, import::import_file, sec_to_time, time_to_sec, JsonPlaylist, PlayoutConfig, - Template, - }, - vec_strings, -}; - -#[derive(Serialize)] -struct UserObj { - message: String, - user: Option, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct DateObj { - #[serde(default)] - date: String, -} - -#[derive(Debug, Deserialize, Serialize)] -struct FileObj { - #[serde(default)] - path: PathBuf, -} - -#[derive(Debug, Default, Deserialize, Serialize)] -pub struct PathsObj { - #[serde(default)] - paths: Option>, - template: Option