diff --git a/lib/polyfill/encryption_scheme.js b/lib/polyfill/encryption_scheme.js index 40ae224934..74b163e8ad 100644 --- a/lib/polyfill/encryption_scheme.js +++ b/lib/polyfill/encryption_scheme.js @@ -26,4 +26,4 @@ shaka.polyfill.EncryptionScheme = class { }; // Install at a low priority so that other EME polyfills go first. -shaka.polyfill.register(shaka.polyfill.EncryptionScheme.install, -1); +shaka.polyfill.register(shaka.polyfill.EncryptionScheme.install, -2); diff --git a/lib/polyfill/media_capabilities.js b/lib/polyfill/media_capabilities.js index a97d02d37d..1dfde7ca3d 100644 --- a/lib/polyfill/media_capabilities.js +++ b/lib/polyfill/media_capabilities.js @@ -143,5 +143,6 @@ shaka.polyfill.MediaCapabilities = class { } }; - -shaka.polyfill.register(shaka.polyfill.MediaCapabilities.install); +// Install at a lower priority than MediaSource polyfill, so that we have +// MediaSource available first. +shaka.polyfill.register(shaka.polyfill.MediaCapabilities.install, -1); diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 236b030f00..3c54229902 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -449,6 +449,7 @@ shaka.util.StreamUtils = class { const allCodecs = video.codecs.split(','); videoCodecs = shaka.util.ManifestParserUtils.guessCodecs( ContentType.VIDEO, allCodecs); + videoCodecs = shaka.util.StreamUtils.patchVp9(videoCodecs); const audioCodecs = shaka.util.ManifestParserUtils.guessCodecs( ContentType.AUDIO, allCodecs); @@ -462,6 +463,7 @@ shaka.util.StreamUtils = class { spatialRendering: false, }; } + videoCodecs = shaka.util.StreamUtils.patchVp9(videoCodecs); const fullType = shaka.util.MimeUtils.getFullOrConvertedType( video.mimeType, videoCodecs, ContentType.VIDEO); // VideoConfiguration @@ -591,6 +593,21 @@ shaka.util.StreamUtils = class { return configs; } + /** + * MediaCapabilities supports 'vp09...' codecs, but not 'vp9'. Translate vp9 + * codec strings into 'vp09...', to allow such content to play with + * mediaCapabilities enabled. + * + * @param {string} codec + * @return {string} + */ + static patchVp9(codec) { + if (codec == 'vp9') { + return 'vp09.00.10.08'; + } + return codec; + } + /** * Alters the given Manifest to filter out any streams uncompatible with the diff --git a/test/util/stream_utils_unit.js b/test/util/stream_utils_unit.js index 455c9fb94c..c9249d7a83 100644 --- a/test/util/stream_utils_unit.js +++ b/test/util/stream_utils_unit.js @@ -633,6 +633,21 @@ describe('StreamUtils', () => { /* useMediaCapabilities= */ true); expect(manifest.variants.length).toBe(1); }); + + it('supports VP9 codec', async () => { + manifest = shaka.test.ManifestGenerator.generate((manifest) => { + manifest.addVariant(0, (variant) => { + variant.addVideo(1, (stream) => { + stream.mime('video/webm', 'vp9'); + }); + }); + }); + + await shaka.util.StreamUtils.filterManifest( + fakeDrmEngine, /* currentVariant= */ null, manifest, + /* useMediaCapabilities= */ true); + expect(manifest.variants.length).toBe(1); + }); }); describe('chooseCodecsAndFilterManifest', () => {