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