Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions scte35/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ type SegmentationDescriptor interface {
SetSubSegmentsExpected(value uint8)
// StreamSwitchSignalID returns the signalID of streamswitch signal if
// present in the descriptor
StreamSwitchSignalId() (string, error)
StreamSwitchSignalId() (string, bool, error)
// IsOut returns true if a signal is an out
IsOut() bool
// IsIn returns true if a signal is an in
Expand All @@ -482,14 +482,15 @@ type SegmentationDescriptor interface {
// example code is below.
// s := scte35.NewState()
// scte,_ := scte.ParseSCTE35(bytes)
// for _,d := range(scte.Descriptors()) {
// closed = s.ProcessDescriptor(d)
// ...handle closed signals appropriately here
// if d.HasDuration() {
// time.AfterFunc(d.Duration() + someFudgeDelta,
// func() { closed = s.Close(d) })
// }
// }
//
// for _,d := range(scte.Descriptors()) {
// closed = s.ProcessDescriptor(d)
// ...handle closed signals appropriately here
// if d.HasDuration() {
// time.AfterFunc(d.Duration() + someFudgeDelta,
// func() { closed = s.Close(d) })
// }
// }
type State interface {
// Open returns a list of open signals
Open() []SegmentationDescriptor
Expand Down
7 changes: 3 additions & 4 deletions scte35/segmentationdescriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,7 @@ func (d *segmentationDescriptor) UPID() []byte {

// StreamSwitchSignalId returns the signalID of streamswitch signal if
// present in the descriptor
func (d *segmentationDescriptor) StreamSwitchSignalId() (string, error) {
var signalId string
var err error
func (d *segmentationDescriptor) StreamSwitchSignalId() (signalId string, licenseRotation bool, err error) {
// The VSS SignalId can be found either in the top level `segmentation_upid` when the UPID type is 0x09, or
// in the MID of len 2 when the first UPID has type 0x09 and the second UPID has type 0x0E.
if d.upidType == SegUPIDADI &&
Expand All @@ -387,10 +385,11 @@ func (d *segmentationDescriptor) StreamSwitchSignalId() (string, error) {
(d.mid[1].upidType == SegUPADSINFO) &&
(strings.Contains(string(d.mid[1].upid), "comcast:linear:licenserotation")) {
signalId = strings.TrimPrefix(string(d.mid[0].upid), "BLACKOUT:")
licenseRotation = true
} else {
err = gots.ErrVSSSignalIdNotFound
}
return signalId, err
return
}

// SegmentNum is deprecated, use SegmentNumber instead.
Expand Down
12 changes: 9 additions & 3 deletions scte35/segmentationdescriptor_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
MIT License

Copyright 2016 Comcast Cable Communications Management, LLC
# Copyright 2016 Comcast Cable Communications Management, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestVSSSignalId(t *testing.T) {
t.FailNow()
}

signalID, err := vssScte35.Descriptors()[0].StreamSwitchSignalId()
signalID, licenseRotation, err := vssScte35.Descriptors()[0].StreamSwitchSignalId()
if err != nil {
t.Fatal(err)
}
Expand All @@ -278,6 +278,9 @@ func TestVSSSignalId(t *testing.T) {
t.Error("SignalID parsed, not as expected")
t.FailNow()
}
if !licenseRotation {
t.Error("License rotation should be true")
}
}

func TestVSSSignalIdSingleUPID(t *testing.T) {
Expand All @@ -289,7 +292,7 @@ func TestVSSSignalIdSingleUPID(t *testing.T) {
t.FailNow()
}

signalID, err := vssScte35.Descriptors()[0].StreamSwitchSignalId()
signalID, licenseRotation, err := vssScte35.Descriptors()[0].StreamSwitchSignalId()
if err != nil {
t.Fatal(err)
}
Expand All @@ -299,4 +302,7 @@ func TestVSSSignalIdSingleUPID(t *testing.T) {
t.Error("SignalID parsed, not as expected")
t.FailNow()
}
if licenseRotation {
t.Error("License rotation should be false")
}
}
12 changes: 7 additions & 5 deletions scte35/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ SOFTWARE.
package scte35

import (
"github.com/Comcast/gots/v2"
"strings"

"github.com/Comcast/gots/v2"
)

const receivedRingLen = 10
Expand Down Expand Up @@ -85,19 +86,20 @@ func (s *state) ProcessDescriptor(desc SegmentationDescriptor) ([]SegmentationDe
// same eventId before.
if desc.EventID() == d.EventID() &&
d.TypeID() == SegDescUnscheduledEventStart && desc.TypeID() == SegDescUnscheduledEventStart {
descStreamSwitchSignalId, err := desc.StreamSwitchSignalId()
descStreamSwitchSignalId, descLicenseRotation, err := desc.StreamSwitchSignalId()
if err != nil {
return nil, err
}

dStreamSwitchSignalId, err := d.StreamSwitchSignalId()
dStreamSwitchSignalId, dLicenseRotation, err := d.StreamSwitchSignalId()
if err != nil {
return nil, err
}

if strings.Compare(descStreamSwitchSignalId, dStreamSwitchSignalId) == 0 &&
(d.EventID() == desc.EventID()) {
// desc and d contain same signalId and same eventID
(d.EventID() == desc.EventID()) &&
(descLicenseRotation == dLicenseRotation) {
// desc and d contain same signalId, same eventID, same license rotation UPID
// we should not be processing this desc.
return nil, gots.ErrSCTE35DuplicateDescriptor
}
Expand Down
Loading