Chromium Code Reviews| 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/mime_util.h" | |
| 6 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | |
|
scherkus (not reviewing)
2012/04/13 02:43:59
one blank line separating first header + rest
ddorwin
2012/04/13 21:48:49
Done.
| |
| 7 | |
| 8 namespace webkit_media { | |
| 9 | |
| 10 namespace mime_util { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | |
| 15 | |
| 16 struct MediaFormatAndKeySystem { | |
| 17 const char* mime_type; | |
| 18 const char* codec; | |
| 19 const char* key_system; | |
| 20 }; | |
| 21 | |
|
scherkus (not reviewing)
2012/04/13 02:43:59
nit: remove extra blank line
ddorwin
2012/04/13 21:48:49
Done.
| |
| 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 mime_util | |
| 80 | |
| 81 } // namespace webkit_media | |
| OLD | NEW |