no regex match validation for scale filter

This commit is contained in:
jb-alvarado 2023-04-12 22:24:42 +02:00
parent 535511f394
commit d1ce475692
3 changed files with 18 additions and 10 deletions

View File

@ -115,7 +115,11 @@ fn get_media_map(media: Media) -> Value {
}
/// prepare json object for response
fn get_data_map(config: &PlayoutConfig, media: Media, server_is_running: bool) -> Map<String, Value> {
fn get_data_map(
config: &PlayoutConfig,
media: Media,
server_is_running: bool,
) -> Map<String, Value> {
let mut data_map = Map::new();
let begin = media.begin.unwrap_or(0.0);
@ -321,7 +325,11 @@ pub fn json_rpc_server(
// get infos about current clip
if map.contains_key("media") && &map["media"] == "current" {
if let Some(media) = play_control.current_media.lock().unwrap().clone() {
let data_map = get_data_map(&config, media, proc.server_is_running.load(Ordering::SeqCst));
let data_map = get_data_map(
&config,
media,
proc.server_is_running.load(Ordering::SeqCst),
);
return Ok(Value::Object(data_map));
};

View File

@ -290,20 +290,14 @@ fn overlay(node: &mut Media, chain: &mut Filters, config: &PlayoutConfig) {
&& &node.category != "advertisement"
{
let mut scale = String::new();
let re = Regex::new(r"[)(\d\w-]+:[)(\d\w-]+").unwrap();
let mut logo = config.processing.logo.clone();
if cfg!(windows) {
logo = logo.replace('\\', "/").replace(':', "\\\\:");
}
if re.is_match(&config.processing.logo_scale) {
if !config.processing.logo_scale.is_empty() {
scale = format!(",scale={}", config.processing.logo_scale);
}
let mut logo_chain = format!(
"null[v];movie={}:loop=0,setpts=N/(FRAME_RATE*TB),format=rgba,colorchannelmixer=aa={}{scale}[l];[v][l]{}:shortest=1",
logo, config.processing.logo_opacity, config.processing.logo_filter
config.processing.logo.replace('\\', "/").replace(':', "\\\\:"), config.processing.logo_opacity, config.processing.logo_filter
);
if node.last_ad.unwrap_or(false) {

View File

@ -358,6 +358,12 @@ impl PlayoutConfig {
config.processing.add_logo = false;
}
config.processing.logo_scale = config
.processing
.logo_scale
.trim_end_matches('~')
.to_string();
if config.processing.audio_tracks < 1 {
config.processing.audio_tracks = 1
}