7272
7373type MPD struct {
7474 XMLNs * string `xml:"xmlns,attr"`
75- XMLNsDolby * string `xml:"xmlns:dolby,attr"`
75+ XMLNsDolby * XmlnsAttr `xml:"dolby,attr"`
76+ XMLNsSCTE214 * XmlnsAttr `xml:"scte214,attr"`
7677 Scte35NS * Scte35NS `xml:"scte35,attr,omitempty"`
7778 XsiNS * XmlnsAttr `xml:"xsi,attr,omitempty"`
7879 XsiSchemaLocation * XsiSL `xml:"schemaLocation,attr,omitempty"`
@@ -108,9 +109,27 @@ func (s *XmlnsAttr) UnmarshalXMLAttr(attr xml.Attr) error {
108109}
109110
110111func (s * XmlnsAttr ) MarshalXMLAttr (name xml.Name ) (xml.Attr , error ) {
112+ if s == nil {
113+ return xml.Attr {}, nil
114+ }
111115 return xml.Attr {Name : xml.Name {Local : fmt .Sprintf ("xmlns:%s" , s .XmlName .Local )}, Value : s .Value }, nil
112116}
113117
118+ type Scte214Attr struct {
119+ XmlName xml.Name
120+ Value string
121+ }
122+
123+ func (s * Scte214Attr ) UnmarshalXMLAttr (attr xml.Attr ) error {
124+ s .XmlName = attr .Name
125+ s .Value = attr .Value
126+ return nil
127+ }
128+
129+ func (s * Scte214Attr ) MarshalXMLAttr (name xml.Name ) (xml.Attr , error ) {
130+ return xml.Attr {Name : xml.Name {Local : fmt .Sprintf ("scte214:%s" , s .XmlName .Local )}, Value : s .Value }, nil
131+ }
132+
114133type XsiSL struct {
115134 XmlName xml.Name
116135 Value string
@@ -246,9 +265,17 @@ func (as *AdaptationSet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er
246265 return err
247266 }
248267 * as = AdaptationSet (n .wrappedAdaptationSet )
268+
269+ if as .Roles != nil {
270+ as .Roles = n .Roles
271+ }
272+
249273 as .ContentProtection = make ([]ContentProtectioner , len (n .ContentProtection ))
250- for i := range n .ContentProtection {
251- as .ContentProtection [i ] = n .ContentProtection [i ]
274+ copy (as .ContentProtection , n .ContentProtection )
275+
276+ for i := range as .Representations {
277+ as .Representations [i ].SupplementalCodecs = n .Representations [i ].SupplementalCodecs
278+ as .Representations [i ].SupplementalProfiles = n .Representations [i ].SupplementalProfiles
252279 }
253280 return nil
254281}
@@ -434,15 +461,17 @@ type Representation struct {
434461 CommonAttributesAndElements
435462 AdaptationSet * AdaptationSet `xml:"-"`
436463 AudioChannelConfiguration * AudioChannelConfiguration `xml:"AudioChannelConfiguration,omitempty"`
437- AudioSamplingRate * int64 `xml:"audioSamplingRate,attr"` // Audio
438- Bandwidth * int64 `xml:"bandwidth,attr"` // Audio + Video
439- Codecs * string `xml:"codecs,attr"` // Audio + Video
440- FrameRate * string `xml:"frameRate,attr,omitempty"` // Video
441- Height * int64 `xml:"height,attr"` // Video
442- ID * string `xml:"id,attr"` // Audio + Video
443- Width * int64 `xml:"width,attr"` // Video
444- BaseURL []string `xml:"BaseURL,omitempty"` // On-Demand Profile
445- SegmentBase * SegmentBase `xml:"SegmentBase,omitempty"` // On-Demand Profile
464+ AudioSamplingRate * int64 `xml:"audioSamplingRate,attr"` // Audio
465+ Bandwidth * int64 `xml:"bandwidth,attr"` // Audio + Video
466+ Codecs * string `xml:"codecs,attr"` // Audio + Video
467+ SupplementalCodecs * Scte214Attr `xml:"supplementalCodecs,attr,omitempty"` // Video
468+ SupplementalProfiles * Scte214Attr `xml:"supplementalProfiles,attr,omitempty"` // Video
469+ FrameRate * string `xml:"frameRate,attr,omitempty"` // Video
470+ Height * int64 `xml:"height,attr"` // Video
471+ ID * string `xml:"id,attr"` // Audio + Video
472+ Width * int64 `xml:"width,attr"` // Video
473+ BaseURL []string `xml:"BaseURL,omitempty"` // On-Demand Profile
474+ SegmentBase * SegmentBase `xml:"SegmentBase,omitempty"` // On-Demand Profile
446475 SegmentList * SegmentList `xml:"SegmentList,omitempty"`
447476 SegmentTemplate * SegmentTemplate `xml:"SegmentTemplate,omitempty"`
448477}
@@ -460,7 +489,17 @@ type AudioChannelConfiguration struct {
460489}
461490
462491func (m * MPD ) SetDolbyXMLNs () {
463- m .XMLNsDolby = Strptr ("http://www.dolby.com/ns/online/DASH" )
492+ m .XMLNsDolby = & XmlnsAttr {
493+ XmlName : xml.Name {Space : "xmlns" , Local : "dolby" },
494+ Value : "http://www.dolby.com/ns/online/DASH" ,
495+ }
496+ }
497+
498+ func (m * MPD ) SetScte214XMLNs () {
499+ m .XMLNsSCTE214 = & XmlnsAttr {
500+ XmlName : xml.Name {Space : "xmlns" , Local : "scte214" },
501+ Value : "urn:scte:dash:scte214-extensions" ,
502+ }
464503}
465504
466505// Creates a new static MPD object.
@@ -1114,6 +1153,30 @@ func (as *AdaptationSet) AddNewRepresentationVideo(bandwidth int64, codecs strin
11141153 return r , nil
11151154}
11161155
1156+ // Adds supplementalCodecs and supplementalProfiles to a Representation
1157+ // supplementalCodecs - scte214:supplementalCodecs attribute for Dovi 8.1 signaling (optional).
1158+ // supplementalProfiles - scte214:supplementalProfiles attribute for Dovi 8.1 signaling (optional).
1159+ func (r * Representation ) AddScte214VideoCodecProperties (supplementalCodecs string , supplementalProfiles string ) (* Representation , error ) {
1160+ // For Dovi 8.1 signaling both supplementalCodecs and supplementalProfiles should be added
1161+ if len (supplementalCodecs ) > 0 && len (supplementalProfiles ) > 0 {
1162+ r .SupplementalCodecs = & Scte214Attr {
1163+ XmlName : xml.Name {
1164+ Space : "scte214" ,
1165+ Local : "supplementalCodecs" ,
1166+ },
1167+ Value : supplementalCodecs ,
1168+ }
1169+ r .SupplementalProfiles = & Scte214Attr {
1170+ XmlName : xml.Name {
1171+ Space : "scte214" ,
1172+ Local : "supplementalProfiles" ,
1173+ },
1174+ Value : supplementalProfiles ,
1175+ }
1176+ }
1177+ return r , nil
1178+ }
1179+
11171180// Adds a new Subtitle representation to an AdaptationSet.
11181181// bandwidth - in Bits/s (i.e. 256).
11191182// id - ID for this representation, will get used as $RepresentationID$ in template strings.
0 commit comments