Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion examples/live.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/zencoder/go-dash/mpd"
)

func exampleLive() {
func main() {
m := mpd.NewMPD(mpd.DASH_PROFILE_LIVE, "PT6M16S", "PT1.97S")

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

mpdStr, _ := m.WriteToString()
fmt.Println(mpdStr)
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module github.com/zencoder/go-dash

go 1.13
1 change: 1 addition & 0 deletions mpd/fixtures/live_profile_dynamic.mpd
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@
</Representation>
</AdaptationSet>
</Period>
<UTCTiming></UTCTiming>
</MPD>
8 changes: 7 additions & 1 deletion mpd/mpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ type MPD struct {
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"`
Periods []*Period `xml:"Period,omitempty"`
UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"`
}

type Period struct {
Expand Down Expand Up @@ -124,6 +127,7 @@ type AdaptationSet struct {
MaxBandwidth *string `xml:"maxBandwidth,attr"`
MinWidth *string `xml:"minWidth,attr"`
MaxWidth *string `xml:"maxWidth,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"`
Expand All @@ -146,6 +150,7 @@ 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"`
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"`
Expand Down Expand Up @@ -478,6 +483,7 @@ func NewDynamicMPD(profile DashProfile, availabilityStartTime, minBufferTime str
MinBufferTime: Strptr(minBufferTime),
period: period,
Periods: []*Period{period},
UTCTiming: &DescriptorType{},
}

for i := range attributes {
Expand Down
1 change: 1 addition & 0 deletions mpd/mpd_read_write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func TestNewDynamicMPDLiveWriteToString(t *testing.T) {
expectedXML := `<?xml version="1.0" encoding="UTF-8"?>
<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">
<Period></Period>
<UTCTiming></UTCTiming>
</MPD>
`
require.EqualString(t, expectedXML, xmlStr)
Expand Down
1 change: 1 addition & 0 deletions mpd/mpd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestNewDynamicMPDLive(t *testing.T) {
MinimumUpdatePeriod: Strptr(VALID_MINIMUM_UPDATE_PERIOD),
period: &Period{},
Periods: []*Period{{}},
UTCTiming: &DescriptorType{},
}

expectedString, err := expectedMPD.WriteToString()
Expand Down