Skip to content

Commit

Permalink
fix: RepresentationBaseType first in AdaptationSet and Representation
Browse files Browse the repository at this point in the history
fix test
  • Loading branch information
tobbee committed Jan 4, 2024
1 parent 8f88a43 commit 0b01f75
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 59 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GetContentProtections, GetMimeType, GetCodecs, and GetSegmentTemplate methods for AdaptationSet and Representation
- ContentProtection elements and name spaces for Marlin DRM and DASH-IF ClearKey

### Fixed

- ContentProtection and other parts of RepresentationBaseType moved before other elements in AdaptationSet and Representation

## [0.10.0] - 2023-05-26

### Changed
Expand Down
111 changes: 56 additions & 55 deletions mpd/mpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,41 +241,41 @@ type UIntVWithIDType struct {
// AdaptationSetType is AdaptationSet or EmptyAdaptationSet.
// Note that XMLName is not set, since the same structure is used also for EmptyAdaptationSet.
type AdaptationSetType struct {
XlinkHref string `xml:"xlink:href,attr,omitempty"`
XlinkActuate string `xml:"xlink:actuate,attr,omitempty"` // default is "onRequest"
XlinkType string `xml:"xlink:type,attr,omitempty"` // fixed "simple"
XlinkShow string `xml:"xlink:show,attr,omitempty"` // fixed "embed"
Id *uint32 `xml:"id,attr"`
Group uint32 `xml:"group,attr,omitempty"`
Lang string `xml:"lang,attr,omitempty"`
ContentType RFC6838ContentTypeType `xml:"contentType,attr,omitempty"`
Par RatioType `xml:"par,attr,omitempty"`
MinBandwidth uint32 `xml:"minBandwidth,attr,omitempty"`
MaxBandwidth uint32 `xml:"maxBandwidth,attr,omitempty"`
MinWidth uint32 `xml:"minWidth,attr,omitempty"`
MaxWidth uint32 `xml:"maxWidth,attr,omitempty"`
MinHeight uint32 `xml:"minHeight,attr,omitempty"`
MaxHeight uint32 `xml:"maxHeight,attr,omitempty"`
MinFrameRate string `xml:"minFrameRate,attr,omitempty"`
MaxFrameRate string `xml:"maxFrameRate,attr,omitempty"`
SegmentAlignment bool `xml:"segmentAlignment,attr,omitempty"` // default = false
SubsegmentAlignment bool `xml:"subsegmentAlignment,attr,omitempty"` // default = false
SubsegmentStartsWithSAP uint32 `xml:"subsegmentStartsWithSAP,attr,omitempty"` // default = 0
BitstreamSwitching *bool `xml:"bitstreamSwitching,attr"`
InitializationSetRef *UIntVectorType `xml:"initializationSetRef,attr,omitempty"`
InitializationPrincipal AnyURI `xml:"initializationPrincipal,attr,omitempty"`
Accessibilities []*DescriptorType `xml:"Accessibility"`
Roles []*DescriptorType `xml:"Role"`
Ratings []*DescriptorType `xml:"Rating"`
Viewpoints []*DescriptorType `xml:"Viewpoint"`
ContentComponents []*ContentComponentType `xml:"ContentComponent"`
BaseURLs []*BaseURLType `xml:"BaseURL"`
SegmentBase *SegmentBaseType `xml:"SegmentBase"`
SegmentList *SegmentListType `xml:"SegmentList"`
SegmentTemplate *SegmentTemplateType `xml:"SegmentTemplate"`
Representations []*RepresentationType `xml:"Representation"`
parent *Period `xml:"-"`
XlinkHref string `xml:"xlink:href,attr,omitempty"`
XlinkActuate string `xml:"xlink:actuate,attr,omitempty"` // default is "onRequest"
XlinkType string `xml:"xlink:type,attr,omitempty"` // fixed "simple"
XlinkShow string `xml:"xlink:show,attr,omitempty"` // fixed "embed"
Id *uint32 `xml:"id,attr"`
Group uint32 `xml:"group,attr,omitempty"`
Lang string `xml:"lang,attr,omitempty"`
ContentType RFC6838ContentTypeType `xml:"contentType,attr,omitempty"`
Par RatioType `xml:"par,attr,omitempty"`
MinBandwidth uint32 `xml:"minBandwidth,attr,omitempty"`
MaxBandwidth uint32 `xml:"maxBandwidth,attr,omitempty"`
MinWidth uint32 `xml:"minWidth,attr,omitempty"`
MaxWidth uint32 `xml:"maxWidth,attr,omitempty"`
MinHeight uint32 `xml:"minHeight,attr,omitempty"`
MaxHeight uint32 `xml:"maxHeight,attr,omitempty"`
MinFrameRate string `xml:"minFrameRate,attr,omitempty"`
MaxFrameRate string `xml:"maxFrameRate,attr,omitempty"`
SegmentAlignment bool `xml:"segmentAlignment,attr,omitempty"` // default = false
SubsegmentAlignment bool `xml:"subsegmentAlignment,attr,omitempty"` // default = false
SubsegmentStartsWithSAP uint32 `xml:"subsegmentStartsWithSAP,attr,omitempty"` // default = 0
BitstreamSwitching *bool `xml:"bitstreamSwitching,attr"`
InitializationSetRef *UIntVectorType `xml:"initializationSetRef,attr,omitempty"`
InitializationPrincipal AnyURI `xml:"initializationPrincipal,attr,omitempty"`
RepresentationBaseType
Accessibilities []*DescriptorType `xml:"Accessibility"`
Roles []*DescriptorType `xml:"Role"`
Ratings []*DescriptorType `xml:"Rating"`
Viewpoints []*DescriptorType `xml:"Viewpoint"`
ContentComponents []*ContentComponentType `xml:"ContentComponent"`
BaseURLs []*BaseURLType `xml:"BaseURL"`
SegmentBase *SegmentBaseType `xml:"SegmentBase"`
SegmentList *SegmentListType `xml:"SegmentList"`
SegmentTemplate *SegmentTemplateType `xml:"SegmentTemplate"`
Representations []*RepresentationType `xml:"Representation"`
parent *Period `xml:"-"`
}

func (a *AdaptationSetType) SetParent(p *Period) {
Expand Down Expand Up @@ -329,22 +329,23 @@ type ContentComponentType struct {

// RepresentationType is Representation.
type RepresentationType struct {
XMLName xml.Name `xml:"Representation"`
Id string `xml:"id,attr"`
Bandwidth uint32 `xml:"bandwidth,attr"`
QualityRanking *uint32 `xml:"qualityRanking,attr,omitempty"`
DependencyId *StringVectorType `xml:"dependencyId,attr,omitempty"`
AssociationId *StringVectorType `xml:"associationId,attr,omitempty"`
AssociationType *ListOf4CCType `xml:"associationType,attr,omitempty"`
MediaStreamStructureId *StringVectorType `xml:"mediaStreamStructureId,attr,omitempty"`
BaseURLs []*BaseURLType `xml:"BaseURL"`
ExtendedBandwidths []*ExtendedBandwidthType `xml:"ExtendedBandwidth"`
SubRepresentations []*SubRepresentationType `xml:"SubRepresentation"`
SegmentBase *SegmentBaseType `xml:"SegmentBase"`
SegmentList *SegmentListType `xml:"SegmentList"`
SegmentTemplate *SegmentTemplateType `xml:"SegmentTemplate"`
parent *AdaptationSetType `xml:"-"` // adaptation set
XMLName xml.Name `xml:"Representation"`
Id string `xml:"id,attr"`
Bandwidth uint32 `xml:"bandwidth,attr"`
QualityRanking *uint32 `xml:"qualityRanking,attr,omitempty"`
DependencyId *StringVectorType `xml:"dependencyId,attr,omitempty"`
AssociationId *StringVectorType `xml:"associationId,attr,omitempty"`
AssociationType *ListOf4CCType `xml:"associationType,attr,omitempty"`
MediaStreamStructureId *StringVectorType `xml:"mediaStreamStructureId,attr,omitempty"`
RepresentationBaseType
BaseURLs []*BaseURLType `xml:"BaseURL"`
ExtendedBandwidths []*ExtendedBandwidthType `xml:"ExtendedBandwidth"`
SubRepresentations []*SubRepresentationType `xml:"SubRepresentation"`
SegmentBase *SegmentBaseType `xml:"SegmentBase"`
SegmentList *SegmentListType `xml:"SegmentList"`
SegmentTemplate *SegmentTemplateType `xml:"SegmentTemplate"`
parent *AdaptationSetType `xml:"-"` // adaptation set

}

func (r *RepresentationType) SetParent(p *AdaptationSetType) {
Expand Down Expand Up @@ -386,13 +387,13 @@ type ModelPairType struct {

// SubRepresentationType is SubRepresentation
type SubRepresentationType struct {
XMLName xml.Name `xml:"SubRepresentation"`
Level *uint32 `xml:"level,attr,omitempty"`
DependencyLevel *UIntVectorType `xml:"dependencyLevel,attr,omitempty"`
Bandwidth uint32 `xml:"bandwidth,attr,omitempty"`
ContentComponent *StringVectorType `xml:"contentComponent,attr,omitempty"`
parent *RepresentationType `xml:"-"`
XMLName xml.Name `xml:"SubRepresentation"`
Level *uint32 `xml:"level,attr,omitempty"`
DependencyLevel *UIntVectorType `xml:"dependencyLevel,attr,omitempty"`
Bandwidth uint32 `xml:"bandwidth,attr,omitempty"`
ContentComponent *StringVectorType `xml:"contentComponent,attr,omitempty"`
RepresentationBaseType
parent *RepresentationType `xml:"-"`
}

func (s *SubRepresentationType) SetParent(p *RepresentationType) {
Expand Down
14 changes: 10 additions & 4 deletions mpd/mpd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (
"github.com/stretchr/testify/require"
)

const (
printProcessMPDFile = "" // Used to see the output of the process even if there is no essential diff
)

func TestDecodeEncodeMPDs(t *testing.T) {
testDirs := []string{"testdata/go-dash-fixtures", "testdata/schema-mpds", "testdata/livesim"}
for _, testDir := range testDirs {
Expand All @@ -36,6 +40,10 @@ func TestDecodeEncodeMPDs(t *testing.T) {
inTree, err := xmltree.Parse(td)
require.NoError(t, err)
outTree, err := xmltree.Parse(out)
if fName == printProcessMPDFile {
err := os.WriteFile(fName, out, 0644)
require.NoError(t, err)
}
require.NoError(t, err)
if !xmltree.Equal(inTree, outTree) {
inBuf := bytes.Buffer{}
Expand All @@ -47,11 +55,9 @@ func TestDecodeEncodeMPDs(t *testing.T) {
d := cmp.Diff(inBuf.String(), outBuf.String())
// Note. There is no canonicalization and there may
// be comments in the input, so the diff is not minimal.
t.Errorf("non-minimal diff for mpd %s:\n%s\n", fName, d[:400])
ofh, err := os.Create(fName)
t.Errorf("non-minimal diff for mpd %s:\n%s. Writing file %s\n", fName, d[:400], fName)
err = os.WriteFile(fName, out, 0644)
require.NoError(t, err)
_, _ = ofh.Write(out)
ofh.Close()
}
}
}
Expand Down

0 comments on commit 0b01f75

Please sign in to comment.