diff --git a/scte35/segmentationdescriptor.go b/scte35/segmentationdescriptor.go index 2a85c6f..954e26b 100644 --- a/scte35/segmentationdescriptor.go +++ b/scte35/segmentationdescriptor.go @@ -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")) && diff --git a/scte35/segmentationdescriptor_test.go b/scte35/segmentationdescriptor_test.go index 69bff3f..1b2d20f 100644 --- a/scte35/segmentationdescriptor_test.go +++ b/scte35/segmentationdescriptor_test.go @@ -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 { @@ -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() + } +}