hls.js 1.5.9-0.canary.10275 → 1.5.9-0.canary.10277

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -130,5 +130,5 @@
130
130
  "url-toolkit": "2.2.5",
131
131
  "wrangler": "3.57.1"
132
132
  },
133
- "version": "1.5.9-0.canary.10275"
133
+ "version": "1.5.9-0.canary.10277"
134
134
  }
@@ -38,7 +38,7 @@ export default class Decrypter {
38
38
  /* no-op */
39
39
  }
40
40
  }
41
- this.useSoftware = this.subtle === null;
41
+ this.useSoftware = !this.subtle;
42
42
  }
43
43
 
44
44
  destroy() {
@@ -155,20 +155,22 @@ export default class Decrypter {
155
155
  iv: ArrayBuffer,
156
156
  aesMode: DecrypterAesMode,
157
157
  ): Promise<ArrayBuffer> {
158
- const subtle = this.subtle;
159
158
  if (this.key !== key || !this.fastAesKey) {
159
+ if (!this.subtle) {
160
+ return Promise.resolve(this.onWebCryptoError(data, key, iv, aesMode));
161
+ }
160
162
  this.key = key;
161
- this.fastAesKey = new FastAESKey(subtle, key, aesMode);
163
+ this.fastAesKey = new FastAESKey(this.subtle, key, aesMode);
162
164
  }
163
165
  return this.fastAesKey
164
166
  .expandKey()
165
167
  .then((aesKey: CryptoKey) => {
166
168
  // decrypt using web crypto
167
- if (!subtle) {
169
+ if (!this.subtle) {
168
170
  return Promise.reject(new Error('web crypto not initialized'));
169
171
  }
170
172
  this.logOnce('WebCrypto AES decrypt');
171
- const crypto = new AESCrypto(subtle, new Uint8Array(iv), aesMode);
173
+ const crypto = new AESCrypto(this.subtle, new Uint8Array(iv), aesMode);
172
174
  return crypto.decrypt(data.buffer, aesKey);
173
175
  })
174
176
  .catch((err) => {
@@ -180,7 +182,12 @@ export default class Decrypter {
180
182
  });
181
183
  }
182
184
 
183
- private onWebCryptoError(data, key, iv, aesMode): ArrayBuffer | never {
185
+ private onWebCryptoError(
186
+ data: Uint8Array,
187
+ key: ArrayBuffer,
188
+ iv: ArrayBuffer,
189
+ aesMode: DecrypterAesMode,
190
+ ): ArrayBuffer | never {
184
191
  const enableSoftwareAES = this.enableSoftwareAES;
185
192
  if (enableSoftwareAES) {
186
193
  this.useSoftware = true;
@@ -1,11 +1,11 @@
1
1
  import { DecrypterAesMode } from './decrypter-aes-mode';
2
2
 
3
3
  export default class FastAESKey {
4
- private subtle: any;
4
+ private subtle: SubtleCrypto;
5
5
  private key: ArrayBuffer;
6
6
  private aesMode: DecrypterAesMode;
7
7
 
8
- constructor(subtle, key, aesMode: DecrypterAesMode) {
8
+ constructor(subtle: SubtleCrypto, key, aesMode: DecrypterAesMode) {
9
9
  this.subtle = subtle;
10
10
  this.key = key;
11
11
  this.aesMode = aesMode;
@@ -329,6 +329,7 @@ export default class TransmuxerInterface {
329
329
  type: ErrorTypes.MEDIA_ERROR,
330
330
  details: ErrorDetails.FRAG_PARSING_ERROR,
331
331
  chunkMeta,
332
+ frag: this.frag || undefined,
332
333
  fatal: false,
333
334
  error,
334
335
  err: error,
@@ -897,8 +897,7 @@ function parsePMT(
897
897
  case 0xc2: // SAMPLE-AES EC3
898
898
  /* falls through */
899
899
  case 0x87:
900
- logger.warn('Unsupported EC-3 in M2TS found');
901
- break;
900
+ throw new Error('Unsupported EC-3 in M2TS found');
902
901
 
903
902
  case 0x24: // ITU-T Rec. H.265 and ISO/IEC 23008-2 (HEVC)
904
903
  if (__USE_M2TS_ADVANCED_CODECS__) {
@@ -908,7 +907,7 @@ function parsePMT(
908
907
  logger.log('HEVC in M2TS found');
909
908
  }
910
909
  } else {
911
- logger.warn('Unsupported HEVC in M2TS found');
910
+ throw new Error('Unsupported HEVC in M2TS found');
912
911
  }
913
912
  break;
914
913