mod audio;
mod number;
mod time;
mod timeline;
mod timeline_expression;
mod video;
pub use audio::{AudioDomain, AudioSpec};
pub use number::Number;
pub(crate) use number::Number as ExactNumber;
pub(crate) use time::{DurationValue, NativeRange, SourceTime, SourceTimeRange};
pub use time::{FrameCount, FrameRange, SampleRange};
pub(crate) use timeline::FrameSampleStep;
pub(crate) use timeline::TimelineRate;
pub(crate) use timeline_expression::{TimelineExpression, TimelineRangeExpression};
pub use video::{FrameRate, ImageFit, VideoDomain, VideoSpec};
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct ValueId(u32);
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct NodeId(u32);
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub(crate) struct TimelineViewId(u32);
impl ValueId {
pub(crate) const fn new(value: u32) -> Self {
Self(value)
}
#[must_use]
pub const fn get(self) -> u32 {
self.0
}
}
impl NodeId {
pub(crate) const fn new(value: u32) -> Self {
Self(value)
}
#[must_use]
pub const fn get(self) -> u32 {
self.0
}
}
impl TimelineViewId {
pub(crate) const fn new(value: u32) -> Self {
Self(value)
}
pub(crate) const fn index(self) -> usize {
self.0 as usize
}
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ValueType {
Video,
Audio,
}
impl ValueType {
#[must_use]
pub(crate) fn from_source_name(name: &str) -> Option<Self> {
match name {
"Video" => Some(Self::Video),
"Audio" => Some(Self::Audio),
_ => None,
}
}
#[must_use]
pub(crate) const fn native_unit_name(self) -> &'static str {
match self {
Self::Video => "frames",
Self::Audio => "samples",
}
}
}
impl std::fmt::Display for ValueType {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Video => formatter.write_str("Video"),
Self::Audio => formatter.write_str("Audio"),
}
}
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct ValueRef {
id: ValueId,
value_type: ValueType,
}
impl ValueRef {
#[must_use]
pub(crate) const fn new(id: ValueId, value_type: ValueType) -> Self {
Self { id, value_type }
}
#[must_use]
pub fn id(self) -> ValueId {
self.id
}
#[must_use]
pub const fn value_type(self) -> ValueType {
self.value_type
}
}