Skip to content

Commit

Permalink
Merge pull request #22 from Comcast/AddSegEventId
Browse files Browse the repository at this point in the history
Add SegmentationEventId field
  • Loading branch information
tjjwilson authored Feb 2, 2024
2 parents f054141 + 51ae1de commit 69274c4
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions types/scte224v20180501/sctestructures.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ type SignalPointInsertionAction struct {

type SignalPoint struct {
Offset Duration `xml:"offset,attr,omitempty" json:"offset,omitempty"`
SegmentationEventId string `xml:"segmentationEventId,attr,omitempty" json:"segmentationEventId,omitempty"`
SegmentationTypeId *uint `xml:"segmentationTypeId,attr,omitempty" json:"segmentationTypeId,omitempty"`
SegmentationUpidType *uint `xml:"segmentationUpidType,attr,omitempty" json:"segmentationUpidType,omitempty"`
SegmentationUpid string `xml:"segmentationUpid,attr,omitempty" json:"segmentationUpid,omitempty"`
Expand Down
66 changes: 66 additions & 0 deletions types/scte224v20180501/sctestructures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ const spi string = `<ViewingPolicy xmlns="http://www.scte.org/schemas/224" id="n
</SignalPointInsertion>
</ViewingPolicy>`

const vpPPOStart string = `<ViewingPolicy xmlns="http://www.scte.org/schemas/224" id="evertz/viewingpolicy/37/GETTV/GET_COM202395/ppostart" description="GET_COM202395 PPO viewing policy start" lastUpdated="2024-01-31T23:52:34.266Z">
<Audience xmlns="http://www.scte.org/schemas/224" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="evertz/audience/GETTV/all"></Audience>
<SignalPointInsertion xmlns="urn:scte:224:action">
<SignalPoint xmlns="urn:scte:224:action" segmentationEventId="123456" segmentationTypeId="52"></SignalPoint>
</SignalPointInsertion>
</ViewingPolicy>`

const spd string = `<ViewingPolicy xmlns="http://www.scte.org/schemas/224" id="deletion" description="Program MASE_ID ViewingPolicy" lastUpdated="2020-02-27T11:15:08.770408-08:00">
<Audience xmlns="http://www.scte.org/schemas/224" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="nbcuni.com/audience/CH61"></Audience>
<SignalPointDeletion xmlns="urn:scte:224:action">True</SignalPointDeletion>
Expand Down Expand Up @@ -263,3 +270,62 @@ func TestSignalPointInsertion(t *testing.T) {
}
}
}

func TestSignalPointInsertion_PPOStart(t *testing.T) {
var vpol *ViewingPolicy
err := xml.Unmarshal([]byte(vpPPOStart), &vpol)
if err != nil {
t.Errorf("Error unmarshalling viewingpolicys %v", err)
t.FailNow()
}
action := vpol.SignalPointInsertion
if nil == action {
t.Error("expected non-nil signalPointInsertion")
} else {
if len(action.SignalPoints) == 0 {
t.Error("expected SignalPoints")
} else {
sp := action.SignalPoints[0]
if nil == sp {
t.Error("expected non-nil signalPoint")
} else {
if sp.Offset.GoDuration() != 0 {
t.Error("expected zero offset rather than" + sp.Offset)
}

if sp.SegmentationEventId != "123456" {
t.Errorf("expected segmentationEventId of \"123456\" rather than \"%s\"", sp.SegmentationEventId)
}
if nil != sp.SegmentationUpidType {
t.Error("expected nil SegmentationUpid")
}
if len(sp.SegmentationUpid) != 0 {
t.Error("expected empty SegmentationUpid")
}
if nil != sp.SegmentationTypeId {
if *sp.SegmentationTypeId != 52 {
t.Error("expected segmentationTypeId of 53 rather than", *sp.SegmentationTypeId)
}
} else {
t.Error("expected non-nil segmentationTypeId")
}
repeatInterval := sp.RepeatInterval.GoDuration()
if time.Second*0 != repeatInterval {
t.Error("expected a 0 second interval rather than", repeatInterval)
}
if nil != sp.RepeatStart {
t.Error("expected nil RepeatStart")
}
if nil != sp.RepeatStop {
t.Error("expected nil RepeatStop")
}
}
}
roundtrip, rerr := xml.MarshalIndent(vpol, "", " ")
if nil != rerr {
t.Error(rerr)
} else {
t.Log(string(roundtrip))
}
}
}
2 changes: 2 additions & 0 deletions types/scte224v20200407/avp.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (vp *ViewingPolicy) Get2018() scte224_2018.ViewingPolicy {

signalPoints2018 = append(signalPoints2018, &scte224_2018.SignalPoint{
Offset: scte224_2018.Duration(signalPoint.Offset),
SegmentationEventId: signalPoint.SegmentationEventId,
SegmentationTypeId: signalPoint.SegmentationTypeId,
SegmentationUpidType: signalPoint.SegmentationUpidType,
SegmentationUpid: signalPoint.SegmentationUpid,
Expand Down Expand Up @@ -194,6 +195,7 @@ type SignalPointInsertionAction struct {

type SignalPoint struct {
Offset Duration `xml:"offset,attr,omitempty" json:"offset,omitempty"`
SegmentationEventId string `xml:"segmentationEventId,attr,omitempty" json:"segmentationEventId,omitempty"`
SegmentationTypeId *uint `xml:"segmentationTypeId,attr,omitempty" json:"segmentationTypeId,omitempty"`
SegmentationUpidType *uint `xml:"segmentationUpidType,attr,omitempty" json:"segmentationUpidType,omitempty"`
SegmentationUpid string `xml:"segmentationUpid,attr,omitempty" json:"segmentationUpid,omitempty"`
Expand Down
17 changes: 17 additions & 0 deletions types/scte224v20200407/avp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ func TestViewingPolicyDowngrade_w_SIS(t *testing.T) {
assert.EqualValues(t, vpSignalPointInsertion_w_SpliceInfoSection, string(vp2018Marshaled), "Downgrade failed")
}

func TestUnmarhalViewingPolicy_PPOStart(t *testing.T) {
var vp *ViewingPolicy
err := xml.Unmarshal([]byte(vpPPOStart), &vp)
assert.Nil(t, err, "Error unmarshalling viewingpolicy")
}

func TestViewingPolicyDowngrade_PPOStart(t *testing.T) {
var vp *ViewingPolicy
err := xml.Unmarshal([]byte(vpPPOStart), &vp)
assert.Nil(t, err, "Error unmarshalling viewingpolicy")

vp2018 := vp.Get2018()
vp2018Marshaled, err := xml.MarshalIndent(vp2018, "", " ")
assert.Nil(t, err, "Error marshaling downgraded viewingpolicy")
assert.EqualValues(t, vpPPOStart, string(vp2018Marshaled), "Downgrade failed")
}

func TestAudienceDowngrade(t *testing.T) {
var aud Audience
err := xml.Unmarshal([]byte(aud2020Raw), &aud)
Expand Down
7 changes: 7 additions & 0 deletions types/scte224v20200407/constants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ const vpSignalPointInsertion_w_SpliceInfoSection string = `<ViewingPolicy xmlns=
</SignalPointReplacement>
</ViewingPolicy>`

const vpPPOStart string = `<ViewingPolicy xmlns="http://www.scte.org/schemas/224" id="evertz/viewingpolicy/37/GETTV/GET_COM202395/ppostart" description="GET_COM202395 PPO viewing policy start" lastUpdated="2024-01-31T23:52:34.266Z">
<Audience xmlns="http://www.scte.org/schemas/224" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="evertz/audience/GETTV/all"></Audience>
<SignalPointInsertion xmlns="urn:scte:224:action">
<SignalPoint xmlns="urn:scte:224:action" segmentationEventId="123456" segmentationTypeId="52"></SignalPoint>
</SignalPointInsertion>
</ViewingPolicy>`

// Same as "vp2020Raw" but without the additional "Allocation" action
const vp2018Raw string = `<ViewingPolicy xmlns="http://www.scte.org/schemas/224" id="test/program" description="test program" lastUpdated="2021-01-19T18:49:26.298986528Z">
<Content xmlns="urn:scte:224:action">CONTENT</Content>
Expand Down

0 comments on commit 69274c4

Please sign in to comment.