streaming

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

commit 2d91eff9749102b83cc82919f67c016e44096676
parent 6f91fd7e149c0466f57b4288c77d2b2c0c35de78
Author: Oliver Lowe <o@olowe.co>
Date:   Fri, 31 May 2024 16:27:29 +1000

scte35: use named segment descriptor type constants

Way better than having magic numbers everywhere!
Continues work on https://github.com/untangledco/streaming/issues/3

Diffstat:
Mscte35/codec_test.go | 2+-
Mscte35/scte35_test.go | 2+-
Mscte35/splice_descriptor.go | 4+---
3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/scte35/codec_test.go b/scte35/codec_test.go @@ -53,7 +53,7 @@ func ExampleEncode() { Type: scte35.UPIDTI, Value: []byte{0x00, 0x00, 0x00, 0x00, 0x2c, 0xa0, 0xa1, 0x8a}, }, - Type: 0x34, + Type: ProviderPlacementOppStart, Number: 2, Expected: 0, }, diff --git a/scte35/scte35_test.go b/scte35/scte35_test.go @@ -28,7 +28,7 @@ var samples = []sample{ Type: UPIDTI, Value: []byte{0x00, 0x00, 0x00, 0x00, 0x2c, 0xa0, 0xa1, 0x8a}, }, - Type: 0x34, + Type: ProviderPlacementOppStart, Number: 2, Expected: 0, }, diff --git a/scte35/splice_descriptor.go b/scte35/splice_descriptor.go @@ -163,8 +163,7 @@ func (d SegmentationDescriptor) Data() []byte { buf = append(buf, byte(d.Type), byte(d.Number), byte(d.Expected)) switch d.Type { - // TODO(otl): use named constants from section 10.3.3.1 Table 23 - segmentation_type_id - case 0x34, 0x30, 0x32, 0x36, 0x38, 0x3a, 0x44, 0x46: + case ProviderAdStart, DistributorAdStart, ProviderPlacementOppStart, DistributorPlacementOppStart, ProviderOverlayPlacementOppStart, DistributorOverlayPlacementOppStart, ProviderAdBlockStart, DistributorAdBlockStart: if d.SubNumber > 0 { buf = append(buf, d.SubNumber) } @@ -217,7 +216,6 @@ func unmarshalSegDescriptor(buf []byte) SegmentationDescriptor { desc.Number = uint8(buf[1]) desc.Expected = uint8(buf[2]) switch desc.Type { - // TODO(otl): use named constants from section 10.3.3.1 Table 23 - segmentation_type_id case ProviderAdStart, DistributorAdStart, ProviderPlacementOppStart, DistributorPlacementOppStart, ProviderOverlayPlacementOppStart, DistributorOverlayPlacementOppStart, ProviderAdBlockStart, DistributorAdBlockStart: if len(buf[2:]) > 1 { desc.SubNumber = uint8(buf[3])