diff --git a/CHANGELOG.md b/CHANGELOG.md index b7492e3..577b312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ ## Unreleased - FutureDate +### Changed + - The `SpliceCommand` enum is now marked `non_exhaustive` since there may be additions to it in future. + +### Added + - New `private_command()` syntax support via a new `SpliceCommand::PrivateCommand` variant + ## 0.15.0 - 2024-02-23 ### Changed diff --git a/README.md b/README.md index fca7c95..47cffda 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ A subset of possible SCTE-35 syntax is currently handled: - [x] `splice_insert()` - [x] `time_signal()` - [x] `bandwidth_reservation()` - - [ ] `private_command()` + - [x] `private_command()` ### Descriptors diff --git a/src/lib.rs b/src/lib.rs index 4e5b360..456a399 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -253,6 +253,7 @@ impl<'a> std::fmt::Debug for SpliceInfoHeader<'a> { } } +#[non_exhaustive] #[derive(Debug, serde_derive::Serialize)] pub enum SpliceCommand { SpliceNull {}, @@ -265,6 +266,10 @@ pub enum SpliceCommand { splice_time: SpliceTime, }, BandwidthReservation {}, + PrivateCommand { + identifier: u32, + private_bytes: Vec, + } } #[derive(Debug, serde_derive::Serialize)] @@ -1251,6 +1256,7 @@ where SpliceCommandType::BandwidthReservation => { Some(Self::bandwidth_reservation(payload)) } + SpliceCommandType::PrivateCommand => Some(Self::private_command(payload)), _ => None, }; match splice_command { @@ -1354,6 +1360,15 @@ where } } + fn private_command(payload: &[u8]) -> Result { + let mut r = bitreader::BitReader::new(payload); + let identifier = r.read_u32(32).named("private_command.identifier")?; + Ok(SpliceCommand::PrivateCommand { + identifier, + private_bytes: payload[4..].to_vec(), + }) + } + fn read_splice_detail( r: &mut bitreader::BitReader<'_>, splice_event_cancel_indicator: bool,