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

Side by Side Diff: media/blink/cdm_session_adapter.cc

Issue 814143004: Encrypted Media: Add DefaultCdmFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 "media/blink/cdm_session_adapter.h" 5 #include "media/blink/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 "media/base/cdm_factory.h" 11 #include "media/base/cdm_factory.h"
12 #include "media/base/cdm_promise.h" 12 #include "media/base/cdm_promise.h"
13 #include "media/base/key_systems.h" 13 #include "media/base/key_systems.h"
14 #include "media/base/media_keys.h" 14 #include "media/base/media_keys.h"
15 #include "media/blink/webcontentdecryptionmodulesession_impl.h" 15 #include "media/blink/webcontentdecryptionmodulesession_impl.h"
16 #include "media/cdm/aes_decryptor.h"
17 #include "url/gurl.h" 16 #include "url/gurl.h"
18 17
19 namespace media { 18 namespace media {
20 19
21 const char kMediaEME[] = "Media.EME."; 20 const char kMediaEME[] = "Media.EME.";
22 const char kDot[] = "."; 21 const char kDot[] = ".";
23 22
24 CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) { 23 CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) {
25 } 24 }
26 25
27 CdmSessionAdapter::~CdmSessionAdapter() {} 26 CdmSessionAdapter::~CdmSessionAdapter() {}
28 27
29 bool CdmSessionAdapter::Initialize(CdmFactory* cdm_factory, 28 bool CdmSessionAdapter::Initialize(CdmFactory* cdm_factory,
30 const std::string& key_system, 29 const std::string& key_system,
31 const GURL& security_origin) { 30 const GURL& security_origin) {
32 key_system_uma_prefix_ = 31 key_system_uma_prefix_ =
33 kMediaEME + GetKeySystemNameForUMA(key_system) + kDot; 32 kMediaEME + GetKeySystemNameForUMA(key_system) + kDot;
34 33
35 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); 34 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr();
36 35
37 if (CanUseAesDecryptor(key_system)) { 36 if (cdm_factory) {
ddorwin 2014/12/19 18:16:56 If we have a default, can this ever be null?
xhwang 2014/12/19 19:18:30 Good point. Done.
38 media_keys_.reset(new AesDecryptor(
39 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
40 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
41 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this)));
42 } else if (cdm_factory) {
43 media_keys_ = cdm_factory->Create( 37 media_keys_ = cdm_factory->Create(
ddorwin 2014/12/19 18:16:56 Clear Key isn't added to the existing factories. H
gunsch 2014/12/19 19:06:19 I think AesDecryptor is still created in RenderCdm
xhwang 2014/12/19 19:18:28 See gunsch's reply. We still create AesDecryptor i
xhwang 2014/12/19 19:18:30 Thanks for the link!
44 key_system, security_origin, 38 key_system, security_origin,
45 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), 39 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
46 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this), 40 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this),
47 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), 41 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
48 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this), 42 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this),
49 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this), 43 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this),
50 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this)); 44 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this));
51 } 45 }
52 46
53 return media_keys_.get() != nullptr; 47 return media_keys_.get() != nullptr;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( 183 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession(
190 const std::string& web_session_id) { 184 const std::string& web_session_id) {
191 // Since session objects may get garbage collected, it is possible that there 185 // Since session objects may get garbage collected, it is possible that there
192 // are events coming back from the CDM and the session has been unregistered. 186 // are events coming back from the CDM and the session has been unregistered.
193 // We can not tell if the CDM is firing events at sessions that never existed. 187 // We can not tell if the CDM is firing events at sessions that never existed.
194 SessionMap::iterator session = sessions_.find(web_session_id); 188 SessionMap::iterator session = sessions_.find(web_session_id);
195 return (session != sessions_.end()) ? session->second.get() : NULL; 189 return (session != sessions_.end()) ? session->second.get() : NULL;
196 } 190 }
197 191
198 } // namespace media 192 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698