Skip to content

Commit

Permalink
Add BaseURL to Representation (#16)
Browse files Browse the repository at this point in the history
Add BaseURL to Representation
  • Loading branch information
maxkur authored Sep 28, 2021
1 parent b20c725 commit 77e8491
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
57 changes: 57 additions & 0 deletions fixture_vod_with_base_url.mpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mpeg:dash:schema:mpd:2011" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd" id="dash" type="dynamic" publishTime="2021-09-21T14:28:50Z" minimumUpdatePeriod="PT5.6S" availabilityStartTime="2021-09-17T04:42:54Z" minBufferTime="PT17S" suggestedPresentationDelay="PT17S" timeShiftBufferDepth="PT136S" profiles="urn:mpeg:dash:profile:isoff-live:2011">
<Period start="PT0S" id="1631853774">
<AdaptationSet mimeType="video/mp4" segmentAlignment="true" startWithSAP="1" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
<ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="e01c0ecc-d0d9-52f7-87c2-febe8577327f"/>
<ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" value="Widevine">
<cenc:pssh>AAAAPnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAB4iFnYzLWRzaC13di12aWRlby0xOTkxODRI49yVmwY=</cenc:pssh>
</ContentProtection>
<Representation id="tracks-v1" width="320" height="180" sar="1:1" frameRate="25" bandwidth="196000" codecs="avc1.4d000c">
<BaseURL>https://video-1-2/</BaseURL>
<SegmentTemplate timescale="1000" media="$RepresentationID$/seg-1631853774-$Number$.m4v?t=$Time$" initialization="$RepresentationID$/init.m4v" startNumber="219269">
<SegmentTimeline>
<S t="380620753" d="8000" r="16"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="tracks-v2" width="640" height="360" sar="1:1" frameRate="25" bandwidth="490000" codecs="avc1.4d001e">
<BaseURL>https://video-1-2/</BaseURL>
<SegmentTemplate timescale="1000" media="$RepresentationID$/seg-1631853774-$Number$.m4v?t=$Time$" initialization="$RepresentationID$/init.m4v" startNumber="219269">
<SegmentTimeline>
<S t="380620753" d="8000" r="16"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="tracks-v3" width="640" height="360" sar="1:1" frameRate="25" bandwidth="1175000" codecs="avc1.4d001e">
<BaseURL>https://video-1-2/</BaseURL>
<SegmentTemplate timescale="1000" media="$RepresentationID$/seg-1631853774-$Number$.m4v?t=$Time$" initialization="$RepresentationID$/init.m4v" startNumber="219269">
<SegmentTimeline>
<S t="380620753" d="8000" r="16"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="tracks-v4" width="768" height="432" sar="1:1" frameRate="25" bandwidth="2332000" codecs="avc1.64001e">
<BaseURL>https://video-1-2/</BaseURL>
<SegmentTemplate timescale="1000" media="$RepresentationID$/seg-1631853774-$Number$.m4v?t=$Time$" initialization="$RepresentationID$/init.m4v" startNumber="219269">
<SegmentTimeline>
<S t="380620753" d="8000" r="16"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
<AdaptationSet mimeType="audio/mp4" segmentAlignment="true" startWithSAP="1" lang="rus">
<ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="e01c0ecc-d0d9-52f7-87c2-febe8577327f"/>
<ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" value="Widevine">
<cenc:pssh>AAAAPnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAB4iFnYzLWRzaC13di12aWRlby0xOTkxODRI49yVmwY=</cenc:pssh>
</ContentProtection>
<Representation id="tracks-a1" bandwidth="62000" codecs="mp4a.40.2">
<BaseURL>https://video-1-2/</BaseURL>
<SegmentTemplate timescale="1000" media="$RepresentationID$/seg-1631853774-$Number$.m4v?t=$Time$" initialization="$RepresentationID$/init.m4v" startNumber="219269">
<SegmentTimeline>
<S t="380620753" d="8000" r="16"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
</Period>
</MPD>
3 changes: 3 additions & 0 deletions mpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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"`
}
Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 5 additions & 1 deletion mpd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 77e8491

Please sign in to comment.