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
13 changes: 7 additions & 6 deletions scte35/segmentationdescriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,13 @@ func (d *segmentationDescriptor) UPID() []byte {
func (d *segmentationDescriptor) StreamSwitchSignalId() (string, error) {
var signalId string
var err error
// The VSS SignalId is present in the MID of len 2.
// SignalId is the UPID value in the MID which has
// delivery_not_restricted flag = 0 and
// contains "BLACKOUT" at UpidType of 0x09 and
// comcast:linear:licenserotation at 0x0E
if len(d.mid) == 2 &&
// 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 &&
!d.deliveryNotRestricted &&
strings.Contains(string(d.upid), "BLACKOUT") {
signalId = strings.TrimPrefix(string(d.upid), "BLACKOUT:")
} else if len(d.mid) == 2 &&
!d.deliveryNotRestricted &&
(d.mid[0].upidType == SegUPIDADI) &&
(strings.Contains(string(d.mid[0].upid), "BLACKOUT")) &&
Expand Down
30 changes: 30 additions & 0 deletions scte35/segmentationdescriptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ var vss = []byte{
0x00, 0x00, 0x00, 0x09, 0x7f, 0x97, 0x00, 0x00, 0x41, 0x00, 0x00, 0x7a, 0xd7, 0xa4, 0x65,
}

var vssSingleUPID = []byte{
0x00, 0xfc, 0x30, 0x59, 0x00, 0x01, 0xa1, 0xe9, 0xbe, 0xfa, 0xff, 0xff, 0xf0, 0x05, 0x06, 0xfe,
0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x02, 0x30, 0x43, 0x55, 0x45, 0x49, 0xfd, 0x88, 0x9d, 0x22,
0x7f, 0x97, 0x09, 0x21, 0x42, 0x4c, 0x41, 0x43, 0x4b, 0x4f, 0x55, 0x54, 0x3a, 0x55, 0x52, 0x53,
0x64, 0x44, 0x67, 0x43, 0x59, 0x64, 0x5f, 0x5f, 0x68, 0x5f, 0x61, 0x77, 0x59, 0x4d, 0x44, 0x41,
0x77, 0x4d, 0x41, 0x41, 0x41, 0x40, 0x00, 0x00, 0x02, 0x0f, 0x43, 0x55, 0x45, 0x49, 0xfd, 0x88,
0x9d, 0x22, 0x7f, 0x97, 0x00, 0x00, 0x41, 0x00, 0x00, 0x36, 0xd9, 0x86, 0xac,
}

func TestNoInRules(t *testing.T) {
out, err := NewSCTE35(poOpen1)
if err != nil {
Expand Down Expand Up @@ -270,3 +279,24 @@ func TestVSSSignalId(t *testing.T) {
t.FailNow()
}
}

func TestVSSSignalIdSingleUPID(t *testing.T) {
expectedSignalId := "URSdDgCYd__h_awYMDAwMAAA"
vssScte35, err := NewSCTE35([]byte(vssSingleUPID))

if err != nil {
t.Error("NewSCTE35(vssSingleUPID) returned err:", err.Error())
t.FailNow()
}

signalID, err := vssScte35.Descriptors()[0].StreamSwitchSignalId()
if err != nil {
t.Fatal(err)
}

// Compare against the Signal ID we should see in the vssScte35 signal.
if strings.Compare(signalID, expectedSignalId) != 0 {
t.Error("SignalID parsed, not as expected")
t.FailNow()
}
}
Loading