use crate::frame::FrameBuffer;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum VideoCodec {
Unspecified,
Vp8,
Vp9Profile0Level10Bit8,
Mock,
}
impl VideoCodec {
pub fn as_webcodecs_str(&self) -> Option<&'static str> {
match self {
VideoCodec::Unspecified => None,
VideoCodec::Vp8 => Some("vp8"),
VideoCodec::Vp9Profile0Level10Bit8 => Some("vp09.00.10.08"),
VideoCodec::Mock => Some("vp8"), }
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DecodedFrame {
pub sequence_number: u64,
pub width: u32,
pub height: u32,
pub data: Vec<u8>,
}
pub trait Decodable: Send + Sync {
type Frame;
fn new(codec: VideoCodec, on_decoded_frame: Box<dyn Fn(Self::Frame) + Send + Sync>) -> Self
where
Self: Sized;
fn decode(&self, frame: FrameBuffer);
}
#[cfg(feature = "native")]
mod native;
#[cfg(feature = "native")]
pub use self::native::NativeDecoder as Decoder;
#[cfg(feature = "wasm")]
mod wasm;
#[cfg(feature = "wasm")]
pub use self::wasm::WasmDecoder;