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

Side by Side Diff: content/renderer/media/webcontentdecryptionmodule_impl.cc

Issue 193523002: Encrypted Media: Implement IPC based SetCdm(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 9 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 "content/renderer/media/webcontentdecryptionmodule_impl.h" 5 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "content/renderer/media/cdm_session_adapter.h" 14 #include "content/renderer/media/cdm_session_adapter.h"
15 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" 15 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h"
16 #include "media/base/media_keys.h" 16 #include "media/base/media_keys.h"
17 17
18 #if defined(ENABLE_PEPPER_CDMS) 18 #if defined(ENABLE_PEPPER_CDMS)
19 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" 19 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h"
20 #elif defined(OS_ANDROID)
21 #include "content/renderer/media/android/renderer_media_player_manager.h"
20 #endif 22 #endif
21 23
22 namespace content { 24 namespace content {
23 25
24 WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create( 26 WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create(
25 const base::string16& key_system) { 27 const base::string16& key_system) {
26 // TODO(ddorwin): Guard against this in supported types check and remove this. 28 // TODO(ddorwin): Guard against this in supported types check and remove this.
27 // Chromium only supports ASCII key systems. 29 // Chromium only supports ASCII key systems.
28 if (!IsStringASCII(key_system)) { 30 if (!IsStringASCII(key_system)) {
29 NOTREACHED(); 31 NOTREACHED();
30 return NULL; 32 return NULL;
31 } 33 }
32 34
33 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); 35 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter());
34 if (!adapter->Initialize( 36
37 #if defined(OS_ANDROID)
38 int cdm_id = RendererMediaPlayerManager::kInvalidCdmId;
39 if (adapter->Initialize(&cdm_id, UTF16ToASCII(key_system)))
40 return new WebContentDecryptionModuleImpl(adapter, cdm_id);
41 #else // defined(OS_ANDROID)
42 if (adapter->Initialize(
35 #if defined(ENABLE_PEPPER_CDMS) 43 #if defined(ENABLE_PEPPER_CDMS)
36 // TODO(jrummell): Figure out how to get a WebFrame from Blink (or 44 // TODO(jrummell): Figure out how to get a WebFrame from Blink (or
37 // something equivalent) so the plugin can actually get created. 45 // something equivalent) so the plugin can actually get created.
38 // http://crbug.com/250049 46 // http://crbug.com/250049
39 base::Bind(&PepperCdmWrapperImpl::Create, 47 base::Bind(&PepperCdmWrapperImpl::Create,
40 static_cast<blink::WebFrame*>(NULL)), 48 static_cast<blink::WebFrame*>(NULL)),
41 #endif 49 #endif // defined(ENABLE_PEPPER_CDMS)
42 UTF16ToASCII(key_system))) { 50 UTF16ToASCII(key_system))) {
43 return NULL; 51 return new WebContentDecryptionModuleImpl(adapter);
44 } 52 }
45 53 #endif // defined(OS_ANDROID)
46 return new WebContentDecryptionModuleImpl(adapter); 54 return NULL;
47 } 55 }
48 56
57 #if defined(OS_ANDROID)
58 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl(
59 scoped_refptr<CdmSessionAdapter> adapter, int cdm_id)
60 : adapter_(adapter), cdm_id_(cdm_id) {}
61 #else
49 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( 62 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl(
50 scoped_refptr<CdmSessionAdapter> adapter) 63 scoped_refptr<CdmSessionAdapter> adapter)
51 : adapter_(adapter) { 64 : adapter_(adapter) {}
52 } 65 #endif
xhwang 2014/03/12 01:20:11 This code (l.37-65) is really messy with #ifdefs.
ddorwin 2014/03/18 22:51:08 How much smaller is the diff if we track this in t
xhwang 2014/03/25 21:49:50 ifdef'ed individual parameters where possible.
53 66
54 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { 67 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() {
55 } 68 }
56 69
57 // The caller owns the created session. 70 // The caller owns the created session.
58 blink::WebContentDecryptionModuleSession* 71 blink::WebContentDecryptionModuleSession*
59 WebContentDecryptionModuleImpl::createSession( 72 WebContentDecryptionModuleImpl::createSession(
60 blink::WebContentDecryptionModuleSession::Client* client) { 73 blink::WebContentDecryptionModuleSession::Client* client) {
61 return adapter_->CreateSession(client); 74 return adapter_->CreateSession(client);
62 } 75 }
63 76
64 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() { 77 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() {
65 return adapter_->GetDecryptor(); 78 return adapter_->GetDecryptor();
66 } 79 }
67 80
81 #if defined(OS_ANDROID)
82 int WebContentDecryptionModuleImpl::GetCdmId() {
83 return cdm_id_;
84 }
85 #endif // defined(OS_ANDROID)
86
68 } // namespace content 87 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698