@@ -108,73 +108,15 @@ shaka.util.StreamUtils = class {
108108 // Now we have filtered variants and text tracks down by user preferences
109109 // for formats, codecs, and decoding attributes (smooth, efficient, etc).
110110
111- const audioStreamsSet = new Set ( ) ;
112111 const videoStreamsSet = new Set ( ) ;
113112 for ( const variant of variants ) {
114- if ( variant . audio ) {
115- audioStreamsSet . add ( variant . audio ) ;
116- }
117113 if ( variant . video ) {
118114 videoStreamsSet . add ( variant . video ) ;
119115 }
120116 }
121117
122- // Audio streams sorted by bandwidth, lowest to highest.
123- const audioStreams = Array . from ( audioStreamsSet ) . sort ( ( v1 , v2 ) => {
124- return v1 . bandwidth - v2 . bandwidth ;
125- } ) ;
126-
127- // Maps that are used to choose codecs when there are no preferences in
128- // effect above.
129- const validAudioIds = [ ] ;
130- const validAudioStreamsMap = new Map ( ) ;
131-
132- // A group ID composed of attributes like language, channels, role, etc to
133- // find redundant audio streams that only differ in terms of things like
134- // codec, format, and bitrate.
135- const getAudioGroupId = ( stream ) => {
136- const idParts = [
137- stream . language ,
138- ( stream . channelsCount || 0 ) ,
139- ( stream . audioSamplingRate || 0 ) ,
140- stream . roles . join ( ',' ) ,
141- stream . label ,
142- stream . groupId ,
143- stream . fastSwitching ,
144- ] ;
145- if ( stream . dependencyStream ) {
146- idParts . push ( stream . dependencyStream . baseOriginalId || '' ) ;
147- }
148- return idParts . join ( ';' ) ;
149- } ;
150-
151- // For the first audio stream in a group (lowest bandwidth by sorting
152- // above), add it to the map. For subsequent audio streams in a group,
153- // only add it to the map if the codec matches. This could make a bad
154- // decision if not every audio codec is used on every quality level in the
155- // audio ladder. In scenarios like this, use preferredAudioCodecs. If
156- // preferredAudioCodecs is used, there should only be one codec left when
157- // we get to this stage.
158- for ( const stream of audioStreams ) {
159- const groupId = getAudioGroupId ( stream ) ;
160- const validAudioStreams = validAudioStreamsMap . get ( groupId ) || [ ] ;
161-
162- if ( ! validAudioStreams . length ) {
163- validAudioStreams . push ( stream ) ;
164- validAudioIds . push ( stream . id ) ;
165- } else {
166- const previousStream = validAudioStreams [ validAudioStreams . length - 1 ] ;
167- const previousCodec =
168- MimeUtils . getNormalizedCodec ( previousStream . codecs ) ;
169- const currentCodec =
170- MimeUtils . getNormalizedCodec ( stream . codecs ) ;
171- if ( previousCodec == currentCodec ) {
172- validAudioStreams . push ( stream ) ;
173- validAudioIds . push ( stream . id ) ;
174- }
175- }
176-
177- validAudioStreamsMap . set ( groupId , validAudioStreams ) ;
118+ if ( ! videoStreamsSet . size ) {
119+ return ;
178120 }
179121
180122 // Keys based in MimeUtils.getNormalizedCodec. Lower is better
@@ -271,14 +213,7 @@ shaka.util.StreamUtils = class {
271213 // from a single video codec and a single audio codec **per stream group**
272214 // (resolution, etc).
273215 manifest . variants = manifest . variants . filter ( ( variant ) => {
274- const audio = variant . audio ;
275216 const video = variant . video ;
276- if ( audio ) {
277- if ( ! validAudioIds . includes ( audio . id ) ) {
278- shaka . log . debug ( 'Dropping Variant (better codec available)' , variant ) ;
279- return false ;
280- }
281- }
282217 if ( video ) {
283218 if ( ! validVideoIds . includes ( video . id ) ) {
284219 shaka . log . debug ( 'Dropping Variant (better codec available)' , variant ) ;
0 commit comments