@@ -3,6 +3,7 @@ package mpd
33import (
44 "encoding/base64"
55 "path/filepath"
6+ "strconv"
67 "testing"
78
89 . "github.com/zencoder/go-dash/helpers/ptrs"
@@ -95,6 +96,34 @@ func TestNewDynamicMPDLive(t *testing.T) {
9596 require .EqualString (t , expectedString , actualString )
9697}
9798
99+ func TestNewMPDMultiPeriod (t * testing.T ) {
100+ m := NewMPD (DASH_PROFILE_LIVE , VALID_MEDIA_PRESENTATION_DURATION , VALID_MIN_BUFFER_TIME ,
101+ AttrAvailabilityStartTime (VALID_AVAILABILITY_START_TIME ))
102+ require .NotNil (t , m )
103+ for i := 0 ; i < 2 ; i ++ {
104+ period := m .AddNewPeriod ()
105+ period .ID = strconv .Itoa (i )
106+ }
107+
108+ expectedMPD := & MPD {
109+ XMLNs : Strptr ("urn:mpeg:dash:schema:mpd:2011" ),
110+ Profiles : Strptr ((string )(DASH_PROFILE_LIVE )),
111+ Type : Strptr ("static" ),
112+ MediaPresentationDuration : Strptr (VALID_MEDIA_PRESENTATION_DURATION ),
113+ MinBufferTime : Strptr (VALID_MIN_BUFFER_TIME ),
114+ AvailabilityStartTime : Strptr (VALID_AVAILABILITY_START_TIME ),
115+ period : nil ,
116+ Periods : []* Period {{ID : "0" }, {ID : "1" }},
117+ }
118+
119+ expectedString , err := expectedMPD .WriteToString ()
120+ require .NoError (t , err )
121+ actualString , err := m .WriteToString ()
122+ require .NoError (t , err )
123+
124+ require .EqualString (t , expectedString , actualString )
125+ }
126+
98127func TestContentProtection_ImplementsInterface (t * testing.T ) {
99128 cp := (* ContentProtectioner )(nil )
100129 require .Implements (t , cp , & ContentProtection {})
0 commit comments