remove mutex

This commit is contained in:
jb-alvarado 2024-03-05 10:17:32 +01:00
parent fb2fee92af
commit b5924f9a60
7 changed files with 14 additions and 19 deletions

View File

@ -61,7 +61,7 @@ pub fn ingest_server(
dummy_media.unit = Ingest;
dummy_media.add_filter(&config, &None);
if let Some(ingest_input_cmd) = &ADVANCED_CONFIG.lock().unwrap().ingest.input_cmd {
if let Some(ingest_input_cmd) = &ADVANCED_CONFIG.ingest.input_cmd {
server_cmd.append(&mut ingest_input_cmd.clone());
}

View File

@ -12,7 +12,7 @@ pub fn output(config: &PlayoutConfig, log_format: &str) -> process::Child {
let mut enc_cmd = vec_strings!["-hide_banner", "-nostats", "-v", log_format];
if let Some(encoder_input_cmd) = &ADVANCED_CONFIG.lock().unwrap().encoder.input_cmd {
if let Some(encoder_input_cmd) = &ADVANCED_CONFIG.encoder.input_cmd {
enc_cmd.append(&mut encoder_input_cmd.clone());
}

View File

@ -50,7 +50,7 @@ fn ingest_to_hls_server(
let mut dummy_media = Media::new(0, "Live Stream", false);
dummy_media.unit = Ingest;
if let Some(ingest_input_cmd) = &ADVANCED_CONFIG.lock().unwrap().ingest.input_cmd {
if let Some(ingest_input_cmd) = &ADVANCED_CONFIG.ingest.input_cmd {
server_prefix.append(&mut ingest_input_cmd.clone());
}
@ -202,7 +202,7 @@ pub fn write_hls(
let mut enc_prefix = vec_strings!["-hide_banner", "-nostats", "-v", &ff_log_format];
if let Some(encoder_input_cmd) = &ADVANCED_CONFIG.lock().unwrap().encoder.input_cmd {
if let Some(encoder_input_cmd) = &ADVANCED_CONFIG.encoder.input_cmd {
enc_prefix.append(&mut encoder_input_cmd.clone());
}

View File

@ -134,7 +134,7 @@ pub fn player(
let mut dec_cmd = vec_strings!["-hide_banner", "-nostats", "-v", &ff_log_format];
if let Some(decoder_input_cmd) = &ADVANCED_CONFIG.lock().unwrap().decoder.input_cmd {
if let Some(decoder_input_cmd) = &ADVANCED_CONFIG.decoder.input_cmd {
dec_cmd.append(&mut decoder_input_cmd.clone());
}

View File

@ -184,7 +184,7 @@ impl Default for Filters {
}
fn deinterlace(field_order: &Option<String>, chain: &mut Filters) {
if let Some(deinterlace) = &ADVANCED_CONFIG.lock().unwrap().decoder.filters.deinterlace {
if let Some(deinterlace) = &ADVANCED_CONFIG.decoder.filters.deinterlace {
chain.add_filter(&deinterlace, 0, Video)
} else if let Some(order) = field_order {
if order != "progressive" {
@ -197,18 +197,16 @@ fn pad(aspect: f64, chain: &mut Filters, v_stream: &ffprobe::Stream, config: &Pl
if !is_close(aspect, config.processing.aspect, 0.03) {
let mut scale = String::new();
let advanced = ADVANCED_CONFIG.lock().unwrap();
if let (Some(w), Some(h)) = (v_stream.width, v_stream.height) {
if w > config.processing.width && aspect > config.processing.aspect {
match &advanced.decoder.filters.pad_scale_w {
match &ADVANCED_CONFIG.decoder.filters.pad_scale_w {
Some(pad_scale_w) => {
scale = custom_format(pad_scale_w, &[&config.processing.width])
}
None => scale = format!("scale={}:-1,", config.processing.width),
};
} else if h > config.processing.height && aspect < config.processing.aspect {
match &advanced.decoder.filters.pad_scale_h {
match &ADVANCED_CONFIG.decoder.filters.pad_scale_h {
Some(pad_scale_h) => {
scale = custom_format(pad_scale_h, &[&config.processing.width])
}
@ -217,7 +215,7 @@ fn pad(aspect: f64, chain: &mut Filters, v_stream: &ffprobe::Stream, config: &Pl
}
}
if let Some(pad_video) = &advanced.decoder.filters.pad_video {
if let Some(pad_video) = &ADVANCED_CONFIG.decoder.filters.pad_video {
chain.add_filter(
&custom_format(
pad_video,
@ -245,9 +243,7 @@ fn pad(aspect: f64, chain: &mut Filters, v_stream: &ffprobe::Stream, config: &Pl
fn fps(fps: f64, chain: &mut Filters, config: &PlayoutConfig) {
if fps != config.processing.fps {
let advanced = ADVANCED_CONFIG.lock().unwrap();
match &advanced.decoder.filters.fps {
match &ADVANCED_CONFIG.decoder.filters.fps {
Some(fps) => chain.add_filter(&custom_format(fps, &[&config.processing.fps]), 0, Video),
None => chain.add_filter(&format!("fps={}", config.processing.fps), 0, Video),
}

View File

@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::Arc;
extern crate log;
extern crate simplelog;
@ -12,6 +12,5 @@ pub mod utils;
use utils::advanced_config::AdvancedConfig;
lazy_static! {
pub static ref ADVANCED_CONFIG: Arc<Mutex<AdvancedConfig>> =
Arc::new(Mutex::new(AdvancedConfig::new()));
pub static ref ADVANCED_CONFIG: Arc<AdvancedConfig> = Arc::new(AdvancedConfig::new());
}

View File

@ -432,7 +432,7 @@ impl PlayoutConfig {
process_cmd.append(&mut vec_strings!["-vn"]);
} else if config.processing.copy_video {
process_cmd.append(&mut vec_strings!["-c:v", "copy"]);
} else if let Some(decoder_cmd) = &ADVANCED_CONFIG.lock().unwrap().decoder.output_cmd {
} else if let Some(decoder_cmd) = &ADVANCED_CONFIG.decoder.output_cmd {
if !decoder_cmd.contains(&"-r".to_string()) {
process_cmd.append(&mut vec_strings!["-r", &config.processing.fps]);
}
@ -471,7 +471,7 @@ impl PlayoutConfig {
if config.processing.copy_audio {
process_cmd.append(&mut vec_strings!["-c:a", "copy"]);
} else if ADVANCED_CONFIG.lock().unwrap().decoder.output_cmd.is_none() {
} else if ADVANCED_CONFIG.decoder.output_cmd.is_none() {
process_cmd.append(&mut pre_audio_codec(
&config.processing.custom_filter,
&config.ingest.custom_filter,