Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(DRM): pass preferredKeySystems to filterManifest() #6468

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/media/manifest_filterer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ shaka.media.ManifestFilterer = class {
*/
async filterManifestWithStreamUtils_(manifest) {
goog.asserts.assert(manifest, 'Manifest should exist!');
await shaka.util.StreamUtils.filterManifest(this.drmEngine_, manifest);
await shaka.util.StreamUtils.filterManifest(this.drmEngine_, manifest,
this.config_.drm.preferredKeySystems);
this.checkPlayableVariants_(manifest);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/offline/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ shaka.offline.Storage = class {
// Filter the manifest based on what we know MediaCapabilities will be able
// to play later (no point storing something we can't play).
await shaka.util.StreamUtils.filterManifestByMediaCapabilities(
drmEngine, manifest, config.offline.usePersistentLicense);
drmEngine, manifest, config.offline.usePersistentLicense,
config.drm.preferredKeySystems);

// Gather all tracks.
const allTracks = [];
Expand Down
11 changes: 7 additions & 4 deletions lib/util/stream_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ shaka.util.StreamUtils = class {
*
* @param {shaka.media.DrmEngine} drmEngine
* @param {shaka.extern.Manifest} manifest
* @param {!Array<string>=} preferredKeySystems
*/
static async filterManifest(drmEngine, manifest) {
static async filterManifest(drmEngine, manifest, preferredKeySystems = []) {
await shaka.util.StreamUtils.filterManifestByMediaCapabilities(
drmEngine, manifest, manifest.offlineSessionIds.length > 0);
drmEngine, manifest, manifest.offlineSessionIds.length > 0,
preferredKeySystems);
shaka.util.StreamUtils.filterTextStreams_(manifest);
await shaka.util.StreamUtils.filterImageStreams_(manifest);
}
Expand All @@ -353,15 +355,16 @@ shaka.util.StreamUtils = class {
* @param {shaka.media.DrmEngine} drmEngine
* @param {shaka.extern.Manifest} manifest
* @param {boolean} usePersistentLicenses
* @param {!Array<string>} preferredKeySystems
*/
static async filterManifestByMediaCapabilities(
drmEngine, manifest, usePersistentLicenses) {
drmEngine, manifest, usePersistentLicenses, preferredKeySystems) {
goog.asserts.assert(navigator.mediaCapabilities,
'MediaCapabilities should be valid.');

await shaka.util.StreamUtils.getDecodingInfosForVariants(
manifest.variants, usePersistentLicenses, /* srcEquals= */ false,
/** preferredKeySystems= */ []);
preferredKeySystems);

let keySystem = null;
if (drmEngine) {
Expand Down