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

Side by Side Diff: content/renderer/media/crypto/encrypted_media_player_support_impl.cc

Issue 660673002: Introduce CdmFactory interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_result_promise
Patch Set: Created 6 years, 2 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/media/crypto/encrypted_media_player_support_impl.h" 5 #include "content/renderer/media/crypto/encrypted_media_player_support_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/renderer/media/crypto/key_systems.h" 15 #include "content/renderer/media/crypto/key_systems.h"
16 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" 16 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
17 #include "content/renderer/pepper/pepper_webplugin_impl.h" 17 #include "content/renderer/pepper/pepper_webplugin_impl.h"
ddorwin 2014/10/16 17:32:52 i don't think we need this.
xhwang 2014/10/16 20:08:39 Done.
18 #include "media/base/bind_to_current_loop.h" 18 #include "media/base/bind_to_current_loop.h"
19 #include "media/blink/encrypted_media_player_support.h" 19 #include "media/blink/encrypted_media_player_support.h"
20 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" 20 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h"
21 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" 21 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
22 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" 22 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
23 #include "third_party/WebKit/public/web/WebDocument.h" 23 #include "third_party/WebKit/public/web/WebDocument.h"
24 #include "third_party/WebKit/public/web/WebLocalFrame.h" 24 #include "third_party/WebKit/public/web/WebLocalFrame.h"
25 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 25 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
26 26
27 #if defined(ENABLE_PEPPER_CDMS) 27 #if defined(ENABLE_PEPPER_CDMS)
28 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" 28 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h"
29 #include "content/renderer/media/crypto/render_cdm_factory.h"
ddorwin 2014/10/16 17:32:52 same comment as below
29 #endif 30 #endif
30 31
31 using blink::WebMediaPlayer; 32 using blink::WebMediaPlayer;
32 using blink::WebMediaPlayerClient; 33 using blink::WebMediaPlayerClient;
33 using blink::WebString; 34 using blink::WebString;
34 35
35 namespace content { 36 namespace content {
36 37
37 #define BIND_TO_RENDER_LOOP(function) \ 38 #define BIND_TO_RENDER_LOOP(function) \
38 (media::BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) 39 (media::BindToCurrentLoop(base::Bind(function, AsWeakPtr())))
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 std::string ascii_key_system = 153 std::string ascii_key_system =
153 GetUnprefixedKeySystemName(ToASCIIOrEmpty(key_system)); 154 GetUnprefixedKeySystemName(ToASCIIOrEmpty(key_system));
154 155
155 WebMediaPlayer::MediaKeyException e = 156 WebMediaPlayer::MediaKeyException e =
156 GenerateKeyRequestInternal(frame, ascii_key_system, init_data, 157 GenerateKeyRequestInternal(frame, ascii_key_system, init_data,
157 init_data_length); 158 init_data_length);
158 ReportMediaKeyExceptionToUMA("generateKeyRequest", ascii_key_system, e); 159 ReportMediaKeyExceptionToUMA("generateKeyRequest", ascii_key_system, e);
159 return e; 160 return e;
160 } 161 }
161 162
162
163 WebMediaPlayer::MediaKeyException 163 WebMediaPlayer::MediaKeyException
164 EncryptedMediaPlayerSupportImpl::GenerateKeyRequestInternal( 164 EncryptedMediaPlayerSupportImpl::GenerateKeyRequestInternal(
165 blink::WebLocalFrame* frame, 165 blink::WebLocalFrame* frame,
166 const std::string& key_system, 166 const std::string& key_system,
167 const unsigned char* init_data, 167 const unsigned char* init_data,
168 unsigned init_data_length) { 168 unsigned init_data_length) {
169 if (!IsConcreteSupportedKeySystem(key_system)) 169 if (!IsConcreteSupportedKeySystem(key_system))
170 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; 170 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
171 171
172 // We do not support run-time switching between key systems for now. 172 // We do not support run-time switching between key systems for now.
173 if (current_key_system_.empty()) { 173 if (current_key_system_.empty()) {
174 if (!proxy_decryptor_) { 174 if (!proxy_decryptor_) {
175 proxy_decryptor_.reset(new ProxyDecryptor( 175 proxy_decryptor_.reset(new ProxyDecryptor(
176 #if defined(ENABLE_PEPPER_CDMS) 176 #if defined(ENABLE_PEPPER_CDMS)
ddorwin 2014/10/16 17:32:52 What if you only wanted to support Clear Key? Shou
xhwang 2014/10/16 20:08:39 Not sure what you are asking exactly... A few poin
ddorwin 2014/10/16 20:33:20 Nevermind. I think the structure threw me off.
xhwang 2014/10/17 00:11:49 Acknowledged.
177 // Create() must be called synchronously as |frame| may not be 177 scoped_ptr<media::CdmFactory>(new RenderCdmFactory(
178 // valid afterwards. 178 base::Bind(&PepperCdmWrapperImpl::Create, frame))),
179 base::Bind(&PepperCdmWrapperImpl::Create, frame),
180 #elif defined(ENABLE_BROWSER_CDMS) 179 #elif defined(ENABLE_BROWSER_CDMS)
181 #error Browser side CDM in WMPI for prefixed EME API not supported yet. 180 #error Browser side CDM in WMPI for prefixed EME API not supported yet.
182 #endif 181 #endif
183 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupportImpl::OnKeyAdded), 182 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupportImpl::OnKeyAdded),
184 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupportImpl::OnKeyError), 183 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupportImpl::OnKeyError),
185 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupportImpl::OnKeyMessage))); 184 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupportImpl::OnKeyMessage)));
186 } 185 }
187 186
188 GURL security_origin(frame->document().securityOrigin().toString()); 187 GURL security_origin(frame->document().securityOrigin().toString());
189 if (!proxy_decryptor_->InitializeCDM(key_system, security_origin)) 188 if (!proxy_decryptor_->InitializeCDM(key_system, security_origin))
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 462
464 if (web_cdm_) { 463 if (web_cdm_) {
465 decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); 464 decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing));
466 return; 465 return;
467 } 466 }
468 467
469 decryptor_ready_cb_ = decryptor_ready_cb; 468 decryptor_ready_cb_ = decryptor_ready_cb;
470 } 469 }
471 470
472 } // namespace content 471 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698