Chromium Code Reviews| Index: content/renderer/media/webcontentdecryptionmodule_impl.cc |
| diff --git a/content/renderer/media/webcontentdecryptionmodule_impl.cc b/content/renderer/media/webcontentdecryptionmodule_impl.cc |
| index 9dcb39ee9ca98931c5f49c05035f805ed883e846..8ab053175dda19a63bb9b0ffcf62ef7923635fb1 100644 |
| --- a/content/renderer/media/webcontentdecryptionmodule_impl.cc |
| +++ b/content/renderer/media/webcontentdecryptionmodule_impl.cc |
| @@ -16,6 +16,7 @@ |
| #include "content/renderer/media/crypto/key_systems.h" |
| #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" |
| #include "media/base/media_keys.h" |
| +#include "net/base/mime_util.h" |
| #include "third_party/WebKit/public/platform/WebString.h" |
| #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| #include "url/gurl.h" |
| @@ -83,6 +84,103 @@ WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( |
| WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { |
| } |
| +// static |
| +blink::WebContentDecryptionModule::SupportsKeySystem |
| +WebContentDecryptionModuleImpl::IsKeySystemSupported( |
| + const blink::WebString& key_system, |
| + const blink::WebString& init_data_type, |
| + const blink::WebString& container, |
| + const blink::WebString& codecs, |
| + const blink::WebString& capability) { |
| + // 15-18. |
|
ddorwin
2014/09/13 01:20:46
It might help to say something like:
// Continue t
sandersd (OOO until July 31)
2014/09/22 23:45:54
Done.
|
| + if (!capability.isEmpty()) |
|
ddorwin
2014/09/13 01:20:46
I believe we need the following:
// Not currently
sandersd (OOO until July 31)
2014/09/22 23:45:53
Done.
|
| + return blink::WebContentDecryptionModule::IsNotSupported; |
|
ddorwin
2014/09/13 01:20:46
Should we move this to the end where it will be ev
sandersd (OOO until July 31)
2014/09/22 23:45:54
The only reason was that an early exit seemed like
|
| + |
| + // 1. If keySystem is an empty string or contains an unrecognized or |
|
ddorwin
2014/09/13 01:20:46
Half of step 1 is handled in Blink. The other half
sandersd (OOO until July 31)
2014/09/22 23:45:53
Done.
|
| + // unsupported Key System, return the empty string and abort these steps. |
| + // String comparison is case-sensitive. |
| + // 2. If the keySystem implementation is not available and usable, return the |
| + // empty string and abort these steps. |
| + const std::string key_system_ascii = key_system.utf8(); |
|
ddorwin
2014/09/13 01:20:46
Are we checking and rejecting non-ascii values in
sandersd (OOO until July 31)
2014/09/22 23:45:54
Because the spec didn't say to do that check, this
ddorwin
2014/09/23 22:48:15
FWIW, there is a note in the spec that lower-case
|
| + if (!IsSupportedKeySystem(key_system_ascii)) |
| + return blink::WebContentDecryptionModule::IsNotSupported; |
| + |
| + // 3. Follow the steps for the first matching condition from the following |
| + // list: |
| + // - If keySystem is a value that may be successfully passed to create() |
| + // Let probably result be "probably" |
| + // - Otherwise (as may be the case for strings that are only used for |
| + // discovery) |
| + // Let probably result be "maybe". |
| + blink::WebContentDecryptionModule::SupportsKeySystem probably_result = |
| + blink::WebContentDecryptionModule::MayBeSupported; |
| + if (IsConcreteSupportedKeySystem(key_system_ascii)) |
|
ddorwin
2014/09/13 01:20:46
nit: Convert to ? :.
sandersd (OOO until July 31)
2014/09/22 23:45:53
Done.
|
| + probably_result = blink::WebContentDecryptionModule::IsSupported; |
| + |
| + // 4. If initDataType was not provided, follow the steps for the first |
| + // matching condition from the following list and abort these steps: |
| + // - If the user agent is not confident that the keySystem implementation |
| + // is available and usable |
| + // Return "maybe" |
| + // - Otherwise |
| + // Return probably result. |
| + if (init_data_type.isEmpty()) |
| + return probably_result; |
| + |
| + // 5. If initDataType is an empty string or contains an unrecognized or |
| + // unsupported initialization data type, return the empty string and abort |
| + // these steps. String comparison is case-sensitive. |
| + // 6. If initDataType is not an initialization data type supported by the |
| + // keySystem implementation, return the empty string and abort these steps. |
| + // 7. If the keySystem implementation supporting initDataType is not available |
| + // and usable, return the empty string and abort these steps. |
| + const std::string init_data_type_ascii = init_data_type.utf8(); |
| + if (!IsSupportedKeySystemWithInitDataType(key_system_ascii, |
| + init_data_type_ascii)) |
| + return blink::WebContentDecryptionModule::IsNotSupported; |
| + |
| + // Exclude some specific combinations that don't make much sense. |
| + if ((key_system_ascii == "mp4" && init_data_type_ascii == "webm") || |
|
ddorwin
2014/09/13 01:20:46
This should be comparing the container.
sandersd (OOO until July 31)
2014/09/22 23:45:53
Whoops, thanks!
|
| + (key_system_ascii == "webm" && init_data_type_ascii == "cenc")) |
|
ddorwin
2014/09/13 01:20:46
Let's move this code to key_systems.cc into a func
sandersd (OOO until July 31)
2014/09/22 23:45:53
Done.
|
| + return blink::WebContentDecryptionModule::IsNotSupported; |
| + |
| + // 8. If contentType was not provided, follow the steps for the first matching |
| + // condition from the following list and abort these steps: |
| + // - If the user agent is not confident that the keySystem implementation |
| + // supporting initDataType is available and usable |
| + // Return "maybe" |
| + // - Otherwise |
| + // Return probably result. |
| + if (container.isEmpty()) |
| + return probably_result; |
| + |
| + // 9. If contentType is an empty string or contains an invalid or |
|
ddorwin
2014/09/13 01:20:46
As noted in the Blink CL, these should be there, e
sandersd (OOO until July 31)
2014/09/22 23:45:54
Done.
|
| + // unrecognized MIME type, return the empty string and abort these steps. |
| + // 10. Let container be the container type specified by contentType. |
| + // 11. Let parameters be the RFC 6381 parameters, if any, specified by |
| + // contentType. |
| + // 12. Let media types be the set of media types specified by parameters. It |
| + // may be empty. The case-sensitivity of string comparisons is determined |
| + // by the appropriate RFC or other specification. |
| + // 13. If the user agent does not support container, return the empty string |
| + // and abort these steps. The case-sensitivity of string comparisons is |
| + // determined by the appropriate RFC. |
| + // 14. If the user agent and keySystem implementation do not support playback |
| + // of encrypted media data for all media types, return the empty string |
| + // and abort these steps. |
| + const std::string container_ascii = container.utf8(); |
| + bool strip_codec_suffixes = !net::IsStrictMediaMimeType(container_ascii); |
|
ddorwin
2014/09/13 01:20:46
TODO: Do a better job validating codecs: crbug.com
sandersd (OOO until July 31)
2014/09/22 23:45:54
Done.
|
| + std::vector<std::string> codec_vector; |
| + net::ParseCodecString(codecs.utf8(), &codec_vector, strip_codec_suffixes); |
|
ddorwin
2014/09/13 01:20:46
note: need to ensure we have checked ASCII before
sandersd (OOO until July 31)
2014/09/22 23:45:54
Acknowledged.
|
| + if (!IsSupportedKeySystemWithMediaMimeType( |
| + container_ascii, codec_vector, key_system_ascii)) |
| + return blink::WebContentDecryptionModule::IsNotSupported; |
| + |
| + // TODO(sandersd): If the codecs are all unambiguous and supported, return |
| + // IsSupported. |
|
ddorwin
2014/09/13 01:20:46
probably_result, right?
sandersd (OOO until July 31)
2014/09/22 23:45:54
That's correct, but because we don't check that th
|
| + return blink::WebContentDecryptionModule::MayBeSupported; |
| +} |
| + |
| // The caller owns the created session. |
| blink::WebContentDecryptionModuleSession* |
| WebContentDecryptionModuleImpl::createSession() { |