Skip to content

Commit f9c7c32

Browse files
authored
fix: flip compliance_indicator semantics (#72)
1 parent c96dd37 commit f9c7c32

File tree

4 files changed

+38
-62
lines changed

4 files changed

+38
-62
lines changed

Taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
version: "3"
33

44
vars:
5-
VERSION: "v1.5.0"
5+
VERSION: "v1.5.1"
66

77
tasks:
88
clean:

pkg/scte35/scte35_test.go

Lines changed: 30 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func TestDecodeBase64(t *testing.T) {
5858
},
5959
SpliceDescriptors: []scte35.SpliceDescriptor{
6060
&scte35.SegmentationDescriptor{
61-
SegmentationEventIDComplianceIndicator: true,
6261
DeliveryRestrictions: &scte35.DeliveryRestrictions{
6362
NoRegionalBlackoutFlag: true,
6463
ArchiveAllowedFlag: true,
@@ -114,7 +113,6 @@ func TestDecodeBase64(t *testing.T) {
114113
},
115114
SpliceDescriptors: []scte35.SpliceDescriptor{
116115
&scte35.SegmentationDescriptor{
117-
SegmentationEventIDComplianceIndicator: true,
118116
DeliveryRestrictions: &scte35.DeliveryRestrictions{
119117
NoRegionalBlackoutFlag: true,
120118
ArchiveAllowedFlag: true,
@@ -144,7 +142,6 @@ func TestDecodeBase64(t *testing.T) {
144142
},
145143
SpliceDescriptors: []scte35.SpliceDescriptor{
146144
&scte35.SegmentationDescriptor{
147-
SegmentationEventIDComplianceIndicator: true,
148145
DeliveryRestrictions: &scte35.DeliveryRestrictions{
149146
NoRegionalBlackoutFlag: true,
150147
ArchiveAllowedFlag: true,
@@ -158,7 +155,6 @@ func TestDecodeBase64(t *testing.T) {
158155
},
159156
},
160157
&scte35.SegmentationDescriptor{
161-
SegmentationEventIDComplianceIndicator: true,
162158
DeliveryRestrictions: &scte35.DeliveryRestrictions{
163159
NoRegionalBlackoutFlag: true,
164160
ArchiveAllowedFlag: true,
@@ -187,7 +183,6 @@ func TestDecodeBase64(t *testing.T) {
187183
},
188184
SpliceDescriptors: []scte35.SpliceDescriptor{
189185
&scte35.SegmentationDescriptor{
190-
SegmentationEventIDComplianceIndicator: true,
191186
DeliveryRestrictions: &scte35.DeliveryRestrictions{
192187
NoRegionalBlackoutFlag: true,
193188
ArchiveAllowedFlag: true,
@@ -216,7 +211,6 @@ func TestDecodeBase64(t *testing.T) {
216211
},
217212
SpliceDescriptors: []scte35.SpliceDescriptor{
218213
&scte35.SegmentationDescriptor{
219-
SegmentationEventIDComplianceIndicator: true,
220214
DeliveryRestrictions: &scte35.DeliveryRestrictions{
221215
NoRegionalBlackoutFlag: true,
222216
ArchiveAllowedFlag: true,
@@ -230,7 +224,6 @@ func TestDecodeBase64(t *testing.T) {
230224
},
231225
},
232226
&scte35.SegmentationDescriptor{
233-
SegmentationEventIDComplianceIndicator: true,
234227
DeliveryRestrictions: &scte35.DeliveryRestrictions{
235228
NoRegionalBlackoutFlag: true,
236229
ArchiveAllowedFlag: true,
@@ -259,7 +252,6 @@ func TestDecodeBase64(t *testing.T) {
259252
},
260253
SpliceDescriptors: []scte35.SpliceDescriptor{
261254
&scte35.SegmentationDescriptor{
262-
SegmentationEventIDComplianceIndicator: true,
263255
DeliveryRestrictions: &scte35.DeliveryRestrictions{
264256
NoRegionalBlackoutFlag: true,
265257
ArchiveAllowedFlag: true,
@@ -288,7 +280,6 @@ func TestDecodeBase64(t *testing.T) {
288280
},
289281
SpliceDescriptors: []scte35.SpliceDescriptor{
290282
&scte35.SegmentationDescriptor{
291-
SegmentationEventIDComplianceIndicator: true,
292283
DeliveryRestrictions: &scte35.DeliveryRestrictions{
293284
NoRegionalBlackoutFlag: true,
294285
ArchiveAllowedFlag: true,
@@ -303,7 +294,6 @@ func TestDecodeBase64(t *testing.T) {
303294
SegmentNum: 2,
304295
},
305296
&scte35.SegmentationDescriptor{
306-
SegmentationEventIDComplianceIndicator: true,
307297
DeliveryRestrictions: &scte35.DeliveryRestrictions{
308298
NoRegionalBlackoutFlag: true,
309299
ArchiveAllowedFlag: true,
@@ -317,7 +307,6 @@ func TestDecodeBase64(t *testing.T) {
317307
},
318308
},
319309
&scte35.SegmentationDescriptor{
320-
SegmentationEventIDComplianceIndicator: true,
321310
DeliveryRestrictions: &scte35.DeliveryRestrictions{
322311
NoRegionalBlackoutFlag: true,
323312
ArchiveAllowedFlag: true,
@@ -365,7 +354,6 @@ func TestDecodeBase64(t *testing.T) {
365354
SpliceCommand: scte35.NewTimeSignal(7316880262),
366355
SpliceDescriptors: []scte35.SpliceDescriptor{
367356
&scte35.SegmentationDescriptor{
368-
SegmentationEventIDComplianceIndicator: true,
369357
DeliveryRestrictions: &scte35.DeliveryRestrictions{
370358
ArchiveAllowedFlag: true,
371359
WebDeliveryAllowedFlag: true,
@@ -383,7 +371,6 @@ func TestDecodeBase64(t *testing.T) {
383371
SegmentationEventID: 1073742098,
384372
},
385373
&scte35.SegmentationDescriptor{
386-
SegmentationEventIDComplianceIndicator: true,
387374
DeliveryRestrictions: &scte35.DeliveryRestrictions{
388375
ArchiveAllowedFlag: true,
389376
WebDeliveryAllowedFlag: true,
@@ -436,7 +423,6 @@ func TestDecodeBase64(t *testing.T) {
436423
SpliceCommand: scte35.NewTimeSignal(4294967296),
437424
SpliceDescriptors: []scte35.SpliceDescriptor{
438425
&scte35.SegmentationDescriptor{
439-
SegmentationEventIDComplianceIndicator: true,
440426
SegmentationUPIDs: []scte35.SegmentationUPID{
441427
{
442428
Type: scte35.SegmentationUPIDTypeEIDR,
@@ -470,7 +456,6 @@ func TestDecodeBase64(t *testing.T) {
470456
SpliceCommand: scte35.NewTimeSignal(3550479013),
471457
SpliceDescriptors: []scte35.SpliceDescriptor{
472458
&scte35.SegmentationDescriptor{
473-
SegmentationEventIDComplianceIndicator: true,
474459
SegmentationUPIDs: []scte35.SegmentationUPID{
475460
{
476461
Type: scte35.SegmentationUPIDTypeMPU,
@@ -512,12 +497,11 @@ func TestDecodeBase64(t *testing.T) {
512497
Value: "urn:nbcuni.com:brc:499866434",
513498
},
514499
},
515-
SegmentationDuration: ptr(uint64(1347087)),
516-
SegmentationEventID: 4294967295,
517-
SegmentationEventIDComplianceIndicator: true,
518-
SegmentationTypeID: scte35.SegmentationTypeProviderAdEnd,
519-
SegmentNum: 10,
520-
SegmentsExpected: 1,
500+
SegmentationDuration: ptr(uint64(1347087)),
501+
SegmentationEventID: 4294967295,
502+
SegmentationTypeID: scte35.SegmentationTypeProviderAdEnd,
503+
SegmentNum: 10,
504+
SegmentsExpected: 1,
521505
},
522506
},
523507
Tier: 4095,
@@ -562,24 +546,22 @@ func TestDecodeBase64(t *testing.T) {
562546
},
563547
SpliceDescriptors: scte35.SpliceDescriptors{
564548
&scte35.SegmentationDescriptor{
565-
SegmentationEventID: uint32(156),
566-
SegmentationTypeID: scte35.SegmentationTypeProviderAdEnd,
567-
SegmentNum: 7,
568-
SegmentsExpected: 10,
569-
SegmentationEventIDComplianceIndicator: true,
549+
SegmentationEventID: uint32(156),
550+
SegmentationTypeID: scte35.SegmentationTypeProviderAdEnd,
551+
SegmentNum: 7,
552+
SegmentsExpected: 10,
570553
SegmentationUPIDs: []scte35.SegmentationUPID{
571554
{Type: scte35.SegmentationUPIDTypeADS, Format: scte35.SegmentationUPIDFormatText, Value: "availid=914866065\u0026bitmap=\u0026inactivity=3120"},
572555
},
573556
},
574557
&scte35.SegmentationDescriptor{
575-
SegmentationEventID: uint32(157),
576-
SegmentationTypeID: scte35.SegmentationTypeProviderAdStart,
577-
SegmentationEventIDComplianceIndicator: true,
578-
SegmentationDuration: ptr(uint64(3600000)),
579-
SegmentNum: 8,
580-
SegmentsExpected: 10,
581-
SubSegmentNum: ptr(uint32(0)),
582-
SubSegmentsExpected: ptr(uint32(0)),
558+
SegmentationEventID: uint32(157),
559+
SegmentationTypeID: scte35.SegmentationTypeProviderAdStart,
560+
SegmentationDuration: ptr(uint64(3600000)),
561+
SegmentNum: 8,
562+
SegmentsExpected: 10,
563+
SubSegmentNum: ptr(uint32(0)),
564+
SubSegmentsExpected: ptr(uint32(0)),
583565
SegmentationUPIDs: []scte35.SegmentationUPID{
584566
{Type: scte35.SegmentationUPIDTypeADS, Format: scte35.SegmentationUPIDFormatText, Value: "availid=910901389\u0026bitmap=\u0026inactivity=3120"},
585567
},
@@ -597,9 +579,8 @@ func TestDecodeBase64(t *testing.T) {
597579
},
598580
SpliceDescriptors: scte35.SpliceDescriptors{
599581
&scte35.SegmentationDescriptor{
600-
SegmentationEventID: uint32(1074667968),
601-
SegmentationTypeID: scte35.SegmentationTypeBreakEnd,
602-
SegmentationEventIDComplianceIndicator: true,
582+
SegmentationEventID: uint32(1074667968),
583+
SegmentationTypeID: scte35.SegmentationTypeBreakEnd,
603584
DeliveryRestrictions: &scte35.DeliveryRestrictions{
604585
ArchiveAllowedFlag: true,
605586
WebDeliveryAllowedFlag: true,
@@ -611,9 +592,8 @@ func TestDecodeBase64(t *testing.T) {
611592
},
612593
},
613594
&scte35.SegmentationDescriptor{
614-
SegmentationEventID: uint32(1074668380),
615-
SegmentationTypeID: scte35.SegmentationTypeProgramEnd,
616-
SegmentationEventIDComplianceIndicator: true,
595+
SegmentationEventID: uint32(1074668380),
596+
SegmentationTypeID: scte35.SegmentationTypeProgramEnd,
617597
DeliveryRestrictions: &scte35.DeliveryRestrictions{
618598
ArchiveAllowedFlag: true,
619599
WebDeliveryAllowedFlag: true,
@@ -625,9 +605,8 @@ func TestDecodeBase64(t *testing.T) {
625605
},
626606
},
627607
&scte35.SegmentationDescriptor{
628-
SegmentationEventID: uint32(1074668000),
629-
SegmentationTypeID: scte35.SegmentationTypeProgramStart,
630-
SegmentationEventIDComplianceIndicator: true,
608+
SegmentationEventID: uint32(1074668000),
609+
SegmentationTypeID: scte35.SegmentationTypeProgramStart,
631610
DeliveryRestrictions: &scte35.DeliveryRestrictions{
632611
ArchiveAllowedFlag: true,
633612
WebDeliveryAllowedFlag: true,
@@ -639,10 +618,9 @@ func TestDecodeBase64(t *testing.T) {
639618
},
640619
},
641620
&scte35.SegmentationDescriptor{
642-
SegmentationEventID: uint32(1074667978),
643-
SegmentationEventIDComplianceIndicator: true,
644-
SegmentationDuration: ptr(uint64(5412012)),
645-
SegmentationTypeID: scte35.SegmentationTypeBreakStart,
621+
SegmentationEventID: uint32(1074667978),
622+
SegmentationDuration: ptr(uint64(5412012)),
623+
SegmentationTypeID: scte35.SegmentationTypeBreakStart,
646624
DeliveryRestrictions: &scte35.DeliveryRestrictions{
647625
ArchiveAllowedFlag: true,
648626
WebDeliveryAllowedFlag: true,
@@ -654,12 +632,11 @@ func TestDecodeBase64(t *testing.T) {
654632
},
655633
},
656634
&scte35.SegmentationDescriptor{
657-
SegmentationEventID: uint32(1074667990),
658-
SegmentationEventIDComplianceIndicator: true,
659-
SegmentationTypeID: 0x05,
660-
SegmentationDuration: ptr(uint64(5412012)),
661-
SegmentNum: 6,
662-
SegmentsExpected: 255,
635+
SegmentationEventID: uint32(1074667990),
636+
SegmentationTypeID: 0x05,
637+
SegmentationDuration: ptr(uint64(5412012)),
638+
SegmentNum: 6,
639+
SegmentsExpected: 255,
663640
DeliveryRestrictions: &scte35.DeliveryRestrictions{
664641
ArchiveAllowedFlag: true,
665642
WebDeliveryAllowedFlag: false,
@@ -741,7 +718,6 @@ func TestDecodeHex(t *testing.T) {
741718
},
742719
SpliceDescriptors: []scte35.SpliceDescriptor{
743720
&scte35.SegmentationDescriptor{
744-
SegmentationEventIDComplianceIndicator: true,
745721
DeliveryRestrictions: &scte35.DeliveryRestrictions{
746722
NoRegionalBlackoutFlag: true,
747723
ArchiveAllowedFlag: true,

pkg/scte35/segmentation_descriptor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ func (sd *SegmentationDescriptor) decode(b []byte) error {
338338
r.Skip(32) // identifier
339339
sd.SegmentationEventID = r.Uint32(32)
340340
sd.SegmentationEventCancelIndicator = r.Bit()
341-
sd.SegmentationEventIDComplianceIndicator = r.Bit()
342-
r.Skip(6) // reserved
341+
sd.SegmentationEventIDComplianceIndicator = !r.Bit() // segmentation_event_id_compliance_indicator has inverted semantics
342+
r.Skip(6) // reserved
343343

344344
if !sd.SegmentationEventCancelIndicator {
345345
programSegmentationFlag := r.Bit()
@@ -441,7 +441,7 @@ func (sd *SegmentationDescriptor) encode() ([]byte, error) {
441441
iow.PutUint32(32, CUEIdentifier)
442442
iow.PutUint32(32, sd.SegmentationEventID)
443443
iow.PutBit(sd.SegmentationEventCancelIndicator)
444-
iow.PutBit(sd.SegmentationEventIDComplianceIndicator)
444+
iow.PutBit(!sd.SegmentationEventIDComplianceIndicator) // segmentation_event_id_compliance_indicator has inverted semantics
445445
iow.PutUint32(6, Reserved)
446446

447447
if !sd.SegmentationEventCancelIndicator {

pkg/scte35/splice_schedule.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func (cmd *SpliceSchedule) decode(b []byte) error {
5555
e := Event{}
5656
e.SpliceEventID = r.Uint32(32)
5757
e.SpliceEventCancelIndicator = r.Bit()
58-
e.EventIDComplianceFlag = r.Bit()
59-
r.Skip(6) // reserved
58+
e.EventIDComplianceFlag = !r.Bit() // event_id_compliance_flag has inverted semantics
59+
r.Skip(6) // reserved
6060
if !e.SpliceEventCancelIndicator {
6161
e.OutOfNetworkIndicator = r.Bit()
6262
programSpliceFlag := r.Bit()
@@ -103,8 +103,8 @@ func (cmd *SpliceSchedule) encode() ([]byte, error) {
103103
for _, e := range cmd.Events {
104104
iow.PutUint32(32, e.SpliceEventID)
105105
iow.PutBit(e.SpliceEventCancelIndicator)
106-
iow.PutBit(e.EventIDComplianceFlag)
107-
iow.PutUint32(6, Reserved) // reserved
106+
iow.PutBit(!e.EventIDComplianceFlag) // event_id_compliance_flag has inverted semantics
107+
iow.PutUint32(6, Reserved) // reserved
108108
if !e.SpliceEventCancelIndicator {
109109
iow.PutBit(e.OutOfNetworkIndicator)
110110
iow.PutBit(e.ProgramSpliceFlag())

0 commit comments

Comments
 (0)