@@ -91,9 +91,17 @@ shaka.media.ManifestFilterer = class {
91
91
this . drmEngine_ ? this . drmEngine_ . getDrmInfo ( ) : null ;
92
92
// DrmEngine.newInitData() requires mediaKeys to be available.
93
93
if ( currentDrmInfo && this . drmEngine_ . getMediaKeys ( ) ) {
94
+ const streams = new Set ( ) ;
94
95
for ( const variant of manifest . variants ) {
95
- this . processDrmInfos ( currentDrmInfo . keySystem , variant . video ) ;
96
- this . processDrmInfos ( currentDrmInfo . keySystem , variant . audio ) ;
96
+ if ( variant . audio ) {
97
+ streams . add ( variant . audio ) ;
98
+ }
99
+ if ( variant . video ) {
100
+ streams . add ( variant . video ) ;
101
+ }
102
+ }
103
+ for ( const stream of streams ) {
104
+ this . processDrmInfos ( currentDrmInfo . keySystem , stream ) ;
97
105
}
98
106
}
99
107
this . checkRestrictedVariants ( manifest ) ;
@@ -122,13 +130,9 @@ shaka.media.ManifestFilterer = class {
122
130
123
131
/**
124
132
* @param {string } keySystem
125
- * @param {? shaka.extern.Stream } stream
133
+ * @param {! shaka.extern.Stream } stream
126
134
*/
127
135
processDrmInfos ( keySystem , stream ) {
128
- if ( ! stream ) {
129
- return ;
130
- }
131
-
132
136
for ( const drmInfo of stream . drmInfos ) {
133
137
// Ignore any data for different key systems.
134
138
if ( drmInfo . keySystem == keySystem ) {
@@ -162,27 +166,15 @@ shaka.media.ManifestFilterer = class {
162
166
/** @type {!Set<string> } */
163
167
const badKeyStatuses = new Set ( ) ;
164
168
169
+ const streams = new Set ( ) ;
170
+
165
171
for ( const variant of manifest . variants ) {
166
172
// TODO: Combine with onKeyStatus_.
167
- const streams = [ ] ;
168
173
if ( variant . audio ) {
169
- streams . push ( variant . audio ) ;
174
+ streams . add ( variant . audio ) ;
170
175
}
171
176
if ( variant . video ) {
172
- streams . push ( variant . video ) ;
173
- }
174
-
175
- for ( const stream of streams ) {
176
- if ( stream . keyIds . size ) {
177
- for ( const keyId of stream . keyIds ) {
178
- const keyStatus = keyStatusMap [ isGlobalStatus ? '00' : keyId ] ;
179
- if ( ! keyStatus ) {
180
- missingKeys . add ( keyId ) ;
181
- } else if ( restrictedStatuses . includes ( keyStatus ) ) {
182
- badKeyStatuses . add ( keyStatus ) ;
183
- }
184
- }
185
- } // if (stream.keyIds.size)
177
+ streams . add ( variant . video ) ;
186
178
}
187
179
188
180
if ( ! variant . allowedByApplication ) {
@@ -192,6 +184,19 @@ shaka.media.ManifestFilterer = class {
192
184
}
193
185
}
194
186
187
+ for ( const stream of streams ) {
188
+ if ( stream . keyIds . size ) {
189
+ for ( const keyId of stream . keyIds ) {
190
+ const keyStatus = keyStatusMap [ isGlobalStatus ? '00' : keyId ] ;
191
+ if ( ! keyStatus ) {
192
+ missingKeys . add ( keyId ) ;
193
+ } else if ( restrictedStatuses . includes ( keyStatus ) ) {
194
+ badKeyStatuses . add ( keyStatus ) ;
195
+ }
196
+ }
197
+ } // if (stream.keyIds.size)
198
+ }
199
+
195
200
if ( ! hasPlayable ) {
196
201
/** @type {shaka.extern.RestrictionInfo } */
197
202
const data = {
0 commit comments