| Index: third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp
|
| diff --git a/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp b/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp
|
| index fbeffbbd610019dfd1d6c4bb317d754e1ea229bb..411573296ea19ebcfa88e09514a5eb5dd70b9c26 100644
|
| --- a/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp
|
| +++ b/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp
|
| @@ -27,6 +27,7 @@
|
| #include "public/platform/WebVector.h"
|
| #include "wtf/Vector.h"
|
| #include "wtf/text/WTFString.h"
|
| +#include <algorithm>
|
|
|
| namespace blink {
|
|
|
| @@ -79,6 +80,11 @@ static WebVector<WebEncryptedMediaSessionType> convertSessionTypes(const Vector<
|
| return result;
|
| }
|
|
|
| +static bool AreCodecsSpecified(const WebMediaKeySystemMediaCapability& capability)
|
| +{
|
| + return !capability.codecs.isEmpty();
|
| +}
|
| +
|
| // This class allows capabilities to be checked and a MediaKeySystemAccess
|
| // object to be created asynchronously.
|
| class MediaKeySystemAccessInitializer final : public EncryptedMediaRequest {
|
| @@ -111,6 +117,12 @@ private:
|
| // See http://crbug.com/482277
|
| void checkVideoCapabilityRobustness() const;
|
|
|
| + // Generate deprecation warning and log UseCounter if configuration
|
| + // contains only container-only contentType strings.
|
| + // TODO(jrummell): Remove once this is no longer allowed.
|
| + // See http://crbug.com/605661.
|
| + void checkEmptyCodecs(const WebMediaKeySystemConfiguration&);
|
| +
|
| Member<ScriptPromiseResolver> m_resolver;
|
| const String m_keySystem;
|
| WebVector<WebMediaKeySystemConfiguration> m_supportedConfigurations;
|
| @@ -154,6 +166,8 @@ MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer(ScriptState* sc
|
|
|
| void MediaKeySystemAccessInitializer::requestSucceeded(WebContentDecryptionModuleAccess* access)
|
| {
|
| + checkEmptyCodecs(access->getConfiguration());
|
| +
|
| m_resolver->resolve(new MediaKeySystemAccess(m_keySystem, adoptPtr(access)));
|
| m_resolver.clear();
|
| }
|
| @@ -202,6 +216,33 @@ void MediaKeySystemAccessInitializer::checkVideoCapabilityRobustness() const
|
| }
|
| }
|
|
|
| +void MediaKeySystemAccessInitializer::checkEmptyCodecs(const WebMediaKeySystemConfiguration& config)
|
| +{
|
| + // This is only checking for empty codecs in the selected configuration,
|
| + // as apps may pass container only contentType strings for compatibility
|
| + // with other implementations.
|
| + // This will only check that all returned capabilities do not contain
|
| + // codecs. This avoids alerting on configurations that will continue
|
| + // to succeed in the future once strict checking is enforced.
|
| + bool areAllAudioCodecsEmpty = false;
|
| + if (config.hasAudioCapabilities && !config.audioCapabilities.isEmpty()) {
|
| + areAllAudioCodecsEmpty = std::find_if(config.audioCapabilities.begin(), config.audioCapabilities.end(), AreCodecsSpecified)
|
| + == config.audioCapabilities.end();
|
| + }
|
| +
|
| + bool areAllVideoCodecsEmpty = false;
|
| + if (config.hasVideoCapabilities && !config.videoCapabilities.isEmpty()) {
|
| + areAllVideoCodecsEmpty = std::find_if(config.videoCapabilities.begin(), config.videoCapabilities.end(), AreCodecsSpecified)
|
| + == config.videoCapabilities.end();
|
| + }
|
| +
|
| + if (areAllAudioCodecsEmpty || areAllVideoCodecsEmpty) {
|
| + Deprecation::countDeprecation(m_resolver->getExecutionContext(), UseCounter::EncryptedMediaAllSelectedContentTypesMissingCodecs);
|
| + } else {
|
| + UseCounter::count(m_resolver->getExecutionContext(), UseCounter::EncryptedMediaAllSelectedContentTypesHaveCodecs);
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess(
|
|
|