OLD | NEW |
---|---|
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/cdm_session_adapter.h" | 5 #include "content/renderer/media/cdm_session_adapter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "content/renderer/media/crypto/content_decryption_module_factory.h" | 10 #include "content/renderer/media/crypto/content_decryption_module_factory.h" |
11 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" | 11 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" |
12 #include "media/base/media_keys.h" | 12 #include "media/base/media_keys.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 const uint32 kStartingSessionId = 1; | 17 const uint32 kStartingSessionId = 1; |
18 uint32 CdmSessionAdapter::next_session_id_ = kStartingSessionId; | 18 uint32 CdmSessionAdapter::next_session_id_ = kStartingSessionId; |
19 COMPILE_ASSERT(kStartingSessionId > media::MediaKeys::kInvalidSessionId, | 19 COMPILE_ASSERT(kStartingSessionId > media::MediaKeys::kInvalidSessionId, |
20 invalid_starting_value); | 20 invalid_starting_value); |
21 | 21 |
22 CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) {} | 22 CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) {} |
23 | 23 |
24 CdmSessionAdapter::~CdmSessionAdapter() {} | 24 CdmSessionAdapter::~CdmSessionAdapter() {} |
25 | 25 |
26 bool CdmSessionAdapter::Initialize( | 26 bool CdmSessionAdapter::Initialize( |
27 #if defined(ENABLE_PEPPER_CDMS) | 27 #if defined(ENABLE_PEPPER_CDMS) |
28 const CreatePepperCdmCB& create_pepper_cdm_cb, | 28 const CreatePepperCdmCB& create_pepper_cdm_cb, |
29 #endif | 29 #elif defined(OS_ANDROID) |
30 int* cdm_id, | |
31 #endif // defined(ENABLE_PEPPER_CDMS) | |
30 const std::string& key_system) { | 32 const std::string& key_system) { |
31 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); | 33 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); |
32 media_keys_ = | 34 media_keys_ = |
33 ContentDecryptionModuleFactory::Create( | 35 ContentDecryptionModuleFactory::Create( |
34 key_system, | 36 key_system, |
35 #if defined(ENABLE_PEPPER_CDMS) | 37 #if defined(ENABLE_PEPPER_CDMS) |
ddorwin
2014/03/25 23:03:59
It would be nice if we could combine these into so
xhwang
2014/03/26 06:02:04
Agreed that we should hide all these differences s
| |
36 create_pepper_cdm_cb, | 38 create_pepper_cdm_cb, |
37 #elif defined(OS_ANDROID) | 39 #elif defined(OS_ANDROID) |
38 // TODO(xhwang): Support Android. | 40 // TODO(xhwang): Support Android. |
39 NULL, | 41 NULL, |
40 0, | |
41 // TODO(ddorwin): Get the URL for the frame containing the MediaKeys. | 42 // TODO(ddorwin): Get the URL for the frame containing the MediaKeys. |
42 GURL(), | 43 GURL(), |
44 cdm_id, | |
43 #endif // defined(ENABLE_PEPPER_CDMS) | 45 #endif // defined(ENABLE_PEPPER_CDMS) |
44 base::Bind(&CdmSessionAdapter::OnSessionCreated, weak_this), | 46 base::Bind(&CdmSessionAdapter::OnSessionCreated, weak_this), |
45 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), | 47 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), |
46 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this), | 48 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this), |
47 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), | 49 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), |
48 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this)); | 50 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this)); |
49 | 51 |
50 // Success if |media_keys_| created. | 52 // Success if |media_keys_| created. |
51 return media_keys_; | 53 return media_keys_; |
52 } | 54 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( | 142 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( |
141 uint32 session_id) { | 143 uint32 session_id) { |
142 // Since session objects may get garbage collected, it is possible that there | 144 // Since session objects may get garbage collected, it is possible that there |
143 // are events coming back from the CDM and the session has been unregistered. | 145 // are events coming back from the CDM and the session has been unregistered. |
144 // We can not tell if the CDM is firing events at sessions that never existed. | 146 // We can not tell if the CDM is firing events at sessions that never existed. |
145 SessionMap::iterator session = sessions_.find(session_id); | 147 SessionMap::iterator session = sessions_.find(session_id); |
146 return (session != sessions_.end()) ? session->second : NULL; | 148 return (session != sessions_.end()) ? session->second : NULL; |
147 } | 149 } |
148 | 150 |
149 } // namespace content | 151 } // namespace content |
OLD | NEW |