use broadcast_common::{Parse, Serialize};
use st12_1::{FrameRate, LtcFrame};
fn main() {
#[rustfmt::skip]
let bytes: [u8; st12_1::FRAME_LEN] =
[0x13, 0x29, 0x35, 0x4C, 0x53, 0x6A, 0x71, 0x88, 0xFC, 0xBF];
let frame = LtcFrame::parse(&bytes).expect("parse LTC codeword");
println!(
"time address: {:02}:{:02}:{:02}:{:02}",
frame.hours, frame.minutes, frame.seconds, frame.frames
);
println!("drop_frame_flag: {}", frame.drop_frame_flag);
println!("color_frame_flag: {}", frame.color_frame_flag);
println!("user bits: {:X?}", frame.user_bits);
for rate in [FrameRate::Fps30, FrameRate::Fps25, FrameRate::Fps24] {
let bgf = frame.binary_group_flags(rate);
println!(
"{rate}: polarity_correction={} binary_group_usage={}",
frame.polarity_correction(rate),
bgf.usage()
);
}
let mut out = [0u8; st12_1::FRAME_LEN];
frame.serialize_into(&mut out).expect("serialize");
assert_eq!(out, bytes, "byte-identical round trip");
println!("round trip byte-identical: OK ({} bytes)", out.len());
}