diff --git a/examples/live.go b/examples/live.go
index d9df1b5..dd955a6 100644
--- a/examples/live.go
+++ b/examples/live.go
@@ -26,7 +26,7 @@ func main() {
_, _ = videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576)
_, _ = videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720)
- subtitleAS, _ := m.AddNewAdaptationSetSubtitle(mpd.DASH_MIME_TYPE_SUBTITLE_VTT, "en")
+ subtitleAS, _ := m.AddNewAdaptationSetSubtitle(mpd.DASH_MIME_TYPE_SUBTITLE_VTT, "en", "Subtitle (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"
diff --git a/examples/ondemand.go b/examples/ondemand.go
index 88b046c..54463f2 100644
--- a/examples/ondemand.go
+++ b/examples/ondemand.go
@@ -31,7 +31,7 @@ func exampleOndemand() {
_ = videoRep2.SetNewBaseURL("1200k/output-video-1.mp4")
_, _ = videoRep2.AddNewSegmentBase("686-813", "0-685")
- subtitleAS, _ := m.AddNewAdaptationSetSubtitle(mpd.DASH_MIME_TYPE_SUBTITLE_VTT, "en")
+ subtitleAS, _ := m.AddNewAdaptationSetSubtitle(mpd.DASH_MIME_TYPE_SUBTITLE_VTT, "en", "Subtitle (En)")
subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(256, "captions_en")
_ = subtitleRep.SetNewBaseURL("http://example.com/content/sintel/subtitles/subtitles_en.vtt")
diff --git a/mpd/fixtures/hbbtv_profile.mpd b/mpd/fixtures/hbbtv_profile.mpd
index f7672e9..ea5ef2c 100644
--- a/mpd/fixtures/hbbtv_profile.mpd
+++ b/mpd/fixtures/hbbtv_profile.mpd
@@ -33,7 +33,7 @@
-
+
http://example.com/content/sintel/subtitles/subtitles_en.vtt
diff --git a/mpd/fixtures/live_profile.mpd b/mpd/fixtures/live_profile.mpd
index 20b4f44..8d63ca2 100644
--- a/mpd/fixtures/live_profile.mpd
+++ b/mpd/fixtures/live_profile.mpd
@@ -31,7 +31,7 @@
-
+
http://example.com/content/sintel/subtitles/subtitles_en.vtt
diff --git a/mpd/fixtures/live_profile_dynamic.mpd b/mpd/fixtures/live_profile_dynamic.mpd
index f06c190..e496cb1 100644
--- a/mpd/fixtures/live_profile_dynamic.mpd
+++ b/mpd/fixtures/live_profile_dynamic.mpd
@@ -31,7 +31,7 @@
-
+
http://example.com/content/sintel/subtitles/subtitles_en.vtt
diff --git a/mpd/fixtures/live_profile_multi_base_url.mpd b/mpd/fixtures/live_profile_multi_base_url.mpd
index dc582cd..208a0c6 100644
--- a/mpd/fixtures/live_profile_multi_base_url.mpd
+++ b/mpd/fixtures/live_profile_multi_base_url.mpd
@@ -34,7 +34,7 @@
-
+
http://example.com/content/sintel/subtitles/subtitles_en.vtt
diff --git a/mpd/fixtures/ondemand_profile.mpd b/mpd/fixtures/ondemand_profile.mpd
index 47a7cc7..2b6bd22 100644
--- a/mpd/fixtures/ondemand_profile.mpd
+++ b/mpd/fixtures/ondemand_profile.mpd
@@ -40,7 +40,7 @@
-
+
http://example.com/content/sintel/subtitles/subtitles_en.vtt
diff --git a/mpd/mpd.go b/mpd/mpd.go
index e491bd0..529964e 100644
--- a/mpd/mpd.go
+++ b/mpd/mpd.go
@@ -190,6 +190,7 @@ type AdaptationSet struct {
SegmentTemplate *SegmentTemplate `xml:"SegmentTemplate,omitempty"` // Live Profile Only
Representations []*Representation `xml:"Representation,omitempty"`
AccessibilityElems []*Accessibility `xml:"Accessibility,omitempty"`
+ Label *string `xml:"label,attr"`
}
func (as *AdaptationSet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
@@ -639,23 +640,27 @@ func (period *Period) AddNewAdaptationSetVideoWithID(id string, mimeType string,
// Create a new Adaptation Set for Subtitle Assets.
// mimeType - MIME Type (i.e. text/vtt).
// lang - Language (i.e. en).
-func (m *MPD) AddNewAdaptationSetSubtitle(mimeType string, lang string) (*AdaptationSet, error) {
- return m.period.AddNewAdaptationSetSubtitle(mimeType, lang)
+// label - Label for the subtitle from Studio (i.e. American)
+func (m *MPD) AddNewAdaptationSetSubtitle(mimeType string, lang string, label string) (*AdaptationSet, error) {
+ return m.period.AddNewAdaptationSetSubtitle(mimeType, lang, label)
}
// Create a new Adaptation Set for Subtitle Assets.
// mimeType - MIME Type (i.e. text/vtt).
// lang - Language (i.e. en).
-func (m *MPD) AddNewAdaptationSetSubtitleWithID(id string, mimeType string, lang string) (*AdaptationSet, error) {
- return m.period.AddNewAdaptationSetSubtitleWithID(id, mimeType, lang)
+// label - Label for the subtitle from Studio (i.e. American)
+func (m *MPD) AddNewAdaptationSetSubtitleWithID(id string, mimeType string, lang string, label string) (*AdaptationSet, error) {
+ return m.period.AddNewAdaptationSetSubtitleWithID(id, mimeType, lang, label)
}
// Create a new Adaptation Set for Subtitle Assets.
// mimeType - MIME Type (i.e. text/vtt).
// lang - Language (i.e. en).
-func (period *Period) AddNewAdaptationSetSubtitle(mimeType string, lang string) (*AdaptationSet, error) {
+// label - Label for the subtitle from Studio (i.e. American)
+func (period *Period) AddNewAdaptationSetSubtitle(mimeType string, lang string, label string) (*AdaptationSet, error) {
as := &AdaptationSet{
- Lang: Strptr(lang),
+ Lang: Strptr(lang),
+ Label: Strptr(label),
CommonAttributesAndElements: CommonAttributesAndElements{
MimeType: Strptr(mimeType),
},
@@ -670,10 +675,12 @@ func (period *Period) AddNewAdaptationSetSubtitle(mimeType string, lang string)
// Create a new Adaptation Set for Subtitle Assets.
// mimeType - MIME Type (i.e. text/vtt).
// lang - Language (i.e. en).
-func (period *Period) AddNewAdaptationSetSubtitleWithID(id string, mimeType string, lang string) (*AdaptationSet, error) {
+// label - Label for the subtitle from Studio (i.e. American)
+func (period *Period) AddNewAdaptationSetSubtitleWithID(id string, mimeType string, lang string, label string) (*AdaptationSet, error) {
as := &AdaptationSet{
- ID: Strptr(id),
- Lang: Strptr(lang),
+ ID: Strptr(id),
+ Lang: Strptr(lang),
+ Label: Strptr(label),
CommonAttributesAndElements: CommonAttributesAndElements{
MimeType: Strptr(mimeType),
},
diff --git a/mpd/mpd_read_write_test.go b/mpd/mpd_read_write_test.go
index e612151..d9c86c1 100644
--- a/mpd/mpd_read_write_test.go
+++ b/mpd/mpd_read_write_test.go
@@ -166,14 +166,14 @@ func TestAddNewAdaptationSetVideoWriteToString(t *testing.T) {
func TestAddNewAdaptationSetSubtitleWriteToString(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- _, _ = m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
+ _, _ = m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG, VALID_SUBTITLE_LABEL)
xmlStr, err := m.WriteToString()
require.NoError(t, err)
expectedXML := `
-
+
`
@@ -266,7 +266,7 @@ func LiveProfile() *MPD {
_, _ = videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576)
_, _ = videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720)
- subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
+ subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG, VALID_SUBTITLE_LABEL)
subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID)
_ = subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL)
@@ -334,7 +334,7 @@ func LiveProfileDynamic() *MPD {
_, _ = videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576)
_, _ = videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720)
- subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
+ subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG, VALID_SUBTITLE_LABEL)
subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID)
_ = subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL)
@@ -390,7 +390,7 @@ func HbbTVProfile() *MPD {
_, _ = videoAS.AddNewRepresentationVideo(2295158, "avc1.4d401f", "1200", "30000/1001", 1024, 576)
_, _ = videoAS.AddNewRepresentationVideo(2780732, "avc1.4d401f", "1500", "30000/1001", 1280, 720)
- subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
+ subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG, VALID_SUBTITLE_LABEL)
subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID)
_ = subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL)
@@ -443,7 +443,7 @@ func OnDemandProfile() *MPD {
_ = videoRep2.SetNewBaseURL("1200k/output-video-1.mp4")
_, _ = videoRep2.AddNewSegmentBase("686-813", "0-685")
- subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
+ subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG, VALID_SUBTITLE_LABEL)
subtitleRep, _ := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID)
_ = subtitleRep.SetNewBaseURL(VALID_SUBTITLE_URL)
diff --git a/mpd/mpd_test.go b/mpd/mpd_test.go
index 1bf7166..19ab6c1 100644
--- a/mpd/mpd_test.go
+++ b/mpd/mpd_test.go
@@ -43,6 +43,7 @@ const (
VALID_WV_HEADER string = "CAESEFq91S9VSk8quNBh92FCUVUaCGNhc3RsYWJzIhhXcjNWTDFWS1R5cTQwR0gzWVVKUlZRPT0yB2RlZmF1bHQ="
VALID_SUBTITLE_BANDWIDTH int64 = 256
VALID_SUBTITLE_ID string = "subtitle_en"
+ VALID_SUBTITLE_LABEL 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"
@@ -356,7 +357,7 @@ func TestAddRepresentationVideo(t *testing.T) {
func TestAddRepresentationSubtitle(t *testing.T) {
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
+ subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG, VALID_SUBTITLE_LABEL)
r, err := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID)
@@ -422,7 +423,7 @@ func TestAddNewBaseURLVideo(t *testing.T) {
func TestSetNewBaseURLSubtitle(t *testing.T) {
m := NewMPD(DASH_PROFILE_ONDEMAND, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
- subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG)
+ subtitleAS, _ := m.AddNewAdaptationSetSubtitleWithID("7357", DASH_MIME_TYPE_SUBTITLE_VTT, VALID_LANG, VALID_SUBTITLE_LABEL)
r, _ := subtitleAS.AddNewRepresentationSubtitle(VALID_SUBTITLE_BANDWIDTH, VALID_SUBTITLE_ID)