From 77e84915827e54dc1bec0a3cdca99207d087dc13 Mon Sep 17 00:00:00 2001 From: Maxim Kurganskiy Date: Tue, 28 Sep 2021 17:52:33 +0300 Subject: [PATCH] Add BaseURL to Representation (#16) Add BaseURL to Representation --- fixture_vod_with_base_url.mpd | 57 +++++++++++++++++++++++++++++++++++ mpd.go | 3 ++ mpd_test.go | 6 +++- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 fixture_vod_with_base_url.mpd diff --git a/fixture_vod_with_base_url.mpd b/fixture_vod_with_base_url.mpd new file mode 100644 index 0000000..eda93ef --- /dev/null +++ b/fixture_vod_with_base_url.mpd @@ -0,0 +1,57 @@ + + + + + + + AAAAPnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAB4iFnYzLWRzaC13di12aWRlby0xOTkxODRI49yVmwY= + + + https://video-1-2/ + + + + + + + + https://video-1-2/ + + + + + + + + https://video-1-2/ + + + + + + + + https://video-1-2/ + + + + + + + + + + + AAAAPnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAB4iFnYzLWRzaC13di12aWRlby0xOTkxODRI49yVmwY= + + + https://video-1-2/ + + + + + + + + + diff --git a/mpd.go b/mpd.go index f4cfd6b..7081f17 100644 --- a/mpd.go +++ b/mpd.go @@ -196,6 +196,7 @@ type Representation struct { Bandwidth *uint64 `xml:"bandwidth,attr"` AudioSamplingRate *string `xml:"audioSamplingRate,attr"` Codecs *string `xml:"codecs,attr"` + BaseURL *string `xml:"BaseURL,omitempty"` ContentProtections []DRMDescriptor `xml:"ContentProtection,omitempty"` SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate,omitempty"` } @@ -209,6 +210,7 @@ type representationMarshal struct { Bandwidth *uint64 `xml:"bandwidth,attr"` AudioSamplingRate *string `xml:"audioSamplingRate,attr"` Codecs *string `xml:"codecs,attr"` + BaseURL *string `xml:"BaseURL,omitempty"` ContentProtections []drmDescriptorMarshal `xml:"ContentProtection,omitempty"` SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate,omitempty"` } @@ -334,6 +336,7 @@ func modifyRepresentations(rs []Representation) []representationMarshal { SegmentTemplate: copySegmentTemplate(r.SegmentTemplate), SAR: copyobj.String(r.SAR), ContentProtections: modifyContentProtections(r.ContentProtections), + BaseURL: copyobj.String(r.BaseURL), } rsm = append(rsm, representation) } diff --git a/mpd_test.go b/mpd_test.go index 9445ef2..18a0ae3 100644 --- a/mpd_test.go +++ b/mpd_test.go @@ -57,6 +57,10 @@ func (s *MPDSuite) TestUnmarshalMarshalLiveDelta161(c *C) { testUnmarshalMarshal(c, "fixture_elemental_delta_vod_multi_drm.mpd") } +func (s *MPDSuite) TestUnmarshalMarshalVodBaseURL(c *C) { + testUnmarshalMarshal(c, "fixture_vod_with_base_url.mpd") +} + func TestMPDEqual(t *testing.T) { a := &MPD{} b := &mpdMarshal{} @@ -87,7 +91,7 @@ func TestAdaptationSetEqual(t *testing.T) { func TestRepresentationEqual(t *testing.T) { a := &Representation{} b := &representationMarshal{} - require.Equal(t, 10, reflect.ValueOf(a).Elem().NumField(), + require.Equal(t, 11, reflect.ValueOf(a).Elem().NumField(), "model was updated, need to update this test and function modifyRepresentations") require.Equal(t, reflect.ValueOf(a).Elem().NumField(), reflect.ValueOf(b).Elem().NumField(), "Representation element count not equal Representation")