hls.js 1.6.0-beta.4.0.canary.11049 → 1.6.0-beta.4.0.canary.11054
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/dist/hls.d.mts +10 -10
- package/dist/hls.d.ts +10 -10
- package/dist/hls.js +13 -26
- package/dist/hls.js.d.ts +10 -10
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +11 -23
- package/dist/hls.light.js.map +1 -1
- package/dist/hls.light.min.js +1 -1
- package/dist/hls.light.min.js.map +1 -1
- package/dist/hls.light.mjs +9 -19
- package/dist/hls.light.mjs.map +1 -1
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +11 -22
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/dist/hls.worker.js.map +1 -1
- package/package.json +2 -2
- package/src/controller/base-stream-controller.ts +0 -2
- package/src/controller/eme-controller.ts +4 -4
- package/src/crypt/aes-decryptor.ts +7 -5
- package/src/crypt/decrypter.ts +6 -7
- package/src/demux/audio/base-audio-demuxer.ts +1 -2
- package/src/demux/sample-aes.ts +10 -15
- package/src/demux/transmuxer.ts +1 -1
- package/src/demux/tsdemuxer.ts +13 -9
- package/src/loader/level-key.ts +10 -10
- package/src/types/demuxer.ts +11 -2
- package/src/utils/chunker.ts +2 -3
- package/src/utils/mediakeys-helper.ts +1 -1
- package/src/utils/mp4-tools.ts +3 -8
- package/src/utils/numeric-encoding-utils.ts +1 -3
- package/src/utils/vttparser.ts +0 -1
- package/src/utils/typed-array.ts +0 -11
package/package.json
CHANGED
@@ -83,7 +83,7 @@
|
|
83
83
|
"@rollup/plugin-replace": "5.0.7",
|
84
84
|
"@rollup/plugin-terser": "0.4.4",
|
85
85
|
"@rollup/plugin-typescript": "12.1.2",
|
86
|
-
"@svta/common-media-library": "0.
|
86
|
+
"@svta/common-media-library": "0.10.0",
|
87
87
|
"@types/chai": "4.3.20",
|
88
88
|
"@types/chart.js": "2.9.41",
|
89
89
|
"@types/mocha": "10.0.10",
|
@@ -134,5 +134,5 @@
|
|
134
134
|
"url-toolkit": "2.2.5",
|
135
135
|
"wrangler": "3.114.1"
|
136
136
|
},
|
137
|
-
"version": "1.6.0-beta.4.0.canary.
|
137
|
+
"version": "1.6.0-beta.4.0.canary.11054"
|
138
138
|
}
|
@@ -157,7 +157,6 @@ export default class BaseStreamController
|
|
157
157
|
|
158
158
|
protected onTickEnd() {}
|
159
159
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
161
160
|
public startLoad(startPosition: number): void {}
|
162
161
|
|
163
162
|
public stopLoad() {
|
@@ -746,7 +745,6 @@ export default class BaseStreamController
|
|
746
745
|
transmuxer.flush(chunkMeta);
|
747
746
|
}
|
748
747
|
|
749
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
750
748
|
protected _handleFragmentLoadProgress(
|
751
749
|
frag: PartsLoadedData | FragLoadedData,
|
752
750
|
) {}
|
@@ -554,7 +554,7 @@ class EMEController extends Logger implements ComponentAPI {
|
|
554
554
|
this.keyFormatPromise.then((keySystemFormat) => {
|
555
555
|
const keySystem = keySystemFormatToKeySystemDomain(keySystemFormat);
|
556
556
|
|
557
|
-
let keyId: Uint8Array | null | undefined;
|
557
|
+
let keyId: Uint8Array<ArrayBuffer> | null | undefined;
|
558
558
|
let keySystemDomain: KeySystems | undefined;
|
559
559
|
|
560
560
|
if (initDataType === 'sinf') {
|
@@ -574,7 +574,7 @@ class EMEController extends Logger implements ComponentAPI {
|
|
574
574
|
`'schm' box missing or not cbcs/cenc with schi > tenc`,
|
575
575
|
);
|
576
576
|
}
|
577
|
-
keyId = tenc.subarray(8, 24);
|
577
|
+
keyId = new Uint8Array(tenc.subarray(8, 24));
|
578
578
|
keySystemDomain = KeySystems.FAIRPLAY;
|
579
579
|
} catch (error) {
|
580
580
|
this.warn(`${logMessage} Failed to parse sinf: ${error}`);
|
@@ -629,7 +629,7 @@ class EMEController extends Logger implements ComponentAPI {
|
|
629
629
|
if (psshInfo.version === 0 && psshInfo.data) {
|
630
630
|
if (keySystemDomain === KeySystems.WIDEVINE) {
|
631
631
|
const offset = psshInfo.data.length - 22;
|
632
|
-
keyId = psshInfo.data.subarray(offset, offset + 16);
|
632
|
+
keyId = new Uint8Array(psshInfo.data.subarray(offset, offset + 16));
|
633
633
|
} else if (keySystemDomain === KeySystems.PLAYREADY) {
|
634
634
|
keyId = parsePlayReadyWRM(psshInfo.data);
|
635
635
|
}
|
@@ -696,7 +696,7 @@ class EMEController extends Logger implements ComponentAPI {
|
|
696
696
|
keySystemToKeySystemFormat(keySystem) ?? '',
|
697
697
|
);
|
698
698
|
decryptdata.pssh = new Uint8Array(initData);
|
699
|
-
decryptdata.keyId = keyId
|
699
|
+
decryptdata.keyId = keyId;
|
700
700
|
return this.attemptSetMediaKeys(keySystem, mediaKeys).then(() => {
|
701
701
|
this.throwIfDestroyed();
|
702
702
|
const keySessionContext = this.createMediaKeySessionContext({
|
@@ -1,12 +1,10 @@
|
|
1
|
-
import { sliceUint8 } from '../utils/typed-array';
|
2
|
-
|
3
1
|
// PKCS7
|
4
|
-
export function removePadding(array: Uint8Array)
|
2
|
+
export function removePadding(array: Uint8Array<ArrayBuffer>) {
|
5
3
|
const outputBytes = array.byteLength;
|
6
4
|
const paddingBytes =
|
7
5
|
outputBytes && new DataView(array.buffer).getUint8(outputBytes - 1);
|
8
6
|
if (paddingBytes) {
|
9
|
-
return
|
7
|
+
return array.slice(0, outputBytes - paddingBytes);
|
10
8
|
}
|
11
9
|
return array;
|
12
10
|
}
|
@@ -216,7 +214,11 @@ export default class AESDecryptor {
|
|
216
214
|
);
|
217
215
|
}
|
218
216
|
|
219
|
-
decrypt(
|
217
|
+
decrypt(
|
218
|
+
inputArrayBuffer: ArrayBufferLike,
|
219
|
+
offset: number,
|
220
|
+
aesIV: ArrayBuffer,
|
221
|
+
) {
|
220
222
|
const nRounds = this.keySize + 6;
|
221
223
|
const invKeySchedule = this.invKeySchedule;
|
222
224
|
const invSBOX = this.invSBox;
|
package/src/crypt/decrypter.ts
CHANGED
@@ -4,7 +4,6 @@ import { DecrypterAesMode } from './decrypter-aes-mode';
|
|
4
4
|
import FastAESKey from './fast-aes-key';
|
5
5
|
import { logger } from '../utils/logger';
|
6
6
|
import { appendUint8Array } from '../utils/mp4-tools';
|
7
|
-
import { sliceUint8 } from '../utils/typed-array';
|
8
7
|
import type { HlsConfig } from '../config';
|
9
8
|
|
10
9
|
const CHUNK_SIZE = 16; // 16 bytes, 128 bits
|
@@ -16,7 +15,7 @@ export default class Decrypter {
|
|
16
15
|
private softwareDecrypter: AESDecryptor | null = null;
|
17
16
|
private key: ArrayBuffer | null = null;
|
18
17
|
private fastAesKey: FastAESKey | null = null;
|
19
|
-
private remainderData: Uint8Array | null = null;
|
18
|
+
private remainderData: Uint8Array<ArrayBuffer> | null = null;
|
20
19
|
private currentIV: ArrayBuffer | null = null;
|
21
20
|
private currentResult: ArrayBuffer | null = null;
|
22
21
|
private useSoftware: boolean;
|
@@ -55,7 +54,7 @@ export default class Decrypter {
|
|
55
54
|
return this.useSoftware;
|
56
55
|
}
|
57
56
|
|
58
|
-
public flush(): Uint8Array | null {
|
57
|
+
public flush(): Uint8Array<ArrayBuffer> | null {
|
59
58
|
const { currentResult, remainderData } = this;
|
60
59
|
if (!currentResult || remainderData) {
|
61
60
|
this.reset();
|
@@ -142,7 +141,7 @@ export default class Decrypter {
|
|
142
141
|
const result = currentResult;
|
143
142
|
|
144
143
|
this.currentResult = softwareDecrypter.decrypt(currentChunk.buffer, 0, iv);
|
145
|
-
this.currentIV =
|
144
|
+
this.currentIV = currentChunk.slice(-16).buffer;
|
146
145
|
|
147
146
|
if (!result) {
|
148
147
|
return null;
|
@@ -151,7 +150,7 @@ export default class Decrypter {
|
|
151
150
|
}
|
152
151
|
|
153
152
|
public webCryptoDecrypt(
|
154
|
-
data: Uint8Array
|
153
|
+
data: Uint8Array<ArrayBuffer>,
|
155
154
|
key: ArrayBuffer,
|
156
155
|
iv: ArrayBuffer,
|
157
156
|
aesMode: DecrypterAesMode,
|
@@ -210,8 +209,8 @@ export default class Decrypter {
|
|
210
209
|
let currentChunk = data;
|
211
210
|
const splitPoint = data.length - (data.length % CHUNK_SIZE);
|
212
211
|
if (splitPoint !== data.length) {
|
213
|
-
currentChunk =
|
214
|
-
this.remainderData =
|
212
|
+
currentChunk = data.slice(0, splitPoint);
|
213
|
+
this.remainderData = data.slice(splitPoint);
|
215
214
|
}
|
216
215
|
return currentChunk;
|
217
216
|
}
|
@@ -13,7 +13,6 @@ import {
|
|
13
13
|
MetadataSchema,
|
14
14
|
} from '../../types/demuxer';
|
15
15
|
import { appendUint8Array } from '../../utils/mp4-tools';
|
16
|
-
import { sliceUint8 } from '../../utils/typed-array';
|
17
16
|
import { dummyTrack } from '../dummy-demuxed-track';
|
18
17
|
import type { RationalTimestamp } from '../../utils/timescale-conversion';
|
19
18
|
|
@@ -129,7 +128,7 @@ class BaseAudioDemuxer implements Demuxer {
|
|
129
128
|
offset++;
|
130
129
|
}
|
131
130
|
if (offset === length && lastDataIndex !== length) {
|
132
|
-
const partialData =
|
131
|
+
const partialData = data.slice(lastDataIndex);
|
133
132
|
if (this.cachedData) {
|
134
133
|
this.cachedData = appendUint8Array(this.cachedData, partialData);
|
135
134
|
} else {
|
package/src/demux/sample-aes.ts
CHANGED
@@ -8,7 +8,7 @@ import { discardEPB } from '../utils/mp4-tools';
|
|
8
8
|
import type { HlsConfig } from '../config';
|
9
9
|
import type { HlsEventEmitter } from '../events';
|
10
10
|
import type {
|
11
|
-
|
11
|
+
AACAudioSample,
|
12
12
|
DemuxedVideoTrackBase,
|
13
13
|
KeyData,
|
14
14
|
VideoSample,
|
@@ -37,7 +37,7 @@ class SampleAesDecrypter {
|
|
37
37
|
|
38
38
|
// AAC - encrypt all full 16 bytes blocks starting from offset 16
|
39
39
|
private decryptAacSample(
|
40
|
-
samples:
|
40
|
+
samples: AACAudioSample[],
|
41
41
|
sampleIndex: number,
|
42
42
|
callback: () => void,
|
43
43
|
) {
|
@@ -67,7 +67,7 @@ class SampleAesDecrypter {
|
|
67
67
|
}
|
68
68
|
|
69
69
|
decryptAacSamples(
|
70
|
-
samples:
|
70
|
+
samples: AACAudioSample[],
|
71
71
|
sampleIndex: number,
|
72
72
|
callback: () => void,
|
73
73
|
) {
|
@@ -109,10 +109,7 @@ class SampleAesDecrypter {
|
|
109
109
|
return encryptedData;
|
110
110
|
}
|
111
111
|
|
112
|
-
getAvcDecryptedUnit(
|
113
|
-
decodedData: Uint8Array,
|
114
|
-
decryptedData: ArrayLike<number> | ArrayBuffer | SharedArrayBuffer,
|
115
|
-
) {
|
112
|
+
getAvcDecryptedUnit(decodedData: Uint8Array, decryptedData: ArrayBufferLike) {
|
116
113
|
const uint8DecryptedData = new Uint8Array(decryptedData);
|
117
114
|
let inputPos = 0;
|
118
115
|
for (
|
@@ -139,15 +136,13 @@ class SampleAesDecrypter {
|
|
139
136
|
const decodedData = discardEPB(curUnit.data);
|
140
137
|
const encryptedData = this.getAvcEncryptedData(decodedData);
|
141
138
|
|
142
|
-
this.decryptBuffer(encryptedData.buffer).then(
|
143
|
-
(decryptedBuffer
|
144
|
-
curUnit.data = this.getAvcDecryptedUnit(decodedData, decryptedBuffer);
|
139
|
+
this.decryptBuffer(encryptedData.buffer).then((decryptedBuffer) => {
|
140
|
+
curUnit.data = this.getAvcDecryptedUnit(decodedData, decryptedBuffer);
|
145
141
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
);
|
142
|
+
if (!this.decrypter.isSync()) {
|
143
|
+
this.decryptAvcSamples(samples, sampleIndex, unitIndex + 1, callback);
|
144
|
+
}
|
145
|
+
});
|
151
146
|
}
|
152
147
|
|
153
148
|
decryptAvcSamples(
|
package/src/demux/transmuxer.ts
CHANGED
@@ -95,7 +95,7 @@ export default class Transmuxer {
|
|
95
95
|
const stats = chunkMeta.transmuxing;
|
96
96
|
stats.executeStart = now();
|
97
97
|
|
98
|
-
let uintData: Uint8Array = new Uint8Array(data);
|
98
|
+
let uintData: Uint8Array<ArrayBuffer> = new Uint8Array(data);
|
99
99
|
const { currentTransmuxState, transmuxConfig } = this;
|
100
100
|
if (state) {
|
101
101
|
this.currentTransmuxState = state;
|
package/src/demux/tsdemuxer.ts
CHANGED
@@ -34,7 +34,7 @@ import { appendUint8Array, RemuxerTrackIdConfig } from '../utils/mp4-tools';
|
|
34
34
|
import type { HlsConfig } from '../config';
|
35
35
|
import type { HlsEventEmitter } from '../events';
|
36
36
|
import type BaseVideoParser from './video/base-video-parser';
|
37
|
-
import type { AudioFrame } from '../types/demuxer';
|
37
|
+
import type { AudioFrame, DemuxedAAC } from '../types/demuxer';
|
38
38
|
import type { TypeSupported } from '../utils/codecs';
|
39
39
|
import type { ILogger } from '../utils/logger';
|
40
40
|
|
@@ -564,15 +564,19 @@ class TSDemuxer implements Demuxer {
|
|
564
564
|
return new Promise((resolve) => {
|
565
565
|
const { audioTrack, videoTrack } = demuxResult;
|
566
566
|
if (audioTrack.samples && audioTrack.segmentCodec === 'aac') {
|
567
|
-
sampleAes.decryptAacSamples(
|
568
|
-
|
569
|
-
|
567
|
+
sampleAes.decryptAacSamples(
|
568
|
+
(audioTrack as DemuxedAAC).samples,
|
569
|
+
0,
|
570
|
+
() => {
|
571
|
+
if (videoTrack.samples) {
|
572
|
+
sampleAes.decryptAvcSamples(videoTrack.samples, 0, 0, () => {
|
573
|
+
resolve(demuxResult);
|
574
|
+
});
|
575
|
+
} else {
|
570
576
|
resolve(demuxResult);
|
571
|
-
}
|
572
|
-
}
|
573
|
-
|
574
|
-
}
|
575
|
-
});
|
577
|
+
}
|
578
|
+
},
|
579
|
+
);
|
576
580
|
} else if (videoTrack.samples) {
|
577
581
|
sampleAes.decryptAvcSamples(videoTrack.samples, 0, 0, () => {
|
578
582
|
resolve(demuxResult);
|
package/src/loader/level-key.ts
CHANGED
@@ -4,17 +4,17 @@ import { logger } from '../utils/logger';
|
|
4
4
|
import { KeySystemFormats, parsePlayReadyWRM } from '../utils/mediakeys-helper';
|
5
5
|
import { mp4pssh } from '../utils/mp4-tools';
|
6
6
|
|
7
|
-
let keyUriToKeyIdMap: { [uri: string]: Uint8Array } = {};
|
7
|
+
let keyUriToKeyIdMap: { [uri: string]: Uint8Array<ArrayBuffer> } = {};
|
8
8
|
|
9
9
|
export interface DecryptData {
|
10
10
|
uri: string;
|
11
11
|
method: string;
|
12
12
|
keyFormat: string;
|
13
13
|
keyFormatVersions: number[];
|
14
|
-
iv: Uint8Array | null;
|
15
|
-
key: Uint8Array | null;
|
16
|
-
keyId: Uint8Array | null;
|
17
|
-
pssh: Uint8Array | null;
|
14
|
+
iv: Uint8Array<ArrayBuffer> | null;
|
15
|
+
key: Uint8Array<ArrayBuffer> | null;
|
16
|
+
keyId: Uint8Array<ArrayBuffer> | null;
|
17
|
+
pssh: Uint8Array<ArrayBuffer> | null;
|
18
18
|
encrypted: boolean;
|
19
19
|
isCommonEncryption: boolean;
|
20
20
|
}
|
@@ -26,9 +26,9 @@ export class LevelKey implements DecryptData {
|
|
26
26
|
public readonly keyFormatVersions: number[];
|
27
27
|
public readonly encrypted: boolean;
|
28
28
|
public readonly isCommonEncryption: boolean;
|
29
|
-
public iv: Uint8Array | null = null;
|
30
|
-
public key: Uint8Array | null = null;
|
31
|
-
public keyId: Uint8Array | null = null;
|
29
|
+
public iv: Uint8Array<ArrayBuffer> | null = null;
|
30
|
+
public key: Uint8Array<ArrayBuffer> | null = null;
|
31
|
+
public keyId: Uint8Array<ArrayBuffer> | null = null;
|
32
32
|
public pssh: Uint8Array<ArrayBuffer> | null = null;
|
33
33
|
|
34
34
|
static clearKeyUriToKeyIdMap() {
|
@@ -40,7 +40,7 @@ export class LevelKey implements DecryptData {
|
|
40
40
|
uri: string,
|
41
41
|
format: string,
|
42
42
|
formatversions: number[] = [1],
|
43
|
-
iv: Uint8Array | null = null,
|
43
|
+
iv: Uint8Array<ArrayBuffer> | null = null,
|
44
44
|
) {
|
45
45
|
this.method = method;
|
46
46
|
this.uri = uri;
|
@@ -174,7 +174,7 @@ export class LevelKey implements DecryptData {
|
|
174
174
|
}
|
175
175
|
}
|
176
176
|
|
177
|
-
function createInitializationVector(segmentNumber: number)
|
177
|
+
function createInitializationVector(segmentNumber: number) {
|
178
178
|
const uint8View = new Uint8Array(16);
|
179
179
|
for (let i = 12; i < 16; i++) {
|
180
180
|
uint8View[i] = (segmentNumber >> (8 * (15 - i))) & 0xff;
|
package/src/types/demuxer.ts
CHANGED
@@ -69,6 +69,11 @@ export interface DemuxedAudioTrack extends DemuxedTrack {
|
|
69
69
|
samples: AudioSample[];
|
70
70
|
}
|
71
71
|
|
72
|
+
export type DemuxedAAC = DemuxedAudioTrack & {
|
73
|
+
segmentCodec: 'aac';
|
74
|
+
samples: AACAudioSample[];
|
75
|
+
};
|
76
|
+
|
72
77
|
export type DemuxedAC3 = DemuxedAudioTrack & {
|
73
78
|
segmentCodec: 'ac3';
|
74
79
|
config: Uint8Array;
|
@@ -180,6 +185,10 @@ export type AudioSample = {
|
|
180
185
|
pts: number;
|
181
186
|
};
|
182
187
|
|
188
|
+
export type AACAudioSample = {
|
189
|
+
unit: Uint8Array<ArrayBuffer>;
|
190
|
+
};
|
191
|
+
|
183
192
|
export type AudioFrame = {
|
184
193
|
sample: AudioSample;
|
185
194
|
length: number;
|
@@ -193,6 +202,6 @@ export interface ElementaryStreamData {
|
|
193
202
|
|
194
203
|
export interface KeyData {
|
195
204
|
method: string;
|
196
|
-
key: Uint8Array
|
197
|
-
iv: Uint8Array
|
205
|
+
key: Uint8Array<ArrayBuffer>;
|
206
|
+
iv: Uint8Array<ArrayBuffer>;
|
198
207
|
}
|
package/src/utils/chunker.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { appendUint8Array } from './mp4-tools';
|
2
|
-
import { sliceUint8 } from './typed-array';
|
3
2
|
|
4
3
|
export default class Chunker {
|
5
4
|
private chunkSize: number;
|
@@ -29,10 +28,10 @@ export default class Chunker {
|
|
29
28
|
let offset = 0;
|
30
29
|
const len = temp.length;
|
31
30
|
while (offset < len - chunkSize) {
|
32
|
-
result.push(
|
31
|
+
result.push(temp.slice(offset, offset + chunkSize));
|
33
32
|
offset += chunkSize;
|
34
33
|
}
|
35
|
-
this.cache =
|
34
|
+
this.cache = temp.slice(offset);
|
36
35
|
} else {
|
37
36
|
result.push(temp);
|
38
37
|
}
|
@@ -166,7 +166,7 @@ function createMediaKeySystemConfigurations(
|
|
166
166
|
return [baseConfig];
|
167
167
|
}
|
168
168
|
|
169
|
-
export function parsePlayReadyWRM(keyBytes: Uint8Array)
|
169
|
+
export function parsePlayReadyWRM(keyBytes: Uint8Array) {
|
170
170
|
const keyBytesUtf16 = new Uint16Array(
|
171
171
|
keyBytes.buffer,
|
172
172
|
keyBytes.byteOffset,
|
package/src/utils/mp4-tools.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { utf8ArrayToStr } from '@svta/common-media-library/utils/utf8ArrayToStr';
|
2
2
|
import Hex from './hex';
|
3
|
-
import { sliceUint8 } from './typed-array';
|
4
3
|
import { ElementaryStreamTypes } from '../loader/fragment';
|
5
4
|
import { logger } from '../utils/logger';
|
6
5
|
import type { KeySystemIds } from './mediakeys-helper';
|
@@ -834,8 +833,8 @@ export function segmentValidRange(data: Uint8Array): SegmentedRange {
|
|
834
833
|
}
|
835
834
|
const last = moofs[moofs.length - 1];
|
836
835
|
// Offset by 8 bytes; findBox offsets the start by as much
|
837
|
-
segmentedRange.valid =
|
838
|
-
segmentedRange.remainder =
|
836
|
+
segmentedRange.valid = data.slice(0, last.byteOffset - 8);
|
837
|
+
segmentedRange.remainder = data.slice(last.byteOffset - 8);
|
839
838
|
return segmentedRange;
|
840
839
|
}
|
841
840
|
|
@@ -844,14 +843,10 @@ export interface SegmentedRange {
|
|
844
843
|
remainder: Uint8Array | null;
|
845
844
|
}
|
846
845
|
|
847
|
-
export function appendUint8Array(
|
848
|
-
data1: Uint8Array,
|
849
|
-
data2: Uint8Array,
|
850
|
-
): Uint8Array {
|
846
|
+
export function appendUint8Array(data1: Uint8Array, data2: Uint8Array) {
|
851
847
|
const temp = new Uint8Array(data1.length + data2.length);
|
852
848
|
temp.set(data1);
|
853
849
|
temp.set(data2, data1.length);
|
854
|
-
|
855
850
|
return temp;
|
856
851
|
}
|
857
852
|
|
@@ -21,8 +21,6 @@ export function base64UrlEncode(input: Uint8Array): string {
|
|
21
21
|
return base64ToBase64Url(base64Encode(input));
|
22
22
|
}
|
23
23
|
|
24
|
-
export function base64Decode(
|
25
|
-
base64encodedStr: string,
|
26
|
-
): Uint8Array<ArrayBuffer> {
|
24
|
+
export function base64Decode(base64encodedStr: string) {
|
27
25
|
return Uint8Array.from(atob(base64encodedStr), (c) => c.charCodeAt(0));
|
28
26
|
}
|
package/src/utils/vttparser.ts
CHANGED
package/src/utils/typed-array.ts
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
export function sliceUint8(
|
2
|
-
array: Uint8Array,
|
3
|
-
start?: number,
|
4
|
-
end?: number,
|
5
|
-
): Uint8Array {
|
6
|
-
// @ts-expect-error This polyfills IE11 usage of Uint8Array slice.
|
7
|
-
// It always exists in the TypeScript definition so fails, but it fails at runtime on IE11.
|
8
|
-
return Uint8Array.prototype.slice
|
9
|
-
? array.slice(start, end)
|
10
|
-
: new Uint8Array(Array.prototype.slice.call(array, start, end));
|
11
|
-
}
|