From 7a8b5b37e95c69bc384d722eecd58e374213feff Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Fri, 21 Feb 2020 11:56:10 -0500 Subject: [PATCH 1/3] add MPD@Location --- mpd/mpd.go | 77 +++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/mpd/mpd.go b/mpd/mpd.go index 3b786e7..0bcfb91 100644 --- a/mpd/mpd.go +++ b/mpd/mpd.go @@ -79,6 +79,7 @@ type MPD struct { TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` SuggestedPresentationDelay *Duration `xml:"suggestedPresentationDelay,attr,omitempty"` BaseURL string `xml:"BaseURL,omitempty"` + Location string `xml:"Location,omitempty"` period *Period Periods []*Period `xml:"Period,omitempty"` UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"` @@ -127,25 +128,25 @@ type CommonAttributesAndElements struct { type AdaptationSet struct { CommonAttributesAndElements - XMLName xml.Name `xml:"AdaptationSet"` - ID *string `xml:"id,attr"` - SegmentAlignment *bool `xml:"segmentAlignment,attr"` - Lang *string `xml:"lang,attr"` - Group *string `xml:"group,attr"` - PAR *string `xml:"par,attr"` - MinBandwidth *string `xml:"minBandwidth,attr"` - 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"` - SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"` - SegmentList *SegmentList `xml:"SegmentList,omitempty"` - SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate,omitempty"` // Live Profile Only - Representations []*Representation `xml:"Representation,omitempty"` + XMLName xml.Name `xml:"AdaptationSet"` + ID *string `xml:"id,attr"` + SegmentAlignment *bool `xml:"segmentAlignment,attr"` + Lang *string `xml:"lang,attr"` + Group *string `xml:"group,attr"` + PAR *string `xml:"par,attr"` + MinBandwidth *string `xml:"minBandwidth,attr"` + 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"` + SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"` + SegmentList *SegmentList `xml:"SegmentList,omitempty"` + SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate,omitempty"` // Live Profile Only + Representations []*Representation `xml:"Representation,omitempty"` AccessibilityElems []*Accessibility `xml:"Accessibility,omitempty"` } @@ -153,25 +154,25 @@ func (as *AdaptationSet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er adaptationSet := struct { CommonAttributesAndElements - XMLName xml.Name `xml:"AdaptationSet"` - ID *string `xml:"id,attr"` - SegmentAlignment *bool `xml:"segmentAlignment,attr"` - Lang *string `xml:"lang,attr"` - Group *string `xml:"group,attr"` - PAR *string `xml:"par,attr"` - MinBandwidth *string `xml:"minBandwidth,attr"` - 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"` - SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"` - SegmentList *SegmentList `xml:"SegmentList,omitempty"` - SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate,omitempty"` // Live Profile Only - Representations []*Representation `xml:"Representation,omitempty"` + XMLName xml.Name `xml:"AdaptationSet"` + ID *string `xml:"id,attr"` + SegmentAlignment *bool `xml:"segmentAlignment,attr"` + Lang *string `xml:"lang,attr"` + Group *string `xml:"group,attr"` + PAR *string `xml:"par,attr"` + MinBandwidth *string `xml:"minBandwidth,attr"` + 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"` + SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"` + SegmentList *SegmentList `xml:"SegmentList,omitempty"` + SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate,omitempty"` // Live Profile Only + Representations []*Representation `xml:"Representation,omitempty"` AccessibilityElems []*Accessibility `xml:"Accessibility,omitempty"` }{} From d5bdaa7e365fc80d6bea8bcdbb82c4f37f801914 Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Fri, 21 Feb 2020 13:59:49 -0500 Subject: [PATCH 2/3] add test for MPD@Location --- mpd/fixtures/location.mpd | 4 ++++ mpd/mpd_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 mpd/fixtures/location.mpd diff --git a/mpd/fixtures/location.mpd b/mpd/fixtures/location.mpd new file mode 100644 index 0000000..2d1bff6 --- /dev/null +++ b/mpd/fixtures/location.mpd @@ -0,0 +1,4 @@ + + + https://example.com/location.mpd + diff --git a/mpd/mpd_test.go b/mpd/mpd_test.go index 6358c0f..9c5f104 100644 --- a/mpd/mpd_test.go +++ b/mpd/mpd_test.go @@ -4,8 +4,10 @@ import ( "encoding/base64" "testing" + "github.com/zencoder/go-dash/helpers/ptrs" . "github.com/zencoder/go-dash/helpers/ptrs" "github.com/zencoder/go-dash/helpers/require" + "github.com/zencoder/go-dash/helpers/testfixtures" ) const ( @@ -41,6 +43,7 @@ const ( VALID_SUBTITLE_ID string = "subtitle_en" VALID_SUBTITLE_URL string = "http://example.com/content/sintel/subtitles/subtitles_en.vtt" VALID_ROLE string = "main" + VALID_LOCATION string = "https://example.com/location.mpd" ) func TestNewMPDLive(t *testing.T) { @@ -484,3 +487,30 @@ func TestAddNewAccessibilityElement(t *testing.T) { require.EqualStringPtr(t, Strptr((string)(ACCESSIBILITY_ELEMENT_SCHEME_DESCRIPTIVE_AUDIO)), elem.SchemeIdUri) require.EqualStringPtr(t, Strptr("1"), elem.Value) } + +func TestLocationWriteToString(t *testing.T) { + m := &MPD{ + XMLNs: ptrs.Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: ptrs.Strptr((string)(DASH_PROFILE_LIVE)), + Type: ptrs.Strptr("dynamic"), + AvailabilityStartTime: ptrs.Strptr(VALID_AVAILABILITY_START_TIME), + MinimumUpdatePeriod: ptrs.Strptr(VALID_MINIMUM_UPDATE_PERIOD), + PublishTime: ptrs.Strptr(VALID_AVAILABILITY_START_TIME), + Location: VALID_LOCATION, + } + + got, err := m.WriteToString() + require.NoError(t, err) + + testfixtures.CompareFixture(t, "fixtures/location.mpd", got) +} + +func TestReadLocation(t *testing.T) { + m, err := ReadFromFile("fixtures/location.mpd") + require.NoError(t, err) + + got, err := m.WriteToString() + require.NoError(t, err) + + testfixtures.CompareFixture(t, "fixtures/location.mpd", got) +} From f35fb0321a1ee7319df3a825b3958e992934e3c0 Mon Sep 17 00:00:00 2001 From: Matthew Neil Date: Fri, 21 Feb 2020 14:08:56 -0500 Subject: [PATCH 3/3] remove unnecessary ptrs import --- mpd/mpd_test.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mpd/mpd_test.go b/mpd/mpd_test.go index 9c5f104..7fbae4b 100644 --- a/mpd/mpd_test.go +++ b/mpd/mpd_test.go @@ -4,7 +4,6 @@ import ( "encoding/base64" "testing" - "github.com/zencoder/go-dash/helpers/ptrs" . "github.com/zencoder/go-dash/helpers/ptrs" "github.com/zencoder/go-dash/helpers/require" "github.com/zencoder/go-dash/helpers/testfixtures" @@ -490,12 +489,12 @@ func TestAddNewAccessibilityElement(t *testing.T) { func TestLocationWriteToString(t *testing.T) { m := &MPD{ - XMLNs: ptrs.Strptr("urn:mpeg:dash:schema:mpd:2011"), - Profiles: ptrs.Strptr((string)(DASH_PROFILE_LIVE)), - Type: ptrs.Strptr("dynamic"), - AvailabilityStartTime: ptrs.Strptr(VALID_AVAILABILITY_START_TIME), - MinimumUpdatePeriod: ptrs.Strptr(VALID_MINIMUM_UPDATE_PERIOD), - PublishTime: ptrs.Strptr(VALID_AVAILABILITY_START_TIME), + XMLNs: Strptr("urn:mpeg:dash:schema:mpd:2011"), + Profiles: Strptr((string)(DASH_PROFILE_LIVE)), + Type: Strptr("dynamic"), + AvailabilityStartTime: Strptr(VALID_AVAILABILITY_START_TIME), + MinimumUpdatePeriod: Strptr(VALID_MINIMUM_UPDATE_PERIOD), + PublishTime: Strptr(VALID_AVAILABILITY_START_TIME), Location: VALID_LOCATION, }