diff --git a/lib/offline/storage.js b/lib/offline/storage.js index bb1c804ab6..3f1c00067e 100644 --- a/lib/offline/storage.js +++ b/lib/offline/storage.js @@ -491,12 +491,11 @@ shaka.offline.Storage = class { manifest, config.offline.usePersistentLicense); } else { StreamUtils.filterManifestByMediaSource(manifest); + // Filter the manifest based on what we know our drm system will support + // playing later. + StreamUtils.filterManifestByDrm(manifest, drmEngine); } - // Filter the manifest based on what we know our drm system will support - // playing later. - StreamUtils.filterManifestByDrm(manifest, drmEngine); - // Gather all tracks. const allTracks = []; diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 5a71739fcf..236b030f00 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -287,18 +287,11 @@ shaka.util.StreamUtils = class { */ static async filterManifest( drmEngine, currentVariant, manifest, useMediaCapabilities) { - // Once we use decodingInfo() with drmInfo of the variants to get media - // keys, the decodingInfo result can tell us whether the variant's DRM is - // supported by the platform. This way, filterManifestByDrm_() won't be - // needed. - // TODO: remove the first parameter 'drmEngine' and the function - // 'filterManifestByDrm_'. - shaka.util.StreamUtils.filterManifestByDrm(manifest, drmEngine); - if (useMediaCapabilities) { await shaka.util.StreamUtils.filterManifestByMediaCapabilities(manifest, manifest.offlineSessionIds.length > 0); } else { + shaka.util.StreamUtils.filterManifestByDrm(manifest, drmEngine); shaka.util.StreamUtils.filterManifestByMediaSource(manifest); } shaka.util.StreamUtils.filterManifestByCurrentVariant( diff --git a/test/player_unit.js b/test/player_unit.js index 1662a088d1..07599aeba9 100644 --- a/test/player_unit.js +++ b/test/player_unit.js @@ -2789,12 +2789,22 @@ describe('Player', () => { expect(tracks[0].id).toBe(4); }); - it('removes if key system does not support codec', async () => { + + for (const useMediaCapabilities of [true, false]) { + const isEnabled = useMediaCapabilities ? 'enabled' : 'disabled'; + it('removes if key system does not support codec with ' + + 'MediaCapabilities ' + isEnabled, async () => { + await testWithUnsupportedCodec(useMediaCapabilities); + }); + } + + async function testWithUnsupportedCodec(useMediaCapabilities) { manifest = shaka.test.ManifestGenerator.generate((manifest) => { manifest.addVariant(0, (variant) => { variant.addVideo(1, (stream) => { stream.encrypted = true; - stream.mimeType = 'video/unsupported'; + stream.mimeType = 'video'; + stream.codecs = 'unsupported'; stream.addDrmInfo('foo.bar'); }); }); @@ -2806,27 +2816,35 @@ describe('Player', () => { }); }); - // We must be careful that our video/unsupported was not filtered out - // because of MSE support. We are specifically testing EME-based - // filtering of codecs. - expect(MediaSource.isTypeSupported('video/unsupported')).toBe(true); - - const decodingResult = await navigator.mediaCapabilities.decodingInfo({ - 'video': {'contentType': 'video/unsupported'}, - }); - expect(decodingResult.supported).toBe(true); - - // Make sure that drm engine will reject the variant with an unsupported - // video mime type. - drmEngine.supportsVariant.and.callFake((variant) => { - return variant.video.mimeType != 'video/unsupported'; - }); + if (useMediaCapabilities) { + navigator.mediaCapabilities.decodingInfo = async (config) => { + await Promise.resolve(); + const videoType = config['video'] ? config['video'].contentType : ''; + if (videoType.includes('video') && + videoType.includes('unsupported')) { + return {supported: false}; + } else { + return {supported: true}; + } + }; + } else { + // We must be careful that our video/unsupported was not filtered out + // because of MSE support. We are specifically testing EME-based + // filtering of codecs. + expect(MediaSource.isTypeSupported('video/unsupported')).toBe(true); + // Make sure that drm engine will reject the variant with an unsupported + // video mime type. + drmEngine.supportsVariant.and.callFake((variant) => { + return variant.video.codecs != 'unsupported'; + }); + } + player.configure({useMediaCapabilities: useMediaCapabilities}); await player.load(fakeManifestUri, 0, fakeMimeType); const tracks = player.getVariantTracks(); expect(tracks.length).toBe(1); expect(tracks[0].id).toBe(1); - }); + } it('removes based on bandwidth', async () => { manifest = shaka.test.ManifestGenerator.generate((manifest) => {