Skip to content

Commit d519baf

Browse files
authored
Merge pull request #63 from zencoder/live-updates
Updates to support dynamic/live manifests
2 parents 6f016ad + 5c4c918 commit d519baf

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

examples/live.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/zencoder/go-dash/mpd"
77
)
88

9-
func exampleLive() {
9+
func main() {
1010
m := mpd.NewMPD(mpd.DASH_PROFILE_LIVE, "PT6M16S", "PT1.97S")
1111

1212
audioAS, _ := m.AddNewAdaptationSetAudio(mpd.DASH_MIME_TYPE_AUDIO_MP4, true, 1, "und")
@@ -29,6 +29,12 @@ func exampleLive() {
2929
subtitleAS, _ := m.AddNewAdaptationSetSubtitle(mpd.DASH_MIME_TYPE_SUBTITLE_VTT, "en")
3030
subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(256, "subtitle_en")
3131
_ = subtitleRep.SetNewBaseURL("http://example.com/content/sintel/subtitles/subtitles_en.vtt")
32+
schemeIDURI := "urn:mpeg:dash:utc:direct:2014"
33+
value := "2019-10-23T15:56:29Z"
34+
m.UTCTiming = &mpd.DescriptorType{
35+
SchemeIDURI: &schemeIDURI,
36+
Value: &value,
37+
}
3238

3339
mpdStr, _ := m.WriteToString()
3440
fmt.Println(mpdStr)

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
module github.com/zencoder/go-dash
2+
3+
go 1.13

mpd/fixtures/live_profile_dynamic.mpd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@
3636
</Representation>
3737
</AdaptationSet>
3838
</Period>
39+
<UTCTiming></UTCTiming>
3940
</MPD>

mpd/mpd.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ type MPD struct {
6767
MinBufferTime *string `xml:"minBufferTime,attr"`
6868
AvailabilityStartTime *string `xml:"availabilityStartTime,attr,omitempty"`
6969
MinimumUpdatePeriod *string `xml:"minimumUpdatePeriod,attr"`
70+
PublishTime *string `xml:"publishTime,attr"`
71+
TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"`
7072
BaseURL string `xml:"BaseURL,omitempty"`
7173
period *Period
72-
Periods []*Period `xml:"Period,omitempty"`
74+
Periods []*Period `xml:"Period,omitempty"`
75+
UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"`
7376
}
7477

7578
type Period struct {
@@ -124,6 +127,7 @@ type AdaptationSet struct {
124127
MaxBandwidth *string `xml:"maxBandwidth,attr"`
125128
MinWidth *string `xml:"minWidth,attr"`
126129
MaxWidth *string `xml:"maxWidth,attr"`
130+
ContentType *string `xml:"contentType,attr"`
127131
ContentProtection []ContentProtectioner `xml:"ContentProtection,omitempty"` // Common attribute, can be deprecated here
128132
Roles []*Role `xml:"Role,omitempty"`
129133
SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"`
@@ -146,6 +150,7 @@ func (as *AdaptationSet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er
146150
MaxBandwidth *string `xml:"maxBandwidth,attr"`
147151
MinWidth *string `xml:"minWidth,attr"`
148152
MaxWidth *string `xml:"maxWidth,attr"`
153+
ContentType *string `xml:"contentType,attr"`
149154
ContentProtection []ContentProtectioner `xml:"ContentProtection,omitempty"` // Common attribute, can be deprecated here
150155
Roles []*Role `xml:"Role,omitempty"`
151156
SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"`
@@ -478,6 +483,7 @@ func NewDynamicMPD(profile DashProfile, availabilityStartTime, minBufferTime str
478483
MinBufferTime: Strptr(minBufferTime),
479484
period: period,
480485
Periods: []*Period{period},
486+
UTCTiming: &DescriptorType{},
481487
}
482488

483489
for i := range attributes {

mpd/mpd_read_write_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func TestNewDynamicMPDLiveWriteToString(t *testing.T) {
6262
expectedXML := `<?xml version="1.0" encoding="UTF-8"?>
6363
<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">
6464
<Period></Period>
65+
<UTCTiming></UTCTiming>
6566
</MPD>
6667
`
6768
require.EqualString(t, expectedXML, xmlStr)

mpd/mpd_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func TestNewDynamicMPDLive(t *testing.T) {
8181
MinimumUpdatePeriod: Strptr(VALID_MINIMUM_UPDATE_PERIOD),
8282
period: &Period{},
8383
Periods: []*Period{{}},
84+
UTCTiming: &DescriptorType{},
8485
}
8586

8687
expectedString, err := expectedMPD.WriteToString()

0 commit comments

Comments
 (0)