Chromium Code Reviews| Index: webkit/media/supported_key_systems.cc |
| diff --git a/webkit/media/supported_key_systems.cc b/webkit/media/supported_key_systems.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d6e1a235ffe8b001672dbc5d7809dbfc8e84bbc2 |
| --- /dev/null |
| +++ b/webkit/media/supported_key_systems.cc |
| @@ -0,0 +1,80 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "webkit/media/supported_key_systems.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| + |
| +namespace webkit_media { |
| + |
| +namespace { |
| + |
| +const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
| + |
| +struct MediaFormatAndKeySystem { |
| + const char* mime_type; |
| + const char* codec; |
| + const char* key_system; |
| +}; |
| + |
| + |
| +static const MediaFormatAndKeySystem |
| +supported_format_key_system_combinations[] = { |
| + // TODO(ddorwin): Reconsider based on how usage of this class evolves. |
| + // For now, this class is stateless, so we do not have the opportunity to |
| + // build a list using ParseCodecString() like MimeUtil. Therfore, the |
| + // following line must be separate entries. |
| + // { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, |
| + { "video/webm", "vorbis", kClearKeyKeySystem }, |
| + { "video/webm", "vp8", kClearKeyKeySystem }, |
| + { "video/webm", "vp8.0", kClearKeyKeySystem }, |
| + { "audio/webm", "vorbis", kClearKeyKeySystem }, |
| + { "video/webm", "", kClearKeyKeySystem }, |
| + { "audio/webm", "", kClearKeyKeySystem } |
| +}; |
| + |
| +} // namespace |
| + |
| +bool SupportedKeySystems::isKeySystemSupported( |
| + const WebKit::WebString& keySystem) { |
| + if (keySystem == kClearKeyKeySystem) |
| + return true; |
| + return false; |
| +} |
| + |
| +bool SupportedKeySystems::IsSupportedKeySystemWithMediaMimeType( |
| + const std::string& mime_type, |
| + const std::vector<std::string>& codecs, |
| + const std::string& key_system) { |
| + if (codecs.empty()) |
| + return IsSupportedKeySystemWithContainerAndCodec(mime_type, "", key_system); |
| + |
| + for (size_t i = 0; i < codecs.size(); ++i) { |
| + if (!IsSupportedKeySystemWithContainerAndCodec(mime_type, |
|
scherkus (not reviewing)
2012/04/12 20:18:41
nit: move all these params to next line so it look
ddorwin
2012/04/12 23:41:23
Done.
|
| + codecs[i], |
| + key_system)) |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +bool SupportedKeySystems::IsSupportedKeySystemWithContainerAndCodec( |
| + const std::string& mime_type, |
| + const std::string& codec, |
| + const std::string& key_system) { |
| + for (size_t i = 0; |
| + i < arraysize(supported_format_key_system_combinations); |
|
scherkus (not reviewing)
2012/04/12 20:18:41
nit: this should be aligned to the (
ddorwin
2012/04/12 23:41:23
Done.
|
| + ++i) { |
| + const MediaFormatAndKeySystem& combination = |
| + supported_format_key_system_combinations[i]; |
| + if (combination.mime_type == mime_type && |
|
scherkus (not reviewing)
2012/04/12 20:18:41
we're comparing a const char* to an std::string
a
ddorwin
2012/04/12 23:41:23
Handled by basic_string::operator==(const charT* s
|
| + combination.codec == codec && |
|
scherkus (not reviewing)
2012/04/12 20:18:41
nit: remove extra space you have after == here + a
ddorwin
2012/04/12 23:41:23
Done.
|
| + combination.key_system == key_system) |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| +} // namespace webkit_media |