hls.js 1.6.0-rc.1.0.canary.11076 → 1.6.0-rc.1.0.canary.11078
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.js +45 -15
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +45 -15
- 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 +45 -15
- 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 +45 -15
- 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 +1 -1
- package/src/controller/buffer-controller.ts +6 -4
- package/src/remux/passthrough-remuxer.ts +1 -0
- package/src/utils/codecs.ts +19 -0
- package/src/utils/mp4-tools.ts +28 -10
package/package.json
CHANGED
@@ -9,6 +9,7 @@ import {
|
|
9
9
|
areCodecsMediaSourceSupported,
|
10
10
|
getCodecCompatibleName,
|
11
11
|
pickMostCompleteCodecName,
|
12
|
+
replaceVideoCodec,
|
12
13
|
} from '../utils/codecs';
|
13
14
|
import { Logger } from '../utils/logger';
|
14
15
|
import {
|
@@ -1436,14 +1437,15 @@ transfer tracks: ${stringify(transferredTracks, (key, value) => (key === 'initSe
|
|
1436
1437
|
private getTrackCodec(track: BaseTrack, trackName: SourceBufferName): string {
|
1437
1438
|
// Use supplemental video codec when supported when adding SourceBuffer (#5558)
|
1438
1439
|
const supplementalCodec = track.supplemental;
|
1440
|
+
let trackCodec = track.codec;
|
1439
1441
|
if (
|
1440
1442
|
supplementalCodec &&
|
1441
|
-
trackName === 'video' &&
|
1442
|
-
areCodecsMediaSourceSupported(supplementalCodec,
|
1443
|
+
(trackName === 'video' || trackName === 'audiovideo') &&
|
1444
|
+
areCodecsMediaSourceSupported(supplementalCodec, 'video')
|
1443
1445
|
) {
|
1444
|
-
|
1446
|
+
trackCodec = replaceVideoCodec(trackCodec, supplementalCodec);
|
1445
1447
|
}
|
1446
|
-
const codec = pickMostCompleteCodecName(
|
1448
|
+
const codec = pickMostCompleteCodecName(trackCodec, track.levelCodec);
|
1447
1449
|
if (codec) {
|
1448
1450
|
if (trackName.slice(0, 5) === 'audio') {
|
1449
1451
|
return getCodecCompatibleName(codec, this.appendSource);
|
package/src/utils/codecs.ts
CHANGED
@@ -202,6 +202,25 @@ export function getCodecCompatibleName(
|
|
202
202
|
);
|
203
203
|
}
|
204
204
|
|
205
|
+
export function replaceVideoCodec(
|
206
|
+
originalCodecs: string | undefined,
|
207
|
+
newVideoCodec: string | undefined,
|
208
|
+
): string | undefined {
|
209
|
+
const codecs: string[] = [];
|
210
|
+
if (originalCodecs) {
|
211
|
+
const allCodecs = originalCodecs.split(',');
|
212
|
+
for (let i = 0; i < allCodecs.length; i++) {
|
213
|
+
if (!isCodecType(allCodecs[i], 'video')) {
|
214
|
+
codecs.push(allCodecs[i]);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
if (newVideoCodec) {
|
219
|
+
codecs.push(newVideoCodec);
|
220
|
+
}
|
221
|
+
return codecs.join(',');
|
222
|
+
}
|
223
|
+
|
205
224
|
export function pickMostCompleteCodecName(
|
206
225
|
parsedCodec: string | undefined,
|
207
226
|
levelCodec: string | undefined,
|
package/src/utils/mp4-tools.ts
CHANGED
@@ -226,13 +226,24 @@ export interface InitDataTrack {
|
|
226
226
|
supplemental: string | undefined;
|
227
227
|
}
|
228
228
|
|
229
|
-
type
|
229
|
+
type HdlrMetadata = 'meta';
|
230
|
+
type HdlrType =
|
231
|
+
| ElementaryStreamTypes.AUDIO
|
232
|
+
| ElementaryStreamTypes.VIDEO
|
233
|
+
| HdlrMetadata;
|
234
|
+
|
235
|
+
type StsdData = {
|
236
|
+
codec: string;
|
237
|
+
encrypted: boolean;
|
238
|
+
supplemental: string | undefined;
|
239
|
+
};
|
230
240
|
|
231
241
|
export interface InitData extends Array<any> {
|
232
242
|
[index: number]:
|
233
243
|
| {
|
234
244
|
timescale: number;
|
235
245
|
type: HdlrType;
|
246
|
+
stsd: StsdData;
|
236
247
|
default?: {
|
237
248
|
duration: number;
|
238
249
|
flags: number;
|
@@ -266,10 +277,20 @@ export function parseInitSegment(initSegment: Uint8Array): InitData {
|
|
266
277
|
}[hdlrType];
|
267
278
|
if (type) {
|
268
279
|
// Parse codec details
|
269
|
-
const
|
270
|
-
const
|
271
|
-
|
272
|
-
|
280
|
+
const stsdBox = findBox(trak, ['mdia', 'minf', 'stbl', 'stsd'])[0];
|
281
|
+
const stsd = parseStsd(stsdBox);
|
282
|
+
if (type) {
|
283
|
+
// Add 'audio', 'video', and 'audiovideo' track records that will map to SourceBuffers
|
284
|
+
result[trackId] = { timescale, type, stsd };
|
285
|
+
result[type] = { timescale, id: trackId, ...stsd };
|
286
|
+
} else {
|
287
|
+
// Add 'meta' and other track records required by `offsetStartDTS`
|
288
|
+
result[trackId] = {
|
289
|
+
timescale,
|
290
|
+
type: hdlrType as HdlrType,
|
291
|
+
stsd,
|
292
|
+
};
|
293
|
+
}
|
273
294
|
}
|
274
295
|
}
|
275
296
|
}
|
@@ -291,11 +312,7 @@ export function parseInitSegment(initSegment: Uint8Array): InitData {
|
|
291
312
|
return result;
|
292
313
|
}
|
293
314
|
|
294
|
-
function parseStsd(stsd: Uint8Array): {
|
295
|
-
codec: string;
|
296
|
-
encrypted: boolean;
|
297
|
-
supplemental: string | undefined;
|
298
|
-
} {
|
315
|
+
function parseStsd(stsd: Uint8Array): StsdData {
|
299
316
|
const sampleEntries = stsd.subarray(8);
|
300
317
|
const sampleEntriesEnd = sampleEntries.subarray(8 + 78);
|
301
318
|
const fourCC = bin2str(sampleEntries.subarray(4, 8));
|
@@ -818,6 +835,7 @@ export function computeRawDurationFromSamples(trun): number {
|
|
818
835
|
return duration;
|
819
836
|
}
|
820
837
|
|
838
|
+
// TODO: Remove `offsetStartDTS` in favor of using `timestampOffset` (issue #5715)
|
821
839
|
export function offsetStartDTS(
|
822
840
|
initData: InitData,
|
823
841
|
fmp4: Uint8Array,
|