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

Side by Side Diff: webkit/media/supported_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: 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/supported_key_systems.h"
6 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
7
8 namespace webkit_media {
9
10 namespace {
11
12 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
13
14 struct MediaFormatAndKeySystem {
15 const char* mime_type;
16 const char* codec;
17 const char* key_system;
18 };
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 MimeUtil. Therfore, the
26 // following line must be separate entries.
27 // { "video/webm", "vorbis,vp8,vp8.0", kClearKeyKeySystem },
28 { "video/webm", "vorbis", kClearKeyKeySystem },
29 { "video/webm", "vp8", kClearKeyKeySystem },
30 { "video/webm", "vp8.0", kClearKeyKeySystem },
31 { "audio/webm", "vorbis", kClearKeyKeySystem },
32 { "video/webm", "", kClearKeyKeySystem },
33 { "audio/webm", "", kClearKeyKeySystem }
34 };
35
36 } // namespace
37
38 bool SupportedKeySystems::isKeySystemSupported(
39 const WebKit::WebString& keySystem) {
40 if (keySystem == kClearKeyKeySystem)
41 return true;
42 return false;
43 }
44
45 bool SupportedKeySystems::IsSupportedKeySystemWithMediaMimeType(
46 const std::string& mime_type,
47 const std::vector<std::string>& codecs,
48 const std::string& key_system) {
49 if (codecs.empty())
50 return IsSupportedKeySystemWithContainerAndCodec(mime_type, "", key_system);
51
52 for (size_t i = 0; i < codecs.size(); ++i) {
53 if (!IsSupportedKeySystemWithContainerAndCodec(mime_type,
scherkus (not reviewing) 2012/04/12 20:18:41 nit: move all these params to next line so it look
ddorwin 2012/04/12 23:41:23 Done.
54 codecs[i],
55 key_system))
56 return false;
57 }
58
59 return true;
60 }
61
62 bool SupportedKeySystems::IsSupportedKeySystemWithContainerAndCodec(
63 const std::string& mime_type,
64 const std::string& codec,
65 const std::string& key_system) {
66 for (size_t i = 0;
67 i < arraysize(supported_format_key_system_combinations);
scherkus (not reviewing) 2012/04/12 20:18:41 nit: this should be aligned to the (
ddorwin 2012/04/12 23:41:23 Done.
68 ++i) {
69 const MediaFormatAndKeySystem& combination =
70 supported_format_key_system_combinations[i];
71 if (combination.mime_type == mime_type &&
scherkus (not reviewing) 2012/04/12 20:18:41 we're comparing a const char* to an std::string a
ddorwin 2012/04/12 23:41:23 Handled by basic_string::operator==(const charT* s
72 combination.codec == codec &&
scherkus (not reviewing) 2012/04/12 20:18:41 nit: remove extra space you have after == here + a
ddorwin 2012/04/12 23:41:23 Done.
73 combination.key_system == key_system)
74 return true;
75 }
76
77 return false;
78 }
79
80 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698