shaka-player 4.7.11 → 4.7.13
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/README.md +2 -4
- package/dist/deps.js +6 -7
- package/dist/locales.js +34 -34
- package/dist/shaka-player.compiled.d.ts +14 -12
- package/dist/shaka-player.compiled.debug.d.ts +14 -12
- package/dist/shaka-player.compiled.debug.externs.js +78 -64
- package/dist/shaka-player.compiled.debug.js +321 -312
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +78 -64
- package/dist/shaka-player.compiled.js +1167 -1153
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +14 -12
- package/dist/shaka-player.ui.debug.d.ts +14 -12
- package/dist/shaka-player.ui.debug.externs.js +78 -64
- package/dist/shaka-player.ui.debug.js +443 -434
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +78 -64
- package/dist/shaka-player.ui.js +1319 -1305
- package/dist/shaka-player.ui.map +4 -4
- package/externs/shaka/manifest.js +11 -1
- package/externs/shaka/offline.js +7 -1
- package/externs/shaka/player.js +32 -19
- package/lib/abr/simple_abr_manager.js +21 -26
- package/lib/cast/cast_proxy.js +1 -3
- package/lib/cast/cast_sender.js +8 -11
- package/lib/cea/cea608_memory.js +1 -1
- package/lib/cea/ts_cea_parser.js +10 -1
- package/lib/dash/dash_parser.js +13 -3
- package/lib/dash/segment_base.js +8 -1
- package/lib/dash/segment_list.js +24 -18
- package/lib/dash/segment_template.js +21 -2
- package/lib/hls/hls_parser.js +36 -17
- package/lib/media/drm_engine.js +6 -3
- package/lib/media/media_source_engine.js +96 -33
- package/lib/media/playhead.js +3 -3
- package/lib/media/presentation_timeline.js +23 -0
- package/lib/media/segment_index.js +21 -20
- package/lib/media/segment_utils.js +10 -1
- package/lib/media/streaming_engine.js +2 -14
- package/lib/mss/mss_parser.js +4 -0
- package/lib/offline/indexeddb/v1_storage_cell.js +2 -0
- package/lib/offline/indexeddb/v2_storage_cell.js +2 -0
- package/lib/offline/manifest_converter.js +10 -3
- package/lib/offline/storage.js +2 -0
- package/lib/player.js +30 -4
- package/lib/polyfill/media_capabilities.js +20 -1
- package/lib/polyfill/mediasource.js +37 -14
- package/lib/text/vtt_text_parser.js +51 -51
- package/lib/transmuxer/h264.js +3 -3
- package/lib/transmuxer/h265.js +3 -3
- package/lib/transmuxer/ts_transmuxer.js +42 -3
- package/lib/util/manifest_parser_utils.js +1 -0
- package/lib/util/mime_utils.js +10 -5
- package/lib/util/mp4_parser.js +57 -0
- package/lib/util/periods.js +5 -37
- package/lib/util/platform.js +4 -0
- package/lib/util/stream_utils.js +334 -271
- package/lib/util/ts_parser.js +99 -10
- package/package.json +1 -1
- package/lib/polyfill/storage_estimate.js +0 -57
package/lib/util/ts_parser.js
CHANGED
|
@@ -10,6 +10,7 @@ goog.require('shaka.Deprecate');
|
|
|
10
10
|
goog.require('shaka.log');
|
|
11
11
|
goog.require('shaka.util.ExpGolomb');
|
|
12
12
|
goog.require('shaka.util.Id3Utils');
|
|
13
|
+
goog.require('shaka.util.StringUtils');
|
|
13
14
|
goog.require('shaka.util.Uint8ArrayUtils');
|
|
14
15
|
|
|
15
16
|
|
|
@@ -55,6 +56,12 @@ shaka.util.TsParser = class {
|
|
|
55
56
|
|
|
56
57
|
/** @private {!Array.<!Array.<Uint8Array>>} */
|
|
57
58
|
this.id3Data_ = [];
|
|
59
|
+
|
|
60
|
+
/** @private {?number} */
|
|
61
|
+
this.referencePts_ = null;
|
|
62
|
+
|
|
63
|
+
/** @private {?number} */
|
|
64
|
+
this.referenceDts_ = null;
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
/**
|
|
@@ -227,6 +234,7 @@ shaka.util.TsParser = class {
|
|
|
227
234
|
* @private
|
|
228
235
|
*/
|
|
229
236
|
parsePMT_(data, offset) {
|
|
237
|
+
const StringUtils = shaka.util.StringUtils;
|
|
230
238
|
const result = {
|
|
231
239
|
audio: -1,
|
|
232
240
|
video: -1,
|
|
@@ -249,26 +257,52 @@ shaka.util.TsParser = class {
|
|
|
249
257
|
case 0x06:
|
|
250
258
|
// stream_type 6 can mean a lot of different things in case of DVB.
|
|
251
259
|
// We need to look at the descriptors. Right now, we're only
|
|
252
|
-
// interested in
|
|
253
|
-
|
|
254
|
-
if (result.audio == -1 && esInfoLength > 0) {
|
|
260
|
+
// interested in a few audio and video formats,.
|
|
261
|
+
if (esInfoLength > 0) {
|
|
255
262
|
let parsePos = offset + 5;
|
|
256
263
|
let remaining = esInfoLength;
|
|
264
|
+
// Descriptor info: https://www.streamguru.de/mpeg-analyzer/supported-descriptor-list/
|
|
257
265
|
while (remaining > 2) {
|
|
258
266
|
const descriptorId = data[parsePos];
|
|
267
|
+
const descriptorLen = data[parsePos + 1] + 2;
|
|
259
268
|
switch (descriptorId) {
|
|
269
|
+
// Registration descriptor
|
|
270
|
+
case 0x05: {
|
|
271
|
+
const registrationData =
|
|
272
|
+
data.subarray(parsePos + 2, parsePos + descriptorLen);
|
|
273
|
+
const registration =
|
|
274
|
+
StringUtils.fromCharCode(registrationData);
|
|
275
|
+
if (result.audio == -1 && registration === 'Opus') {
|
|
276
|
+
result.audio = pid;
|
|
277
|
+
result.audioCodec = 'opus';
|
|
278
|
+
} else if (result.video == -1 && registration === 'AV01') {
|
|
279
|
+
result.video = pid;
|
|
280
|
+
result.videoCodec = 'av1';
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
260
284
|
// DVB Descriptor for AC-3
|
|
261
285
|
case 0x6a:
|
|
262
|
-
result.audio
|
|
263
|
-
|
|
286
|
+
if (result.audio == -1) {
|
|
287
|
+
result.audio = pid;
|
|
288
|
+
result.audioCodec = 'ac3';
|
|
289
|
+
}
|
|
264
290
|
break;
|
|
265
291
|
// DVB Descriptor for EC-3
|
|
266
292
|
case 0x7a:
|
|
267
|
-
result.audio
|
|
268
|
-
|
|
293
|
+
if (result.audio == -1) {
|
|
294
|
+
result.audio = pid;
|
|
295
|
+
result.audioCodec = 'ec3';
|
|
296
|
+
}
|
|
297
|
+
break;
|
|
298
|
+
// DVB Descriptor for AAC
|
|
299
|
+
case 0x7c:
|
|
300
|
+
if (result.audio == -1) {
|
|
301
|
+
result.audio = pid;
|
|
302
|
+
result.audioCodec = 'aac';
|
|
303
|
+
}
|
|
269
304
|
break;
|
|
270
305
|
}
|
|
271
|
-
const descriptorLen = data[parsePos + 1] + 2;
|
|
272
306
|
parsePos += descriptorLen;
|
|
273
307
|
remaining -= descriptorLen;
|
|
274
308
|
}
|
|
@@ -284,6 +318,13 @@ shaka.util.TsParser = class {
|
|
|
284
318
|
result.audioCodec = 'aac';
|
|
285
319
|
}
|
|
286
320
|
break;
|
|
321
|
+
// LOAS/LATM AAC
|
|
322
|
+
case 0x11:
|
|
323
|
+
if (result.audio == -1) {
|
|
324
|
+
result.audio = pid;
|
|
325
|
+
result.audioCodec = 'aac-loas';
|
|
326
|
+
}
|
|
327
|
+
break;
|
|
287
328
|
// Packetized metadata (ID3)
|
|
288
329
|
case 0x15:
|
|
289
330
|
if (result.id3 == -1) {
|
|
@@ -390,22 +431,36 @@ shaka.util.TsParser = class {
|
|
|
390
431
|
// the PTS and DTS are not written out directly. For information
|
|
391
432
|
// on how they are encoded, see
|
|
392
433
|
// http://dvd.sourceforge.net/dvdinfo/pes-hdr.html
|
|
393
|
-
|
|
434
|
+
const pts =
|
|
394
435
|
(data[9] & 0x0e) * 536870912 + // 1 << 29
|
|
395
436
|
(data[10] & 0xff) * 4194304 + // 1 << 22
|
|
396
437
|
(data[11] & 0xfe) * 16384 + // 1 << 14
|
|
397
438
|
(data[12] & 0xff) * 128 + // 1 << 7
|
|
398
439
|
(data[13] & 0xfe) / 2;
|
|
399
440
|
|
|
441
|
+
if (this.referencePts_ == null) {
|
|
442
|
+
this.referencePts_ = pts;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
pes.pts = this.handleRollover_(pts, this.referencePts_);
|
|
446
|
+
this.referencePts_ = pes.pts;
|
|
447
|
+
|
|
400
448
|
pes.dts = pes.pts;
|
|
401
449
|
if (ptsDtsFlags & 0x40) {
|
|
402
|
-
|
|
450
|
+
const dts =
|
|
403
451
|
(data[14] & 0x0e) * 536870912 + // 1 << 29
|
|
404
452
|
(data[15] & 0xff) * 4194304 + // 1 << 22
|
|
405
453
|
(data[16] & 0xfe) * 16384 + // 1 << 14
|
|
406
454
|
(data[17] & 0xff) * 128 + // 1 << 7
|
|
407
455
|
(data[18] & 0xfe) / 2;
|
|
456
|
+
|
|
457
|
+
if (this.referenceDts_ == null) {
|
|
458
|
+
this.referenceDts_ = dts;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
pes.dts = this.handleRollover_(dts, this.referenceDts_);
|
|
408
462
|
}
|
|
463
|
+
this.referenceDts_ = pes.dts;
|
|
409
464
|
}
|
|
410
465
|
|
|
411
466
|
const pesHdrLen = data[8];
|
|
@@ -1069,6 +1124,40 @@ shaka.util.TsParser = class {
|
|
|
1069
1124
|
return ('0' + x.toString(16).toUpperCase()).slice(-2);
|
|
1070
1125
|
}
|
|
1071
1126
|
|
|
1127
|
+
/**
|
|
1128
|
+
* @param {number} value
|
|
1129
|
+
* @param {number} reference
|
|
1130
|
+
* @return {number}
|
|
1131
|
+
* @private
|
|
1132
|
+
*/
|
|
1133
|
+
handleRollover_(value, reference) {
|
|
1134
|
+
const MAX_TS = 8589934592;
|
|
1135
|
+
const RO_THRESH = 4294967296;
|
|
1136
|
+
|
|
1137
|
+
let direction = 1;
|
|
1138
|
+
|
|
1139
|
+
if (value > reference) {
|
|
1140
|
+
// If the current timestamp value is greater than our reference timestamp
|
|
1141
|
+
// and we detect a timestamp rollover, this means the roll over is
|
|
1142
|
+
// happening in the opposite direction.
|
|
1143
|
+
// Example scenario: Enter a long stream/video just after a rollover
|
|
1144
|
+
// occurred. The reference point will be set to a small number, e.g. 1.
|
|
1145
|
+
// The user then seeks backwards over the rollover point. In loading this
|
|
1146
|
+
// segment, the timestamp values will be very large, e.g. 2^33 - 1. Since
|
|
1147
|
+
// this comes before the data we loaded previously, we want to adjust the
|
|
1148
|
+
// time stamp to be `value - 2^33`.
|
|
1149
|
+
direction = -1;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// Note: A seek forwards or back that is greater than the RO_THRESH
|
|
1153
|
+
// (2^32, ~13 hours) will cause an incorrect adjustment.
|
|
1154
|
+
while (Math.abs(reference - value) > RO_THRESH) {
|
|
1155
|
+
value += (direction * MAX_TS);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
return value;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1072
1161
|
/**
|
|
1073
1162
|
* Check if the passed data corresponds to an MPEG2-TS
|
|
1074
1163
|
*
|
package/package.json
CHANGED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*! @license
|
|
2
|
-
* Shaka Player
|
|
3
|
-
* Copyright 2016 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
goog.provide('shaka.polyfill.StorageEstimate');
|
|
8
|
-
|
|
9
|
-
goog.require('shaka.polyfill');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @summary A polyfill to provide navigator.storage.estimate in old
|
|
14
|
-
* webkit browsers.
|
|
15
|
-
* See: https://developers.google.com/web/updates/2017/08/estimating-available-storage-space#the-present
|
|
16
|
-
* @export
|
|
17
|
-
*/
|
|
18
|
-
shaka.polyfill.StorageEstimate = class {
|
|
19
|
-
/**
|
|
20
|
-
* Install the polyfill if needed.
|
|
21
|
-
* @export
|
|
22
|
-
*/
|
|
23
|
-
static install() {
|
|
24
|
-
if (navigator.storage && navigator.storage.estimate) {
|
|
25
|
-
// No need.
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (navigator.webkitTemporaryStorage &&
|
|
30
|
-
navigator.webkitTemporaryStorage.queryUsageAndQuota) {
|
|
31
|
-
if (!('storage' in navigator)) {
|
|
32
|
-
navigator.storage = /** @type {!StorageManager} */ ({});
|
|
33
|
-
}
|
|
34
|
-
navigator.storage.estimate =
|
|
35
|
-
shaka.polyfill.StorageEstimate.storageEstimate_;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @this {StorageManager}
|
|
41
|
-
* @return {!Promise}
|
|
42
|
-
* @private
|
|
43
|
-
*/
|
|
44
|
-
static storageEstimate_() {
|
|
45
|
-
return new Promise((resolve, reject) => {
|
|
46
|
-
navigator.webkitTemporaryStorage.queryUsageAndQuota(
|
|
47
|
-
(usage, quota) => {
|
|
48
|
-
resolve({usage: usage, quota: quota});
|
|
49
|
-
},
|
|
50
|
-
reject,
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
shaka.polyfill.register(shaka.polyfill.StorageEstimate.install);
|