smpte_timecode/mtc/
mod.rs1mod decoder;
9mod encoder;
10mod errors;
11
12pub use decoder::{LockState, MtcDecoder, MtcEvent};
13pub use encoder::MtcEncoder;
14pub use errors::MtcError;
15
16use crate::FrameRate;
17
18const QUARTER_FRAME: u8 = 0xF1;
19const SYSEX_START: u8 = 0xF0;
20const SYSEX_END: u8 = 0xF7;
21const UNIVERSAL_REAL_TIME: u8 = 0x7F;
22const ALL_DEVICES: u8 = 0x7F;
23const SUB_ID_TIME_CODE: u8 = 0x01;
24const SUB_ID_FULL_FRAME: u8 = 0x01;
25
26#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
28pub enum Direction {
29 Forward,
31 Reverse,
33}
34
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
37pub enum Motion {
38 Forward,
40 Reverse,
42 Located,
44}
45
46const fn stream_rate(code: u8) -> FrameRate {
48 match code {
49 0 => FrameRate::FPS_24,
50 1 => FrameRate::FPS_25,
51 2 => FrameRate::FPS_29_97_DF,
52 _ => FrameRate::FPS_30,
53 }
54}
55
56const fn rate_code(rate: FrameRate) -> Result<u8, MtcError> {
58 match (rate.nominal(), rate.is_drop_frame()) {
59 (24, _) => Ok(0),
60 (25, _) => Ok(1),
61 (30, true) => Ok(2),
62 (30, false) => Ok(3),
63 _ => Err(MtcError::NoRateCode),
64 }
65}