Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into offlineFailingSilen…
Browse files Browse the repository at this point in the history
…tlyBranch
  • Loading branch information
joeyparrish committed Feb 27, 2024
2 parents 5b0335d + bca9f25 commit 699c576
Show file tree
Hide file tree
Showing 47 changed files with 324 additions and 151 deletions.
19 changes: 19 additions & 0 deletions build/shaka-lab.yaml
Expand Up @@ -19,6 +19,10 @@ vars:
media.gmp-manager.updateEnabled: true
# Overrides Firefox's Linux-specific default setting to disable DRM.
media.eme.enabled: true
# Disable GPU acceleration to avoid contention for hardware resources
# during parallel testing and to create more stability for screenshots.
media.hardware-video-decoding.enabled: false
media.hardware-video-decoding.force-enabled: false

basic_chrome_config: &basic_chrome_config
goog:chromeOptions:
Expand All @@ -37,6 +41,9 @@ vars:
- "--disable-background-media-suspend"
- "--disable-background-timer-throttling"
- "--disable-backgrounding-occluded-windows"
# Disable GPU acceleration to avoid contention for hardware resources
# during parallel testing and to create more stability for screenshots.
- "--disable-gpu"

# Instruct chromedriver not to disable component updater. The component
# updater must run in order for the Widevine CDM to be available when
Expand All @@ -55,6 +62,9 @@ vars:
- "--disable-background-media-suspend"
- "--disable-background-timer-throttling"
- "--disable-backgrounding-occluded-windows"
# Disable GPU acceleration to avoid contention for hardware resources
# during parallel testing and to create more stability for screenshots.
- "--disable-gpu"

# Instruct edgedriver not to disable component updater. The component
# updater must run in order for the Widevine CDM to be available when
Expand Down Expand Up @@ -88,6 +98,12 @@ vars:
# --unsafely-allow... does not work.
- "--user-data-dir=/data/data/com.android.chrome/cache"

excludeSwitches:
# On Android, we must override the --disable-gpu set in the general
# Chrome settings. This flag is not supported on Android, where GPU is
# required.
- "disable-gpu"

# Once the new session request reaches chromedriver, it will take
# the androidPackage option as a request to start Chrome through
# adb on the tethered device.
Expand Down Expand Up @@ -119,6 +135,9 @@ vars:
- "--disable-background-media-suspend"
- "--disable-background-timer-throttling"
- "--disable-backgrounding-occluded-windows"
# Disable GPU acceleration to avoid contention for hardware resources
# during parallel testing and to create more stability for screenshots.
- "--disable-gpu"

safari_tp_config: &safari_tp_config
safari.options:
Expand Down
6 changes: 4 additions & 2 deletions docs/tutorials/upgrade.md
Expand Up @@ -96,8 +96,10 @@ application:
- Configuration changes:
- `streaming.forceTransmuxTS` has been renamed to `streaming.forceTransmux`
(deprecated in v4.3.0)
- `manifest.dash.manifestPreprocessor` callback now receives a type of `shaka.externs.xml.Node` instead of `Element`.
- `manifest.mss.manifestPreprocessor` callback now receives a type of `shaka.externs.xml.Node` instead of `Element`.
- Callbacks that used to accept `Element` now accept `shaka.externs.xml.Node`:
(`manifest.dash.manifestPreprocessor` and `manifest.mss.manifestPreprocessor`).
`getAttribute()` and `textContent` results must now be decoded if they might contain
escape sequences. You can use `shaka.util.StringUtils.htmlUnescape` for this purpose.
- `streaming.useNativeHlsOnSafari` has removed. Now we have another config to do the same for FairPlay `streaming.useNativeHlsForFairPlay` or for HLS (any browser) `streaming.preferNativeHls`.

- Plugin changes:
Expand Down
2 changes: 1 addition & 1 deletion lib/ads/ad_manager.js
Expand Up @@ -656,7 +656,7 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
*/
getServerSideCuePoints() {
shaka.Deprecate.deprecateFeature(5,
'AdManager',
'AdManager.getServerSideCuePoints',
'Please use getCuePoints function.');
return this.getCuePoints();
}
Expand Down
7 changes: 5 additions & 2 deletions lib/dash/content_protection.js
Expand Up @@ -191,6 +191,7 @@ shaka.dash.ContentProtection = class {
* @return {string}
*/
static getWidevineLicenseUrl(element) {
const StringUtils = shaka.util.StringUtils;
const dashIfLaurlNode = shaka.util.TXml.findChildNS(
element.node, shaka.dash.ContentProtection.DashIfNamespaceUri_,
'Laurl',
Expand All @@ -204,7 +205,8 @@ shaka.dash.ContentProtection = class {
const mslaurlNode = shaka.util.TXml.findChildNS(
element.node, 'urn:microsoft', 'laurl');
if (mslaurlNode) {
return mslaurlNode.attributes['licenseUrl'] || '';
return StringUtils.htmlUnescape(
mslaurlNode.attributes['licenseUrl']) || '';
}
return '';
}
Expand Down Expand Up @@ -642,7 +644,8 @@ shaka.dash.ContentProtection = class {
}

const ivHex = cryptoPeriod.attributes['IV'];
const keyUri = cryptoPeriod.attributes['keyUriTemplate'];
const keyUri = shaka.util.StringUtils.htmlUnescape(
cryptoPeriod.attributes['keyUriTemplate']);
if (!ivHex || !keyUri) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
Expand Down
10 changes: 8 additions & 2 deletions lib/dash/segment_base.js
Expand Up @@ -16,6 +16,7 @@ goog.require('shaka.media.WebmSegmentIndexParser');
goog.require('shaka.util.Error');
goog.require('shaka.util.ManifestParserUtils');
goog.require('shaka.util.ObjectUtils');
goog.require('shaka.util.StringUtils');
goog.require('shaka.util.TXml');
goog.requireType('shaka.dash.DashParser');
goog.requireType('shaka.media.PresentationTimeline');
Expand All @@ -39,6 +40,7 @@ shaka.dash.SegmentBase = class {
const MpdUtils = shaka.dash.MpdUtils;
const TXml = shaka.util.TXml;
const ManifestParserUtils = shaka.util.ManifestParserUtils;
const StringUtils = shaka.util.StringUtils;

const initialization =
MpdUtils.inheritChild(context, callback, 'Initialization');
Expand All @@ -49,7 +51,9 @@ shaka.dash.SegmentBase = class {
let resolvedUris = context.representation.getBaseUris();
const uri = initialization.attributes['sourceURL'];
if (uri) {
resolvedUris = ManifestParserUtils.resolveUris(resolvedUris, [uri]);
resolvedUris = ManifestParserUtils.resolveUris(resolvedUris, [
StringUtils.htmlUnescape(uri),
]);
}

let startByte = 0;
Expand Down Expand Up @@ -244,13 +248,15 @@ shaka.dash.SegmentBase = class {
const ManifestParserUtils = shaka.util.ManifestParserUtils;
const MpdUtils = shaka.dash.MpdUtils;
const SegmentBase = shaka.dash.SegmentBase;
const StringUtils = shaka.util.StringUtils;

const representationIndex = MpdUtils.inheritChild(
context, SegmentBase.fromInheritance_, 'RepresentationIndex');

let indexUris = context.representation.getBaseUris();
if (representationIndex) {
const representationUri = representationIndex.attributes['sourceURL'];
const representationUri =
StringUtils.htmlUnescape(representationIndex.attributes['sourceURL']);
if (representationUri) {
indexUris = ManifestParserUtils.resolveUris(
indexUris, [representationUri]);
Expand Down
4 changes: 3 additions & 1 deletion lib/dash/segment_list.js
Expand Up @@ -16,6 +16,7 @@ goog.require('shaka.media.SegmentReference');
goog.require('shaka.util.Error');
goog.require('shaka.util.Functional');
goog.require('shaka.util.ManifestParserUtils');
goog.require('shaka.util.StringUtils');
goog.require('shaka.util.TXml');
goog.requireType('shaka.dash.DashParser');
goog.requireType('shaka.media.PresentationTimeline');
Expand Down Expand Up @@ -290,6 +291,7 @@ shaka.dash.SegmentList = class {
].filter(Functional.isNotNull);

const TXml = shaka.util.TXml;
const StringUtils = shaka.util.StringUtils;
// Search each SegmentList for one with at least one SegmentURL element,
// select the first one, and convert each SegmentURL element to a tuple.
return segmentLists
Expand All @@ -305,7 +307,7 @@ shaka.dash.SegmentList = class {
'attribute or SegmentTimeline, which must be accurate.');
}

const uri = urlNode.attributes['media'];
const uri = StringUtils.htmlUnescape(urlNode.attributes['media']);
const range = TXml.parseAttr(
urlNode, 'mediaRange', TXml.parseRange,
{start: 0, end: null});
Expand Down
7 changes: 5 additions & 2 deletions lib/dash/segment_template.js
Expand Up @@ -17,6 +17,7 @@ goog.require('shaka.util.Error');
goog.require('shaka.util.IReleasable');
goog.require('shaka.util.ManifestParserUtils');
goog.require('shaka.util.ObjectUtils');
goog.require('shaka.util.StringUtils');
goog.requireType('shaka.dash.DashParser');
goog.requireType('shaka.media.PresentationTimeline');

Expand Down Expand Up @@ -195,6 +196,7 @@ shaka.dash.SegmentTemplate = class {
static parseSegmentTemplateInfo_(context) {
const SegmentTemplate = shaka.dash.SegmentTemplate;
const MpdUtils = shaka.dash.MpdUtils;
const StringUtils = shaka.util.StringUtils;
const segmentInfo =
MpdUtils.parseSegmentInfo(context, SegmentTemplate.fromInheritance_);

Expand All @@ -211,7 +213,7 @@ shaka.dash.SegmentTemplate = class {
unscaledPresentationTimeOffset:
segmentInfo.unscaledPresentationTimeOffset,
timeline: segmentInfo.timeline,
mediaTemplate: media,
mediaTemplate: media && StringUtils.htmlUnescape(media),
indexTemplate: index,
};
}
Expand Down Expand Up @@ -534,11 +536,12 @@ shaka.dash.SegmentTemplate = class {
const ManifestParserUtils = shaka.util.ManifestParserUtils;
const SegmentTemplate = shaka.dash.SegmentTemplate;

const initialization = MpdUtils.inheritAttribute(
let initialization = MpdUtils.inheritAttribute(
context, SegmentTemplate.fromInheritance_, 'initialization');
if (!initialization) {
return null;
}
initialization = shaka.util.StringUtils.htmlUnescape(initialization);

const repId = context.representation.id;
const bandwidth = context.bandwidth || null;
Expand Down
2 changes: 1 addition & 1 deletion lib/deprecate/deprecate.js
Expand Up @@ -107,7 +107,7 @@ shaka.Deprecate = class {
libraryVersion,
'. Additional information:',
description,
].join('');
].join(' ');

shaka.log.alwaysError(errorMessage);
goog.asserts.assert(false, errorMessage);
Expand Down
25 changes: 22 additions & 3 deletions lib/hls/hls_parser.js
Expand Up @@ -31,6 +31,7 @@ goog.require('shaka.util.Error');
goog.require('shaka.util.FakeEvent');
goog.require('shaka.util.LanguageUtils');
goog.require('shaka.util.ManifestParserUtils');
goog.require('shaka.util.Networking');
goog.require('shaka.util.OperationManager');
goog.require('shaka.util.Pssh');
goog.require('shaka.media.SegmentUtils');
Expand Down Expand Up @@ -912,8 +913,11 @@ shaka.hls.HlsParser = class {
playlist, middleSegment.tags, getUris);
this.mapTagToInitSegmentRefMap_.clear();
if (initSegmentRef) {
const initSegmentRequest = shaka.net.NetworkingEngine.makeRequest(
initSegmentRef.getUris(), this.config_.retryParameters);
const initSegmentRequest = shaka.util.Networking.createSegmentRequest(
initSegmentRef.getUris(),
initSegmentRef.getStartByte(),
initSegmentRef.getEndByte(),
this.config_.retryParameters);
const initType =
shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT;
const initResponse = await this.makeNetworkRequest_(
Expand Down Expand Up @@ -4151,7 +4155,22 @@ shaka.hls.HlsParser = class {
* @return {?shaka.extern.DrmInfo}
* @private
*/
static identityDrmParser_(drmTag) {
static identityDrmParser_(drmTag, mimeType) {
if (mimeType == 'video/mp2t') {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED);
}

if (shaka.util.Platform.isMediaKeysPolyfilled()) {
throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code
.HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED);
}

const method = drmTag.getRequiredAttrValue('METHOD');
const VALID_METHODS = ['SAMPLE-AES', 'SAMPLE-AES-CTR'];
if (!VALID_METHODS.includes(method)) {
Expand Down
52 changes: 2 additions & 50 deletions lib/media/drm_engine.js
Expand Up @@ -1218,56 +1218,8 @@ shaka.media.DrmEngine = class {
return null;
}

const StringUtils = shaka.util.StringUtils;
const Uint8ArrayUtils = shaka.util.Uint8ArrayUtils;
const keys = [];
const keyIds = [];

clearKeys.forEach((key, keyId) => {
let kid = keyId;
if (kid.length != 22) {
kid = Uint8ArrayUtils.toBase64(
Uint8ArrayUtils.fromHex(keyId), false);
}
let k = key;
if (k.length != 22) {
k = Uint8ArrayUtils.toBase64(
Uint8ArrayUtils.fromHex(key), false);
}
const keyObj = {
kty: 'oct',
kid: kid,
k: k,
};

keys.push(keyObj);
keyIds.push(keyObj.kid);
});

const jwkSet = {keys: keys};
const license = JSON.stringify(jwkSet);

// Use the keyids init data since is suggested by EME.
// Suggestion: https://bit.ly/2JYcNTu
// Format: https://www.w3.org/TR/eme-initdata-keyids/
const initDataStr = JSON.stringify({'kids': keyIds});
const initData =
shaka.util.BufferUtils.toUint8(StringUtils.toUTF8(initDataStr));
const initDatas = [{initData: initData, initDataType: 'keyids'}];

return {
keySystem: 'org.w3.clearkey',
licenseServerUri: 'data:application/json;base64,' + window.btoa(license),
distinctiveIdentifierRequired: false,
persistentStateRequired: false,
audioRobustness: '',
videoRobustness: '',
serverCertificate: null,
serverCertificateUri: '',
sessionType: '',
initData: initDatas,
keyIds: new Set(keyIds),
};
const ManifestParserUtils = shaka.util.ManifestParserUtils;
return ManifestParserUtils.createDrmInfoFromClearKeys(clearKeys);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/media/manifest_parser.js
Expand Up @@ -28,7 +28,7 @@ shaka.media.ManifestParser = class {
*/
static registerParserByExtension(extension, parserFactory) {
shaka.Deprecate.deprecateFeature(5,
'ManifestParser',
'ManifestParser.registerParserByExtension',
'Please use an ManifestParser with registerParserByMime function.');
}

Expand Down Expand Up @@ -125,7 +125,8 @@ shaka.media.ManifestParser = class {
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.UNABLE_TO_GUESS_MANIFEST_TYPE,
uri);
uri,
mimeType);
}


Expand Down
2 changes: 1 addition & 1 deletion lib/media/segment_utils.js
Expand Up @@ -349,7 +349,7 @@ shaka.media.SegmentUtils = class {
// This signals an encrypted sample, which we can go inside of to
// find the codec used.
// Note: If encrypted, you can only have audio or video, not both.
.box('enca', Mp4Parser.visualSampleEntry)
.box('enca', Mp4Parser.audioSampleEntry)
.box('encv', Mp4Parser.visualSampleEntry)
.box('sinf', Mp4Parser.children)
.box('frma', (box) => {
Expand Down
8 changes: 4 additions & 4 deletions lib/player.js
Expand Up @@ -752,7 +752,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
// player having been initialized.
if (mediaElement) {
shaka.Deprecate.deprecateFeature(5,
'Player',
'Player w/ mediaElement',
'Please migrate from initializing Player with a mediaElement; ' +
'use the attach method instead.');
this.attach(mediaElement, /* initializeMediaSource= */ true);
Expand Down Expand Up @@ -1532,19 +1532,19 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
this.abrManagerFactory_ = preloadManager.getAbrManagerFactory();
if (typeof this.abrManager_.setMediaElement != 'function') {
shaka.Deprecate.deprecateFeature(5,
'AbrManager',
'AbrManager w/o setMediaElement',
'Please use an AbrManager with setMediaElement function.');
this.abrManager_.setMediaElement = () => {};
}
if (typeof this.abrManager_.setCmsdManager != 'function') {
shaka.Deprecate.deprecateFeature(5,
'AbrManager',
'AbrManager w/o setCmsdManager',
'Please use an AbrManager with setCmsdManager function.');
this.abrManager_.setCmsdManager = () => {};
}
if (typeof this.abrManager_.trySuggestStreams != 'function') {
shaka.Deprecate.deprecateFeature(5,
'AbrManager',
'AbrManager w/o trySuggestStreams',
'Please use an AbrManager with trySuggestStreams function.');
this.abrManager_.trySuggestStreams = () => {};
}
Expand Down

0 comments on commit 699c576

Please sign in to comment.