@@ -123,39 +123,46 @@ function CapabilitiesFilter() {
123123 if ( ! as . Representation || as . Representation . length === 0 ) {
124124 return ;
125125 }
126- const configurations = [ ] ;
127126
128127 as . Representation = as . Representation . filter ( ( rep , i ) => {
129128 const codec = adapter . getCodec ( as , i , false ) ;
130- const config = _createConfiguration ( type , rep , codec ) ;
131- configurations . push ( config ) ;
132- const isCodecSupported = capabilities . isCodecSupportedBasedOnTestedConfigurations ( config , type ) ;
129+ const isMainCodecSupported = _isCodecSupported ( type , rep , codec ) ;
133130
134- let isSupplementalCodecSupported = false ;
135- const supplementalCodecs = adapter . getSupplementalCodecs ( rep ) ;
136- if ( supplementalCodecs . length > 0 ) {
137- if ( supplementalCodecs . length > 1 ) {
138- logger . warn ( `[CapabilitiesFilter] Multiple supplemental codecs not supported; using first in list` ) ;
139- }
140- const supplementalCodec = supplementalCodecs [ 0 ] ;
141- const supplementalCodecConfig = _createConfiguration ( type , rep , supplementalCodec ) ;
142- configurations . push ( supplementalCodecConfig ) ;
143- isSupplementalCodecSupported = capabilities . isCodecSupportedBasedOnTestedConfigurations ( supplementalCodecConfig , type ) ;
144- if ( isSupplementalCodecSupported ) {
145- logger . debug ( `[CapabilitiesFilter] Codec ${ supplementalCodec } supported. Upgrading Representation with ID ${ rep . id } ` ) ;
146- // overriding default codec
147- rep . codecs = rep [ DashConstants . SUPPLEMENTAL_CODECS ]
148- }
131+ let isSupplementalCodecSupported = _isSupplementalCodecSupported ( rep , type ) ;
132+ if ( isSupplementalCodecSupported ) {
133+ logger . debug ( `[CapabilitiesFilter] Codec supported. Upgrading codecs string of Representation with ID ${ rep . id } ` ) ;
134+ rep . codecs = rep [ DashConstants . SUPPLEMENTAL_CODECS ]
149135 }
150136
151- if ( ! isCodecSupported && ! isSupplementalCodecSupported ) {
152- logger . debug ( `[CapabilitiesFilter] Codec ${ codec } not supported. Removing Representation with ID ${ rep . id } ` ) ;
137+ if ( ! isMainCodecSupported && ! isSupplementalCodecSupported ) {
138+ logger . warn ( `[CapabilitiesFilter] Codec ${ codec } not supported. Removing Representation with ID ${ rep . id } ` ) ;
153139 }
154140
155- return isCodecSupported || isSupplementalCodecSupported ;
141+ return isMainCodecSupported || isSupplementalCodecSupported ;
156142 } ) ;
157143 }
158144
145+ function _isSupplementalCodecSupported ( rep , type ) {
146+ let isSupplementalCodecSupported = false ;
147+ const supplementalCodecs = adapter . getSupplementalCodecs ( rep ) ;
148+
149+ if ( supplementalCodecs . length > 0 ) {
150+ if ( supplementalCodecs . length > 1 ) {
151+ logger . warn ( `[CapabilitiesFilter] Multiple supplemental codecs not supported; using the first in list` ) ;
152+ }
153+ const supplementalCodec = supplementalCodecs [ 0 ] ;
154+ isSupplementalCodecSupported = _isCodecSupported ( type , rep , supplementalCodec ) ;
155+ }
156+
157+ return isSupplementalCodecSupported
158+ }
159+
160+ function _isCodecSupported ( type , rep , codec ) {
161+ const config = _createConfiguration ( type , rep , codec ) ;
162+
163+ return capabilities . isCodecSupportedBasedOnTestedConfigurations ( config , type ) ;
164+ }
165+
159166 function _getConfigurationsToCheck ( manifest , type ) {
160167 if ( ! manifest || ! manifest . Period || manifest . Period . length === 0 ) {
161168 return [ ] ;
@@ -169,22 +176,11 @@ function CapabilitiesFilter() {
169176 if ( adapter . getIsTypeOf ( as , type ) ) {
170177 as . Representation . forEach ( ( rep , i ) => {
171178 const codec = adapter . getCodec ( as , i , false ) ;
172- const config = _createConfiguration ( type , rep , codec ) ;
173- const configString = JSON . stringify ( config ) ;
174-
175- if ( ! configurationsSet . has ( configString ) ) {
176- configurationsSet . add ( configString ) ;
177- configurations . push ( config ) ;
178- }
179+ _processCodecToCheck ( type , rep , codec , configurationsSet , configurations ) ;
179180
180181 const supplementalCodecs = adapter . getSupplementalCodecs ( rep )
181182 if ( supplementalCodecs . length > 0 ) {
182- const config = _createConfiguration ( type , rep , supplementalCodecs [ 0 ] ) ;
183- const configString = JSON . stringify ( config ) ;
184- if ( ! configurationsSet . has ( configString ) ) {
185- configurationsSet . add ( configString ) ;
186- configurations . push ( config ) ;
187- }
183+ _processCodecToCheck ( type , rep , supplementalCodecs [ 0 ] , configurationsSet , configurations ) ;
188184 }
189185 } ) ;
190186 }
@@ -194,6 +190,15 @@ function CapabilitiesFilter() {
194190 return configurations ;
195191 }
196192
193+ function _processCodecToCheck ( type , rep , codec , configurationsSet , configurations ) {
194+ const config = _createConfiguration ( type , rep , codec ) ;
195+ const configString = JSON . stringify ( config ) ;
196+
197+ if ( ! configurationsSet . has ( configString ) ) {
198+ configurationsSet . add ( configString ) ;
199+ configurations . push ( config ) ;
200+ }
201+ }
197202
198203 function _createConfiguration ( type , rep , codec ) {
199204 let config = null ;
0 commit comments