Skip to content

Commit

Permalink
filter div 0; ensure all frames have interval
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna-f1sh committed Dec 4, 2024
1 parent 8f891e2 commit 7a032c0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/function/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl From<Frame> for UvcFrame {
UvcFrame {
width: frame.width,
height: frame.height,
intervals: frame.fps.iter().map(|i| (1_000_000_000 / *i as u32)).collect(),
intervals: frame.fps.iter().filter(|i| **i != 0).map(|i| (1_000_000_000 / *i as u32)).collect(),
color_matching: None,
format: frame.format,
}
Expand Down Expand Up @@ -239,6 +239,10 @@ impl Function for UvcFunction {
return Err(Error::new(ErrorKind::InvalidInput, "at least one frame must exist"));
}

if self.builder.frames.iter().any(|f| f.intervals.is_empty()) {
return Err(Error::new(ErrorKind::InvalidInput, "at least one interval must exist for every frame"));
}

// format groups to link to header
let mut formats_to_link: HashSet<Format> = HashSet::new();

Expand Down

0 comments on commit 7a032c0

Please sign in to comment.