streaming

Media streaming and broadcast systems in Go
Log | Files | Refs | README | LICENSE

commit e0c941281a3edfd9fff650adfc1d09c29725cf64
parent b9498a86e1f4278c17f3e3574f0b7a1c00a99b55
Author: Oliver Lowe <o@olowe.co>
Date:   Tue,  7 May 2024 17:42:12 +1000

internal/scte35: add first end-to-end splice info encode test

Diffstat:
Minternal/scte35/splice_info_test.go | 44++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+), 0 deletions(-)

diff --git a/internal/scte35/splice_info_test.go b/internal/scte35/splice_info_test.go @@ -1,6 +1,8 @@ package scte35 import ( + "encoding/base64" + "encoding/binary" "fmt" "testing" ) @@ -15,3 +17,45 @@ func TestPackTier(t *testing.T) { t.Errorf("want packed tier %d, got %d", want, got) } } + +func TestReadSpliceInfo(t *testing.T) { + var tsig uint64 = 0x072bd0050 + var segdur uint64 = 0x0001a599b0 + sdesc := SegmentationDescriptor{ + EventID: 0x4800008e, + Restrictions: NoRegionalBlackout | ArchiveAllowed | DeviceRestrictGroup2, + Duration: &segdur, + UPID: UPID{ + UPIDTypeTI, + []byte{0x8a, 0xa1, 0xa0, 0x2c, 0x00, 0x00, 0x00, 0x00}, + }, + Type: 0x34, + Number: 2, + } + sis := SpliceInfo{ + Tier: 0xfff, + Command: &Command{ + Type: TimeSignal, + TimeSignal: &tsig, + }, + Descriptors: []SpliceDescriptor{ + { + Tag: TagSegmentation, + ID: binary.LittleEndian.Uint32([]byte(DescriptorIDCUEI)), + Data: encodeSegDescriptor(&sdesc), + }, + }, + CRC32: 0x9ac9d17e, + } + + want := "/DAvAAAAAAAA///wFAVIAACPf+/+c2nALv4AUsz1AAAAAAAKAAhDVUVJAAABNWLbowo=" + + bgot, err := encodeSpliceInfo(&sis) + if err != nil { + t.Fatalf("encode splice info: %v", err) + } + got := base64.StdEncoding.EncodeToString(bgot) + if got != want { + t.Fatalf("want %s, got %s", want, got) + } +}