From 42fa63aa459033a8450fca29c63aa1444172c089 Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Fri, 13 Dec 2019 13:45:48 -0500 Subject: [PATCH 1/5] add MPD@suggestedPresentationDelay and AdaptationSet@maxHeight, AdaptationSet@minHeight --- mpd/mpd.go | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/mpd/mpd.go b/mpd/mpd.go index 022cb45..87855f7 100644 --- a/mpd/mpd.go +++ b/mpd/mpd.go @@ -60,19 +60,20 @@ var ( ) type MPD struct { - XMLNs *string `xml:"xmlns,attr"` - Profiles *string `xml:"profiles,attr"` - Type *string `xml:"type,attr"` - MediaPresentationDuration *string `xml:"mediaPresentationDuration,attr"` - MinBufferTime *string `xml:"minBufferTime,attr"` - AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"` - MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"` - PublishTime *string `xml:"publishTime,attr"` - TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` - BaseURL string `xml:"BaseURL,omitempty"` - period *Period - Periods []*Period `xml:"Period,omitempty"` - UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"` + XMLNs *string `xml:"xmlns,attr"` + Profiles *string `xml:"profiles,attr"` + Type *string `xml:"type,attr"` + MediaPresentationDuration *string `xml:"mediaPresentationDuration,attr"` + MinBufferTime *string `xml:"minBufferTime,attr"` + AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"` + MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"` + PublishTime *string `xml:"publishTime,attr"` + SuggestedPresentationDelay Duration `xml:"suggestedPresentationDelay,attr,omitempty"` + TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` + BaseURL string `xml:"BaseURL,omitempty"` + period *Period + Periods []*Period `xml:"Period,omitempty"` + UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"` } type Period struct { @@ -127,6 +128,8 @@ type AdaptationSet struct { MaxBandwidth *string `xml:"maxBandwidth,attr"` MinWidth *string `xml:"minWidth,attr"` MaxWidth *string `xml:"maxWidth,attr"` + MinHeight *string `xml:"minHeight,attr"` + MaxHeight *string `xml:"maxHeight,attr"` ContentType *string `xml:"contentType,attr"` ContentProtection []ContentProtectioner `xml:"ContentProtection,omitempty"` // Common attribute, can be deprecated here Roles []*Role `xml:"Role,omitempty"` @@ -150,6 +153,8 @@ func (as *AdaptationSet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er MaxBandwidth *string `xml:"maxBandwidth,attr"` MinWidth *string `xml:"minWidth,attr"` MaxWidth *string `xml:"maxWidth,attr"` + MinHeight *string `xml:"minHeight,attr"` + MaxHeight *string `xml:"maxHeight,attr"` ContentType *string `xml:"contentType,attr"` ContentProtection []ContentProtectioner `xml:"ContentProtection,omitempty"` // Common attribute, can be deprecated here Roles []*Role `xml:"Role,omitempty"` From 52c45a2c04bce9345a29d42000ef77ad5adb5449 Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Fri, 13 Dec 2019 14:54:51 -0500 Subject: [PATCH 2/5] use pointer for optional suggestedPresentationDelay --- mpd/mpd.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mpd/mpd.go b/mpd/mpd.go index 87855f7..f3d836a 100644 --- a/mpd/mpd.go +++ b/mpd/mpd.go @@ -60,17 +60,17 @@ var ( ) type MPD struct { - XMLNs *string `xml:"xmlns,attr"` - Profiles *string `xml:"profiles,attr"` - Type *string `xml:"type,attr"` - MediaPresentationDuration *string `xml:"mediaPresentationDuration,attr"` - MinBufferTime *string `xml:"minBufferTime,attr"` - AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"` - MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"` - PublishTime *string `xml:"publishTime,attr"` - SuggestedPresentationDelay Duration `xml:"suggestedPresentationDelay,attr,omitempty"` - TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` - BaseURL string `xml:"BaseURL,omitempty"` + XMLNs *string `xml:"xmlns,attr"` + Profiles *string `xml:"profiles,attr"` + Type *string `xml:"type,attr"` + MediaPresentationDuration *string `xml:"mediaPresentationDuration,attr"` + MinBufferTime *string `xml:"minBufferTime,attr"` + AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"` + MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"` + PublishTime *string `xml:"publishTime,attr"` + SuggestedPresentationDelay *Duration `xml:"suggestedPresentationDelay,attr,omitempty"` + TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` + BaseURL string `xml:"BaseURL,omitempty"` period *Period Periods []*Period `xml:"Period,omitempty"` UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"` From 68986997d106df8f59eebde4f3f80990a373a0fc Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Fri, 13 Dec 2019 13:45:48 -0500 Subject: [PATCH 3/5] add MPD@suggestedPresentationDelay and AdaptationSet@maxHeight, AdaptationSet@minHeight --- mpd/mpd.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mpd/mpd.go b/mpd/mpd.go index f3d836a..87855f7 100644 --- a/mpd/mpd.go +++ b/mpd/mpd.go @@ -60,17 +60,17 @@ var ( ) type MPD struct { - XMLNs *string `xml:"xmlns,attr"` - Profiles *string `xml:"profiles,attr"` - Type *string `xml:"type,attr"` - MediaPresentationDuration *string `xml:"mediaPresentationDuration,attr"` - MinBufferTime *string `xml:"minBufferTime,attr"` - AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"` - MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"` - PublishTime *string `xml:"publishTime,attr"` - SuggestedPresentationDelay *Duration `xml:"suggestedPresentationDelay,attr,omitempty"` - TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` - BaseURL string `xml:"BaseURL,omitempty"` + XMLNs *string `xml:"xmlns,attr"` + Profiles *string `xml:"profiles,attr"` + Type *string `xml:"type,attr"` + MediaPresentationDuration *string `xml:"mediaPresentationDuration,attr"` + MinBufferTime *string `xml:"minBufferTime,attr"` + AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"` + MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"` + PublishTime *string `xml:"publishTime,attr"` + SuggestedPresentationDelay Duration `xml:"suggestedPresentationDelay,attr,omitempty"` + TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` + BaseURL string `xml:"BaseURL,omitempty"` period *Period Periods []*Period `xml:"Period,omitempty"` UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"` From d3495c8acb9b7d6da65bdb866606ff1ef65e96b1 Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Fri, 13 Dec 2019 14:54:51 -0500 Subject: [PATCH 4/5] use pointer for optional suggestedPresentationDelay --- mpd/mpd.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mpd/mpd.go b/mpd/mpd.go index 87855f7..f3d836a 100644 --- a/mpd/mpd.go +++ b/mpd/mpd.go @@ -60,17 +60,17 @@ var ( ) type MPD struct { - XMLNs *string `xml:"xmlns,attr"` - Profiles *string `xml:"profiles,attr"` - Type *string `xml:"type,attr"` - MediaPresentationDuration *string `xml:"mediaPresentationDuration,attr"` - MinBufferTime *string `xml:"minBufferTime,attr"` - AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"` - MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"` - PublishTime *string `xml:"publishTime,attr"` - SuggestedPresentationDelay Duration `xml:"suggestedPresentationDelay,attr,omitempty"` - TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` - BaseURL string `xml:"BaseURL,omitempty"` + XMLNs *string `xml:"xmlns,attr"` + Profiles *string `xml:"profiles,attr"` + Type *string `xml:"type,attr"` + MediaPresentationDuration *string `xml:"mediaPresentationDuration,attr"` + MinBufferTime *string `xml:"minBufferTime,attr"` + AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"` + MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"` + PublishTime *string `xml:"publishTime,attr"` + SuggestedPresentationDelay *Duration `xml:"suggestedPresentationDelay,attr,omitempty"` + TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` + BaseURL string `xml:"BaseURL,omitempty"` period *Period Periods []*Period `xml:"Period,omitempty"` UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"` From 5fd38ad50b7ff842359616fc8e88a0299468c523 Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Mon, 6 Jan 2020 10:25:17 -0500 Subject: [PATCH 5/5] add tests --- mpd/mpd.go | 2 +- mpd/mpd_read_write_test.go | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/mpd/mpd.go b/mpd/mpd.go index f3d836a..2fdfa73 100644 --- a/mpd/mpd.go +++ b/mpd/mpd.go @@ -68,8 +68,8 @@ type MPD struct { AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"` MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"` PublishTime *string `xml:"publishTime,attr"` - SuggestedPresentationDelay *Duration `xml:"suggestedPresentationDelay,attr,omitempty"` TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` + SuggestedPresentationDelay *Duration `xml:"suggestedPresentationDelay,attr,omitempty"` BaseURL string `xml:"BaseURL,omitempty"` period *Period Periods []*Period `xml:"Period,omitempty"` diff --git a/mpd/mpd_read_write_test.go b/mpd/mpd_read_write_test.go index c0757b6..0449f16 100644 --- a/mpd/mpd_read_write_test.go +++ b/mpd/mpd_read_write_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "github.com/zencoder/go-dash/helpers/ptrs" "github.com/zencoder/go-dash/helpers/require" "github.com/zencoder/go-dash/helpers/testfixtures" ) @@ -89,6 +90,26 @@ func TestNewDynamicMPDLiveWithPeriodStartWriteToString(t *testing.T) { require.EqualString(t, expectedXML, xmlStr) } +func TestNewDynamicMPDLiveWithSuggestedPresentationDelayToString(t *testing.T) { + m := NewDynamicMPD(DASH_PROFILE_LIVE, VALID_AVAILABILITY_START_TIME, VALID_MIN_BUFFER_TIME, + AttrMediaPresentationDuration(VALID_MEDIA_PRESENTATION_DURATION), + AttrMinimumUpdatePeriod(VALID_MINIMUM_UPDATE_PERIOD)) + + // Set first period start time to PT0S + spd := Duration(time.Duration(18) * time.Second) + m.SuggestedPresentationDelay = &spd + + xmlStr, err := m.WriteToString() + require.NoError(t, err) + expectedXML := ` + + + + +` + require.EqualString(t, expectedXML, xmlStr) +} + func TestNewMPDOnDemandWriteToString(t *testing.T) { m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME) @@ -122,14 +143,20 @@ func TestAddNewAdaptationSetAudioWriteToString(t *testing.T) { func TestAddNewAdaptationSetVideoWriteToString(t *testing.T) { m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME) - _, _ = m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) + as, err := m.AddNewAdaptationSetVideoWithID("7357", DASH_MIME_TYPE_VIDEO_MP4, VALID_SCAN_TYPE, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP) + require.NoError(t, err) + + as.MinWidth = ptrs.Strptr("720") + as.MaxWidth = ptrs.Strptr("720") + as.MinHeight = ptrs.Strptr("480") + as.MaxHeight = ptrs.Strptr("480") xmlStr, err := m.WriteToString() require.NoError(t, err) expectedXML := ` - + `