From 652522da32a7b1012b01370a82fb3fd5e76f90cf Mon Sep 17 00:00:00 2001 From: amazing Date: Fri, 27 Oct 2023 10:51:05 +0200 Subject: [PATCH] add task runner to hls output --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- ffplayout-engine/src/output/hls.rs | 21 ++++++++++++++++++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 058ad7a4..4929b47f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1112,7 +1112,7 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "ffplayout" -version = "0.20.0-beta2" +version = "0.20.0-beta3" dependencies = [ "chrono", "clap", @@ -1134,7 +1134,7 @@ dependencies = [ [[package]] name = "ffplayout-api" -version = "0.20.0-beta2" +version = "0.20.0-beta3" dependencies = [ "actix-files", "actix-multipart", @@ -1167,7 +1167,7 @@ dependencies = [ [[package]] name = "ffplayout-lib" -version = "0.20.0-beta2" +version = "0.20.0-beta3" dependencies = [ "chrono", "crossbeam-channel", @@ -3126,7 +3126,7 @@ dependencies = [ [[package]] name = "tests" -version = "0.20.0-beta2" +version = "0.20.0-beta3" dependencies = [ "chrono", "crossbeam-channel", diff --git a/Cargo.toml b/Cargo.toml index e0fb31b2..4ad5672f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["ffplayout-api", "ffplayout-engine", "tests"] resolver = "2" [workspace.package] -version = "0.20.0-beta2" +version = "0.20.0-beta3" license = "GPL-3.0" repository = "https://github.com/ffplayout/ffplayout" authors = ["Jonathan Baecker "] diff --git a/ffplayout-engine/src/output/hls.rs b/ffplayout-engine/src/output/hls.rs index 98fdb1a7..2da18f7c 100644 --- a/ffplayout-engine/src/output/hls.rs +++ b/ffplayout-engine/src/output/hls.rs @@ -28,7 +28,7 @@ use std::{ use simplelog::*; use crate::input::source_generator; -use crate::utils::{log_line, prepare_output_cmd, valid_stream}; +use crate::utils::{log_line, prepare_output_cmd, task_runner, valid_stream}; use ffplayout_lib::{ utils::{ controller::ProcessUnit::*, get_delta, sec_to_time, stderr_reader, test_tcp_port, Media, @@ -161,8 +161,8 @@ pub fn write_hls( for node in get_source { *player_control.current_media.lock().unwrap() = Some(node.clone()); - let mut cmd = match node.cmd { - Some(cmd) => cmd, + let mut cmd = match &node.cmd { + Some(cmd) => cmd.clone(), None => break, }; @@ -176,6 +176,21 @@ pub fn write_hls( node.source ); + if config.task.enable { + let task_config = config.clone(); + let task_node = node.clone(); + let server_running = proc_control.server_is_running.load(Ordering::SeqCst); + + if config.task.path.is_file() { + thread::spawn(move || task_runner::run(task_config, task_node, server_running)); + } else { + error!( + "{:?} executable not exists!", + config.task.path + ); + } + } + let mut enc_prefix = vec_strings!["-hide_banner", "-nostats", "-v", &ff_log_format]; let mut read_rate = 1.0;