commit
f3f42f9861
80
Cargo.lock
generated
80
Cargo.lock
generated
@ -277,9 +277,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.19"
|
version = "0.7.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e"
|
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
@ -377,13 +377,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-io"
|
name = "async-io"
|
||||||
version = "1.10.0"
|
version = "1.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e8121296a9f05be7f34aa4196b1747243b3b62e048bb7906f644f3fbfc490cf7"
|
checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-lock",
|
"async-lock",
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"concurrent-queue 1.2.4",
|
"concurrent-queue 2.0.0",
|
||||||
"futures-lite",
|
"futures-lite",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
@ -392,7 +392,7 @@ dependencies = [
|
|||||||
"slab",
|
"slab",
|
||||||
"socket2",
|
"socket2",
|
||||||
"waker-fn",
|
"waker-fn",
|
||||||
"winapi 0.3.9",
|
"windows-sys 0.42.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -532,16 +532,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blocking"
|
name = "blocking"
|
||||||
version = "1.2.0"
|
version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc"
|
checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
|
"async-lock",
|
||||||
"async-task",
|
"async-task",
|
||||||
"atomic-waker",
|
"atomic-waker",
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"futures-lite",
|
"futures-lite",
|
||||||
"once_cell",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -588,9 +588,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.2.1"
|
version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"
|
checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytestring"
|
name = "bytestring"
|
||||||
@ -609,9 +609,9 @@ checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.76"
|
version = "1.0.77"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f"
|
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
]
|
]
|
||||||
@ -638,7 +638,7 @@ dependencies = [
|
|||||||
"js-sys",
|
"js-sys",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"time 0.1.44",
|
"time 0.1.45",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
@ -788,9 +788,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-queue"
|
name = "crossbeam-queue"
|
||||||
version = "0.3.6"
|
version = "0.3.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7"
|
checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
@ -798,9 +798,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.8.12"
|
version = "0.8.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
|
checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
]
|
]
|
||||||
@ -971,7 +971,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ffplayout"
|
name = "ffplayout"
|
||||||
version = "0.16.4"
|
version = "0.16.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
@ -991,7 +991,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ffplayout-api"
|
name = "ffplayout-api"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-multipart",
|
"actix-multipart",
|
||||||
@ -1022,7 +1022,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ffplayout-lib"
|
name = "ffplayout-lib"
|
||||||
version = "0.16.4"
|
version = "0.16.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
@ -1080,9 +1080,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.24"
|
version = "1.0.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
|
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
@ -1841,9 +1841,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.5.4"
|
version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
|
checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler",
|
"adler",
|
||||||
]
|
]
|
||||||
@ -2017,9 +2017,9 @@ checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.10.42"
|
version = "0.10.43"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13"
|
checksum = "020433887e44c27ff16365eaa2d380547a94544ad509aff6eb5b6e3e0b27b376"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
@ -2058,9 +2058,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.9.77"
|
version = "0.9.78"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a"
|
checksum = "07d5c8cb6e57b3a3612064d7b18b117912b4ce70955c2504d4b741c9e244b132"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"cc",
|
"cc",
|
||||||
@ -2072,9 +2072,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "os_str_bytes"
|
name = "os_str_bytes"
|
||||||
version = "6.4.0"
|
version = "6.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7b5bf27447411e9ee3ff51186bf7a08e16c341efdde93f4d823e8844429bed7e"
|
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "paris"
|
name = "paris"
|
||||||
@ -2208,16 +2208,16 @@ checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polling"
|
name = "polling"
|
||||||
version = "2.4.0"
|
version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ab4609a838d88b73d8238967b60dd115cc08d38e2bbaf51ee1e4b695f89122e2"
|
checksum = "9f7d73f1eaed1ca1fb37b54dcc9b38e3b17d6c7b8ecb7abfffcac8d0351f17d4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"wepoll-ffi",
|
"wepoll-ffi",
|
||||||
"winapi 0.3.9",
|
"windows-sys 0.42.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2516,9 +2516,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.88"
|
version = "1.0.89"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e8b3801309262e8184d9687fb697586833e939767aea0dda89f5a8e650e8bd7"
|
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"ryu",
|
"ryu",
|
||||||
@ -2855,9 +2855,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.44"
|
version = "0.1.45"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
|
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||||
@ -3468,9 +3468,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zstd-sys"
|
name = "zstd-sys"
|
||||||
version = "2.0.1+zstd.1.5.2"
|
version = "2.0.3+zstd.1.5.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b"
|
checksum = "44ccf97612ac95f3ccb89b2d7346b345e52f1c3019be4984f0455fb4ba991f8a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -4,7 +4,7 @@ description = "Rest API for ffplayout"
|
|||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -7,7 +7,10 @@ use rand::{distributions::Alphanumeric, Rng};
|
|||||||
use simplelog::*;
|
use simplelog::*;
|
||||||
use sqlx::{migrate::MigrateDatabase, sqlite::SqliteQueryResult, Pool, Sqlite};
|
use sqlx::{migrate::MigrateDatabase, sqlite::SqliteQueryResult, Pool, Sqlite};
|
||||||
|
|
||||||
use crate::db::models::{Channel, TextPreset, User};
|
use crate::db::{
|
||||||
|
db_pool,
|
||||||
|
models::{Channel, TextPreset, User},
|
||||||
|
};
|
||||||
use crate::utils::{db_path, local_utc_offset, GlobalSettings};
|
use crate::utils::{db_path, local_utc_offset, GlobalSettings};
|
||||||
|
|
||||||
#[derive(Debug, sqlx::FromRow)]
|
#[derive(Debug, sqlx::FromRow)]
|
||||||
@ -74,15 +77,15 @@ async fn create_schema(conn: &Pool<Sqlite>) -> Result<SqliteQueryResult, sqlx::E
|
|||||||
sqlx::query(query).execute(conn).await
|
sqlx::query(query).execute(conn).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn db_init(
|
pub async fn db_init(domain: Option<String>) -> Result<&'static str, Box<dyn std::error::Error>> {
|
||||||
conn: &Pool<Sqlite>,
|
|
||||||
domain: Option<String>,
|
|
||||||
) -> Result<&'static str, Box<dyn std::error::Error>> {
|
|
||||||
let db_path = db_path()?;
|
let db_path = db_path()?;
|
||||||
|
|
||||||
if !Sqlite::database_exists(&db_path).await.unwrap_or(false) {
|
if !Sqlite::database_exists(&db_path).await.unwrap_or(false) {
|
||||||
Sqlite::create_database(&db_path).await.unwrap();
|
Sqlite::create_database(&db_path).await.unwrap();
|
||||||
match create_schema(conn).await {
|
|
||||||
|
let pool = db_pool().await?;
|
||||||
|
|
||||||
|
match create_schema(&pool).await {
|
||||||
Ok(_) => info!("Database created Successfully"),
|
Ok(_) => info!("Database created Successfully"),
|
||||||
Err(e) => panic!("{e}"),
|
Err(e) => panic!("{e}"),
|
||||||
}
|
}
|
||||||
@ -115,10 +118,13 @@ pub async fn db_init(
|
|||||||
'1', '#000000@0x80', '4', 'ifnot(ld(1),st(1,t));if(lt(t,ld(1)+1),0,if(lt(t,ld(1)+2),(t-(ld(1)+1))/1,if(lt(t,ld(1)+8),1,if(lt(t,ld(1)+9),(1-(t-(ld(1)+8)))/1,0))))', '1'),
|
'1', '#000000@0x80', '4', 'ifnot(ld(1),st(1,t));if(lt(t,ld(1)+1),0,if(lt(t,ld(1)+2),(t-(ld(1)+1))/1,if(lt(t,ld(1)+8),1,if(lt(t,ld(1)+9),(1-(t-(ld(1)+8)))/1,0))))', '1'),
|
||||||
('Scrolling Text', 'We have a very important announcement to make.', 'ifnot(ld(1),st(1,t));if(lt(t,ld(1)+1),w+4,w-w/12*mod(t-ld(1),12*(w+tw)/w))', '(h-line_h)*0.9',
|
('Scrolling Text', 'We have a very important announcement to make.', 'ifnot(ld(1),st(1,t));if(lt(t,ld(1)+1),w+4,w-w/12*mod(t-ld(1),12*(w+tw)/w))', '(h-line_h)*0.9',
|
||||||
'24', '4', '#ffffff', '1', '#000000@0x80', '4', '1.0', '1');";
|
'24', '4', '#ffffff', '1', '#000000@0x80', '4', '1.0', '1');";
|
||||||
|
|
||||||
|
let pool = db_pool().await?;
|
||||||
|
|
||||||
sqlx::query(query)
|
sqlx::query(query)
|
||||||
.bind(secret)
|
.bind(secret)
|
||||||
.bind(url)
|
.bind(url)
|
||||||
.execute(conn)
|
.execute(&pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok("Database initialized!")
|
Ok("Database initialized!")
|
||||||
|
@ -64,6 +64,10 @@ async fn main() -> std::io::Result<()> {
|
|||||||
let logging = init_logging(&config, None, None);
|
let logging = init_logging(&config, None, None);
|
||||||
CombinedLogger::init(logging).unwrap();
|
CombinedLogger::init(logging).unwrap();
|
||||||
|
|
||||||
|
if let Err(c) = run_args(args.clone()).await {
|
||||||
|
exit(c);
|
||||||
|
}
|
||||||
|
|
||||||
let pool = match db_pool().await {
|
let pool = match db_pool().await {
|
||||||
Ok(p) => p,
|
Ok(p) => p,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -72,10 +76,6 @@ async fn main() -> std::io::Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(c) = run_args(&pool, args.clone()).await {
|
|
||||||
exit(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(conn) = args.listen {
|
if let Some(conn) = args.listen {
|
||||||
if let Ok(p) = db_path() {
|
if let Ok(p) = db_path() {
|
||||||
if !Path::new(&p).is_file() {
|
if !Path::new(&p).is_file() {
|
||||||
|
@ -21,6 +21,7 @@ pub mod files;
|
|||||||
pub mod playlist;
|
pub mod playlist;
|
||||||
|
|
||||||
use crate::db::{
|
use crate::db::{
|
||||||
|
db_pool,
|
||||||
handles::{db_init, insert_user, select_channel, select_global},
|
handles::{db_init, insert_user, select_channel, select_global},
|
||||||
models::{Channel, User},
|
models::{Channel, User},
|
||||||
};
|
};
|
||||||
@ -90,7 +91,7 @@ pub fn db_path() -> Result<String, Box<dyn std::error::Error>> {
|
|||||||
Ok(db_path)
|
Ok(db_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_args(conn: &Pool<Sqlite>, mut args: Args) -> Result<(), i32> {
|
pub async fn run_args(mut args: Args) -> Result<(), i32> {
|
||||||
if !args.init && args.listen.is_none() && !args.ask && args.username.is_none() {
|
if !args.init && args.listen.is_none() && !args.ask && args.username.is_none() {
|
||||||
error!("Wrong number of arguments! Run ffpapi --help for more information.");
|
error!("Wrong number of arguments! Run ffpapi --help for more information.");
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ pub async fn run_args(conn: &Pool<Sqlite>, mut args: Args) -> Result<(), i32> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if args.init {
|
if args.init {
|
||||||
if let Err(e) = db_init(conn, args.domain).await {
|
if let Err(e) = db_init(args.domain).await {
|
||||||
panic!("{e}");
|
panic!("{e}");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -162,9 +163,18 @@ pub async fn run_args(conn: &Pool<Sqlite>, mut args: Args) -> Result<(), i32> {
|
|||||||
token: None,
|
token: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = insert_user(conn, user).await {
|
match db_pool().await {
|
||||||
error!("{e}");
|
Ok(conn) => {
|
||||||
return Err(1);
|
if let Err(e) = insert_user(&conn, user).await {
|
||||||
|
error!("{e}");
|
||||||
|
return Err(1);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(e) => {
|
||||||
|
error!("{e}");
|
||||||
|
return Err(1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Create admin user \"{username}\" done...");
|
info!("Create admin user \"{username}\" done...");
|
||||||
|
@ -4,7 +4,7 @@ description = "24/7 playout based on rust and ffmpeg"
|
|||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "0.16.4"
|
version = "0.16.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
default-run = "ffplayout"
|
default-run = "ffplayout"
|
||||||
|
|
||||||
|
@ -88,8 +88,7 @@ fn main() {
|
|||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
fake_time(&args);
|
fake_time(&args);
|
||||||
|
|
||||||
let config = get_config(args.clone());
|
let mut config = get_config(args.clone());
|
||||||
let config_clone = config.clone();
|
|
||||||
let play_control = PlayerControl::new();
|
let play_control = PlayerControl::new();
|
||||||
let playout_stat = PlayoutStatus::new();
|
let playout_stat = PlayoutStatus::new();
|
||||||
let proc_control = ProcessControl::new();
|
let proc_control = ProcessControl::new();
|
||||||
@ -102,11 +101,13 @@ fn main() {
|
|||||||
let logging = init_logging(&config, Some(proc_ctl1), Some(messages.clone()));
|
let logging = init_logging(&config, Some(proc_ctl1), Some(messages.clone()));
|
||||||
CombinedLogger::init(logging).unwrap();
|
CombinedLogger::init(logging).unwrap();
|
||||||
|
|
||||||
if let Err(e) = validate_ffmpeg(&config) {
|
if let Err(e) = validate_ffmpeg(&mut config) {
|
||||||
error!("{e}");
|
error!("{e}");
|
||||||
exit(1);
|
exit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let config_clone = config.clone();
|
||||||
|
|
||||||
if ![2, 4, 6, 8].contains(&config.processing.audio_channels) {
|
if ![2, 4, 6, 8].contains(&config.processing.audio_channels) {
|
||||||
error!(
|
error!(
|
||||||
"Encoding {} channel(s) is not allowed. Only 2, 4, 6 and 8 channels are supported!",
|
"Encoding {} channel(s) is not allowed. Only 2, 4, 6 and 8 channels are supported!",
|
||||||
|
@ -4,7 +4,7 @@ description = "Library for ffplayout"
|
|||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "0.16.4"
|
version = "0.16.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -110,6 +110,12 @@ pub struct General {
|
|||||||
|
|
||||||
#[serde(skip_serializing, skip_deserializing)]
|
#[serde(skip_serializing, skip_deserializing)]
|
||||||
pub stat_file: String,
|
pub stat_file: String,
|
||||||
|
|
||||||
|
#[serde(skip_serializing, skip_deserializing)]
|
||||||
|
pub ffmpeg_filters: Vec<String>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing, skip_deserializing)]
|
||||||
|
pub ffmpeg_libs: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
@ -693,16 +693,30 @@ fn is_in_system(name: &str) -> Result<(), String> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ffmpeg_libs() -> Result<Vec<String>, String> {
|
fn ffmpeg_filter_and_libs(config: &mut PlayoutConfig) -> Result<(), String> {
|
||||||
let mut libs: Vec<String> = vec![];
|
let ignore_flags = [
|
||||||
|
"--enable-gpl",
|
||||||
|
"--enable-version3",
|
||||||
|
"--enable-runtime-cpudetect",
|
||||||
|
"--enable-avfilter",
|
||||||
|
"--enable-zlib",
|
||||||
|
"--enable-pic",
|
||||||
|
"--enable-nonfree",
|
||||||
|
];
|
||||||
|
|
||||||
let mut ff_proc = match Command::new("ffmpeg").stderr(Stdio::piped()).spawn() {
|
let mut ff_proc = match Command::new("ffmpeg")
|
||||||
|
.args(["-filters"])
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
{
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Err(format!("couldn't spawn ffmpeg process: {e}"));
|
return Err(format!("couldn't spawn ffmpeg process: {e}"));
|
||||||
}
|
}
|
||||||
Ok(proc) => proc,
|
Ok(proc) => proc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let out_buffer = BufReader::new(ff_proc.stdout.take().unwrap());
|
||||||
let err_buffer = BufReader::new(ff_proc.stderr.take().unwrap());
|
let err_buffer = BufReader::new(ff_proc.stderr.take().unwrap());
|
||||||
|
|
||||||
// stderr shows only the ffmpeg configuration
|
// stderr shows only the ffmpeg configuration
|
||||||
@ -711,26 +725,44 @@ fn ffmpeg_libs() -> Result<Vec<String>, String> {
|
|||||||
if line.contains("configuration:") {
|
if line.contains("configuration:") {
|
||||||
let configs = line.split_whitespace();
|
let configs = line.split_whitespace();
|
||||||
|
|
||||||
for config in configs {
|
for flag in configs {
|
||||||
if config.contains("--enable-lib") {
|
if flag.contains("--enable") && !ignore_flags.contains(&flag) {
|
||||||
libs.push(config.replace("--enable-", ""));
|
config
|
||||||
|
.general
|
||||||
|
.ffmpeg_libs
|
||||||
|
.push(flag.replace("--enable-", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stdout shows filter from ffmpeg
|
||||||
|
// get filters
|
||||||
|
for line in out_buffer.lines().flatten() {
|
||||||
|
if line.contains('>') {
|
||||||
|
let filter_line = line.split_whitespace().collect::<Vec<_>>();
|
||||||
|
|
||||||
|
if filter_line.len() > 2 {
|
||||||
|
config
|
||||||
|
.general
|
||||||
|
.ffmpeg_filters
|
||||||
|
.push(filter_line[1].to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Err(e) = ff_proc.wait() {
|
if let Err(e) = ff_proc.wait() {
|
||||||
error!("{:?}", e)
|
error!("{:?}", e)
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(libs)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate ffmpeg/ffprobe/ffplay.
|
/// Validate ffmpeg/ffprobe/ffplay.
|
||||||
///
|
///
|
||||||
/// Check if they are in system and has all libs and codecs we need.
|
/// Check if they are in system and has all libs and codecs we need.
|
||||||
pub fn validate_ffmpeg(config: &PlayoutConfig) -> Result<(), String> {
|
pub fn validate_ffmpeg(config: &mut PlayoutConfig) -> Result<(), String> {
|
||||||
is_in_system("ffmpeg")?;
|
is_in_system("ffmpeg")?;
|
||||||
is_in_system("ffprobe")?;
|
is_in_system("ffprobe")?;
|
||||||
|
|
||||||
@ -738,15 +770,15 @@ pub fn validate_ffmpeg(config: &PlayoutConfig) -> Result<(), String> {
|
|||||||
is_in_system("ffplay")?;
|
is_in_system("ffplay")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let libs = ffmpeg_libs()?;
|
ffmpeg_filter_and_libs(config)?;
|
||||||
|
|
||||||
if !libs.contains(&"libx264".to_string()) {
|
if !config.general.ffmpeg_libs.contains(&"libx264".to_string()) {
|
||||||
return Err("ffmpeg contains no libx264!".to_string());
|
return Err("ffmpeg contains no libx264!".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.text.add_text
|
if config.text.add_text
|
||||||
&& !config.text.text_from_filename
|
&& !config.text.text_from_filename
|
||||||
&& !libs.contains(&"libzmq".to_string())
|
&& !config.general.ffmpeg_libs.contains(&"libzmq".to_string())
|
||||||
{
|
{
|
||||||
return Err(
|
return Err(
|
||||||
"ffmpeg contains no libzmq! Disable add_text in config or compile ffmpeg with libzmq."
|
"ffmpeg contains no libzmq! Disable add_text in config or compile ffmpeg with libzmq."
|
||||||
@ -754,7 +786,11 @@ pub fn validate_ffmpeg(config: &PlayoutConfig) -> Result<(), String> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !libs.contains(&"libfdk-aac".to_string()) {
|
if !config
|
||||||
|
.general
|
||||||
|
.ffmpeg_libs
|
||||||
|
.contains(&"libfdk-aac".to_string())
|
||||||
|
{
|
||||||
warn!("ffmpeg contains no libfdk-aac! Can't use high quality aac encoder...");
|
warn!("ffmpeg contains no libfdk-aac! Can't use high quality aac encoder...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user