From 24b7039a4b426cdfa91691e16318b2a1b266db30 Mon Sep 17 00:00:00 2001 From: Jack Dunham Date: Wed, 6 May 2026 09:12:36 -0700 Subject: [PATCH 1/2] [MT-4732]: fix(mpd): emit ContentSteering as last child of MPD per ISO/IEC 23009-1 Amd 1 DASH-MPD.xsd requires ContentSteering to be the final child of the MPD element, after Period, Metrics, EssentialProperty, SupplementalProperty, UTCTiming, and LeapSecondInformation. Strict XSD validators reject manifests that emit it earlier (lenient players such as dash.js and Shaka tolerate it, masking the bug). Move the ContentSteering struct field to follow UTCTiming so encoded output matches the schema. Add a regression test asserting that the encoded byte offset of and ") + utcIdx := strings.Index(out, " periodCloseIdx) { + t.Fatalf("ContentSteering must come after : %s", out) + } + if !(csIdx > utcIdx) { + t.Fatalf("ContentSteering must come after UTCTiming: %s", out) + } +} + func TestReadFromStringWithOptionsAppliesSteeringOptionsForWrite(t *testing.T) { xml := ` diff --git a/mpd/mpd.go b/mpd/mpd.go index 2c7fc8c..94fa835 100644 --- a/mpd/mpd.go +++ b/mpd/mpd.go @@ -88,14 +88,14 @@ type MPD struct { PublishTime *string `xml:"publishTime,attr"` TimeShiftBufferDepth *string `xml:"timeShiftBufferDepth,attr"` SuggestedPresentationDelay *Duration `xml:"suggestedPresentationDelay,attr,omitempty"` - BaseURL []BaseURLValue `xml:"BaseURL,omitempty"` - ContentSteering *ContentSteering `xml:"ContentSteering,omitempty"` + BaseURL []BaseURLValue `xml:"BaseURL,omitempty"` Location string `xml:"Location,omitempty"` period *Period - Periods []*Period `xml:"Period,omitempty"` - UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"` - ID string `xml:"id,attr,omitempty"` - Comment string `xml:"-"` + Periods []*Period `xml:"Period,omitempty"` + UTCTiming *DescriptorType `xml:"UTCTiming,omitempty"` + ContentSteering *ContentSteering `xml:"ContentSteering,omitempty"` + ID string `xml:"id,attr,omitempty"` + Comment string `xml:"-"` } type XmlnsAttr struct { From 0b3306ae5f05820c3e3698767aa25d362c8f9394 Mon Sep 17 00:00:00 2001 From: Jack Dunham Date: Wed, 6 May 2026 10:16:18 -0700 Subject: [PATCH 2/2] [MT-4732]: comment regarding behaviro of encoding/xml package --- mpd/mpd.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mpd/mpd.go b/mpd/mpd.go index 94fa835..bb95c5e 100644 --- a/mpd/mpd.go +++ b/mpd/mpd.go @@ -70,6 +70,9 @@ var ( ErrInbandEventStreamSchemeUriEmpty = errors.New("Inband Event Stream schemeIdUri Empty") ) +// MPD is marshaled with encoding/xml (e.g. xml.Encoder.Encode). The marshaller reflects +// on the concrete type and walks exported fields in struct source order, so reordering +// fields changes emitted XML (attributes and child element sequence). type MPD struct { XMLNs *string `xml:"xmlns,attr"` XMLNsDolby *XmlnsAttr `xml:"dolby,attr"`