Skip to content

Commit

Permalink
Add support for private_command() syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
dholroyd committed Mar 10, 2024
1 parent a53e3f5 commit 449f170
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ impl<'a> std::fmt::Debug for SpliceInfoHeader<'a> {
}
}

#[non_exhaustive]
#[derive(Debug, serde_derive::Serialize)]
pub enum SpliceCommand {
SpliceNull {},
Expand All @@ -265,6 +266,10 @@ pub enum SpliceCommand {
splice_time: SpliceTime,
},
BandwidthReservation {},
PrivateCommand {
identifier: u32,
private_bytes: Vec<u8>,
}
}

#[derive(Debug, serde_derive::Serialize)]
Expand Down Expand Up @@ -1251,6 +1256,7 @@ where
SpliceCommandType::BandwidthReservation => {
Some(Self::bandwidth_reservation(payload))
}
SpliceCommandType::PrivateCommand => Some(Self::private_command(payload)),
_ => None,
};
match splice_command {
Expand Down Expand Up @@ -1354,6 +1360,15 @@ where
}
}

fn private_command(payload: &[u8]) -> Result<SpliceCommand, SpliceDescriptorErr> {
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,
Expand Down

0 comments on commit 449f170

Please sign in to comment.