shaka-player 4.1.4 → 4.1.6
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/.github/workflows/build-and-test.yaml +42 -22
- package/.github/workflows/compute-incremental-coverage.py +14 -3
- package/.github/workflows/custom-actions/set-commit-status/action.yaml +1 -5
- package/.github/workflows/deflake.yaml +28 -0
- package/.github/workflows/demo-version-index.yaml +1 -1
- package/.github/workflows/nightly-demo.yaml +1 -1
- package/.github/workflows/release-please.yaml +5 -5
- package/.github/workflows/report-incremental-coverage.yaml +1 -1
- package/.github/workflows/selenium-lab-tests.yaml +21 -10
- package/AUTHORS +3 -0
- package/CHANGELOG.md +35 -0
- package/CONTRIBUTORS +3 -0
- package/demo/common/message_ids.js +1 -0
- package/demo/config.js +3 -1
- package/demo/locales/en.json +1 -0
- package/demo/locales/source.json +4 -0
- package/dist/demo.compiled.debug.js +6 -6
- package/dist/demo.compiled.debug.map +2 -2
- package/dist/demo.compiled.js +6 -6
- package/dist/demo.compiled.map +2 -2
- package/dist/deps.js +3 -3
- package/dist/locales.js +31 -31
- package/dist/receiver.compiled.debug.js +3 -3
- package/dist/receiver.compiled.debug.map +2 -2
- package/dist/receiver.compiled.js +3 -3
- package/dist/receiver.compiled.map +2 -2
- package/dist/shaka-player.compiled.d.ts +3 -2
- package/dist/shaka-player.compiled.debug.d.ts +3 -2
- package/dist/shaka-player.compiled.debug.externs.js +25 -24
- package/dist/shaka-player.compiled.debug.js +233 -224
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +25 -24
- package/dist/shaka-player.compiled.js +800 -797
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +3 -2
- package/dist/shaka-player.ui.debug.d.ts +3 -2
- package/dist/shaka-player.ui.debug.externs.js +25 -24
- package/dist/shaka-player.ui.debug.js +286 -278
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +25 -24
- package/dist/shaka-player.ui.js +939 -935
- package/dist/shaka-player.ui.map +4 -4
- package/docs/jsdoc-template/publish.js +33 -0
- package/docs/jsdoc-template/tmpl/container.tmpl +4 -1
- package/docs/jsdoc.conf.json +1 -0
- package/docs/tutorials/welcome.md +2 -2
- package/externs/shaka/manifest_parser.js +4 -1
- package/externs/shaka/player.js +7 -1
- package/lib/ads/client_side_ad_manager.js +12 -2
- package/lib/cast/cast_sender.js +39 -14
- package/lib/cea/cea608_memory.js +4 -0
- package/lib/hls/hls_parser.js +48 -15
- package/lib/media/drm_engine.js +59 -7
- package/lib/media/media_source_engine.js +43 -15
- package/lib/media/playhead.js +1 -1
- package/lib/media/streaming_engine.js +79 -14
- package/lib/offline/indexeddb/storage_mechanism.js +24 -0
- package/lib/offline/storage.js +1 -0
- package/lib/player.js +17 -5
- package/lib/polyfill/media_capabilities.js +7 -6
- package/lib/text/ttml_text_parser.js +69 -87
- package/lib/text/vtt_text_parser.js +1 -1
- package/lib/util/error.js +7 -0
- package/lib/util/periods.js +9 -9
- package/lib/util/platform.js +19 -5
- package/lib/util/player_configuration.js +4 -0
- package/lib/util/pssh.js +2 -1
- package/lib/util/stream_utils.js +2 -1
- package/lib/util/xml_utils.js +45 -6
- package/package.json +1 -1
- package/test/cea/cea608_memory_unit.js +88 -0
- package/test/dash/dash_parser_content_protection_unit.js +1 -0
- package/test/dash/dash_parser_live_unit.js +1 -0
- package/test/dash/dash_parser_manifest_unit.js +1 -0
- package/test/dash/dash_parser_segment_base_unit.js +1 -0
- package/test/dash/dash_parser_segment_list_unit.js +1 -0
- package/test/dash/dash_parser_segment_template_unit.js +1 -0
- package/test/hls/hls_live_unit.js +169 -247
- package/test/hls/hls_parser_unit.js +60 -2
- package/test/media/drm_engine_unit.js +61 -0
- package/test/media/media_source_engine_integration.js +36 -0
- package/test/media/media_source_engine_unit.js +118 -1
- package/test/media/streaming_engine_integration.js +9 -7
- package/test/media/streaming_engine_unit.js +29 -0
- package/test/offline/offline_integration.js +3 -3
- package/test/offline/storage_integration.js +30 -0
- package/test/player_integration.js +2 -2
- package/test/test/util/dash_parser_util.js +2 -0
- package/test/test/util/ttml_utils.js +0 -2
- package/test/text/ttml_text_parser_unit.js +46 -0
- package/test/text/vtt_text_parser_unit.js +23 -1
- package/test/ui/text_displayer_layout_unit.js +17 -2
- package/test/util/periods_unit.js +149 -11
- package/test/util/xml_utils_unit.js +64 -0
- package/ui/controls.js +0 -7
|
@@ -320,8 +320,14 @@ shaka.media.StreamingEngine = class {
|
|
|
320
320
|
* @param {number=} safeMargin
|
|
321
321
|
* @param {boolean=} force
|
|
322
322
|
* If true, reload the variant even if it did not change.
|
|
323
|
+
* @param {boolean=} adaptation
|
|
324
|
+
* If true, update the media state to indicate MediaSourceEngine should
|
|
325
|
+
* reset the timestamp offset to ensure the new track segments are correctly
|
|
326
|
+
* placed on the timeline.
|
|
323
327
|
*/
|
|
324
|
-
switchVariant(
|
|
328
|
+
switchVariant(
|
|
329
|
+
variant, clearBuffer = false, safeMargin = 0, force = false,
|
|
330
|
+
adaptation = false) {
|
|
325
331
|
this.currentVariant_ = variant;
|
|
326
332
|
|
|
327
333
|
if (!this.startupComplete_) {
|
|
@@ -332,12 +338,14 @@ shaka.media.StreamingEngine = class {
|
|
|
332
338
|
if (variant.video) {
|
|
333
339
|
this.switchInternal_(
|
|
334
340
|
variant.video, /* clearBuffer= */ clearBuffer,
|
|
335
|
-
/* safeMargin= */ safeMargin, /* force= */ force
|
|
341
|
+
/* safeMargin= */ safeMargin, /* force= */ force,
|
|
342
|
+
/* adaptation= */ adaptation);
|
|
336
343
|
}
|
|
337
344
|
if (variant.audio) {
|
|
338
345
|
this.switchInternal_(
|
|
339
346
|
variant.audio, /* clearBuffer= */ clearBuffer,
|
|
340
|
-
/* safeMargin= */ safeMargin, /* force= */ force
|
|
347
|
+
/* safeMargin= */ safeMargin, /* force= */ force,
|
|
348
|
+
/* adaptation= */ adaptation);
|
|
341
349
|
}
|
|
342
350
|
}
|
|
343
351
|
|
|
@@ -383,9 +391,13 @@ shaka.media.StreamingEngine = class {
|
|
|
383
391
|
* @param {number} safeMargin
|
|
384
392
|
* @param {boolean} force
|
|
385
393
|
* If true, reload the text stream even if it did not change.
|
|
394
|
+
* @param {boolean=} adaptation
|
|
395
|
+
* If true, update the media state to indicate MediaSourceEngine should
|
|
396
|
+
* reset the timestamp offset to ensure the new track segments are correctly
|
|
397
|
+
* placed on the timeline.
|
|
386
398
|
* @private
|
|
387
399
|
*/
|
|
388
|
-
switchInternal_(stream, clearBuffer, safeMargin, force) {
|
|
400
|
+
switchInternal_(stream, clearBuffer, safeMargin, force, adaptation) {
|
|
389
401
|
const ContentType = shaka.util.ManifestParserUtils.ContentType;
|
|
390
402
|
const type = /** @type {!ContentType} */(stream.type);
|
|
391
403
|
const mediaState = this.mediaStates_.get(type);
|
|
@@ -440,6 +452,7 @@ shaka.media.StreamingEngine = class {
|
|
|
440
452
|
|
|
441
453
|
mediaState.stream = stream;
|
|
442
454
|
mediaState.segmentIterator = null;
|
|
455
|
+
mediaState.adaptation = !!adaptation;
|
|
443
456
|
|
|
444
457
|
const streamTag = shaka.media.StreamingEngine.logPrefix_(mediaState);
|
|
445
458
|
shaka.log.debug('switch: switching to Stream ' + streamTag);
|
|
@@ -769,12 +782,11 @@ shaka.media.StreamingEngine = class {
|
|
|
769
782
|
const mediaSourceEngine = this.playerInterface_.mediaSourceEngine;
|
|
770
783
|
const forceTransmuxTS = this.config_.forceTransmuxTS;
|
|
771
784
|
|
|
772
|
-
|
|
773
785
|
await mediaSourceEngine.init(streamsByType, forceTransmuxTS,
|
|
774
786
|
this.manifest_.sequenceMode);
|
|
775
787
|
this.destroyer_.ensureNotDestroyed();
|
|
776
788
|
|
|
777
|
-
this.
|
|
789
|
+
this.updateDuration();
|
|
778
790
|
|
|
779
791
|
for (const type of streamsByType.keys()) {
|
|
780
792
|
const stream = streamsByType.get(type);
|
|
@@ -824,9 +836,8 @@ shaka.media.StreamingEngine = class {
|
|
|
824
836
|
|
|
825
837
|
/**
|
|
826
838
|
* Sets the MediaSource's duration.
|
|
827
|
-
* @private
|
|
828
839
|
*/
|
|
829
|
-
|
|
840
|
+
updateDuration() {
|
|
830
841
|
const duration = this.manifest_.presentationTimeline.getDuration();
|
|
831
842
|
if (duration < Infinity) {
|
|
832
843
|
this.playerInterface_.mediaSourceEngine.setDuration(duration);
|
|
@@ -1001,7 +1012,11 @@ shaka.media.StreamingEngine = class {
|
|
|
1001
1012
|
const timeUntilEnd =
|
|
1002
1013
|
this.manifest_.presentationTimeline.getDuration() - timeNeeded;
|
|
1003
1014
|
const oneMicrosecond = 1e-6;
|
|
1004
|
-
|
|
1015
|
+
|
|
1016
|
+
const bufferEnd =
|
|
1017
|
+
this.playerInterface_.mediaSourceEngine.bufferEnd(mediaState.type);
|
|
1018
|
+
|
|
1019
|
+
if (timeUntilEnd < oneMicrosecond && !!bufferEnd) {
|
|
1005
1020
|
// We shouldn't rebuffer if the playhead is close to the end of the
|
|
1006
1021
|
// presentation.
|
|
1007
1022
|
shaka.log.debug(logPrefix, 'buffered to end of presentation');
|
|
@@ -1031,8 +1046,6 @@ shaka.media.StreamingEngine = class {
|
|
|
1031
1046
|
return this.config_.updateIntervalSeconds / 2;
|
|
1032
1047
|
}
|
|
1033
1048
|
|
|
1034
|
-
const bufferEnd =
|
|
1035
|
-
this.playerInterface_.mediaSourceEngine.bufferEnd(mediaState.type);
|
|
1036
1049
|
const reference = this.getSegmentReferenceNeeded_(
|
|
1037
1050
|
mediaState, presentationTime, bufferEnd);
|
|
1038
1051
|
if (!reference) {
|
|
@@ -1235,7 +1248,16 @@ shaka.media.StreamingEngine = class {
|
|
|
1235
1248
|
// Enable MP4 low latency streaming with ReadableStream chunked data.
|
|
1236
1249
|
if (this.config_.lowLatencyMode && isReadableStreamSupported && isMP4) {
|
|
1237
1250
|
let remaining = new Uint8Array(0);
|
|
1251
|
+
let processingResult = false;
|
|
1252
|
+
let callbackCalled = false;
|
|
1238
1253
|
const streamDataCallback = async (data) => {
|
|
1254
|
+
if (processingResult) {
|
|
1255
|
+
// If the fallback result processing was triggered, don't also
|
|
1256
|
+
// append the buffer here. In theory this should never happen,
|
|
1257
|
+
// but it does on some older TVs.
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
callbackCalled = true;
|
|
1239
1261
|
this.destroyer_.ensureNotDestroyed();
|
|
1240
1262
|
if (this.fatalError_) {
|
|
1241
1263
|
return;
|
|
@@ -1266,7 +1288,33 @@ shaka.media.StreamingEngine = class {
|
|
|
1266
1288
|
}
|
|
1267
1289
|
};
|
|
1268
1290
|
|
|
1269
|
-
|
|
1291
|
+
const result =
|
|
1292
|
+
await this.fetch_(mediaState, reference, streamDataCallback);
|
|
1293
|
+
if (!callbackCalled) {
|
|
1294
|
+
// In some environments, we might be forced to use network plugins
|
|
1295
|
+
// that don't support streamDataCallback. In those cases, as a
|
|
1296
|
+
// fallback, append the buffer here.
|
|
1297
|
+
processingResult = true;
|
|
1298
|
+
this.destroyer_.ensureNotDestroyed();
|
|
1299
|
+
if (this.fatalError_) {
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// If the text stream gets switched between fetch_() and append_(),
|
|
1304
|
+
// the new text parser is initialized, but the new init segment is
|
|
1305
|
+
// not fetched yet. That would cause an error in
|
|
1306
|
+
// TextParser.parseMedia().
|
|
1307
|
+
// See http://b/168253400
|
|
1308
|
+
if (mediaState.waitingToClearBuffer) {
|
|
1309
|
+
shaka.log.info(logPrefix, 'waitingToClearBuffer, skip append');
|
|
1310
|
+
mediaState.performingUpdate = false;
|
|
1311
|
+
this.scheduleUpdate_(mediaState, 0);
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
await this.append_(
|
|
1316
|
+
mediaState, presentationTime, stream, reference, result);
|
|
1317
|
+
}
|
|
1270
1318
|
} else {
|
|
1271
1319
|
if (this.config_.lowLatencyMode && !isReadableStreamSupported) {
|
|
1272
1320
|
shaka.log.warning('Low latency streaming mode is enabled, but ' +
|
|
@@ -1554,6 +1602,8 @@ shaka.media.StreamingEngine = class {
|
|
|
1554
1602
|
shaka.log.v1(logPrefix, 'appending init segment');
|
|
1555
1603
|
const hasClosedCaptions = mediaState.stream.closedCaptions &&
|
|
1556
1604
|
mediaState.stream.closedCaptions.size > 0;
|
|
1605
|
+
await this.playerInterface_.beforeAppendSegment(
|
|
1606
|
+
mediaState.type, initSegment);
|
|
1557
1607
|
await this.playerInterface_.mediaSourceEngine.appendBuffer(
|
|
1558
1608
|
mediaState.type, initSegment, /* reference= */ null,
|
|
1559
1609
|
hasClosedCaptions);
|
|
@@ -1604,14 +1654,21 @@ shaka.media.StreamingEngine = class {
|
|
|
1604
1654
|
shaka.log.v1(logPrefix, 'appending media segment at',
|
|
1605
1655
|
(reference.syncTime == null ? 'unknown' : reference.syncTime));
|
|
1606
1656
|
|
|
1657
|
+
// 'seeked' or 'adaptation' triggered logic applies only to this
|
|
1658
|
+
// appendBuffer() call.
|
|
1607
1659
|
const seeked = mediaState.seeked;
|
|
1608
1660
|
mediaState.seeked = false;
|
|
1661
|
+
const adaptation = mediaState.adaptation;
|
|
1662
|
+
mediaState.adaptation = false;
|
|
1663
|
+
|
|
1664
|
+
await this.playerInterface_.beforeAppendSegment(mediaState.type, segment);
|
|
1609
1665
|
await this.playerInterface_.mediaSourceEngine.appendBuffer(
|
|
1610
1666
|
mediaState.type,
|
|
1611
1667
|
segment,
|
|
1612
1668
|
reference,
|
|
1613
1669
|
hasClosedCaptions,
|
|
1614
|
-
seeked
|
|
1670
|
+
seeked,
|
|
1671
|
+
adaptation);
|
|
1615
1672
|
this.destroyer_.ensureNotDestroyed();
|
|
1616
1673
|
shaka.log.v2(logPrefix, 'appended media segment');
|
|
1617
1674
|
}
|
|
@@ -1988,7 +2045,9 @@ shaka.media.StreamingEngine = class {
|
|
|
1988
2045
|
* onEvent: function(!Event),
|
|
1989
2046
|
* onManifestUpdate: function(),
|
|
1990
2047
|
* onSegmentAppended: function(),
|
|
1991
|
-
* onInitSegmentAppended: function(!number,!shaka.media.InitSegmentReference)
|
|
2048
|
+
* onInitSegmentAppended: function(!number,!shaka.media.InitSegmentReference),
|
|
2049
|
+
* beforeAppendSegment: function(
|
|
2050
|
+
* shaka.util.ManifestParserUtils.ContentType,!BufferSource):Promise
|
|
1992
2051
|
* }}
|
|
1993
2052
|
*
|
|
1994
2053
|
* @property {function():number} getPresentationTime
|
|
@@ -2016,6 +2075,9 @@ shaka.media.StreamingEngine = class {
|
|
|
2016
2075
|
* @property
|
|
2017
2076
|
* {function(!number, !shaka.media.InitSegmentReference)} onInitSegmentAppended
|
|
2018
2077
|
* Called when an init segment is appended to a MediaSource.
|
|
2078
|
+
* @property {!function(shaka.util.ManifestParserUtils.ContentType,
|
|
2079
|
+
* !BufferSource):Promise} beforeAppendSegment
|
|
2080
|
+
* A function called just before appending to the source buffer.
|
|
2019
2081
|
*/
|
|
2020
2082
|
shaka.media.StreamingEngine.PlayerInterface;
|
|
2021
2083
|
|
|
@@ -2039,6 +2101,7 @@ shaka.media.StreamingEngine.PlayerInterface;
|
|
|
2039
2101
|
* clearBufferSafeMargin: number,
|
|
2040
2102
|
* clearingBuffer: boolean,
|
|
2041
2103
|
* seeked: boolean,
|
|
2104
|
+
* adaptation: boolean,
|
|
2042
2105
|
* recovering: boolean,
|
|
2043
2106
|
* hasError: boolean,
|
|
2044
2107
|
* operation: shaka.net.NetworkingEngine.PendingRequest
|
|
@@ -2085,6 +2148,8 @@ shaka.media.StreamingEngine.PlayerInterface;
|
|
|
2085
2148
|
* True indicates that the buffer is being cleared.
|
|
2086
2149
|
* @property {boolean} seeked
|
|
2087
2150
|
* True indicates that the presentation just seeked.
|
|
2151
|
+
* @property {boolean} adaptation
|
|
2152
|
+
* True indicates that the presentation just automatically switched variants.
|
|
2088
2153
|
* @property {boolean} recovering
|
|
2089
2154
|
* True indicates that the last segment was not appended because it could not
|
|
2090
2155
|
* fit in the buffer.
|
|
@@ -16,6 +16,7 @@ goog.require('shaka.offline.indexeddb.V5StorageCell');
|
|
|
16
16
|
goog.require('shaka.util.Error');
|
|
17
17
|
goog.require('shaka.util.PublicPromise');
|
|
18
18
|
goog.require('shaka.util.Platform');
|
|
19
|
+
goog.require('shaka.util.Timer');
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -55,8 +56,25 @@ shaka.offline.indexeddb.StorageMechanism = class {
|
|
|
55
56
|
const version = shaka.offline.indexeddb.StorageMechanism.VERSION;
|
|
56
57
|
|
|
57
58
|
const p = new shaka.util.PublicPromise();
|
|
59
|
+
|
|
60
|
+
// Add a timeout mechanism, for the (rare?) case where no callbacks are
|
|
61
|
+
// called at all, so that this method doesn't hang forever.
|
|
62
|
+
let timedOut = false;
|
|
63
|
+
const timeOutTimer = new shaka.util.Timer(() => {
|
|
64
|
+
timedOut = true;
|
|
65
|
+
p.reject(new shaka.util.Error(
|
|
66
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
67
|
+
shaka.util.Error.Category.STORAGE,
|
|
68
|
+
shaka.util.Error.Code.INDEXED_DB_INIT_TIMED_OUT));
|
|
69
|
+
});
|
|
70
|
+
timeOutTimer.tickAfter(2);
|
|
71
|
+
|
|
58
72
|
const open = window.indexedDB.open(name, version);
|
|
59
73
|
open.onsuccess = (event) => {
|
|
74
|
+
if (timedOut) {
|
|
75
|
+
// Too late, we have already given up on opening the storage mechanism.
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
60
78
|
const db = open.result;
|
|
61
79
|
this.db_ = db;
|
|
62
80
|
this.v1_ = shaka.offline.indexeddb.StorageMechanism.createV1_(db);
|
|
@@ -68,6 +86,7 @@ shaka.offline.indexeddb.StorageMechanism = class {
|
|
|
68
86
|
this.v5_ = shaka.offline.indexeddb.StorageMechanism.createV5_(db);
|
|
69
87
|
this.sessions_ =
|
|
70
88
|
shaka.offline.indexeddb.StorageMechanism.createEmeSessionCell_(db);
|
|
89
|
+
timeOutTimer.stop();
|
|
71
90
|
p.resolve();
|
|
72
91
|
};
|
|
73
92
|
open.onupgradeneeded = (event) => {
|
|
@@ -75,11 +94,16 @@ shaka.offline.indexeddb.StorageMechanism = class {
|
|
|
75
94
|
this.createStores_(open.result);
|
|
76
95
|
};
|
|
77
96
|
open.onerror = (event) => {
|
|
97
|
+
if (timedOut) {
|
|
98
|
+
// Too late, we have already given up on opening the storage mechanism.
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
78
101
|
p.reject(new shaka.util.Error(
|
|
79
102
|
shaka.util.Error.Severity.CRITICAL,
|
|
80
103
|
shaka.util.Error.Category.STORAGE,
|
|
81
104
|
shaka.util.Error.Code.INDEXED_DB_ERROR,
|
|
82
105
|
open.error));
|
|
106
|
+
timeOutTimer.stop();
|
|
83
107
|
|
|
84
108
|
// Firefox will raise an error on the main thread unless we stop it here.
|
|
85
109
|
event.preventDefault();
|
package/lib/offline/storage.js
CHANGED
package/lib/player.js
CHANGED
|
@@ -1770,6 +1770,11 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
|
|
|
1770
1770
|
enableLowLatencyMode: () => {
|
|
1771
1771
|
this.configure('streaming.lowLatencyMode', true);
|
|
1772
1772
|
},
|
|
1773
|
+
updateDuration: () => {
|
|
1774
|
+
if (this.streamingEngine_) {
|
|
1775
|
+
this.streamingEngine_.updateDuration();
|
|
1776
|
+
}
|
|
1777
|
+
},
|
|
1773
1778
|
};
|
|
1774
1779
|
|
|
1775
1780
|
const startTime = Date.now() / 1000;
|
|
@@ -2945,6 +2950,9 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
|
|
|
2945
2950
|
this.qualityObserver_.addMediaQualityChange(mediaQuality, position);
|
|
2946
2951
|
}
|
|
2947
2952
|
},
|
|
2953
|
+
beforeAppendSegment: (contentType, segment) => {
|
|
2954
|
+
return this.drmEngine_.parseInbandPssh(contentType, segment);
|
|
2955
|
+
},
|
|
2948
2956
|
};
|
|
2949
2957
|
|
|
2950
2958
|
return new shaka.media.StreamingEngine(this.manifest_, playerInterface);
|
|
@@ -3831,8 +3839,8 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
|
|
|
3831
3839
|
return;
|
|
3832
3840
|
}
|
|
3833
3841
|
|
|
3834
|
-
this.switchVariant_(
|
|
3835
|
-
safeMargin);
|
|
3842
|
+
this.switchVariant_(
|
|
3843
|
+
variant, /* fromAdaptation= */ false, clearBuffer, safeMargin);
|
|
3836
3844
|
|
|
3837
3845
|
// Workaround for
|
|
3838
3846
|
// https://github.com/shaka-project/shaka-player/issues/1299
|
|
@@ -5369,7 +5377,9 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
|
|
|
5369
5377
|
const currentVariant = this.streamingEngine_.getCurrentVariant();
|
|
5370
5378
|
if (variant == currentVariant) {
|
|
5371
5379
|
shaka.log.debug('Variant already selected.');
|
|
5372
|
-
// If you want to clear the buffer, we force to reselect the same variant
|
|
5380
|
+
// If you want to clear the buffer, we force to reselect the same variant.
|
|
5381
|
+
// We don't need to reset the timestampOffset since it's the same variant,
|
|
5382
|
+
// so 'adaptation' isn't passed here.
|
|
5373
5383
|
if (clearBuffer) {
|
|
5374
5384
|
this.streamingEngine_.switchVariant(variant, clearBuffer, safeMargin,
|
|
5375
5385
|
/* force= */ true);
|
|
@@ -5379,7 +5389,9 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
|
|
|
5379
5389
|
|
|
5380
5390
|
// Add entries to the history.
|
|
5381
5391
|
this.addVariantToSwitchHistory_(variant, fromAdaptation);
|
|
5382
|
-
this.streamingEngine_.switchVariant(
|
|
5392
|
+
this.streamingEngine_.switchVariant(
|
|
5393
|
+
variant, clearBuffer, safeMargin, /* force= */ undefined,
|
|
5394
|
+
/* adaptation= */ fromAdaptation);
|
|
5383
5395
|
let oldTrack = null;
|
|
5384
5396
|
if (currentVariant) {
|
|
5385
5397
|
oldTrack = shaka.util.StreamUtils.variantToTrack(currentVariant);
|
|
@@ -6563,7 +6575,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
|
|
|
6563
6575
|
* @define {string} A version number taken from git at compile time.
|
|
6564
6576
|
* @export
|
|
6565
6577
|
*/
|
|
6566
|
-
shaka.Player.version = 'v4.1.
|
|
6578
|
+
shaka.Player.version = 'v4.1.6-uncompiled';
|
|
6567
6579
|
|
|
6568
6580
|
// Initialize the deprecation system using the version string we just set
|
|
6569
6581
|
// on the player.
|
|
@@ -24,8 +24,9 @@ shaka.polyfill.MediaCapabilities = class {
|
|
|
24
24
|
* @export
|
|
25
25
|
*/
|
|
26
26
|
static install() {
|
|
27
|
-
// Since MediaCapabilities is
|
|
28
|
-
//
|
|
27
|
+
// Since MediaCapabilities implementation is buggy on the Chromecast
|
|
28
|
+
// platform (see https://github.com/shaka-project/shaka-player/issues/4569),
|
|
29
|
+
// we should always install polyfills on all Chromecast models.
|
|
29
30
|
// TODO: re-evaluate MediaCapabilities in the future versions of Chromecast.
|
|
30
31
|
// Since MediaCapabilities implementation is buggy in Apple browsers, we
|
|
31
32
|
// should always install polyfill for Apple browsers.
|
|
@@ -43,18 +44,18 @@ shaka.polyfill.MediaCapabilities = class {
|
|
|
43
44
|
// should always install polyfill for Tizen browsers.
|
|
44
45
|
// Since MediaCapabilities implementation is buggy in WebOS browsers, we
|
|
45
46
|
// should always install polyfill for WebOS browsers.
|
|
47
|
+
// Since MediaCapabilities implementation is buggy in EOS browsers, we
|
|
48
|
+
// should always install polyfill for EOS browsers.
|
|
46
49
|
let canUseNativeMCap = true;
|
|
47
50
|
if (shaka.util.Platform.isApple() ||
|
|
48
51
|
shaka.util.Platform.isPS5() ||
|
|
49
52
|
shaka.util.Platform.isPS4() ||
|
|
50
53
|
shaka.util.Platform.isWebOS() ||
|
|
51
54
|
shaka.util.Platform.isTizen() ||
|
|
52
|
-
shaka.util.Platform.isChromecast()
|
|
55
|
+
shaka.util.Platform.isChromecast() ||
|
|
56
|
+
shaka.util.Platform.isEOS()) {
|
|
53
57
|
canUseNativeMCap = false;
|
|
54
58
|
}
|
|
55
|
-
if (shaka.util.Platform.isAndroidCastDevice()) {
|
|
56
|
-
canUseNativeMCap = true;
|
|
57
|
-
}
|
|
58
59
|
if (canUseNativeMCap && navigator.mediaCapabilities) {
|
|
59
60
|
shaka.log.info(
|
|
60
61
|
'MediaCapabilities: Native mediaCapabilities support found.');
|
|
@@ -49,8 +49,6 @@ shaka.text.TtmlTextParser = class {
|
|
|
49
49
|
const ttsNs = TtmlTextParser.styleNs_;
|
|
50
50
|
const str = shaka.util.StringUtils.fromUTF8(data);
|
|
51
51
|
const cues = [];
|
|
52
|
-
const parser = new DOMParser();
|
|
53
|
-
let xml = null;
|
|
54
52
|
|
|
55
53
|
// dont try to parse empty string as
|
|
56
54
|
// DOMParser will not throw error but return an errored xml
|
|
@@ -58,9 +56,8 @@ shaka.text.TtmlTextParser = class {
|
|
|
58
56
|
return cues;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} catch (exception) {
|
|
59
|
+
const tt = XmlUtils.parseXmlString(str, 'tt');
|
|
60
|
+
if (!tt) {
|
|
64
61
|
throw new shaka.util.Error(
|
|
65
62
|
shaka.util.Error.Severity.CRITICAL,
|
|
66
63
|
shaka.util.Error.Category.TEXT,
|
|
@@ -68,104 +65,89 @@ shaka.text.TtmlTextParser = class {
|
|
|
68
65
|
'Failed to parse TTML.');
|
|
69
66
|
}
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
shaka.util.Error.Severity.CRITICAL,
|
|
76
|
-
shaka.util.Error.Category.TEXT,
|
|
77
|
-
shaka.util.Error.Code.INVALID_XML,
|
|
78
|
-
parserError.textContent);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const tt = xml.getElementsByTagName('tt')[0];
|
|
82
|
-
// TTML should always have tt element.
|
|
83
|
-
if (!tt) {
|
|
84
|
-
throw new shaka.util.Error(
|
|
85
|
-
shaka.util.Error.Severity.CRITICAL,
|
|
86
|
-
shaka.util.Error.Category.TEXT,
|
|
87
|
-
shaka.util.Error.Code.INVALID_XML,
|
|
88
|
-
'TTML does not contain <tt> tag.');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const body = tt.getElementsByTagName('body')[0];
|
|
92
|
-
if (!body) {
|
|
93
|
-
return [];
|
|
94
|
-
}
|
|
68
|
+
const body = tt.getElementsByTagName('body')[0];
|
|
69
|
+
if (!body) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
95
72
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
73
|
+
// Get the framerate, subFrameRate and frameRateMultiplier if applicable.
|
|
74
|
+
const frameRate = XmlUtils.getAttributeNSList(tt, ttpNs, 'frameRate');
|
|
75
|
+
const subFrameRate = XmlUtils.getAttributeNSList(
|
|
76
|
+
tt, ttpNs, 'subFrameRate');
|
|
77
|
+
const frameRateMultiplier =
|
|
78
|
+
XmlUtils.getAttributeNSList(tt, ttpNs, 'frameRateMultiplier');
|
|
79
|
+
const tickRate = XmlUtils.getAttributeNSList(tt, ttpNs, 'tickRate');
|
|
103
80
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
81
|
+
const cellResolution = XmlUtils.getAttributeNSList(
|
|
82
|
+
tt, ttpNs, 'cellResolution');
|
|
83
|
+
const spaceStyle = tt.getAttribute('xml:space') || 'default';
|
|
84
|
+
const extent = XmlUtils.getAttributeNSList(tt, ttsNs, 'extent');
|
|
108
85
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
86
|
+
if (spaceStyle != 'default' && spaceStyle != 'preserve') {
|
|
87
|
+
throw new shaka.util.Error(
|
|
88
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
89
|
+
shaka.util.Error.Category.TEXT,
|
|
90
|
+
shaka.util.Error.Code.INVALID_XML,
|
|
91
|
+
'Invalid xml:space value: ' + spaceStyle);
|
|
92
|
+
}
|
|
93
|
+
const whitespaceTrim = spaceStyle == 'default';
|
|
117
94
|
|
|
118
|
-
|
|
119
|
-
|
|
95
|
+
const rateInfo = new TtmlTextParser.RateInfo_(
|
|
96
|
+
frameRate, subFrameRate, frameRateMultiplier, tickRate);
|
|
120
97
|
|
|
121
|
-
|
|
122
|
-
|
|
98
|
+
const cellResolutionInfo =
|
|
99
|
+
TtmlTextParser.getCellResolution_(cellResolution);
|
|
123
100
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
101
|
+
const metadata = tt.getElementsByTagName('metadata')[0];
|
|
102
|
+
const metadataElements = metadata ? XmlUtils.getChildren(metadata) : [];
|
|
103
|
+
const styles = Array.from(tt.getElementsByTagName('style'));
|
|
104
|
+
const regionElements = Array.from(tt.getElementsByTagName('region'));
|
|
128
105
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
106
|
+
const cueRegions = [];
|
|
107
|
+
for (const region of regionElements) {
|
|
108
|
+
const cueRegion =
|
|
109
|
+
TtmlTextParser.parseCueRegion_(region, styles, extent);
|
|
110
|
+
if (cueRegion) {
|
|
111
|
+
cueRegions.push(cueRegion);
|
|
136
112
|
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// A <body> element should only contain <div> elements, not <p> or <span>
|
|
116
|
+
// elements. We used to allow this, but it is non-compliant, and the
|
|
117
|
+
// loose nature of our previous parser made it difficult to implement TTML
|
|
118
|
+
// nesting more fully.
|
|
119
|
+
if (XmlUtils.findChildren(body, 'p').length) {
|
|
120
|
+
throw new shaka.util.Error(
|
|
121
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
122
|
+
shaka.util.Error.Category.TEXT,
|
|
123
|
+
shaka.util.Error.Code.INVALID_TEXT_CUE,
|
|
124
|
+
'<p> can only be inside <div> in TTML');
|
|
125
|
+
}
|
|
137
126
|
|
|
138
|
-
|
|
139
|
-
//
|
|
140
|
-
|
|
141
|
-
// nesting more fully.
|
|
142
|
-
if (XmlUtils.findChildren(body, 'p').length) {
|
|
127
|
+
for (const div of XmlUtils.findChildren(body, 'div')) {
|
|
128
|
+
// A <div> element should only contain <p>, not <span>.
|
|
129
|
+
if (XmlUtils.findChildren(div, 'span').length) {
|
|
143
130
|
throw new shaka.util.Error(
|
|
144
131
|
shaka.util.Error.Severity.CRITICAL,
|
|
145
132
|
shaka.util.Error.Category.TEXT,
|
|
146
133
|
shaka.util.Error.Code.INVALID_TEXT_CUE,
|
|
147
|
-
'<
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
for (const div of XmlUtils.findChildren(body, 'div')) {
|
|
151
|
-
// A <div> element should only contain <p>, not <span>.
|
|
152
|
-
if (XmlUtils.findChildren(div, 'span').length) {
|
|
153
|
-
throw new shaka.util.Error(
|
|
154
|
-
shaka.util.Error.Severity.CRITICAL,
|
|
155
|
-
shaka.util.Error.Category.TEXT,
|
|
156
|
-
shaka.util.Error.Code.INVALID_TEXT_CUE,
|
|
157
|
-
'<span> can only be inside <p> in TTML');
|
|
158
|
-
}
|
|
134
|
+
'<span> can only be inside <p> in TTML');
|
|
159
135
|
}
|
|
136
|
+
}
|
|
160
137
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
138
|
+
const cue = TtmlTextParser.parseCue_(
|
|
139
|
+
body, time.periodStart, rateInfo, metadataElements, styles,
|
|
140
|
+
regionElements, cueRegions, whitespaceTrim,
|
|
141
|
+
cellResolutionInfo, /* parentCueElement= */ null,
|
|
142
|
+
/* isContent= */ false);
|
|
143
|
+
if (cue) {
|
|
144
|
+
// According to the TTML spec, backgrounds default to transparent.
|
|
145
|
+
// So default the background of the top-level element to transparent.
|
|
146
|
+
// Nested elements may override that background color already.
|
|
147
|
+
if (!cue.backgroundColor) {
|
|
148
|
+
cue.backgroundColor = 'transparent';
|
|
168
149
|
}
|
|
150
|
+
cues.push(cue);
|
|
169
151
|
}
|
|
170
152
|
|
|
171
153
|
return cues;
|
|
@@ -105,7 +105,7 @@ shaka.text.VttTextParser = class {
|
|
|
105
105
|
|
|
106
106
|
const rolloverSeconds =
|
|
107
107
|
shaka.text.VttTextParser.TS_ROLLOVER_ / mpegTimescale;
|
|
108
|
-
let segmentStart = time.segmentStart;
|
|
108
|
+
let segmentStart = time.segmentStart - time.periodStart;
|
|
109
109
|
while (segmentStart >= rolloverSeconds) {
|
|
110
110
|
segmentStart -= rolloverSeconds;
|
|
111
111
|
mpegTime += shaka.text.VttTextParser.TS_ROLLOVER_;
|
package/lib/util/error.js
CHANGED
|
@@ -1001,6 +1001,13 @@ shaka.util.Error.Code = {
|
|
|
1001
1001
|
*/
|
|
1002
1002
|
'MODIFY_OPERATION_NOT_SUPPORTED': 9016,
|
|
1003
1003
|
|
|
1004
|
+
/**
|
|
1005
|
+
* When attempting to open an indexedDB instance, nothing happened for long
|
|
1006
|
+
* enough for us to time out. This keeps the storage mechanism from hanging
|
|
1007
|
+
* indefinitely, if neither the success nor error callbacks are called.
|
|
1008
|
+
*/
|
|
1009
|
+
'INDEXED_DB_INIT_TIMED_OUT': 9017,
|
|
1010
|
+
|
|
1004
1011
|
/**
|
|
1005
1012
|
* CS IMA SDK, required for ad insertion, has not been included on the page.
|
|
1006
1013
|
*/
|
package/lib/util/periods.js
CHANGED
|
@@ -1180,15 +1180,6 @@ shaka.util.PeriodCombiner = class {
|
|
|
1180
1180
|
return false;
|
|
1181
1181
|
}
|
|
1182
1182
|
|
|
1183
|
-
// If the language doesn't match, but the candidate is the "primary"
|
|
1184
|
-
// language, then that should be preferred as a fallback.
|
|
1185
|
-
if (!best.primary && candidate.primary) {
|
|
1186
|
-
return true;
|
|
1187
|
-
}
|
|
1188
|
-
if (best.primary && !candidate.primary) {
|
|
1189
|
-
return false;
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
1183
|
// If language-based differences haven't decided this, look at roles. If
|
|
1193
1184
|
// the candidate has more roles in common with the output, upgrade to the
|
|
1194
1185
|
// candidate.
|
|
@@ -1222,6 +1213,15 @@ shaka.util.PeriodCombiner = class {
|
|
|
1222
1213
|
return false;
|
|
1223
1214
|
}
|
|
1224
1215
|
|
|
1216
|
+
// If the language doesn't match, but the candidate is the "primary"
|
|
1217
|
+
// language, then that should be preferred as a fallback.
|
|
1218
|
+
if (!best.primary && candidate.primary) {
|
|
1219
|
+
return true;
|
|
1220
|
+
}
|
|
1221
|
+
if (best.primary && !candidate.primary) {
|
|
1222
|
+
return false;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
1225
|
// If language-based and role-based features are equivalent, take the audio
|
|
1226
1226
|
// with the closes channel count to the output.
|
|
1227
1227
|
const channelsBetterOrWorse =
|
package/lib/util/platform.js
CHANGED
|
@@ -164,13 +164,27 @@ shaka.util.Platform = class {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
|
-
*
|
|
167
|
+
* Returns a major version number for Chrome, or Chromium-based browsers.
|
|
168
168
|
*
|
|
169
|
-
*
|
|
169
|
+
* For example:
|
|
170
|
+
* - Chrome 106.0.5249.61 returns 106.
|
|
171
|
+
* - Edge 106.0.1370.34 returns 106 (since this is based on Chromium).
|
|
172
|
+
* - Safari returns null (since this is independent of Chromium).
|
|
173
|
+
*
|
|
174
|
+
* @return {?number} A major version number or null if not Chromium-based.
|
|
170
175
|
*/
|
|
171
|
-
static
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
static chromeVersion() {
|
|
177
|
+
if (!shaka.util.Platform.userAgentContains_('Chrome')) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Looking for something like "Chrome/106.0.0.0".
|
|
182
|
+
const match = navigator.userAgent.match(/Chrome\/(\d+)/);
|
|
183
|
+
if (match) {
|
|
184
|
+
return parseInt(match[1], /* base= */ 10);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return null;
|
|
174
188
|
}
|
|
175
189
|
|
|
176
190
|
/**
|