Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: webkit/media/key_systems.cc

Issue 10020053: Initial implementation of Encrypted Media Extensions in Chrome. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: removed key_systems namespace Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webkit/media/key_systems.h ('k') | webkit/media/webkit_media.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « webkit/media/key_systems.h ('k') | webkit/media/webkit_media.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698