Merge branch 'main' of github.com:jb-alvarado/ffplayout-rs
This commit is contained in:
commit
ba49e9baa9
22
.github/workflows/rust.yml
vendored
Normal file
22
.github/workflows/rust.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
name: Rust
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
@ -155,14 +155,18 @@ fn overlay(node: &mut Media, chain: &mut Filters, config: &GlobalConfig) {
|
||||
config.processing.logo
|
||||
);
|
||||
|
||||
if node.last_ad.unwrap() {
|
||||
logo_chain.push_str(",fade=in:st=0:d=1.0:alpha=1")
|
||||
if let Some(last) = &node.last {
|
||||
if last.category == "advertisement" {
|
||||
logo_chain.push_str(",fade=in:st=0:d=1.0:alpha=1")
|
||||
}
|
||||
}
|
||||
|
||||
if node.next_ad.unwrap() {
|
||||
logo_chain.push_str(
|
||||
format!(",fade=out:st={}:d=1.0:alpha=1", node.out - node.seek - 1.0).as_str(),
|
||||
)
|
||||
if let Some(next) = &node.next {
|
||||
if next.category == "advertisement" {
|
||||
logo_chain.push_str(
|
||||
format!(",fade=out:st={}:d=1.0:alpha=1", node.out - node.seek - 1.0).as_str(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
logo_chain
|
||||
|
@ -7,8 +7,8 @@ use simplelog::*;
|
||||
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,
|
||||
check_sync, gen_dummy, get_delta, get_sec, is_close, json_reader::read_json, modified_time,
|
||||
seek_and_length, GlobalConfig, Media, DUMMY_LEN,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -142,23 +142,13 @@ impl CurrentProgram {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_ad(&mut self, i: usize, next: bool) -> Option<bool> {
|
||||
if next {
|
||||
if i + 1 < self.nodes.len() && self.nodes[i + 1].category == "advertisement".to_string()
|
||||
{
|
||||
return Some(true);
|
||||
} else {
|
||||
return Some(false);
|
||||
}
|
||||
} else {
|
||||
if i > 0
|
||||
&& i < self.nodes.len()
|
||||
&& self.nodes[i - 1].category == "advertisement".to_string()
|
||||
{
|
||||
return Some(true);
|
||||
} else {
|
||||
return Some(false);
|
||||
}
|
||||
fn last_next_node(&mut self) {
|
||||
if self.index + 1 < self.nodes.len() {
|
||||
self.current_node.next = Some(Box::new(self.nodes[self.index + 1].clone()));
|
||||
}
|
||||
|
||||
if self.index > 0 && self.index < self.nodes.len() {
|
||||
self.current_node.last = Some(Box::new(self.nodes[self.index - 1].clone()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,8 +242,7 @@ impl Iterator for CurrentProgram {
|
||||
}
|
||||
}
|
||||
|
||||
self.current_node.last_ad = self.is_ad(self.index, false);
|
||||
self.current_node.next_ad = self.is_ad(self.index, true);
|
||||
self.last_next_node();
|
||||
|
||||
return Some(self.current_node.clone());
|
||||
}
|
||||
@ -267,8 +256,7 @@ impl Iterator for CurrentProgram {
|
||||
}
|
||||
|
||||
self.current_node = timed_source(self.nodes[self.index].clone(), &self.config, is_last);
|
||||
self.current_node.last_ad = self.is_ad(self.index, false);
|
||||
self.current_node.next_ad = self.is_ad(self.index, true);
|
||||
self.last_next_node();
|
||||
self.index += 1;
|
||||
|
||||
// update playlist should happen after current clip,
|
||||
@ -277,9 +265,9 @@ impl Iterator for CurrentProgram {
|
||||
Some(self.current_node.clone())
|
||||
} else {
|
||||
let last_playlist = self.json_path.clone();
|
||||
let last = self.current_node.clone();
|
||||
self.check_for_next_playlist();
|
||||
let (_, total_delta) = get_delta(&self.config.playlist.start_sec.unwrap());
|
||||
let mut last_ad = self.is_ad(self.index, false);
|
||||
|
||||
if last_playlist == self.json_path
|
||||
&& total_delta.abs() > self.config.general.stop_threshold
|
||||
@ -299,16 +287,16 @@ impl Iterator for CurrentProgram {
|
||||
self.current_node = gen_source(self.current_node.clone());
|
||||
self.nodes.push(self.current_node.clone());
|
||||
|
||||
last_ad = self.is_ad(self.index, false);
|
||||
self.current_node.last_ad = last_ad;
|
||||
self.current_node.last = Some(Box::new(last));
|
||||
self.current_node.add_filter();
|
||||
|
||||
return Some(self.current_node.clone());
|
||||
}
|
||||
|
||||
self.current_node = gen_source(self.nodes[0].clone());
|
||||
self.current_node.last_ad = last_ad;
|
||||
self.current_node.next_ad = self.is_ad(0, true);
|
||||
self.index = 0;
|
||||
self.current_node = gen_source(self.nodes[self.index].clone());
|
||||
self.last_next_node();
|
||||
self.current_node.last = Some(Box::new(last));
|
||||
|
||||
self.index = 1;
|
||||
|
||||
|
@ -172,6 +172,7 @@ pub fn player(rt_handle: &Handle, is_terminated: Arc<Mutex<bool>>) {
|
||||
ProcessCleanup::new(server_term.clone(), is_terminated.clone(), enc_proc);
|
||||
|
||||
'source_iter: for node in get_source {
|
||||
println!("{:?}", &node.clone());
|
||||
let cmd = match node.cmd {
|
||||
Some(cmd) => cmd,
|
||||
None => break,
|
||||
|
@ -93,8 +93,6 @@ pub fn read_json(
|
||||
for (i, item) in playlist.program.iter_mut().enumerate() {
|
||||
item.begin = Some(start_sec);
|
||||
item.index = Some(i);
|
||||
item.last_ad = Some(false);
|
||||
item.next_ad = Some(false);
|
||||
item.process = Some(true);
|
||||
item.filter = Some(vec![]);
|
||||
|
||||
|
@ -42,8 +42,8 @@ pub struct Media {
|
||||
pub cmd: Option<Vec<String>>,
|
||||
pub filter: Option<Vec<String>>,
|
||||
pub probe: Option<MediaProbe>,
|
||||
pub last_ad: Option<bool>,
|
||||
pub next_ad: Option<bool>,
|
||||
pub last: Option<Box<Media>>,
|
||||
pub next: Option<Box<Media>>,
|
||||
pub process: Option<bool>,
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ impl Media {
|
||||
cmd: Some(vec!["-i".to_string(), src]),
|
||||
filter: Some(vec![]),
|
||||
probe: probe,
|
||||
last_ad: Some(false),
|
||||
next_ad: Some(false),
|
||||
last: None,
|
||||
next: None,
|
||||
process: Some(true),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user