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
|
config.processing.logo
|
||||||
);
|
);
|
||||||
|
|
||||||
if node.last_ad.unwrap() {
|
if let Some(last) = &node.last {
|
||||||
logo_chain.push_str(",fade=in:st=0:d=1.0:alpha=1")
|
if last.category == "advertisement" {
|
||||||
|
logo_chain.push_str(",fade=in:st=0:d=1.0:alpha=1")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.next_ad.unwrap() {
|
if let Some(next) = &node.next {
|
||||||
logo_chain.push_str(
|
if next.category == "advertisement" {
|
||||||
format!(",fade=out:st={}:d=1.0:alpha=1", node.out - node.seek - 1.0).as_str(),
|
logo_chain.push_str(
|
||||||
)
|
format!(",fade=out:st={}:d=1.0:alpha=1", node.out - node.seek - 1.0).as_str(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logo_chain
|
logo_chain
|
||||||
|
@ -7,8 +7,8 @@ use simplelog::*;
|
|||||||
use tokio::runtime::Handle;
|
use tokio::runtime::Handle;
|
||||||
|
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
check_sync, gen_dummy, get_delta, get_sec, is_close, json_reader::read_json,
|
check_sync, gen_dummy, get_delta, get_sec, is_close, json_reader::read_json, modified_time,
|
||||||
modified_time, seek_and_length, GlobalConfig, Media, DUMMY_LEN,
|
seek_and_length, GlobalConfig, Media, DUMMY_LEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -142,23 +142,13 @@ impl CurrentProgram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_ad(&mut self, i: usize, next: bool) -> Option<bool> {
|
fn last_next_node(&mut self) {
|
||||||
if next {
|
if self.index + 1 < self.nodes.len() {
|
||||||
if i + 1 < self.nodes.len() && self.nodes[i + 1].category == "advertisement".to_string()
|
self.current_node.next = Some(Box::new(self.nodes[self.index + 1].clone()));
|
||||||
{
|
}
|
||||||
return Some(true);
|
|
||||||
} else {
|
if self.index > 0 && self.index < self.nodes.len() {
|
||||||
return Some(false);
|
self.current_node.last = Some(Box::new(self.nodes[self.index - 1].clone()));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if i > 0
|
|
||||||
&& i < self.nodes.len()
|
|
||||||
&& self.nodes[i - 1].category == "advertisement".to_string()
|
|
||||||
{
|
|
||||||
return Some(true);
|
|
||||||
} else {
|
|
||||||
return Some(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,8 +242,7 @@ impl Iterator for CurrentProgram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.current_node.last_ad = self.is_ad(self.index, false);
|
self.last_next_node();
|
||||||
self.current_node.next_ad = self.is_ad(self.index, true);
|
|
||||||
|
|
||||||
return Some(self.current_node.clone());
|
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 = timed_source(self.nodes[self.index].clone(), &self.config, is_last);
|
||||||
self.current_node.last_ad = self.is_ad(self.index, false);
|
self.last_next_node();
|
||||||
self.current_node.next_ad = self.is_ad(self.index, true);
|
|
||||||
self.index += 1;
|
self.index += 1;
|
||||||
|
|
||||||
// update playlist should happen after current clip,
|
// update playlist should happen after current clip,
|
||||||
@ -277,9 +265,9 @@ impl Iterator for CurrentProgram {
|
|||||||
Some(self.current_node.clone())
|
Some(self.current_node.clone())
|
||||||
} else {
|
} else {
|
||||||
let last_playlist = self.json_path.clone();
|
let last_playlist = self.json_path.clone();
|
||||||
|
let last = self.current_node.clone();
|
||||||
self.check_for_next_playlist();
|
self.check_for_next_playlist();
|
||||||
let (_, total_delta) = get_delta(&self.config.playlist.start_sec.unwrap());
|
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
|
if last_playlist == self.json_path
|
||||||
&& total_delta.abs() > self.config.general.stop_threshold
|
&& 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.current_node = gen_source(self.current_node.clone());
|
||||||
self.nodes.push(self.current_node.clone());
|
self.nodes.push(self.current_node.clone());
|
||||||
|
|
||||||
last_ad = self.is_ad(self.index, false);
|
self.current_node.last = Some(Box::new(last));
|
||||||
self.current_node.last_ad = last_ad;
|
|
||||||
self.current_node.add_filter();
|
self.current_node.add_filter();
|
||||||
|
|
||||||
return Some(self.current_node.clone());
|
return Some(self.current_node.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.current_node = gen_source(self.nodes[0].clone());
|
self.index = 0;
|
||||||
self.current_node.last_ad = last_ad;
|
self.current_node = gen_source(self.nodes[self.index].clone());
|
||||||
self.current_node.next_ad = self.is_ad(0, true);
|
self.last_next_node();
|
||||||
|
self.current_node.last = Some(Box::new(last));
|
||||||
|
|
||||||
self.index = 1;
|
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);
|
ProcessCleanup::new(server_term.clone(), is_terminated.clone(), enc_proc);
|
||||||
|
|
||||||
'source_iter: for node in get_source {
|
'source_iter: for node in get_source {
|
||||||
|
println!("{:?}", &node.clone());
|
||||||
let cmd = match node.cmd {
|
let cmd = match node.cmd {
|
||||||
Some(cmd) => cmd,
|
Some(cmd) => cmd,
|
||||||
None => break,
|
None => break,
|
||||||
|
@ -93,8 +93,6 @@ pub fn read_json(
|
|||||||
for (i, item) in playlist.program.iter_mut().enumerate() {
|
for (i, item) in playlist.program.iter_mut().enumerate() {
|
||||||
item.begin = Some(start_sec);
|
item.begin = Some(start_sec);
|
||||||
item.index = Some(i);
|
item.index = Some(i);
|
||||||
item.last_ad = Some(false);
|
|
||||||
item.next_ad = Some(false);
|
|
||||||
item.process = Some(true);
|
item.process = Some(true);
|
||||||
item.filter = Some(vec![]);
|
item.filter = Some(vec![]);
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ pub struct Media {
|
|||||||
pub cmd: Option<Vec<String>>,
|
pub cmd: Option<Vec<String>>,
|
||||||
pub filter: Option<Vec<String>>,
|
pub filter: Option<Vec<String>>,
|
||||||
pub probe: Option<MediaProbe>,
|
pub probe: Option<MediaProbe>,
|
||||||
pub last_ad: Option<bool>,
|
pub last: Option<Box<Media>>,
|
||||||
pub next_ad: Option<bool>,
|
pub next: Option<Box<Media>>,
|
||||||
pub process: Option<bool>,
|
pub process: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +72,8 @@ impl Media {
|
|||||||
cmd: Some(vec!["-i".to_string(), src]),
|
cmd: Some(vec!["-i".to_string(), src]),
|
||||||
filter: Some(vec![]),
|
filter: Some(vec![]),
|
||||||
probe: probe,
|
probe: probe,
|
||||||
last_ad: Some(false),
|
last: None,
|
||||||
next_ad: Some(false),
|
next: None,
|
||||||
process: Some(true),
|
process: Some(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user