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

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

Issue 318753010: Introduce the ENABLE_BROWSER_CDMS macro. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review. Please diff against PS1 for easy life. Created 6 years, 6 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 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() : 22 CdmSessionAdapter::CdmSessionAdapter() :
23 #if defined(OS_ANDROID) 23 #if defined(ENABLE_BROWSER_CDMS)
24 cdm_id_(0), 24 cdm_id_(0),
25 #endif 25 #endif
26 weak_ptr_factory_(this) {} 26 weak_ptr_factory_(this) {}
27 27
28 CdmSessionAdapter::~CdmSessionAdapter() {} 28 CdmSessionAdapter::~CdmSessionAdapter() {}
29 29
30 bool CdmSessionAdapter::Initialize( 30 bool CdmSessionAdapter::Initialize(
31 #if defined(ENABLE_PEPPER_CDMS) 31 #if defined(ENABLE_PEPPER_CDMS)
32 const CreatePepperCdmCB& create_pepper_cdm_cb, 32 const CreatePepperCdmCB& create_pepper_cdm_cb,
33 #elif defined(OS_ANDROID) 33 #elif defined(ENABLE_BROWSER_CDMS)
34 RendererCdmManager* manager, 34 RendererCdmManager* manager,
35 #endif // defined(ENABLE_PEPPER_CDMS) 35 #endif // defined(ENABLE_PEPPER_CDMS)
36 const std::string& key_system, 36 const std::string& key_system,
37 const GURL& security_origin) { 37 const GURL& security_origin) {
38 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); 38 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr();
39 media_keys_ = ContentDecryptionModuleFactory::Create( 39 media_keys_ = ContentDecryptionModuleFactory::Create(
40 key_system, 40 key_system,
41 security_origin, 41 security_origin,
42 #if defined(ENABLE_PEPPER_CDMS) 42 #if defined(ENABLE_PEPPER_CDMS)
43 create_pepper_cdm_cb, 43 create_pepper_cdm_cb,
44 #elif defined(OS_ANDROID) 44 #elif defined(ENABLE_BROWSER_CDMS)
45 manager, 45 manager,
46 &cdm_id_, 46 &cdm_id_,
47 #endif // defined(ENABLE_PEPPER_CDMS) 47 #endif // defined(ENABLE_PEPPER_CDMS)
48 base::Bind(&CdmSessionAdapter::OnSessionCreated, weak_this), 48 base::Bind(&CdmSessionAdapter::OnSessionCreated, weak_this),
49 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), 49 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
50 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this), 50 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this),
51 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), 51 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
52 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this)); 52 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this));
53 53
54 // Success if |media_keys_| created. 54 // Success if |media_keys_| created.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 void CdmSessionAdapter::ReleaseSession(uint32 session_id) { 90 void CdmSessionAdapter::ReleaseSession(uint32 session_id) {
91 DCHECK(sessions_.find(session_id) != sessions_.end()); 91 DCHECK(sessions_.find(session_id) != sessions_.end());
92 media_keys_->ReleaseSession(session_id); 92 media_keys_->ReleaseSession(session_id);
93 } 93 }
94 94
95 media::Decryptor* CdmSessionAdapter::GetDecryptor() { 95 media::Decryptor* CdmSessionAdapter::GetDecryptor() {
96 return media_keys_->GetDecryptor(); 96 return media_keys_->GetDecryptor();
97 } 97 }
98 98
99 #if defined(OS_ANDROID) 99 #if defined(ENABLE_BROWSER_CDMS)
100 int CdmSessionAdapter::GetCdmId() const { 100 int CdmSessionAdapter::GetCdmId() const {
101 return cdm_id_; 101 return cdm_id_;
102 } 102 }
103 #endif // defined(OS_ANDROID) 103 #endif // defined(ENABLE_BROWSER_CDMS)
104 104
105 void CdmSessionAdapter::OnSessionCreated(uint32 session_id, 105 void CdmSessionAdapter::OnSessionCreated(uint32 session_id,
106 const std::string& web_session_id) { 106 const std::string& web_session_id) {
107 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); 107 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id);
108 DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session " 108 DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session "
109 << session_id; 109 << session_id;
110 if (session) 110 if (session)
111 session->OnSessionCreated(web_session_id); 111 session->OnSessionCreated(web_session_id);
112 } 112 }
113 113
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( 150 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession(
151 uint32 session_id) { 151 uint32 session_id) {
152 // Since session objects may get garbage collected, it is possible that there 152 // Since session objects may get garbage collected, it is possible that there
153 // are events coming back from the CDM and the session has been unregistered. 153 // are events coming back from the CDM and the session has been unregistered.
154 // We can not tell if the CDM is firing events at sessions that never existed. 154 // We can not tell if the CDM is firing events at sessions that never existed.
155 SessionMap::iterator session = sessions_.find(session_id); 155 SessionMap::iterator session = sessions_.find(session_id);
156 return (session != sessions_.end()) ? session->second : NULL; 156 return (session != sessions_.end()) ? session->second : NULL;
157 } 157 }
158 158
159 } // namespace content 159 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698