shaka-player 4.12.5 → 4.12.7
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/controls.css +1 -1
- package/dist/controls.css.map +1 -1
- package/dist/deps.js +3 -3
- package/dist/locales.js +34 -34
- package/dist/shaka-player.compiled.d.ts +12 -4
- package/dist/shaka-player.compiled.debug.d.ts +12 -4
- package/dist/shaka-player.compiled.debug.externs.js +10 -6
- package/dist/shaka-player.compiled.debug.js +439 -425
- package/dist/shaka-player.compiled.debug.map +3 -3
- package/dist/shaka-player.compiled.externs.js +10 -6
- package/dist/shaka-player.compiled.js +1352 -1345
- package/dist/shaka-player.compiled.map +3 -3
- package/dist/shaka-player.ui.d.ts +12 -4
- package/dist/shaka-player.ui.debug.d.ts +12 -4
- package/dist/shaka-player.ui.debug.externs.js +10 -6
- package/dist/shaka-player.ui.debug.js +439 -425
- package/dist/shaka-player.ui.debug.map +3 -3
- package/dist/shaka-player.ui.externs.js +10 -6
- package/dist/shaka-player.ui.js +1596 -1588
- package/dist/shaka-player.ui.map +3 -3
- package/externs/shaka/codecs.js +21 -0
- package/externs/shaka/offline.js +4 -0
- package/lib/cast/cast_utils.js +1 -0
- package/lib/cea/cea708_service.js +27 -2
- package/lib/cea/dtvcc_packet_builder.js +15 -0
- package/lib/dash/dash_parser.js +5 -2
- package/lib/dash/mpd_utils.js +7 -4
- package/lib/dash/segment_template.js +30 -17
- package/lib/hls/hls_parser.js +31 -7
- package/lib/media/drm_engine.js +55 -12
- package/lib/media/media_source_engine.js +127 -41
- package/lib/media/segment_utils.js +65 -47
- package/lib/net/http_fetch_plugin.js +1 -1
- package/lib/net/http_plugin_utils.js +3 -0
- package/lib/offline/download_info.js +5 -0
- package/lib/offline/download_manager.js +54 -0
- package/lib/offline/manifest_converter.js +1 -0
- package/lib/offline/storage.js +11 -2
- package/lib/player.js +53 -22
- package/lib/polyfill/media_capabilities.js +1 -1
- package/lib/text/simple_text_displayer.js +9 -1
- package/lib/text/ui_text_displayer.js +2 -14
- package/lib/transmuxer/aac_transmuxer.js +11 -3
- package/lib/transmuxer/ac3_transmuxer.js +11 -3
- package/lib/transmuxer/ec3_transmuxer.js +11 -3
- package/lib/transmuxer/h264.js +143 -70
- package/lib/transmuxer/mp3_transmuxer.js +11 -3
- package/lib/transmuxer/ts_transmuxer.js +68 -28
- package/lib/util/drm_utils.js +20 -0
- package/lib/util/stream_utils.js +0 -60
- package/lib/util/ts_parser.js +111 -85
- package/package.json +1 -1
- package/ui/audio_language_selection.js +1 -1
- package/ui/controls.js +4 -0
- package/ui/fast_forward_button.js +7 -0
- package/ui/play_button.js +1 -1
- package/ui/playback_rate_selection.js +1 -1
- package/ui/rewind_button.js +7 -0
|
@@ -333,6 +333,11 @@ shaka.media.MediaSourceEngine = class {
|
|
|
333
333
|
for (const ref of stream.segmentIndex) {
|
|
334
334
|
const mimeType = ref.mimeType || stream.mimeType || '';
|
|
335
335
|
let codecs = ref.codecs || stream.codecs || '';
|
|
336
|
+
// Optimization for the case where the codecs and mimetype of the stream
|
|
337
|
+
// match the reference.
|
|
338
|
+
if (mimeType == stream.mimeType && codecs == stream.codecs) {
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
336
341
|
// Don't check the same combination of mimetype + codecs twice.
|
|
337
342
|
const combo = mimeType + ':' + codecs;
|
|
338
343
|
if (seenCombos.has(combo)) {
|
|
@@ -551,6 +556,13 @@ shaka.media.MediaSourceEngine = class {
|
|
|
551
556
|
const ContentType = shaka.util.ManifestParserUtils.ContentType;
|
|
552
557
|
|
|
553
558
|
await this.mediaSourceOpen_;
|
|
559
|
+
if (this.ended() || this.closed()) {
|
|
560
|
+
shaka.log.alwaysError('Expected MediaSource to be open during init(); ' +
|
|
561
|
+
'reopening the media source.');
|
|
562
|
+
this.mediaSourceOpen_ = new shaka.util.PublicPromise();
|
|
563
|
+
this.mediaSource_ = this.createMediaSource(this.mediaSourceOpen_);
|
|
564
|
+
await this.mediaSourceOpen_;
|
|
565
|
+
}
|
|
554
566
|
|
|
555
567
|
this.sequenceMode_ = sequenceMode;
|
|
556
568
|
this.manifestType_ = manifestType;
|
|
@@ -724,6 +736,17 @@ shaka.media.MediaSourceEngine = class {
|
|
|
724
736
|
return this.mediaSource_ ? this.mediaSource_.readyState == 'ended' : true;
|
|
725
737
|
}
|
|
726
738
|
|
|
739
|
+
/**
|
|
740
|
+
* @return {boolean} True if the MediaSource is in an "closed" state, or if
|
|
741
|
+
* the object has been destroyed.
|
|
742
|
+
*/
|
|
743
|
+
closed() {
|
|
744
|
+
if (this.reloadingMediaSource_) {
|
|
745
|
+
return false;
|
|
746
|
+
}
|
|
747
|
+
return this.mediaSource_ ? this.mediaSource_.readyState == 'closed' : true;
|
|
748
|
+
}
|
|
749
|
+
|
|
727
750
|
/**
|
|
728
751
|
* Gets the first timestamp in buffer for the given content type.
|
|
729
752
|
*
|
|
@@ -918,14 +941,18 @@ shaka.media.MediaSourceEngine = class {
|
|
|
918
941
|
.box('moof', Mp4Parser.children)
|
|
919
942
|
.box('traf', Mp4Parser.children)
|
|
920
943
|
.fullBox('tfdt', (box) => {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
944
|
+
if (!parsedMedia) {
|
|
945
|
+
goog.asserts.assert(
|
|
946
|
+
box.version == 0 || box.version == 1,
|
|
947
|
+
'TFDT version can only be 0 or 1');
|
|
948
|
+
const parsed = shaka.util.Mp4BoxParsers.parseTFDTInaccurate(
|
|
949
|
+
box.reader, box.version);
|
|
950
|
+
startTime = parsed.baseMediaDecodeTime / timescale;
|
|
951
|
+
parsedMedia = true;
|
|
952
|
+
if (!hasEmsg) {
|
|
953
|
+
box.parser.stop();
|
|
954
|
+
}
|
|
955
|
+
}
|
|
929
956
|
}).parse(data, /* partialOkay= */ true);
|
|
930
957
|
if (parsedMedia && reference.timestampOffset == 0) {
|
|
931
958
|
timestamp = startTime;
|
|
@@ -1210,7 +1237,16 @@ shaka.media.MediaSourceEngine = class {
|
|
|
1210
1237
|
this.audioCompensation_.resolve(compensation);
|
|
1211
1238
|
}
|
|
1212
1239
|
}
|
|
1213
|
-
|
|
1240
|
+
let realTimestamp = timestamp;
|
|
1241
|
+
const RAW_FORMATS = shaka.util.MimeUtils.RAW_FORMATS;
|
|
1242
|
+
// For formats without containers and using segments mode, we need to
|
|
1243
|
+
// adjust TimestampOffset relative to 0 because segments do not have
|
|
1244
|
+
// any timestamp information.
|
|
1245
|
+
if (!this.sequenceMode_ &&
|
|
1246
|
+
RAW_FORMATS.includes(this.sourceBufferTypes_[contentType])) {
|
|
1247
|
+
realTimestamp = 0;
|
|
1248
|
+
}
|
|
1249
|
+
const calculatedTimestampOffset = reference.startTime - realTimestamp;
|
|
1214
1250
|
const timestampOffsetDifference =
|
|
1215
1251
|
Math.abs(timestampOffset - calculatedTimestampOffset);
|
|
1216
1252
|
if ((timestampOffsetDifference >= 0.001 || seeked || adaptation) &&
|
|
@@ -1567,6 +1603,13 @@ shaka.media.MediaSourceEngine = class {
|
|
|
1567
1603
|
return;
|
|
1568
1604
|
}
|
|
1569
1605
|
|
|
1606
|
+
// Avoid changing timestampOffset when the difference is less than 100 ms
|
|
1607
|
+
// from the end of the current buffer.
|
|
1608
|
+
const bufferEnd = this.bufferEnd(contentType);
|
|
1609
|
+
if (bufferEnd && Math.abs(bufferEnd - timestampOffset) < 0.1) {
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1570
1613
|
// Queue an abort() to help MSE splice together overlapping segments.
|
|
1571
1614
|
// We set appendWindowEnd when we change periods in DASH content, and the
|
|
1572
1615
|
// period transition may result in overlap.
|
|
@@ -1608,7 +1651,7 @@ shaka.media.MediaSourceEngine = class {
|
|
|
1608
1651
|
// don't call it again. Also do not call if readyState is
|
|
1609
1652
|
// 'closed' (not attached to video element) since it is not a
|
|
1610
1653
|
// valid operation.
|
|
1611
|
-
if (this.ended() || this.
|
|
1654
|
+
if (this.ended() || this.closed()) {
|
|
1612
1655
|
return;
|
|
1613
1656
|
}
|
|
1614
1657
|
// Tizen won't let us pass undefined, but it will let us omit the
|
|
@@ -2224,32 +2267,32 @@ shaka.media.MediaSourceEngine = class {
|
|
|
2224
2267
|
}
|
|
2225
2268
|
|
|
2226
2269
|
/**
|
|
2227
|
-
* Codec switch if necessary, this will not resolve until the codec
|
|
2228
|
-
* switch is over.
|
|
2229
2270
|
* @param {shaka.util.ManifestParserUtils.ContentType} contentType
|
|
2230
2271
|
* @param {string} mimeType
|
|
2231
2272
|
* @param {string} codecs
|
|
2232
|
-
* @
|
|
2233
|
-
*
|
|
2234
|
-
*
|
|
2235
|
-
* false otherwise.
|
|
2273
|
+
* @return {{transmuxer: ?shaka.extern.Transmuxer,
|
|
2274
|
+
* transmuxerMuxed: boolean, basicType: string, codec: string,
|
|
2275
|
+
* mimeType: string}}
|
|
2236
2276
|
* @private
|
|
2237
2277
|
*/
|
|
2238
|
-
|
|
2278
|
+
getRealInfo_(contentType, mimeType, codecs) {
|
|
2239
2279
|
const ContentType = shaka.util.ManifestParserUtils.ContentType;
|
|
2240
|
-
if (contentType == ContentType.TEXT) {
|
|
2241
|
-
return false;
|
|
2242
|
-
}
|
|
2243
2280
|
const MimeUtils = shaka.util.MimeUtils;
|
|
2244
|
-
const currentCodec = MimeUtils.getNormalizedCodec(
|
|
2245
|
-
MimeUtils.getCodecs(this.sourceBufferTypes_[contentType]));
|
|
2246
|
-
const currentBasicType = MimeUtils.getBasicType(
|
|
2247
|
-
this.sourceBufferTypes_[contentType]);
|
|
2248
|
-
|
|
2249
2281
|
/** @type {?shaka.extern.Transmuxer} */
|
|
2250
2282
|
let transmuxer;
|
|
2251
2283
|
let transmuxerMuxed = false;
|
|
2252
|
-
|
|
2284
|
+
const audioCodec = shaka.util.ManifestParserUtils.guessCodecsSafe(
|
|
2285
|
+
ContentType.AUDIO, (codecs || '').split(','));
|
|
2286
|
+
const videoCodec = shaka.util.ManifestParserUtils.guessCodecsSafe(
|
|
2287
|
+
ContentType.VIDEO, (codecs || '').split(','));
|
|
2288
|
+
let codec = videoCodec;
|
|
2289
|
+
if (contentType == ContentType.AUDIO) {
|
|
2290
|
+
codec = audioCodec;
|
|
2291
|
+
}
|
|
2292
|
+
if (!codec) {
|
|
2293
|
+
codec = codecs;
|
|
2294
|
+
}
|
|
2295
|
+
let newMimeType = shaka.util.MimeUtils.getFullType(mimeType, codec);
|
|
2253
2296
|
let needTransmux = this.config_.forceTransmux;
|
|
2254
2297
|
if (!shaka.media.Capabilities.isTypeSupported(newMimeType) ||
|
|
2255
2298
|
(!this.sequenceMode_ &&
|
|
@@ -2259,36 +2302,79 @@ shaka.media.MediaSourceEngine = class {
|
|
|
2259
2302
|
const TransmuxerEngine = shaka.transmuxer.TransmuxerEngine;
|
|
2260
2303
|
if (needTransmux) {
|
|
2261
2304
|
const newMimeTypeWithAllCodecs =
|
|
2262
|
-
shaka.util.MimeUtils.getFullTypeWithAllCodecs(mimeType,
|
|
2305
|
+
shaka.util.MimeUtils.getFullTypeWithAllCodecs(mimeType, codec);
|
|
2263
2306
|
const transmuxerPlugin =
|
|
2264
2307
|
TransmuxerEngine.findTransmuxer(newMimeTypeWithAllCodecs);
|
|
2265
2308
|
if (transmuxerPlugin) {
|
|
2266
2309
|
transmuxer = transmuxerPlugin();
|
|
2267
|
-
const audioCodec = shaka.util.ManifestParserUtils.guessCodecsSafe(
|
|
2268
|
-
ContentType.AUDIO, (codecs || '').split(','));
|
|
2269
|
-
const videoCodec = shaka.util.ManifestParserUtils.guessCodecsSafe(
|
|
2270
|
-
ContentType.VIDEO, (codecs || '').split(','));
|
|
2271
2310
|
if (audioCodec && videoCodec) {
|
|
2272
2311
|
transmuxerMuxed = true;
|
|
2273
|
-
let codec = videoCodec;
|
|
2274
|
-
if (contentType == ContentType.AUDIO) {
|
|
2275
|
-
codec = audioCodec;
|
|
2276
|
-
}
|
|
2277
|
-
newMimeType = transmuxer.convertCodecs(contentType,
|
|
2278
|
-
shaka.util.MimeUtils.getFullTypeWithAllCodecs(mimeType, codec));
|
|
2279
|
-
} else {
|
|
2280
|
-
newMimeType =
|
|
2281
|
-
transmuxer.convertCodecs(contentType, newMimeTypeWithAllCodecs);
|
|
2282
2312
|
}
|
|
2313
|
+
newMimeType =
|
|
2314
|
+
transmuxer.convertCodecs(contentType, newMimeTypeWithAllCodecs);
|
|
2283
2315
|
}
|
|
2284
2316
|
}
|
|
2285
2317
|
|
|
2286
2318
|
const newCodec = MimeUtils.getNormalizedCodec(
|
|
2287
2319
|
MimeUtils.getCodecs(newMimeType));
|
|
2288
2320
|
const newBasicType = MimeUtils.getBasicType(newMimeType);
|
|
2321
|
+
return {
|
|
2322
|
+
transmuxer,
|
|
2323
|
+
transmuxerMuxed,
|
|
2324
|
+
basicType: newBasicType,
|
|
2325
|
+
codec: newCodec,
|
|
2326
|
+
mimeType: newMimeType,
|
|
2327
|
+
};
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
/**
|
|
2331
|
+
* Codec switch if necessary, this will not resolve until the codec
|
|
2332
|
+
* switch is over.
|
|
2333
|
+
* @param {shaka.util.ManifestParserUtils.ContentType} contentType
|
|
2334
|
+
* @param {string} mimeType
|
|
2335
|
+
* @param {string} codecs
|
|
2336
|
+
* @param {!Map.<shaka.util.ManifestParserUtils.ContentType,
|
|
2337
|
+
* shaka.extern.Stream>} streamsByType
|
|
2338
|
+
* @return {!Promise.<boolean>} true if there was a codec switch,
|
|
2339
|
+
* false otherwise.
|
|
2340
|
+
* @private
|
|
2341
|
+
*/
|
|
2342
|
+
async codecSwitchIfNecessary_(contentType, mimeType, codecs, streamsByType) {
|
|
2343
|
+
const ContentType = shaka.util.ManifestParserUtils.ContentType;
|
|
2344
|
+
if (contentType == ContentType.TEXT) {
|
|
2345
|
+
return false;
|
|
2346
|
+
}
|
|
2347
|
+
const MimeUtils = shaka.util.MimeUtils;
|
|
2348
|
+
const currentCodec = MimeUtils.getNormalizedCodec(
|
|
2349
|
+
MimeUtils.getCodecs(this.sourceBufferTypes_[contentType]));
|
|
2350
|
+
const currentBasicType = MimeUtils.getBasicType(
|
|
2351
|
+
this.sourceBufferTypes_[contentType]);
|
|
2352
|
+
|
|
2353
|
+
const realInfo = this.getRealInfo_(contentType, mimeType, codecs);
|
|
2354
|
+
const transmuxer = realInfo.transmuxer;
|
|
2355
|
+
const transmuxerMuxed = realInfo.transmuxerMuxed;
|
|
2356
|
+
const newBasicType = realInfo.basicType;
|
|
2357
|
+
const newCodec = realInfo.codec;
|
|
2358
|
+
const newMimeType = realInfo.mimeType;
|
|
2359
|
+
|
|
2360
|
+
let muxedContentCheck = true;
|
|
2361
|
+
if (transmuxerMuxed) {
|
|
2362
|
+
const muxedRealInfo =
|
|
2363
|
+
this.getRealInfo_(ContentType.AUDIO, mimeType, codecs);
|
|
2364
|
+
const muxedCurrentCodec = MimeUtils.getNormalizedCodec(
|
|
2365
|
+
MimeUtils.getCodecs(this.sourceBufferTypes_[ContentType.AUDIO]));
|
|
2366
|
+
const muxedCurrentBasicType = MimeUtils.getBasicType(
|
|
2367
|
+
this.sourceBufferTypes_[ContentType.AUDIO]);
|
|
2368
|
+
muxedContentCheck = muxedCurrentCodec == muxedRealInfo.codec &&
|
|
2369
|
+
muxedCurrentBasicType == muxedRealInfo.basicType;
|
|
2370
|
+
if (muxedRealInfo.transmuxer) {
|
|
2371
|
+
muxedRealInfo.transmuxer.destroy();
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2289
2374
|
|
|
2290
2375
|
// Current/new codecs base and basic type match then no need to switch
|
|
2291
|
-
if (currentCodec === newCodec && currentBasicType === newBasicType
|
|
2376
|
+
if (currentCodec === newCodec && currentBasicType === newBasicType &&
|
|
2377
|
+
muxedContentCheck) {
|
|
2292
2378
|
if (this.transmuxers_[contentType] && !transmuxer) {
|
|
2293
2379
|
this.transmuxers_[contentType].destroy();
|
|
2294
2380
|
delete this.transmuxers_[contentType];
|
|
@@ -48,9 +48,12 @@ shaka.media.SegmentUtils = class {
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* @param {!BufferSource} data
|
|
51
|
+
* @param {boolean} disableAudio
|
|
52
|
+
* @param {boolean} disableVideo
|
|
53
|
+
* @param {boolean} disableText
|
|
51
54
|
* @return {?shaka.media.SegmentUtils.BasicInfo}
|
|
52
55
|
*/
|
|
53
|
-
static getBasicInfoFromTs(data) {
|
|
56
|
+
static getBasicInfoFromTs(data, disableAudio, disableVideo, disableText) {
|
|
54
57
|
const uint8ArrayData = shaka.util.BufferUtils.toUint8(data);
|
|
55
58
|
const tsParser = new shaka.util.TsParser().parse(uint8ArrayData);
|
|
56
59
|
const tsCodecs = tsParser.getCodecs();
|
|
@@ -58,57 +61,71 @@ shaka.media.SegmentUtils = class {
|
|
|
58
61
|
const codecs = [];
|
|
59
62
|
let hasAudio = false;
|
|
60
63
|
let hasVideo = false;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
if (!disableAudio) {
|
|
65
|
+
switch (tsCodecs.audio) {
|
|
66
|
+
case 'aac':
|
|
67
|
+
case 'aac-loas':
|
|
68
|
+
if (tsParser.getAudioData().length) {
|
|
69
|
+
codecs.push('mp4a.40.2');
|
|
70
|
+
hasAudio = true;
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case 'mp3':
|
|
74
|
+
if (tsParser.getAudioData().length) {
|
|
75
|
+
codecs.push('mp4a.40.34');
|
|
76
|
+
hasAudio = true;
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case 'ac3':
|
|
80
|
+
if (tsParser.getAudioData().length) {
|
|
81
|
+
codecs.push('ac-3');
|
|
82
|
+
hasAudio = true;
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case 'ec3':
|
|
86
|
+
if (tsParser.getAudioData().length) {
|
|
87
|
+
codecs.push('ec-3');
|
|
88
|
+
hasAudio = true;
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case 'opus':
|
|
92
|
+
if (tsParser.getAudioData().length) {
|
|
93
|
+
codecs.push('opus');
|
|
94
|
+
hasAudio = true;
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
83
98
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
if (!disableVideo) {
|
|
100
|
+
switch (tsCodecs.video) {
|
|
101
|
+
case 'avc':
|
|
102
|
+
if (videoInfo.codec) {
|
|
103
|
+
codecs.push(videoInfo.codec);
|
|
104
|
+
} else {
|
|
105
|
+
codecs.push('avc1.42E01E');
|
|
106
|
+
}
|
|
107
|
+
hasVideo = true;
|
|
108
|
+
break;
|
|
109
|
+
case 'hvc':
|
|
110
|
+
if (videoInfo.codec) {
|
|
111
|
+
codecs.push(videoInfo.codec);
|
|
112
|
+
} else {
|
|
113
|
+
codecs.push('hvc1.1.6.L93.90');
|
|
114
|
+
}
|
|
115
|
+
hasVideo = true;
|
|
116
|
+
break;
|
|
117
|
+
case 'av1':
|
|
118
|
+
codecs.push('av01.0.01M.08');
|
|
119
|
+
hasVideo = true;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
105
122
|
}
|
|
106
123
|
if (!codecs.length) {
|
|
107
124
|
return null;
|
|
108
125
|
}
|
|
109
126
|
const onlyAudio = hasAudio && !hasVideo;
|
|
110
127
|
const closedCaptions = new Map();
|
|
111
|
-
if (hasVideo) {
|
|
128
|
+
if (hasVideo && !disableText) {
|
|
112
129
|
const captionParser = new shaka.media.ClosedCaptionParser('video/mp2t');
|
|
113
130
|
captionParser.parseFrom(data);
|
|
114
131
|
for (const stream of captionParser.getStreams()) {
|
|
@@ -135,9 +152,10 @@ shaka.media.SegmentUtils = class {
|
|
|
135
152
|
/**
|
|
136
153
|
* @param {?BufferSource} initData
|
|
137
154
|
* @param {!BufferSource} data
|
|
155
|
+
* @param {boolean} disableText
|
|
138
156
|
* @return {?shaka.media.SegmentUtils.BasicInfo}
|
|
139
157
|
*/
|
|
140
|
-
static getBasicInfoFromMp4(initData, data) {
|
|
158
|
+
static getBasicInfoFromMp4(initData, data, disableText) {
|
|
141
159
|
const Mp4Parser = shaka.util.Mp4Parser;
|
|
142
160
|
const SegmentUtils = shaka.media.SegmentUtils;
|
|
143
161
|
|
|
@@ -412,7 +430,7 @@ shaka.media.SegmentUtils = class {
|
|
|
412
430
|
}
|
|
413
431
|
const onlyAudio = hasAudio && !hasVideo;
|
|
414
432
|
const closedCaptions = new Map();
|
|
415
|
-
if (hasVideo) {
|
|
433
|
+
if (hasVideo && !disableText) {
|
|
416
434
|
const captionParser = new shaka.media.ClosedCaptionParser('video/mp4');
|
|
417
435
|
if (initData) {
|
|
418
436
|
captionParser.init(initData);
|
|
@@ -109,7 +109,7 @@ shaka.net.HttpFetchPlugin = class {
|
|
|
109
109
|
const fetch = shaka.net.HttpFetchPlugin.fetch_;
|
|
110
110
|
const ReadableStream = shaka.net.HttpFetchPlugin.ReadableStream_;
|
|
111
111
|
let response;
|
|
112
|
-
let arrayBuffer;
|
|
112
|
+
let arrayBuffer = new ArrayBuffer(0);
|
|
113
113
|
let loaded = 0;
|
|
114
114
|
let lastLoaded = 0;
|
|
115
115
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
goog.provide('shaka.net.HttpPluginUtils');
|
|
8
8
|
|
|
9
|
+
goog.require('goog.asserts');
|
|
9
10
|
goog.require('shaka.log');
|
|
10
11
|
goog.require('shaka.util.Error');
|
|
11
12
|
goog.require('shaka.util.StringUtils');
|
|
@@ -27,6 +28,8 @@ shaka.net.HttpPluginUtils = class {
|
|
|
27
28
|
* @return {!shaka.extern.Response}
|
|
28
29
|
*/
|
|
29
30
|
static makeResponse(headers, data, status, uri, responseURL, requestType) {
|
|
31
|
+
goog.asserts.assert(data, 'Data should be non-null!');
|
|
32
|
+
|
|
30
33
|
if (status >= 200 && status <= 299 && status != 202) {
|
|
31
34
|
// Most 2xx HTTP codes are success cases.
|
|
32
35
|
/** @type {shaka.extern.Response} */
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
goog.provide('shaka.offline.DownloadInfo');
|
|
8
8
|
|
|
9
9
|
goog.require('shaka.util.Networking');
|
|
10
|
+
goog.require('shaka.util.Uint8ArrayUtils');
|
|
10
11
|
goog.requireType('shaka.media.InitSegmentReference');
|
|
11
12
|
goog.requireType('shaka.media.SegmentReference');
|
|
12
13
|
|
|
@@ -43,6 +44,10 @@ shaka.offline.DownloadInfo = class {
|
|
|
43
44
|
* @return {string}
|
|
44
45
|
*/
|
|
45
46
|
static idForSegmentRef(ref) {
|
|
47
|
+
const segmentData = ref.getSegmentData();
|
|
48
|
+
if (segmentData) {
|
|
49
|
+
return shaka.util.Uint8ArrayUtils.toBase64(segmentData);
|
|
50
|
+
}
|
|
46
51
|
// Escape the URIs using encodeURI, to make sure that a weirdly formed URI
|
|
47
52
|
// cannot cause two unrelated refs to be considered equivalent.
|
|
48
53
|
const removeSprites = (uri) => {
|
|
@@ -168,6 +168,60 @@ shaka.offline.DownloadManager = class {
|
|
|
168
168
|
return newPromise;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Add already-downloaded data to a group.
|
|
173
|
+
*
|
|
174
|
+
* @param {number} groupId
|
|
175
|
+
* The group to add this segment to. If the group does not exist, a new
|
|
176
|
+
* group will be created.
|
|
177
|
+
* @param {!BufferSource} queueData
|
|
178
|
+
* @param {number} estimateId
|
|
179
|
+
* @param {boolean} isInitSegment
|
|
180
|
+
* @param {function(BufferSource):!Promise} onDownloaded
|
|
181
|
+
* The callback for when this request has been downloaded. Downloading for
|
|
182
|
+
* |group| will pause until the promise returned by |onDownloaded| resolves.
|
|
183
|
+
* @return {!Promise} Resolved when this request is complete.
|
|
184
|
+
*/
|
|
185
|
+
queueData(groupId, queueData, estimateId, isInitSegment, onDownloaded) {
|
|
186
|
+
this.destroyer_.ensureNotDestroyed();
|
|
187
|
+
|
|
188
|
+
const group = this.groups_.get(groupId) || Promise.resolve();
|
|
189
|
+
|
|
190
|
+
// Add another download to the group.
|
|
191
|
+
const newPromise = group.then(() => {
|
|
192
|
+
// Make sure we stop downloading if we have been destroyed.
|
|
193
|
+
if (this.destroyer_.destroyed()) {
|
|
194
|
+
throw new shaka.util.Error(
|
|
195
|
+
shaka.util.Error.Severity.CRITICAL,
|
|
196
|
+
shaka.util.Error.Category.STORAGE,
|
|
197
|
+
shaka.util.Error.Code.OPERATION_ABORTED);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Update initData
|
|
201
|
+
if (isInitSegment) {
|
|
202
|
+
const segmentBytes = shaka.util.BufferUtils.toUint8(queueData);
|
|
203
|
+
const pssh = new shaka.util.Pssh(segmentBytes);
|
|
204
|
+
for (const key in pssh.data) {
|
|
205
|
+
const index = Number(key);
|
|
206
|
+
const data = pssh.data[index];
|
|
207
|
+
const systemId = pssh.systemIds[index];
|
|
208
|
+
this.onInitData_(data, systemId);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Update all our internal stats.
|
|
213
|
+
this.estimator_.close(estimateId, queueData.byteLength);
|
|
214
|
+
this.onProgress_(
|
|
215
|
+
this.estimator_.getEstimatedProgress(),
|
|
216
|
+
this.estimator_.getTotalDownloaded());
|
|
217
|
+
|
|
218
|
+
return onDownloaded(queueData);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
this.groups_.set(groupId, newPromise);
|
|
222
|
+
return newPromise;
|
|
223
|
+
}
|
|
224
|
+
|
|
171
225
|
/**
|
|
172
226
|
* Add additional async work to the group work queue.
|
|
173
227
|
*
|
|
@@ -216,6 +216,7 @@ shaka.offline.ManifestConverter = class {
|
|
|
216
216
|
spatialAudio: streamDB.spatialAudio,
|
|
217
217
|
closedCaptions: streamDB.closedCaptions,
|
|
218
218
|
tilesLayout: streamDB.tilesLayout,
|
|
219
|
+
mssPrivateData: streamDB.mssPrivateData,
|
|
219
220
|
accessibilityPurpose: null,
|
|
220
221
|
external: streamDB.external,
|
|
221
222
|
fastSwitching: streamDB.fastSwitching,
|
package/lib/offline/storage.js
CHANGED
|
@@ -511,8 +511,16 @@ shaka.offline.Storage = class {
|
|
|
511
511
|
pendingDataSize += data.byteLength;
|
|
512
512
|
};
|
|
513
513
|
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
const ref = /** @type {!shaka.media.SegmentReference} */ (
|
|
515
|
+
download.ref);
|
|
516
|
+
const segmentData = ref.getSegmentData();
|
|
517
|
+
if (segmentData) {
|
|
518
|
+
downloader.queueData(download.groupId,
|
|
519
|
+
segmentData, estimateId, isInitSegment, onDownloaded);
|
|
520
|
+
} else {
|
|
521
|
+
downloader.queue(download.groupId,
|
|
522
|
+
request, estimateId, isInitSegment, onDownloaded);
|
|
523
|
+
}
|
|
516
524
|
}
|
|
517
525
|
await downloader.waitToFinish();
|
|
518
526
|
|
|
@@ -1608,6 +1616,7 @@ shaka.offline.Storage = class {
|
|
|
1608
1616
|
spatialAudio: stream.spatialAudio,
|
|
1609
1617
|
closedCaptions: stream.closedCaptions,
|
|
1610
1618
|
tilesLayout: stream.tilesLayout,
|
|
1619
|
+
mssPrivateData: stream.mssPrivateData,
|
|
1611
1620
|
external: stream.external,
|
|
1612
1621
|
fastSwitching: stream.fastSwitching,
|
|
1613
1622
|
isAudioMuxedInVideo: stream.isAudioMuxedInVideo,
|