Skip to content

Commit

Permalink
add attrPublishTime, as publishTime must be present for @type='dynami…
Browse files Browse the repository at this point in the history
…c' (#84)

Co-authored-by: liuyanhit <[email protected]>
  • Loading branch information
liuyanhit and liuyanhit authored Feb 23, 2022
1 parent 70504f6 commit 4b8af7b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mpd/mpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ func NewDynamicMPD(profile DashProfile, availabilityStartTime, minBufferTime str
mpd.MinimumUpdatePeriod = attr.GetStrptr()
case *attrMediaPresentationDuration:
mpd.MediaPresentationDuration = attr.GetStrptr()
case *attrPublishTime:
mpd.PublishTime = attr.GetStrptr()
}
}

Expand Down
13 changes: 13 additions & 0 deletions mpd/mpd_attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,16 @@ func (attr *attrMediaPresentationDuration) GetStrptr() *string {
func AttrMediaPresentationDuration(value string) AttrMPD {
return &attrMediaPresentationDuration{strptr: &value}
}

type attrPublishTime struct {
strptr *string
}

func (attr *attrPublishTime) GetStrptr() *string {
return attr.strptr
}

// AttrPublishTime returns AttrMPD object for NewMPD
func AttrPublishTime(value string) AttrMPD {
return &attrPublishTime{strptr: &value}
}
5 changes: 4 additions & 1 deletion mpd/mpd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
VALID_MEDIA_PRESENTATION_DURATION string = "PT6M16S"
VALID_MIN_BUFFER_TIME string = "PT1.97S"
VALID_AVAILABILITY_START_TIME string = "1970-01-01T00:00:00Z"
VALID_PUBLISH_TIME string = "2020-03-12T10:39:45Z"
VALID_MINIMUM_UPDATE_PERIOD string = "PT5S"
VALID_SCAN_TYPE string = "progressive"
VALID_SEGMENT_ALIGNMENT bool = true
Expand Down Expand Up @@ -73,7 +74,8 @@ func TestNewMPDLive(t *testing.T) {
func TestNewDynamicMPDLive(t *testing.T) {
m := NewDynamicMPD(DASH_PROFILE_LIVE, VALID_AVAILABILITY_START_TIME, VALID_MIN_BUFFER_TIME,
AttrMediaPresentationDuration(VALID_MEDIA_PRESENTATION_DURATION),
AttrMinimumUpdatePeriod(VALID_MINIMUM_UPDATE_PERIOD))
AttrMinimumUpdatePeriod(VALID_MINIMUM_UPDATE_PERIOD),
AttrPublishTime(VALID_PUBLISH_TIME))
require.NotNil(t, m)
expectedMPD := &MPD{
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
Expand All @@ -86,6 +88,7 @@ func TestNewDynamicMPDLive(t *testing.T) {
period: &Period{},
Periods: []*Period{{}},
UTCTiming: &DescriptorType{},
PublishTime: Strptr(VALID_PUBLISH_TIME),
}

expectedString, err := expectedMPD.WriteToString()
Expand Down

0 comments on commit 4b8af7b

Please sign in to comment.