func TestNewMPDMultiPeriod(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME,
AttrAvailabilityStartTime(VALID_AVAILABILITY_START_TIME))
require.NotNil(t, m)
for i := 0; i < 2; i++ {
period := m.AddNewPeriod()
period.ID = strconv.Itoa(i)
}
ms, _ := m.WriteToString()
expectedMPD := &MPD{
XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"),
Profiles: Strptr((string)(DASH_PROFILE_LIVE)),
Type: Strptr("static"),
MediaPresentationDuration: Strptr(VALID_MEDIA_PRESENTATION_DURATION),
MinBufferTime: Strptr(VALID_MIN_BUFFER_TIME),
AvailabilityStartTime: Strptr(VALID_AVAILABILITY_START_TIME),
period: nil,
Periods: []*Period{&Period{ID: "0"}, &Period{ID: "1"}},
}
expectedString, err := expectedMPD.WriteToString()
require.NoError(t, err)
actualString, err := m.WriteToString()
require.NoError(t, err)
require.EqualString(t, expectedString, actualString)
}
require.go:99: Expected <?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediaPresentationDuration="PT6M16S" minBufferTime="PT1.97S" availabilityStartTime="1970-01-01T00:00:00Z">
<Period id="0"></Period>
<Period id="1"></Period>
</MPD>
but got <?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediaPresentationDuration="PT6M16S" minBufferTime="PT1.97S" availabilityStartTime="1970-01-01T00:00:00Z">
<Period></Period>
<Period id="0"></Period>
<Period id="1"></Period>
</MPD>
Let me know if this test makes sense ? Coz I see the other tests were written in a similar way but might make sense back in day before when it was a single period only support, so one would just assume that a an empty period is created with NewMPD() and we call GetCurrentPeriod() to fetch current period.