Skip to content

Commit 34ac3a6

Browse files
authored
Merge pull request #68 from zencoder/period-start
make Period.Start a pointer for optional 0 value support
2 parents 9925fc4 + bde8899 commit 34ac3a6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

mpd/mpd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type MPD struct {
7878
type Period struct {
7979
ID string `xml:"id,attr,omitempty"`
8080
Duration Duration `xml:"duration,attr,omitempty"`
81-
Start Duration `xml:"start,attr,omitempty"`
81+
Start *Duration `xml:"start,attr,omitempty"`
8282
BaseURL string `xml:"BaseURL,omitempty"`
8383
SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"`
8484
SegmentList *SegmentList `xml:"SegmentList,omitempty"`

mpd/mpd_read_write_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@ func TestNewDynamicMPDLiveWriteToString(t *testing.T) {
6868
require.EqualString(t, expectedXML, xmlStr)
6969
}
7070

71+
func TestNewDynamicMPDLiveWithPeriodStartWriteToString(t *testing.T) {
72+
m := NewDynamicMPD(DASH_PROFILE_LIVE, VALID_AVAILABILITY_START_TIME, VALID_MIN_BUFFER_TIME,
73+
AttrMediaPresentationDuration(VALID_MEDIA_PRESENTATION_DURATION),
74+
AttrMinimumUpdatePeriod(VALID_MINIMUM_UPDATE_PERIOD))
75+
76+
// Set first period start time to PT0S
77+
p := m.GetCurrentPeriod()
78+
start := Duration(time.Duration(0))
79+
p.Start = &start
80+
81+
xmlStr, err := m.WriteToString()
82+
require.NoError(t, err)
83+
expectedXML := `<?xml version="1.0" encoding="UTF-8"?>
84+
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="dynamic" mediaPresentationDuration="PT6M16S" minBufferTime="PT1.97S" availabilityStartTime="1970-01-01T00:00:00Z" minimumUpdatePeriod="PT5S">
85+
<Period start="PT0S"></Period>
86+
<UTCTiming></UTCTiming>
87+
</MPD>
88+
`
89+
require.EqualString(t, expectedXML, xmlStr)
90+
}
91+
7192
func TestNewMPDOnDemandWriteToString(t *testing.T) {
7293
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
7394

0 commit comments

Comments
 (0)