Skip to content

Commit 5fd38ad

Browse files
committed
add tests
1 parent d3495c8 commit 5fd38ad

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

mpd/mpd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ type MPD struct {
6868
AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"`
6969
MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"`
7070
PublishTime *string `xml:"publishTime,attr"`
71-
SuggestedPresentationDelay *Duration `xml:"suggestedPresentationDelay,attr,omitempty"`
7271
TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"`
72+
SuggestedPresentationDelay *Duration `xml:"suggestedPresentationDelay,attr,omitempty"`
7373
BaseURL string `xml:"BaseURL,omitempty"`
7474
period *Period
7575
Periods []*Period `xml:"Period,omitempty"`

mpd/mpd_read_write_test.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66
"time"
77

8+
"github.com/zencoder/go-dash/helpers/ptrs"
89
"github.com/zencoder/go-dash/helpers/require"
910
"github.com/zencoder/go-dash/helpers/testfixtures"
1011
)
@@ -89,6 +90,26 @@ func TestNewDynamicMPDLiveWithPeriodStartWriteToString(t *testing.T) {
8990
require.EqualString(t, expectedXML, xmlStr)
9091
}
9192

93+
func TestNewDynamicMPDLiveWithSuggestedPresentationDelayToString(t *testing.T) {
94+
m := NewDynamicMPD(DASH_PROFILE_LIVE, VALID_AVAILABILITY_START_TIME, VALID_MIN_BUFFER_TIME,
95+
AttrMediaPresentationDuration(VALID_MEDIA_PRESENTATION_DURATION),
96+
AttrMinimumUpdatePeriod(VALID_MINIMUM_UPDATE_PERIOD))
97+
98+
// Set first period start time to PT0S
99+
spd := Duration(time.Duration(18) * time.Second)
100+
m.SuggestedPresentationDelay = &spd
101+
102+
xmlStr, err := m.WriteToString()
103+
require.NoError(t, err)
104+
expectedXML := `<?xml version="1.0" encoding="UTF-8"?>
105+
<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" suggestedPresentationDelay="PT18S">
106+
<Period></Period>
107+
<UTCTiming></UTCTiming>
108+
</MPD>
109+
`
110+
require.EqualString(t, expectedXML, xmlStr)
111+
}
112+
92113
func TestNewMPDOnDemandWriteToString(t *testing.T) {
93114
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
94115

@@ -122,14 +143,20 @@ func TestAddNewAdaptationSetAudioWriteToString(t *testing.T) {
122143
func TestAddNewAdaptationSetVideoWriteToString(t *testing.T) {
123144
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
124145

125-
_, _ = m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
146+
as, err := m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP)
147+
require.NoError(t, err)
148+
149+
as.MinWidth = ptrs.Strptr("720")
150+
as.MaxWidth = ptrs.Strptr("720")
151+
as.MinHeight = ptrs.Strptr("480")
152+
as.MaxHeight = ptrs.Strptr("480")
126153

127154
xmlStr, err := m.WriteToString()
128155
require.NoError(t, err)
129156
expectedXML := `<?xml version="1.0" encoding="UTF-8"?>
130157
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediaPresentationDuration="PT6M16S" minBufferTime="PT1.97S">
131158
<Period>
132-
<AdaptationSet mimeType="video/mp4" startWithSAP="1" scanType="progressive" id="7357" segmentAlignment="true"></AdaptationSet>
159+
<AdaptationSet mimeType="video/mp4" startWithSAP="1" scanType="progressive" id="7357" segmentAlignment="true" minWidth="720" maxWidth="720" minHeight="480" maxHeight="480"></AdaptationSet>
133160
</Period>
134161
</MPD>
135162
`

0 commit comments

Comments
 (0)