commit - 3b1acc9102e2f96d3b40224dee1007a820c89675
commit + 52483617f8dc2116b504a6a85274b3c44a119ecd
blob - fc345b7152f9df4ae4271dcfb80f54af30d2acff
blob + 8509c58887b6b6618cc0ea89e76265a3768738c8
--- scte35/command.go
+++ scte35/command.go
binary.BigEndian.PutUint32(buf[:4], c.ID)
copy(buf[4:], c.Data)
return buf
+}
+
+func decodePrivateCommand(b []byte) (PrivateCommand, error) {
+ if len(b) < 4 {
+ return PrivateCommand{}, fmt.Errorf("need at least 4 bytes, have %d", len(b))
+ }
+ return PrivateCommand{
+ ID: binary.BigEndian.Uint32(b[:4]),
+ Data: b[4:],
+ }, nil
}
// Insert represents the splice_insert command
blob - 09dc49d4a9fc2ad191cd7adc467bdd0944d8215e
blob + 5512a4cdb4a92941f104cc8e6744c9c2c656ce26
--- scte35/splice.go
+++ scte35/splice.go
ins.AvailNum = uint8(buf[2])
ins.AvailExpected = uint8(buf[3])
cmd.Insert = &ins
+ case Private:
+ pcmd, err := decodePrivateCommand(buf[1:])
+ if err != nil {
+ return nil, fmt.Errorf("decode private command: %w", err)
+ }
+ cmd.Private = &pcmd
default:
// TODO(otl): we could support more commands but we
// just haven't written the code yet. See issues