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

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 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.
35 // Each value represents a codec within a specific container.
36 enum SupportedCodecs {
37 WEBM_VP8_AND_VORBIS = 1 << 0,
38 #if defined(USE_PROPRIETARY_CODECS)
39 MP4_AAC = 1 << 1,
40 MP4_AVC1 = 1 << 2,
41 #endif // defined(USE_PROPRIETARY_CODECS)
42 };
43 40
44 static void AddWidevineWithCodecs( 41 static void AddWidevineWithCodecs(
45 SupportedCodecs supported_codecs, 42 SupportedCodecs supported_codecs,
46 std::vector<KeySystemInfo>* concrete_key_systems) { 43 std::vector<KeySystemInfo>* concrete_key_systems) {
47 static const char kWidevineParentKeySystem[] = "com.widevine"; 44 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 45
54 #if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) 46 #if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
55 Version glibc_version(gnu_get_libc_version()); 47 Version glibc_version(gnu_get_libc_version());
56 DCHECK(glibc_version.IsValid()); 48 DCHECK(glibc_version.IsValid());
57 if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION)) 49 if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION))
58 return; 50 return;
59 #endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) 51 #endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
60 52
61 KeySystemInfo info(kWidevineKeySystem); 53 KeySystemInfo info(kWidevineKeySystem);
62 54
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) 91 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
100 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1); 92 supported_codecs = static_cast<SupportedCodecs>(supported_codecs | MP4_AVC1);
101 #endif 93 #endif
102 #endif // defined(USE_PROPRIETARY_CODECS) 94 #endif // defined(USE_PROPRIETARY_CODECS)
103 95
104 AddWidevineWithCodecs(supported_codecs, concrete_key_systems); 96 AddWidevineWithCodecs(supported_codecs, concrete_key_systems);
105 } 97 }
106 #elif defined(OS_ANDROID) 98 #elif defined(OS_ANDROID)
107 static void AddAndroidWidevine( 99 static void AddAndroidWidevine(
108 std::vector<KeySystemInfo>* concrete_key_systems) { 100 std::vector<KeySystemInfo>* concrete_key_systems) {
101 SupportedKeySystemRequest request;
102 SupportedKeySystemResponse response;
103
104 request.uuid.insert(
105 request.uuid.begin(), kWidevineUuid, kWidevineUuid + 16);
ddorwin 2013/09/17 22:29:08 s/16/arraysize/
qinmin 2013/09/18 00:45:44 Done.
109 #if defined(USE_PROPRIETARY_CODECS) 106 #if defined(USE_PROPRIETARY_CODECS)
110 SupportedCodecs supported_codecs = 107 request.supported_codecs = static_cast<SupportedCodecs>(MP4_AAC | MP4_AVC1);
111 static_cast<SupportedCodecs>(MP4_AAC | MP4_AVC1); 108 #endif // defined(USE_PROPRIETARY_CODECS)
109 content::RenderThread::Get()->Send(
110 new ChromeViewHostMsg_GetSupportedKeySystems(
111 request, &response));
112 // TODO(qinmin): using different key system types for compositing and
ddorwin 2013/09/17 22:29:08 s/using/Use/
qinmin 2013/09/18 00:45:44 Done.
113 // non-compositing codecs.
114 SupportedCodecs supported_codecs = static_cast<SupportedCodecs>(
115 response.compositing_codecs | response.non_compositing_codecs);
112 AddWidevineWithCodecs(supported_codecs, concrete_key_systems); 116 AddWidevineWithCodecs(supported_codecs, concrete_key_systems);
113 #endif // defined(USE_PROPRIETARY_CODECS)
114 } 117 }
115 #endif // defined(ENABLE_PEPPER_CDMS) 118 #endif // defined(ENABLE_PEPPER_CDMS)
116 #endif // defined(WIDEVINE_CDM_AVAILABLE) 119 #endif // defined(WIDEVINE_CDM_AVAILABLE)
117 120
118 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { 121 static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) {
119 KeySystemInfo info(kClearKeyKeySystem); 122 KeySystemInfo info(kClearKeyKeySystem);
120 123
121 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); 124 info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis));
122 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); 125 info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8));
123 #if defined(USE_PROPRIETARY_CODECS) 126 #if defined(USE_PROPRIETARY_CODECS)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 #endif 165 #endif
163 166
164 #if defined(WIDEVINE_CDM_AVAILABLE) 167 #if defined(WIDEVINE_CDM_AVAILABLE)
165 #if defined(ENABLE_PEPPER_CDMS) 168 #if defined(ENABLE_PEPPER_CDMS)
166 AddPepperBasedWidevine(key_systems_info); 169 AddPepperBasedWidevine(key_systems_info);
167 #elif defined(OS_ANDROID) 170 #elif defined(OS_ANDROID)
168 AddAndroidWidevine(key_systems_info); 171 AddAndroidWidevine(key_systems_info);
169 #endif 172 #endif
170 #endif 173 #endif
171 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698