streaming

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

commit 8c5823d831ca8c25cf4b0e1119b049acf32e3471
parent 95f3dab6a9cc691761cc0b2ce737533ea17f02fb
Author: Oliver Lowe <o@olowe.co>
Date:   Thu, 30 May 2024 16:06:49 +1000

scte35: unexport EventIDCompliance field

This probably should be calculated at runtime, or at least we need to
document when it should be set. Until then, just hide it and only set
it based on messages we need to parse.
Fixes https://github.com/untangledco/streaming/issues/2

Diffstat:
Mscte35/command.go | 26++++++++++++++++----------
Mscte35/command_test.go | 14+++++++-------
Mscte35/scte35_test.go | 48++++++++++++++++++++++++------------------------
Mscte35/splice_descriptor.go | 16++++++++++------
Mscte35/splice_info.go | 2+-
5 files changed, 58 insertions(+), 48 deletions(-)

diff --git a/scte35/command.go b/scte35/command.go @@ -94,9 +94,6 @@ type Event struct { // Indicates a previously sent event identified by ID should // be cancelled. Cancel bool - // Indicates the event's ID is prepared in the method - // described in SCTE 35 section 9.3.3. - IDCompliance bool OutOfNetwork bool // TODO(otl): should always be true? should we support @@ -109,6 +106,11 @@ type Event struct { ProgramID uint16 AvailNum uint8 AvailExpected uint8 + // Indicates the event's ID is prepared in the method + // described in SCTE 35 section 9.3.3. + // TODO(otl): can we calculate this at runtime? + // See https://github.com/untangledco/streaming/issues/2 + idCompliance bool } func packEvents(events []Event) ([]byte, error) { @@ -131,7 +133,7 @@ func packEvent(e *Event) []byte { if e.Cancel { p[4] |= 1 << 7 } - if e.IDCompliance { + if e.idCompliance { p[4] |= 1 << 6 } // 6 remaining bits are reserved. @@ -179,17 +181,21 @@ func encodePrivateCommand(c *PrivateCommand) []byte { // Insert represents the splice_insert command // as specified in SCTE 35 section 9.7.3. type Insert struct { - ID uint32 - Cancel bool - OutOfNetwork bool - Immediate bool - EventIDCompliance bool + ID uint32 + Cancel bool + OutOfNetwork bool + Immediate bool // Number of ticks of a 90KHz clock. SpliceTime *uint64 Duration *BreakDuration ProgramID uint16 AvailNum uint8 AvailExpected uint8 + // Indicates the event's ID is prepared in the method + // described in SCTE 35 section 9.3.3. + // TODO(otl): can we calculate this at runtime? + // See https://github.com/untangledco/streaming/issues/2 + idCompliance bool } func encodeInsert(ins *Insert) []byte { @@ -215,7 +221,7 @@ func encodeInsert(ins *Insert) []byte { if ins.Immediate { buf[5] |= (1 << 4) } - if ins.EventIDCompliance { + if ins.idCompliance { buf[5] |= (1 << 3) } // toggle remaining 3 reserved bits. diff --git a/scte35/command_test.go b/scte35/command_test.go @@ -7,15 +7,15 @@ import ( func TestEncodeInsert(t *testing.T) { out := &Insert{ - ID: 12345, - EventIDCompliance: true, - OutOfNetwork: true, - Immediate: true, - Duration: &BreakDuration{true, uint64(90000 * 2)}, + ID: 12345, + idCompliance: true, + OutOfNetwork: true, + Immediate: true, + Duration: &BreakDuration{true, uint64(90000 * 2)}, } in := &Insert{ - ID: out.ID, - EventIDCompliance: true, + ID: out.ID, + idCompliance: true, } bout := encodeInsert(out) diff --git a/scte35/scte35_test.go b/scte35/scte35_test.go @@ -20,10 +20,10 @@ var samples = []sample{ }, Descriptors: []SpliceDescriptor{ SegmentationDescriptor{ - EventID: 0x4800008e, - EventIDCompliance: true, - Restrictions: NoRegionalBlackout | ArchiveAllowed | DeviceRestrictionsNone, - Duration: newuint64(0x0001a599b0), + EventID: 0x4800008e, + idCompliance: true, + Restrictions: NoRegionalBlackout | ArchiveAllowed | DeviceRestrictionsNone, + Duration: newuint64(0x0001a599b0), UPID: UPID{ Type: UPIDTI, Value: []byte{0x00, 0x00, 0x00, 0x00, 0x2c, 0xa0, 0xa1, 0x8a}, @@ -46,10 +46,10 @@ var samples = []sample{ Command: &Command{ Type: SpliceInsert, Insert: &Insert{ - ID: 0x4800008f, - EventIDCompliance: true, - OutOfNetwork: true, - SpliceTime: newuint64(0x07369c02e), + ID: 0x4800008f, + idCompliance: true, + OutOfNetwork: true, + SpliceTime: newuint64(0x07369c02e), Duration: &BreakDuration{ AutoReturn: true, Duration: 0x00052ccf5, @@ -75,9 +75,9 @@ var samples = []sample{ }, Descriptors: []SpliceDescriptor{ SegmentationDescriptor{ - EventID: 0x4800008e, - EventIDCompliance: true, - Restrictions: WebDeliveryAllowed | NoRegionalBlackout | ArchiveAllowed | DeviceRestrictionsNone, + EventID: 0x4800008e, + idCompliance: true, + Restrictions: WebDeliveryAllowed | NoRegionalBlackout | ArchiveAllowed | DeviceRestrictionsNone, UPID: UPID{ Type: UPIDTI, Value: []byte{0x00, 0x00, 0x00, 0x00, 0x2c, 0xa0, 0xa1, 0x8a}, @@ -102,9 +102,9 @@ var samples = []sample{ }, Descriptors: []SpliceDescriptor{ SegmentationDescriptor{ - EventID: 0x48000018, - Restrictions: WebDeliveryAllowed | NoRegionalBlackout | ArchiveAllowed | DeviceRestrictionsNone, - EventIDCompliance: true, + EventID: 0x48000018, + Restrictions: WebDeliveryAllowed | NoRegionalBlackout | ArchiveAllowed | DeviceRestrictionsNone, + idCompliance: true, UPID: UPID{ Type: UPIDTI, Value: []byte{0, 0, 0, 0, 0x2c, 0xcb, 0xc3, 0x44}, @@ -112,9 +112,9 @@ var samples = []sample{ Type: 0x11, }, SegmentationDescriptor{ - EventID: 0x48000019, - EventIDCompliance: true, - Restrictions: WebDeliveryAllowed | NoRegionalBlackout | ArchiveAllowed | DeviceRestrictionsNone, + EventID: 0x48000019, + idCompliance: true, + Restrictions: WebDeliveryAllowed | NoRegionalBlackout | ArchiveAllowed | DeviceRestrictionsNone, UPID: UPID{ Type: UPIDTI, Value: []byte{0, 0, 0, 0, 0x2c, 0xa4, 0xdb, 0xa0}, @@ -138,9 +138,9 @@ var samples = []sample{ }, Descriptors: []SpliceDescriptor{ SegmentationDescriptor{ - EventID: 1560886545, - EventIDCompliance: true, - Restrictions: WebDeliveryAllowed | NoRegionalBlackout | DeviceRestrictionsNone, + EventID: 1560886545, + idCompliance: true, + Restrictions: WebDeliveryAllowed | NoRegionalBlackout | DeviceRestrictionsNone, UPID: UPID{ Type: UPIDType(1), Value: []byte{69, 80, 48, 49, 56, 48, 51, 56, 52, 48, 48, 54, 54, 54}, @@ -150,10 +150,10 @@ var samples = []sample{ Expected: 100, }, SegmentationDescriptor{ - EventID: 1560886545, - EventIDCompliance: true, - Restrictions: WebDeliveryAllowed | NoRegionalBlackout | DeviceRestrictionsNone, - Duration: newuint64(19803003), + EventID: 1560886545, + idCompliance: true, + Restrictions: WebDeliveryAllowed | NoRegionalBlackout | DeviceRestrictionsNone, + Duration: newuint64(19803003), UPID: UPID{ Type: UPIDType(1), Value: []byte{67, 49, 52, 54, 52}, diff --git a/scte35/splice_descriptor.go b/scte35/splice_descriptor.go @@ -110,10 +110,9 @@ const ( // SegmentationDescriptor represents the segmentation_descriptor // structure defined in SCTE 35 section 10.3.3. type SegmentationDescriptor struct { - EventID uint32 - Cancel bool - EventIDCompliance bool - Restrictions DeliveryRestrictions + EventID uint32 + Cancel bool + Restrictions DeliveryRestrictions // 40-bit integer representing the number of ticks of a 90KHz clock. Duration *uint64 UPID UPID @@ -127,6 +126,11 @@ type SegmentationDescriptor struct { SubNumber uint8 // Expected count of subsegments. SubExpected uint8 + // Indicates the event's ID is prepared in the method + // described in SCTE 35 section 9.3.3. + // TODO(otl): can we calculate this at runtime? + // See https://github.com/untangledco/streaming/issues/2 + idCompliance bool } func (d SegmentationDescriptor) Tag() uint8 { return TagSegmentation } @@ -138,7 +142,7 @@ func (d SegmentationDescriptor) Data() []byte { if d.Cancel { buf[4] |= (1 << 7) } - if d.EventIDCompliance { + if d.idCompliance { buf[4] |= (1 << 6) } // toggle next remaining 6 reserved bits. @@ -179,7 +183,7 @@ func unmarshalSegDescriptor(buf []byte) SegmentationDescriptor { desc.Cancel = true } if buf[4]&0b01000000 > 0 { - desc.EventIDCompliance = true + desc.idCompliance = true } // next 6 bits are reserved diff --git a/scte35/splice_info.go b/scte35/splice_info.go @@ -230,7 +230,7 @@ func decodeCommand(buf []byte) (*Command, error) { ins.Immediate = true } if buf[6]&(1<<3) > 0 { - ins.EventIDCompliance = true + ins.idCompliance = true } // next 3 bits are reserved.