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

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

Issue 660673002: Introduce CdmFactory interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_result_promise
Patch Set: comments addressed 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/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 "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "content/renderer/media/crypto/content_decryption_module_factory.h"
12 #include "content/renderer/media/crypto/key_systems.h" 11 #include "content/renderer/media/crypto/key_systems.h"
13 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" 12 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h"
13 #include "media/base/cdm_factory.h"
14 #include "media/base/cdm_promise.h" 14 #include "media/base/cdm_promise.h"
15 #include "media/base/media_keys.h" 15 #include "media/base/media_keys.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 #if defined(ENABLE_BROWSER_CDMS)
19 #include "content/renderer/media/crypto/renderer_cdm_manager.h"
20 #endif // defined(ENABLE_BROWSER_CDMS)
21
18 namespace content { 22 namespace content {
19 23
20 const char kMediaEME[] = "Media.EME."; 24 const char kMediaEME[] = "Media.EME.";
21 const char kDot[] = "."; 25 const char kDot[] = ".";
22 26
23 CdmSessionAdapter::CdmSessionAdapter() : 27 CdmSessionAdapter::CdmSessionAdapter() :
24 #if defined(ENABLE_BROWSER_CDMS) 28 #if defined(ENABLE_BROWSER_CDMS)
25 cdm_id_(0), 29 // TODO(xhwang): Move kInvalidCdmId to src/media.
30 cdm_id_(RendererCdmManager::kInvalidCdmId),
26 #endif 31 #endif
27 weak_ptr_factory_(this) {} 32 weak_ptr_factory_(this) {}
28 33
29 CdmSessionAdapter::~CdmSessionAdapter() {} 34 CdmSessionAdapter::~CdmSessionAdapter() {}
30 35
31 bool CdmSessionAdapter::Initialize( 36 bool CdmSessionAdapter::Initialize(const media::CdmFactory& cdm_factory,
32 #if defined(ENABLE_PEPPER_CDMS) 37 const std::string& key_system,
33 const CreatePepperCdmCB& create_pepper_cdm_cb, 38 const GURL& security_origin) {
34 #elif defined(ENABLE_BROWSER_CDMS) 39 // TODO(xhwang): This is why we need to include "key_systems.h". Move
35 RendererCdmManager* manager, 40 // KeySystemNameForUMA out of src/content so we can move CdmSessionAdapter to
36 #endif // defined(ENABLE_PEPPER_CDMS) 41 // src/media.
37 const std::string& key_system,
38 const GURL& security_origin) {
39 key_system_uma_prefix_ = kMediaEME + KeySystemNameForUMA(key_system) + kDot; 42 key_system_uma_prefix_ = kMediaEME + KeySystemNameForUMA(key_system) + kDot;
43
40 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); 44 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr();
41 media_keys_ = ContentDecryptionModuleFactory::Create( 45 media_keys_ = cdm_factory.Create(
42 key_system, 46 key_system,
43 security_origin, 47 security_origin,
44 #if defined(ENABLE_PEPPER_CDMS) 48 #if defined(ENABLE_BROWSER_CDMS)
45 create_pepper_cdm_cb,
46 #elif defined(ENABLE_BROWSER_CDMS)
47 manager,
48 &cdm_id_, 49 &cdm_id_,
49 #endif // defined(ENABLE_PEPPER_CDMS) 50 #endif // defined(ENABLE_PEPPER_CDMS)
50 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), 51 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
51 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this), 52 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this),
52 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), 53 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
53 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this), 54 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this),
54 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this), 55 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this),
55 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this)); 56 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this));
56 57
57 // Success if |media_keys_| created. 58 // Success if |media_keys_| created.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( 207 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession(
207 const std::string& web_session_id) { 208 const std::string& web_session_id) {
208 // Since session objects may get garbage collected, it is possible that there 209 // Since session objects may get garbage collected, it is possible that there
209 // are events coming back from the CDM and the session has been unregistered. 210 // are events coming back from the CDM and the session has been unregistered.
210 // We can not tell if the CDM is firing events at sessions that never existed. 211 // We can not tell if the CDM is firing events at sessions that never existed.
211 SessionMap::iterator session = sessions_.find(web_session_id); 212 SessionMap::iterator session = sessions_.find(web_session_id);
212 return (session != sessions_.end()) ? session->second.get() : NULL; 213 return (session != sessions_.end()) ? session->second.get() : NULL;
213 } 214 }
214 215
215 } // namespace content 216 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698