#![forbid(unsafe_code)]
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct DecodedVideoFrames {
timestamps_us: Vec<f64>,
luma_planes: Vec<Vec<u8>>,
}
impl DecodedVideoFrames {
#[must_use]
pub const fn new(timestamps_us: Vec<f64>, luma_planes: Vec<Vec<u8>>) -> Self {
Self {
timestamps_us,
luma_planes,
}
}
}
#[wasm_bindgen]
impl DecodedVideoFrames {
#[wasm_bindgen(getter)]
#[allow(
clippy::cast_possible_truncation,
reason = "test/smoke frame counts are tiny"
)]
pub fn frame_count(&self) -> u32 {
self.timestamps_us.len() as u32
}
pub fn timestamp_us(&self, index: u32) -> f64 {
self.timestamps_us[index as usize]
}
pub fn luma_plane(&self, index: u32) -> Vec<u8> {
self.luma_planes[index as usize].clone() }
}
#[cfg(test)]
#[path = "frames_tests.rs"]
mod tests;