Skip to content

Commit acfe4eb

Browse files
author
Andrew Sinclair
committed
First stage adding additional parameters to match spec
1 parent dde1f05 commit acfe4eb

File tree

2 files changed

+80
-4
lines changed

2 files changed

+80
-4
lines changed

mpd/mpd.go

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,50 @@ type Period struct {
8181
AdaptationSets []*AdaptationSet `xml:"AdaptationSet,omitempty"`
8282
}
8383

84+
type DescriptorType struct {
85+
SchemeIDURI *string `xml:"schemeIDURI,attr"`
86+
Value *string `xml:"value,attr"`
87+
ID *string `xml:"id,attr"`
88+
}
89+
90+
// ISO 23009-1-2014 5.3.7
91+
type CommonAttributesAndElements struct {
92+
Profiles *string `xml:"profiles,attr"`
93+
Width *string `xml:"width,attr"`
94+
Height *string `xml:"height,attr"`
95+
Sar *string `xml:"sar,attr"`
96+
FrameRate *string `xml:"frameRate,attr"`
97+
AudioSamplingRate *string `xml:"audioSamplingRate,attr"`
98+
MimeType *string `xml:"mimeType,attr"`
99+
SegmentProfiles *string `xml:"segmentProfiles,attr"`
100+
Codecs *string `xml:"codecs,attr"`
101+
MaximumSAPPeriod *string `xml:"MaximumSAPPeriod,attr"`
102+
StartWithSAP *string `xml:"startWithSAP,attr"`
103+
MaxPlayoutRate *string `xml:"maxPlayoutRate,attr"`
104+
ScanType *string `xml:"scanType,attr"`
105+
FramePacking *DescriptorType `xml:"framePacking,attr"`
106+
AudioChannelConfiguration *DescriptorType `xml:"audioChannelConfiguration,attr"`
107+
ContentProtection *DescriptorType `xml:"contentProtection,attr"`
108+
EssentialProperty *DescriptorType `xml:"essentialProperty,attr"`
109+
SupplementalProperty *DescriptorType `xml:"supplmentalProperty,attr"`
110+
InbandEventStream *DescriptorType `xml:"inbandEventStream,attr"`
111+
}
112+
84113
type AdaptationSet struct {
85-
MimeType *string `xml:"mimeType,attr"`
86-
ScanType *string `xml:"scanType,attr"`
114+
CommonAttributesAndElements
115+
MimeType *string `xml:"mimeType,attr"` // Common attribute, can be deprecated here
116+
ScanType *string `xml:"scanType,attr"` // Common attribute, can be deprecated here
87117
SegmentAlignment *bool `xml:"segmentAlignment,attr"`
88-
StartWithSAP *int64 `xml:"startWithSAP,attr"`
118+
StartWithSAP *int64 `xml:"startWithSAP,attr"` // Common attribute, can be deprecated here
89119
Lang *string `xml:"lang,attr"`
90-
ContentProtection []ContentProtectioner `xml:"ContentProtection,omitempty"`
120+
ID *string `xml:"id,attr"`
121+
Group *string `xml:"group,attr"`
122+
PAR *string `xml:"par,attr"`
123+
MinBandwidth *string `xml:"minBandwidth,attr"`
124+
MaxBandwidth *string `xml:"maxBandwidth,attr"`
125+
MinWidth *string `xml:"minWidth,attr"`
126+
MaxWidth *string `xml:"maxWidth,attr"`
127+
ContentProtection []ContentProtectioner `xml:"ContentProtection,omitempty"` // Common attribute, can be deprecated here
91128
Roles []*Role `xml:"Role,omitempty"`
92129
SegmentBase *SegmentBase `xml:"SegmentBase,omitempty"`
93130
SegmentList *SegmentList `xml:"SegmentList,omitempty"`
@@ -159,6 +196,7 @@ type SegmentTemplate struct {
159196
}
160197

161198
type Representation struct {
199+
CommonAttributesAndElements
162200
AdaptationSet *AdaptationSet `xml:"-"`
163201
AudioChannelConfiguration *AudioChannelConfiguration `xml:"AudioChannelConfiguration,omitempty"`
164202
AudioSamplingRate *int64 `xml:"audioSamplingRate,attr"` // Audio

mpd/mpd_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,44 @@ func (s *MPDSuite) TestAddNewAdaptationSetAudio() {
184184
assert.Equal(s.T(), expectedAS, as)
185185
}
186186

187+
func (s *MPDSuite) TestAddNewAdaptationSetAudioSetAdditionalAttributes() {
188+
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
189+
as, err := m.AddNewAdaptationSetAudio(DASH_MIME_TYPE_AUDIO_MP4, VALID_SEGMENT_ALIGNMENT, VALID_START_WITH_SAP, VALID_LANG)
190+
assert.NotNil(s.T(), as)
191+
assert.Nil(s.T(), err)
192+
as.ID = Strptr("1")
193+
as.CommonAttributesAndElements.Codecs = Strptr(VALID_AUDIO_CODEC)
194+
expectedAS := &AdaptationSet{
195+
MimeType: Strptr(VALID_MIME_TYPE_AUDIO),
196+
SegmentAlignment: Boolptr(VALID_SEGMENT_ALIGNMENT),
197+
StartWithSAP: Int64ptr(VALID_START_WITH_SAP),
198+
Lang: Strptr(VALID_LANG),
199+
ID: Strptr("1"),
200+
CommonAttributesAndElements: CommonAttributesAndElements{
201+
Profiles: nil,
202+
Width: nil,
203+
Height: nil,
204+
Sar: nil,
205+
FrameRate: nil,
206+
AudioSamplingRate: nil,
207+
MimeType: nil,
208+
SegmentProfiles: nil,
209+
Codecs: Strptr(VALID_AUDIO_CODEC),
210+
MaximumSAPPeriod: nil,
211+
StartWithSAP: nil,
212+
MaxPlayoutRate: nil,
213+
ScanType: nil,
214+
FramePacking: nil,
215+
AudioChannelConfiguration: nil,
216+
ContentProtection: nil,
217+
EssentialProperty: nil,
218+
SupplementalProperty: nil,
219+
InbandEventStream: nil,
220+
},
221+
}
222+
assert.Equal(s.T(), expectedAS, as)
223+
}
224+
187225
func (s *MPDSuite) TestAddNewAdaptationSetVideo() {
188226
m := NewMPD(DASH_PROFILE_LIVE, VALID_MEDIA_PRESENTATION_DURATION, VALID_MIN_BUFFER_TIME)
189227

0 commit comments

Comments
 (0)