commit 7df33c66e9115e28fc1f2a8f5de235128e6be934
parent f8b93b8eb11ea50ba94dee757fd4ae066ded24d7
Author: Oliver Lowe <o@olowe.co>
Date: Mon, 13 May 2024 14:32:06 +1000
internal/scte35: implement encoding of splice insert commands
Diffstat:
4 files changed, 5 insertions(+), 25 deletions(-)
diff --git a/internal/scte35/break_duration.go b/internal/scte35/break_duration.go
@@ -15,7 +15,8 @@ func packBreakDuration(b *BreakDuration) [5]byte {
if b.AutoReturn {
p[0] |= (1 << 7)
}
- // next 6 bits are reserved.
+ // toggle 6 reserved bits
+ p[0] |= 0b01111110
pts := toPTS(b.Duration)
// 1 bit remaining in the first byte, so pack 1 bit from the timestamp
p[0] |= pts[0]
diff --git a/internal/scte35/break_duration_test.go b/internal/scte35/break_duration_test.go
@@ -8,7 +8,7 @@ func TestPackBreakDuration(t *testing.T) {
dur := uint64(8589934492) // 2^33 - 100
bd := BreakDuration{true, dur}
want := [5]byte{
- 0b10000001,
+ 0b11111111,
0b11111111,
0b11111111,
0b11111111,
diff --git a/internal/scte35/command.go b/internal/scte35/command.go
@@ -209,7 +209,8 @@ func encodeInsert(ins *Insert) []byte {
if ins.EventIDCompliance {
buf[5] |= (1 << 3)
}
- // next 3 bits are reserved.
+ // toggle remaining 3 reserved bits.
+ buf[5] |= 0x07
if ins.SpliceTime != nil && !ins.Immediate {
b := encodeSpliceTime(*ins.SpliceTime)
diff --git a/internal/scte35/splice_info_test.go b/internal/scte35/splice_info_test.go
@@ -128,25 +128,3 @@ func TestEncodeSpliceInfo(t *testing.T) {
})
}
}
-
-func TestEncodeInsert(t *testing.T) {
- // want := 0x4800008f7feffe7369c02efe
- ins := samples[1].want.Command.Insert
- b := encodeInsert(ins)
- want := []byte{
- 0x48,
- 0x00,
- 0x00,
- 0x8f,
- 0x7f,
- 0xef,
- 0xfe,
- 0x73,
- 0x69,
- 0xc0,
- 0x2e,
- 0xfe,
- }
- fmt.Printf("%#x\n", want)
- fmt.Printf("%#x\n", b)
-}