OLD | NEW |
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 "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "content/renderer/media/cdm_session_adapter.h" | 15 #include "content/renderer/media/cdm_session_adapter.h" |
16 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" | 16 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" |
17 #include "media/base/media_keys.h" | 17 #include "media/base/media_keys.h" |
18 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 18 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
19 | 19 |
20 #if defined(ENABLE_PEPPER_CDMS) | 20 #if defined(ENABLE_PEPPER_CDMS) |
21 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" | 21 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" |
| 22 #elif defined(OS_ANDROID) |
| 23 #include "content/renderer/media/android/renderer_media_player_manager.h" |
22 #endif | 24 #endif |
23 | 25 |
24 namespace blink { | 26 namespace blink { |
25 class WebFrame; | 27 class WebFrame; |
26 } | 28 } |
27 | 29 |
28 namespace content { | 30 namespace content { |
29 | 31 |
30 WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create( | 32 WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create( |
31 const base::string16& key_system) { | 33 const base::string16& key_system) { |
(...skipping 11 matching lines...) Expand all Loading... |
43 DCHECK(!key_system.empty()); | 45 DCHECK(!key_system.empty()); |
44 | 46 |
45 // TODO(ddorwin): Guard against this in supported types check and remove this. | 47 // TODO(ddorwin): Guard against this in supported types check and remove this. |
46 // Chromium only supports ASCII key systems. | 48 // Chromium only supports ASCII key systems. |
47 if (!IsStringASCII(key_system)) { | 49 if (!IsStringASCII(key_system)) { |
48 NOTREACHED(); | 50 NOTREACHED(); |
49 return NULL; | 51 return NULL; |
50 } | 52 } |
51 | 53 |
52 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); | 54 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); |
| 55 |
| 56 #if defined(OS_ANDROID) |
| 57 int cdm_id = RendererMediaPlayerManager::kInvalidCdmId; |
| 58 #endif |
| 59 |
53 if (!adapter->Initialize( | 60 if (!adapter->Initialize( |
54 #if defined(ENABLE_PEPPER_CDMS) | 61 #if defined(ENABLE_PEPPER_CDMS) |
55 base::Bind(&PepperCdmWrapperImpl::Create, frame), | 62 base::Bind(&PepperCdmWrapperImpl::Create, frame), |
| 63 #elif defined(OS_ANDROID) |
| 64 &cdm_id, |
56 #endif | 65 #endif |
57 base::UTF16ToASCII(key_system))) { | 66 base::UTF16ToASCII(key_system))) { |
58 return NULL; | 67 return NULL; |
59 } | 68 } |
60 | 69 |
61 return new WebContentDecryptionModuleImpl(adapter); | 70 return new WebContentDecryptionModuleImpl( |
| 71 #if defined(OS_ANDROID) |
| 72 adapter, cdm_id); |
| 73 #else |
| 74 adapter); |
| 75 #endif |
62 } | 76 } |
63 | 77 |
64 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( | 78 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( |
| 79 #if defined(OS_ANDROID) |
| 80 scoped_refptr<CdmSessionAdapter> adapter, |
| 81 int cdm_id) |
| 82 : adapter_(adapter), cdm_id_(cdm_id) {} |
| 83 #else |
65 scoped_refptr<CdmSessionAdapter> adapter) | 84 scoped_refptr<CdmSessionAdapter> adapter) |
66 : adapter_(adapter) { | 85 : adapter_(adapter) {} |
67 } | 86 #endif |
68 | 87 |
69 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { | 88 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { |
70 } | 89 } |
71 | 90 |
72 // The caller owns the created session. | 91 // The caller owns the created session. |
73 blink::WebContentDecryptionModuleSession* | 92 blink::WebContentDecryptionModuleSession* |
74 WebContentDecryptionModuleImpl::createSession( | 93 WebContentDecryptionModuleImpl::createSession( |
75 blink::WebContentDecryptionModuleSession::Client* client) { | 94 blink::WebContentDecryptionModuleSession::Client* client) { |
76 return adapter_->CreateSession(client); | 95 return adapter_->CreateSession(client); |
77 } | 96 } |
78 | 97 |
79 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() { | 98 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() { |
80 return adapter_->GetDecryptor(); | 99 return adapter_->GetDecryptor(); |
81 } | 100 } |
82 | 101 |
| 102 #if defined(OS_ANDROID) |
| 103 int WebContentDecryptionModuleImpl::GetCdmId() { |
| 104 return cdm_id_; |
| 105 } |
| 106 #endif // defined(OS_ANDROID) |
| 107 |
83 } // namespace content | 108 } // namespace content |
OLD | NEW |