fix init playlist after live ingest stops
This commit is contained in:
parent
25fccf1a67
commit
e4dd9db22d
@ -251,7 +251,7 @@ fn add_loudnorm(node: &mut Media, chain: &mut Filters, config: &GlobalConfig) {
|
||||
|
||||
let audio_streams = node.probe.clone().unwrap().audio_streams.unwrap();
|
||||
|
||||
if audio_streams.len() != 0 && config.processing.add_loudnorm {
|
||||
if audio_streams.len() > 0 && config.processing.add_loudnorm {
|
||||
let loud_filter = format!(
|
||||
"loudnorm=I={}:TP={}:LRA={}",
|
||||
config.processing.loud_i, config.processing.loud_tp, config.processing.loud_lra
|
||||
|
@ -33,13 +33,13 @@ fn overlay(config: &GlobalConfig) -> String {
|
||||
|
||||
pub async fn ingest_server(
|
||||
log_format: String,
|
||||
ingest_sender: Sender<[u8; 65424]>,
|
||||
ingest_sender: Sender<[u8; 32256]>,
|
||||
rt_handle: Handle,
|
||||
proc_terminator: Arc<Mutex<Option<Terminator>>>,
|
||||
is_terminated: Arc<Mutex<bool>>,
|
||||
) -> Result<(), Error> {
|
||||
let config = GlobalConfig::global();
|
||||
let mut buffer: [u8; 65424] = [0; 65424];
|
||||
let mut buffer: [u8; 32256] = [0; 32256];
|
||||
let mut filter = format!(
|
||||
"[0:v]fps={},scale={}:{},setdar=dar={}",
|
||||
config.processing.fps,
|
||||
|
@ -8,7 +8,7 @@ use tokio::runtime::Handle;
|
||||
|
||||
use crate::utils::{
|
||||
check_sync, gen_dummy, get_delta, get_sec, is_close, json_reader::read_json, modified_time,
|
||||
seek_and_length, GlobalConfig, Media, DUMMY_LEN,
|
||||
sec_to_time, seek_and_length, GlobalConfig, Media, DUMMY_LEN,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -46,7 +46,12 @@ impl CurrentProgram {
|
||||
|
||||
fn check_update(&mut self, seek: bool) {
|
||||
if self.json_path.is_none() {
|
||||
let json = read_json(self.rt_handle.clone(), self.is_terminated.clone(), seek, 0.0);
|
||||
let json = read_json(
|
||||
self.rt_handle.clone(),
|
||||
self.is_terminated.clone(),
|
||||
seek,
|
||||
0.0,
|
||||
);
|
||||
|
||||
self.json_path = json.current_file;
|
||||
self.json_mod = json.modified;
|
||||
@ -60,7 +65,12 @@ impl CurrentProgram {
|
||||
.eq(&self.json_mod.clone().unwrap())
|
||||
{
|
||||
// when playlist has changed, reload it
|
||||
let json = read_json(self.rt_handle.clone(), self.is_terminated.clone(), false, 0.0);
|
||||
let json = read_json(
|
||||
self.rt_handle.clone(),
|
||||
self.is_terminated.clone(),
|
||||
false,
|
||||
0.0,
|
||||
);
|
||||
|
||||
self.json_mod = json.modified;
|
||||
self.nodes = json.program;
|
||||
@ -145,18 +155,20 @@ impl CurrentProgram {
|
||||
time_sec += self.config.playlist.length_sec.unwrap()
|
||||
}
|
||||
|
||||
let mut start_sec = self.start_sec.clone();
|
||||
|
||||
for (i, item) in self.nodes.iter_mut().enumerate() {
|
||||
if start_sec + item.out - item.seek > time_sec {
|
||||
if item.begin.unwrap() + item.out - item.seek > time_sec {
|
||||
*self.init.lock().unwrap() = false;
|
||||
self.index = i + 1;
|
||||
item.seek = time_sec - start_sec;
|
||||
item.seek = time_sec - item.begin.unwrap();
|
||||
|
||||
println!("time_sec: {}", sec_to_time(time_sec));
|
||||
println!("item.begin: {}", sec_to_time(item.begin.unwrap()));
|
||||
println!("item.seek: {}", item.seek);
|
||||
println!("item.out: {}", item.out);
|
||||
|
||||
self.current_node = handle_list_init(item.clone());
|
||||
break;
|
||||
}
|
||||
start_sec += item.out - item.seek;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,8 @@ pub fn play(rt_handle: &Handle) {
|
||||
"Encoder".to_string(),
|
||||
));
|
||||
|
||||
let (ingest_sender, ingest_receiver): (Sender<[u8; 65424]>, Receiver<([u8; 65424])>) = channel();
|
||||
let (ingest_sender, ingest_receiver): (Sender<[u8; 32256]>, Receiver<([u8; 32256])>) =
|
||||
channel();
|
||||
|
||||
if config.ingest.enable {
|
||||
rt_handle.spawn(ingest_server(
|
||||
@ -168,7 +169,7 @@ pub fn play(rt_handle: &Handle) {
|
||||
if let Err(e) = enc_writer.write_all(&receive) {
|
||||
error!("Ingest receiver error: {:?}", e);
|
||||
|
||||
break 'source_iter
|
||||
break 'source_iter;
|
||||
};
|
||||
|
||||
live_on = true;
|
||||
@ -177,7 +178,7 @@ pub fn play(rt_handle: &Handle) {
|
||||
if let Some(dec) = &*decoder_term.lock().unwrap() {
|
||||
unsafe {
|
||||
if let Ok(_) = dec.terminate() {
|
||||
info!("Switch from decoder to live ingest");
|
||||
info!("Switch from {} to live ingest", config.processing.mode);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -192,11 +193,11 @@ pub fn play(rt_handle: &Handle) {
|
||||
if let Err(e) = enc_writer.write(&buffer[..dec_bytes_len]) {
|
||||
error!("Encoder write error: {:?}", e);
|
||||
|
||||
break 'source_iter
|
||||
break 'source_iter;
|
||||
};
|
||||
} else {
|
||||
if live_on {
|
||||
info!("Switch from live ingest to decoder");
|
||||
info!("Switch from live ingest to {}", config.processing.mode);
|
||||
|
||||
live_on = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user