Skip to content

Commit 4b8af7b

Browse files
liuyanhitliuyanhit
and
liuyanhit
authored
add attrPublishTime, as publishTime must be present for @type='dynamic' (#84)
Co-authored-by: liuyanhit <[email protected]>
1 parent 70504f6 commit 4b8af7b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

mpd/mpd.go

+2
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ func NewDynamicMPD(profile DashProfile, availabilityStartTime, minBufferTime str
441441
mpd.MinimumUpdatePeriod = attr.GetStrptr()
442442
case *attrMediaPresentationDuration:
443443
mpd.MediaPresentationDuration = attr.GetStrptr()
444+
case *attrPublishTime:
445+
mpd.PublishTime = attr.GetStrptr()
444446
}
445447
}
446448

mpd/mpd_attr.go

+13
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,16 @@ func (attr *attrMediaPresentationDuration) GetStrptr() *string {
4242
func AttrMediaPresentationDuration(value string) AttrMPD {
4343
return &attrMediaPresentationDuration{strptr: &value}
4444
}
45+
46+
type attrPublishTime struct {
47+
strptr *string
48+
}
49+
50+
func (attr *attrPublishTime) GetStrptr() *string {
51+
return attr.strptr
52+
}
53+
54+
// AttrPublishTime returns AttrMPD object for NewMPD
55+
func AttrPublishTime(value string) AttrMPD {
56+
return &attrPublishTime{strptr: &value}
57+
}

mpd/mpd_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const (
1515
VALID_MEDIA_PRESENTATION_DURATION string = "PT6M16S"
1616
VALID_MIN_BUFFER_TIME string = "PT1.97S"
1717
VALID_AVAILABILITY_START_TIME string = "1970-01-01T00:00:00Z"
18+
VALID_PUBLISH_TIME string = "2020-03-12T10:39:45Z"
1819
VALID_MINIMUM_UPDATE_PERIOD string = "PT5S"
1920
VALID_SCAN_TYPE string = "progressive"
2021
VALID_SEGMENT_ALIGNMENT bool = true
@@ -73,7 +74,8 @@ func TestNewMPDLive(t *testing.T) {
7374
func TestNewDynamicMPDLive(t *testing.T) {
7475
m := NewDynamicMPD(DASH_PROFILE_LIVE, VALID_AVAILABILITY_START_TIME, VALID_MIN_BUFFER_TIME,
7576
AttrMediaPresentationDuration(VALID_MEDIA_PRESENTATION_DURATION),
76-
AttrMinimumUpdatePeriod(VALID_MINIMUM_UPDATE_PERIOD))
77+
AttrMinimumUpdatePeriod(VALID_MINIMUM_UPDATE_PERIOD),
78+
AttrPublishTime(VALID_PUBLISH_TIME))
7779
require.NotNil(t, m)
7880
expectedMPD := &MPD{
7981
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
@@ -86,6 +88,7 @@ func TestNewDynamicMPDLive(t *testing.T) {
8688
period: &Period{},
8789
Periods: []*Period{{}},
8890
UTCTiming: &DescriptorType{},
91+
PublishTime: Strptr(VALID_PUBLISH_TIME),
8992
}
9093

9194
expectedString, err := expectedMPD.WriteToString()

0 commit comments

Comments
 (0)