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

Side by Side Diff: chrome/renderer/media/chrome_key_systems.cc

Issue 23513055: Populate canPlayType to renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing ddorwin's comments Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/media/chrome_key_systems.h" 5 #include "chrome/renderer/media/chrome_key_systems.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/common/widevine_cdm_constants.h"
9 #include "content/public/renderer/render_thread.h"
8 10
9 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 11 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
10 12
11 // The following must be after widevine_cdm_version.h. 13 // The following must be after widevine_cdm_version.h.
12 14
13 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) 15 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
14 #include <gnu/libc-version.h> 16 #include <gnu/libc-version.h>
15 #include "base/version.h" 17 #include "base/version.h"
16 #endif 18 #endif
17 19
20 #if defined(OS_ANDROID)
21 #include "chrome/common/encrypted_media_messages_android.h"
22 #endif
23
18 using content::KeySystemInfo; 24 using content::KeySystemInfo;
19 25
20 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; 26 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
21 27
22 static const char kAudioWebM[] = "audio/webm"; 28 static const char kAudioWebM[] = "audio/webm";
23 static const char kVideoWebM[] = "video/webm"; 29 static const char kVideoWebM[] = "video/webm";
24 static const char kVorbis[] = "vorbis"; 30 static const char kVorbis[] = "vorbis";
25 static const char kVorbisVP8[] = "vorbis,vp8,vp8.0"; 31 static const char kVorbisVP8[] = "vorbis,vp8,vp8.0";
26 32
27 static const char kAudioMp4[] = "audio/mp4"; 33 static const char kAudioMp4[] = "audio/mp4";
28 static const char kVideoMp4[] = "video/mp4"; 34 static const char kVideoMp4[] = "video/mp4";
29 static const char kMp4a[] = "mp4a"; 35 static const char kMp4a[] = "mp4a";
30 static const char kAvc1[] = "avc1"; 36 static const char kAvc1[] = "avc1";
31 static const char kMp4aAvc1[] = "mp4a,avc1"; 37 static const char kMp4aAvc1[] = "mp4a,avc1";
32 38
33 #if defined(WIDEVINE_CDM_AVAILABLE) 39 #if defined(WIDEVINE_CDM_AVAILABLE)
34 // Defines bitmask values used to specify supported codecs. 40 // Defines bitmask values used to specify supported codecs.
35 // Each value represents a codec within a specific container. 41 // Each value represents a codec within a specific container.
36 enum SupportedCodecs { 42 enum SupportedCodecs {
37 WEBM_VP8_AND_VORBIS = 1 << 0, 43 WEBM_VP8_AND_VORBIS = 1 << 0,
38 #if defined(USE_PROPRIETARY_CODECS) 44 #if defined(USE_PROPRIETARY_CODECS)
39 MP4_AAC = 1 << 1, 45 MP4_AAC = 1 << 1,
40 MP4_AVC1 = 1 << 2, 46 MP4_AVC1 = 1 << 2,
41 #endif // defined(USE_PROPRIETARY_CODECS) 47 #endif // defined(USE_PROPRIETARY_CODECS)
42 }; 48 };
43 49
50 #if defined(OS_ANDROID)
51 static const uint8 kWidevineUuid[16] = {
52 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
53 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
54 #endif
55
44 static void AddWidevineWithCodecs( 56 static void AddWidevineWithCodecs(
45 SupportedCodecs supported_codecs, 57 SupportedCodecs supported_codecs,
46 std::vector<KeySystemInfo>* concrete_key_systems) { 58 std::vector<KeySystemInfo>* concrete_key_systems) {
47 static const char kWidevineParentKeySystem[] = "com.widevine"; 59 static const char kWidevineParentKeySystem[] = "com.widevine";
48 #if defined(OS_ANDROID)
49 static const uint8 kWidevineUuid[16] = {
50 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
51 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
52 #endif
53 60
54 #if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) 61 #if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
55 Version glibc_version(gnu_get_libc_version()); 62 Version glibc_version(gnu_get_libc_version());
56 DCHECK(glibc_version.IsValid()); 63 DCHECK(glibc_version.IsValid());
57 if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION)) 64 if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION))
58 return; 65 return;
59 #endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) 66 #endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
60 67
61 KeySystemInfo info(kWidevineKeySystem); 68 KeySystemInfo info(kWidevineKeySystem);
62 69
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AAC); 104 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AAC);
98 #endif 105 #endif
99 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) 106 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
100 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1); 107 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1);
101 #endif 108 #endif
102 #endif // defined(USE_PROPRIETARY_CODECS) 109 #endif // defined(USE_PROPRIETARY_CODECS)
103 110
104 AddWidevineWithCodecs(supported_codecs, concrete_key_systems); 111 AddWidevineWithCodecs(supported_codecs, concrete_key_systems);
105 } 112 }
106 #elif defined(OS_ANDROID) 113 #elif defined(OS_ANDROID)
114
115 #define COMPILE_ASSERT_MATCHING_ENUM(name) \
ddorwin 2013/09/18 03:58:31 Maybe put this up at line 51 so it's near the enum
qinmin 2013/09/18 05:08:21 Done.
116 COMPILE_ASSERT(static_cast<int>(name) == \
117 static_cast<int>(android::name), \
118 mismatching_enums)
119 COMPILE_ASSERT_MATCHING_ENUM(WEBM_VP8_AND_VORBIS);
120 COMPILE_ASSERT_MATCHING_ENUM(MP4_AAC);
121 COMPILE_ASSERT_MATCHING_ENUM(MP4_AVC1);
122 #undef COMPILE_ASSERT_MATCHING_ENUM
123
107 static void AddAndroidWidevine( 124 static void AddAndroidWidevine(
108 std::vector<KeySystemInfo>* concrete_key_systems) { 125 std::vector<KeySystemInfo>* concrete_key_systems) {
126 android::SupportedKeySystemRequest request;
127 android::SupportedKeySystemResponse response;
128
129 request.uuid.insert(request.uuid.begin(), kWidevineUuid,
130 kWidevineUuid + arraysize(kWidevineUuid));
109 #if defined(USE_PROPRIETARY_CODECS) 131 #if defined(USE_PROPRIETARY_CODECS)
132 request.requested_codecs =
133 static_cast<android::SupportedCodecs>(
134 android::MP4_AAC | android::MP4_AVC1);
135 #endif // defined(USE_PROPRIETARY_CODECS)
136 content::RenderThread::Get()->Send(
137 new ChromeViewHostMsg_GetSupportedKeySystems(
138 request, &response));
139 // TODO(qinmin): Use different key system types for compositing and
140 // non-compositing codecs. Need to ignore the extra bit masks defined in
ddorwin 2013/09/18 03:58:31 What extra bit masks?
qinmin 2013/09/18 05:08:21 The COMPILER_ASSERT only catches the 3 known enums
ddorwin 2013/09/18 05:19:54 You could do a runtime check on the results: DCHEC
qinmin 2013/09/18 17:51:37 seems I missed it, a DCHECK is added here and in t
141 // android if that happens.
110 SupportedCodecs supported_codecs = 142 SupportedCodecs supported_codecs =
111 static_cast<SupportedCodecs>(MP4_AAC | MP4_AVC1); 143 static_cast<SupportedCodecs>(
144 response.compositing_codecs | response.non_compositing_codecs);
112 AddWidevineWithCodecs(supported_codecs, concrete_key_systems); 145 AddWidevineWithCodecs(supported_codecs, concrete_key_systems);
113 #endif // defined(USE_PROPRIETARY_CODECS)
114 } 146 }
115 #endif // defined(ENABLE_PEPPER_CDMS) 147 #endif // defined(ENABLE_PEPPER_CDMS)
116 #endif // defined(WIDEVINE_CDM_AVAILABLE) 148 #endif // defined(WIDEVINE_CDM_AVAILABLE)
117 149
118 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { 150 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) {
119 KeySystemInfo info(kClearKeyKeySystem); 151 KeySystemInfo info(kClearKeyKeySystem);
120 152
121 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); 153 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
122 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); 154 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
123 #if defined(USE_PROPRIETARY_CODECS) 155 #if defined(USE_PROPRIETARY_CODECS)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 #endif 194 #endif
163 195
164 #if defined(WIDEVINE_CDM_AVAILABLE) 196 #if defined(WIDEVINE_CDM_AVAILABLE)
165 #if defined(ENABLE_PEPPER_CDMS) 197 #if defined(ENABLE_PEPPER_CDMS)
166 AddPepperBasedWidevine(key_systems_info); 198 AddPepperBasedWidevine(key_systems_info);
167 #elif defined(OS_ANDROID) 199 #elif defined(OS_ANDROID)
168 AddAndroidWidevine(key_systems_info); 200 AddAndroidWidevine(key_systems_info);
169 #endif 201 #endif
170 #endif 202 #endif
171 } 203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698