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

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: renamed function 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
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 key_systems {
12
13 namespace {
14
15 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
darin (slow to review) 2012/04/18 23:57:40 nit: should we be concerned about claiming "webkit
ddorwin 2012/04/19 00:52:54 This is really a "webkit-" prefix to "org.w3.clear
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
darin (slow to review) 2012/04/18 23:57:40 does "MimeUtil" in this comment refer to net/base/
ddorwin 2012/04/19 00:52:54 Done.
28 // following line must be separate entries.
29 // { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem },
30 { "video/webm", "vorbis", kClearKeyKeySystem },
darin (slow to review) 2012/04/18 23:57:40 do you intend for there to be other key_system val
ddorwin 2012/04/19 00:52:54 Yes. We will add to this table when we add new key
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 IsSupportedKeySystem(const WebKit::WebString& key_system) {
58 if (key_system == 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698