@@ -39,12 +39,28 @@ func TestReadingManifests(t *testing.T) {
39
39
}
40
40
41
41
func TestNewMPDLiveWriteToString (t * testing.T ) {
42
- m := NewMPD (DASH_PROFILE_LIVE , VALID_MEDIA_PRESENTATION_DURATION , VALID_MIN_BUFFER_TIME )
42
+ m := NewMPD (DASH_PROFILE_LIVE , VALID_MEDIA_PRESENTATION_DURATION , VALID_MIN_BUFFER_TIME ,
43
+ AttrAvailabilityStartTime (VALID_AVAILABILITY_START_TIME ))
43
44
44
45
xmlStr , err := m .WriteToString ()
45
46
require .Nil (t , err )
46
47
expectedXML := `<?xml version="1.0" encoding="UTF-8"?>
47
- <MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediaPresentationDuration="PT6M16S" minBufferTime="PT1.97S">
48
+ <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">
49
+ <Period></Period>
50
+ </MPD>
51
+ `
52
+ require .Equal (t , expectedXML , xmlStr )
53
+ }
54
+
55
+ func TestNewDynamicMPDLiveWriteToString (t * testing.T ) {
56
+ m := NewDynamicMPD (DASH_PROFILE_LIVE , VALID_AVAILABILITY_START_TIME , VALID_MIN_BUFFER_TIME ,
57
+ AttrMediaPresentationDuration (VALID_MEDIA_PRESENTATION_DURATION ),
58
+ AttrMinimumUpdatePeriod (VALID_MINIMUM_UPDATE_PERIOD ))
59
+
60
+ xmlStr , err := m .WriteToString ()
61
+ require .Nil (t , err )
62
+ expectedXML := `<?xml version="1.0" encoding="UTF-8"?>
63
+ <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">
48
64
<Period></Period>
49
65
</MPD>
50
66
`
@@ -143,7 +159,8 @@ func TestExampleAddNewPeriod(t *testing.T) {
143
159
}
144
160
145
161
func LiveProfile () * MPD {
146
- m := NewMPD (DASH_PROFILE_LIVE , VALID_MEDIA_PRESENTATION_DURATION , VALID_MIN_BUFFER_TIME )
162
+ m := NewMPD (DASH_PROFILE_LIVE , VALID_MEDIA_PRESENTATION_DURATION , VALID_MIN_BUFFER_TIME ,
163
+ AttrAvailabilityStartTime (VALID_AVAILABILITY_START_TIME ))
147
164
148
165
audioAS , _ := m .AddNewAdaptationSetAudioWithID ("7357" , DASH_MIME_TYPE_AUDIO_MP4 , VALID_SEGMENT_ALIGNMENT , VALID_START_WITH_SAP , VALID_LANG )
149
166
@@ -196,6 +213,62 @@ func TestFullLiveProfileWriteToFile(t *testing.T) {
196
213
require .Nil (t , err )
197
214
}
198
215
216
+ func LiveProfileDynamic () * MPD {
217
+ m := NewDynamicMPD (DASH_PROFILE_LIVE , VALID_AVAILABILITY_START_TIME , VALID_MIN_BUFFER_TIME ,
218
+ AttrMediaPresentationDuration (VALID_MEDIA_PRESENTATION_DURATION ),
219
+ AttrMinimumUpdatePeriod (VALID_MINIMUM_UPDATE_PERIOD ))
220
+
221
+ audioAS , _ := m .AddNewAdaptationSetAudioWithID ("7357" , DASH_MIME_TYPE_AUDIO_MP4 , VALID_SEGMENT_ALIGNMENT , VALID_START_WITH_SAP , VALID_LANG )
222
+
223
+ audioAS .AddNewContentProtectionRoot ("08e367028f33436ca5dd60ffe5571e60" )
224
+ audioAS .AddNewContentProtectionSchemeWidevineWithPSSH (getValidWVHeaderBytes ())
225
+ audioAS .AddNewContentProtectionSchemePlayreadyWithPSSH (VALID_PLAYREADY_PRO )
226
+
227
+ audioAS .AddNewRole ("urn:mpeg:dash:role:2011" , VALID_ROLE )
228
+
229
+ audioAS .SetNewSegmentTemplate (1968 , "$RepresentationID$/audio/en/init.mp4" , "$RepresentationID$/audio/en/seg-$Number$.m4f" , 0 , 1000 )
230
+ audioAS .AddNewRepresentationAudio (44100 , 67095 , "mp4a.40.2" , "800" )
231
+
232
+ videoAS , _ := m .AddNewAdaptationSetVideoWithID ("7357" , DASH_MIME_TYPE_VIDEO_MP4 , VALID_SCAN_TYPE , VALID_SEGMENT_ALIGNMENT , VALID_START_WITH_SAP )
233
+
234
+ videoAS .AddNewContentProtectionRoot ("08e367028f33436ca5dd60ffe5571e60" )
235
+ videoAS .AddNewContentProtectionSchemeWidevineWithPSSH (getValidWVHeaderBytes ())
236
+ videoAS .AddNewContentProtectionSchemePlayreadyWithPSSH (VALID_PLAYREADY_PRO )
237
+
238
+ videoAS .AddNewRole ("urn:mpeg:dash:role:2011" , VALID_ROLE )
239
+
240
+ videoAS .SetNewSegmentTemplate (1968 , "$RepresentationID$/video/1/init.mp4" , "$RepresentationID$/video/1/seg-$Number$.m4f" , 0 , 1000 )
241
+ videoAS .AddNewRepresentationVideo (1518664 , "avc1.4d401f" , "800" , "30000/1001" , 960 , 540 )
242
+ videoAS .AddNewRepresentationVideo (1911775 , "avc1.4d401f" , "1000" , "30000/1001" , 1024 , 576 )
243
+ videoAS .AddNewRepresentationVideo (2295158 , "avc1.4d401f" , "1200" , "30000/1001" , 1024 , 576 )
244
+ videoAS .AddNewRepresentationVideo (2780732 , "avc1.4d401f" , "1500" , "30000/1001" , 1280 , 720 )
245
+
246
+ subtitleAS , _ := m .AddNewAdaptationSetSubtitleWithID ("7357" , DASH_MIME_TYPE_SUBTITLE_VTT , VALID_LANG )
247
+ subtitleRep , _ := subtitleAS .AddNewRepresentationSubtitle (VALID_SUBTITLE_BANDWIDTH , VALID_SUBTITLE_ID )
248
+ subtitleRep .SetNewBaseURL (VALID_SUBTITLE_URL )
249
+
250
+ return m
251
+ }
252
+
253
+ func TestFullLiveProfileDynamicWriteToString (t * testing.T ) {
254
+ m := LiveProfileDynamic ()
255
+ require .NotNil (t , m )
256
+ xmlStr , err := m .WriteToString ()
257
+ require .Nil (t , err )
258
+ testfixtures .CompareFixture (t , "fixtures/live_profile_dynamic.mpd" , xmlStr )
259
+ }
260
+
261
+ func TestFullLiveProfileDynamicWriteToFile (t * testing.T ) {
262
+ m := LiveProfileDynamic ()
263
+ require .NotNil (t , m )
264
+ err := m .WriteToFile ("test_live_dynamic.mpd" )
265
+ xmlStr := testfixtures .LoadFixture ("test_live_dynamic.mpd" )
266
+ expectedXML := testfixtures .LoadFixture ("fixtures/live_profile_dynamic.mpd" )
267
+ require .Equal (t , expectedXML , xmlStr )
268
+ defer os .Remove ("test_live_dynamic.mpd" )
269
+ require .Nil (t , err )
270
+ }
271
+
199
272
func HbbTVProfile () * MPD {
200
273
m := NewMPD (DASH_PROFILE_HBBTV_1_5_LIVE , VALID_MEDIA_PRESENTATION_DURATION , VALID_MIN_BUFFER_TIME )
201
274
0 commit comments