| 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 { |
| 12 |
| 13 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
| 14 |
| 15 struct MediaFormatAndKeySystem { |
| 16 const char* mime_type; |
| 17 const char* codec; |
| 18 const char* key_system; |
| 19 }; |
| 20 |
| 21 static const MediaFormatAndKeySystem |
| 22 supported_format_key_system_combinations[] = { |
| 23 // TODO(ddorwin): Reconsider based on how usage of this class evolves. |
| 24 // For now, this class is stateless, so we do not have the opportunity to |
| 25 // build a list using ParseCodecString() like |
| 26 // net::MimeUtil::InitializeMimeTypeMaps(). Therfore, the following line must |
| 27 // be separate entries. |
| 28 // { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem }, |
| 29 { "video/webm", "vorbis", kClearKeyKeySystem }, |
| 30 { "video/webm", "vp8", kClearKeyKeySystem }, |
| 31 { "video/webm", "vp8.0", kClearKeyKeySystem }, |
| 32 { "audio/webm", "vorbis", kClearKeyKeySystem }, |
| 33 { "video/webm", "", kClearKeyKeySystem }, |
| 34 { "audio/webm", "", kClearKeyKeySystem } |
| 35 }; |
| 36 |
| 37 bool IsSupportedKeySystemWithContainerAndCodec(const std::string& mime_type, |
| 38 const std::string& codec, |
| 39 const std::string& key_system) { |
| 40 for (size_t i = 0; |
| 41 i < arraysize(supported_format_key_system_combinations); |
| 42 ++i) { |
| 43 const MediaFormatAndKeySystem& combination = |
| 44 supported_format_key_system_combinations[i]; |
| 45 if (combination.mime_type == mime_type && |
| 46 combination.codec == codec && |
| 47 combination.key_system == key_system) |
| 48 return true; |
| 49 } |
| 50 |
| 51 return false; |
| 52 } |
| 53 |
| 54 } // namespace |
| 55 |
| 56 bool IsSupportedKeySystem(const WebKit::WebString& key_system) { |
| 57 if (key_system == kClearKeyKeySystem) |
| 58 return true; |
| 59 return false; |
| 60 } |
| 61 |
| 62 bool IsSupportedKeySystemWithMediaMimeType( |
| 63 const std::string& mime_type, |
| 64 const std::vector<std::string>& codecs, |
| 65 const std::string& key_system) { |
| 66 if (codecs.empty()) |
| 67 return IsSupportedKeySystemWithContainerAndCodec(mime_type, "", key_system); |
| 68 |
| 69 for (size_t i = 0; i < codecs.size(); ++i) { |
| 70 if (!IsSupportedKeySystemWithContainerAndCodec( |
| 71 mime_type, codecs[i], key_system)) |
| 72 return false; |
| 73 } |
| 74 |
| 75 return true; |
| 76 } |
| 77 |
| 78 } // namespace webkit_media |
| OLD | NEW |