| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "webkit/media/key_systems.h" |
| 6 |
| 7 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 8 |
| 9 namespace webkit_media { |
| 10 |
| 11 namespace key_systems { |
| 12 |
| 13 namespace { |
| 14 |
| 15 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
| 16 |
| 17 struct MediaFormatAndKeySystem { |
| 18 const char* mime_type; |
| 19 const char* codec; |
| 20 const char* key_system; |
| 21 }; |
| 22 |
| 23 static const MediaFormatAndKeySystem |
| 24 supported_format_key_system_combinations[] = { |
| 25 // TODO(ddorwin): Reconsider based on how usage of this class evolves. |
| 26 // For now, this class is stateless, so we do not have the opportunity to |
| 27 // build a list using ParseCodecString() like MimeUtil. Therfore, the |
| 28 // following line must be separate entries. |
| 29 // { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, |
| 30 { "video/webm", "vorbis", kClearKeyKeySystem }, |
| 31 { "video/webm", "vp8", kClearKeyKeySystem }, |
| 32 { "video/webm", "vp8.0", kClearKeyKeySystem }, |
| 33 { "audio/webm", "vorbis", kClearKeyKeySystem }, |
| 34 { "video/webm", "", kClearKeyKeySystem }, |
| 35 { "audio/webm", "", kClearKeyKeySystem } |
| 36 }; |
| 37 |
| 38 bool IsSupportedKeySystemWithContainerAndCodec(const std::string& mime_type, |
| 39 const std::string& codec, |
| 40 const std::string& key_system) { |
| 41 for (size_t i = 0; |
| 42 i < arraysize(supported_format_key_system_combinations); |
| 43 ++i) { |
| 44 const MediaFormatAndKeySystem& combination = |
| 45 supported_format_key_system_combinations[i]; |
| 46 if (combination.mime_type == mime_type && |
| 47 combination.codec == codec && |
| 48 combination.key_system == key_system) |
| 49 return true; |
| 50 } |
| 51 |
| 52 return false; |
| 53 } |
| 54 |
| 55 } // namespace |
| 56 |
| 57 bool isKeySystemSupported(const WebKit::WebString& keySystem) { |
| 58 if (keySystem == kClearKeyKeySystem) |
| 59 return true; |
| 60 return false; |
| 61 } |
| 62 |
| 63 bool IsSupportedKeySystemWithMediaMimeType( |
| 64 const std::string& mime_type, |
| 65 const std::vector<std::string>& codecs, |
| 66 const std::string& key_system) { |
| 67 if (codecs.empty()) |
| 68 return IsSupportedKeySystemWithContainerAndCodec(mime_type, "", key_system); |
| 69 |
| 70 for (size_t i = 0; i < codecs.size(); ++i) { |
| 71 if (!IsSupportedKeySystemWithContainerAndCodec( |
| 72 mime_type, codecs[i], key_system)) |
| 73 return false; |
| 74 } |
| 75 |
| 76 return true; |
| 77 } |
| 78 |
| 79 } // namespace key_systems |
| 80 |
| 81 } // namespace webkit_media |
| OLD | NEW |