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 #ifndef CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
6 #define CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 6 #define CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "content/common/media/cdm_messages.h" | 17 #include "content/common/media/cdm_messages.h" |
18 #include "content/common/media/cdm_messages_enums.h" | 18 #include "content/common/media/cdm_messages_enums.h" |
19 #include "content/public/browser/browser_message_filter.h" | 19 #include "content/public/browser/browser_message_filter.h" |
20 #include "content/public/common/permission_status.mojom.h" | 20 #include "content/public/common/permission_status.mojom.h" |
21 #include "ipc/ipc_message.h" | 21 #include "ipc/ipc_message.h" |
22 #include "media/base/cdm_promise.h" | 22 #include "media/base/cdm_promise.h" |
23 #include "media/base/eme_constants.h" | 23 #include "media/base/eme_constants.h" |
24 #include "media/base/media_keys.h" | 24 #include "media/base/media_keys.h" |
25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
26 | 26 |
27 struct CdmHostMsg_CreateSessionAndGenerateRequest_Params; | 27 struct CdmHostMsg_CreateSessionAndGenerateRequest_Params; |
28 | 28 |
| 29 namespace media { |
| 30 class CdmFactory; |
| 31 } |
| 32 |
29 namespace content { | 33 namespace content { |
30 | 34 |
31 // This class manages all CDM objects. It receives control operations from the | 35 // This class manages all CDM objects. It receives control operations from the |
32 // the render process, and forwards them to corresponding CDM object. Callbacks | 36 // the render process, and forwards them to corresponding CDM object. Callbacks |
33 // from CDM objects are converted to IPCs and then sent to the render process. | 37 // from CDM objects are converted to IPCs and then sent to the render process. |
34 class CONTENT_EXPORT BrowserCdmManager : public BrowserMessageFilter { | 38 class CONTENT_EXPORT BrowserCdmManager : public BrowserMessageFilter { |
35 public: | 39 public: |
36 // Returns the BrowserCdmManager associated with the |render_process_id|. | 40 // Returns the BrowserCdmManager associated with the |render_process_id|. |
37 // Returns NULL if no BrowserCdmManager is associated. | 41 // Returns NULL if no BrowserCdmManager is associated. |
38 static BrowserCdmManager* FromProcess(int render_process_id); | 42 static BrowserCdmManager* FromProcess(int render_process_id); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 media::MediaKeys::Exception exception, | 76 media::MediaKeys::Exception exception, |
73 uint32_t system_code, | 77 uint32_t system_code, |
74 const std::string& error_message); | 78 const std::string& error_message); |
75 | 79 |
76 protected: | 80 protected: |
77 friend class base::RefCountedThreadSafe<BrowserCdmManager>; | 81 friend class base::RefCountedThreadSafe<BrowserCdmManager>; |
78 friend class base::DeleteHelper<BrowserCdmManager>; | 82 friend class base::DeleteHelper<BrowserCdmManager>; |
79 ~BrowserCdmManager() override; | 83 ~BrowserCdmManager() override; |
80 | 84 |
81 private: | 85 private: |
| 86 // Returns the CdmFactory that can be used to create CDMs. Returns null if |
| 87 // CDM is not supported. |
| 88 media::CdmFactory* GetCdmFactory(); |
| 89 |
82 // CDM callbacks. | 90 // CDM callbacks. |
83 void OnSessionMessage(int render_frame_id, | 91 void OnSessionMessage(int render_frame_id, |
84 int cdm_id, | 92 int cdm_id, |
85 const std::string& session_id, | 93 const std::string& session_id, |
86 media::MediaKeys::MessageType message_type, | 94 media::MediaKeys::MessageType message_type, |
87 const std::vector<uint8>& message, | 95 const std::vector<uint8>& message, |
88 const GURL& legacy_destination_url); | 96 const GURL& legacy_destination_url); |
89 void OnSessionClosed(int render_frame_id, | 97 void OnSessionClosed(int render_frame_id, |
90 int cdm_id, | 98 int cdm_id, |
91 const std::string& session_id); | 99 const std::string& session_id); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 void OnCloseSession(int render_frame_id, | 138 void OnCloseSession(int render_frame_id, |
131 int cdm_id, | 139 int cdm_id, |
132 uint32_t promise_id, | 140 uint32_t promise_id, |
133 const std::string& session_id); | 141 const std::string& session_id); |
134 void OnRemoveSession(int render_frame_id, | 142 void OnRemoveSession(int render_frame_id, |
135 int cdm_id, | 143 int cdm_id, |
136 uint32_t promise_id, | 144 uint32_t promise_id, |
137 const std::string& session_id); | 145 const std::string& session_id); |
138 void OnDestroyCdm(int render_frame_id, int cdm_id); | 146 void OnDestroyCdm(int render_frame_id, int cdm_id); |
139 | 147 |
140 // Adds a new CDM identified by |cdm_id| for the given |key_system| and | 148 // Callback for CDM creation. |
141 // |security_origin|. | 149 void OnCdmCreated(int render_frame_id, |
142 void AddCdm(int render_frame_id, | 150 int cdm_id, |
143 int cdm_id, | 151 const GURL& security_origin, |
144 uint32_t promise_id, | 152 scoped_ptr<media::SimpleCdmPromise> promise, |
145 const std::string& key_system, | 153 const scoped_refptr<media::MediaKeys>& cdm, |
146 const GURL& security_origin, | 154 const std::string& error_message); |
147 bool use_hw_secure_codecs); | |
148 | 155 |
149 // Removes all CDMs associated with |render_frame_id|. | 156 // Removes all CDMs associated with |render_frame_id|. |
150 void RemoveAllCdmForFrame(int render_frame_id); | 157 void RemoveAllCdmForFrame(int render_frame_id); |
151 | 158 |
152 // Removes the CDM with the specified id. | 159 // Removes the CDM with the specified id. |
153 void RemoveCdm(uint64 id); | 160 void RemoveCdm(uint64 id); |
154 | 161 |
155 using PermissionStatusCB = base::Callback<void(bool)>; | 162 using PermissionStatusCB = base::Callback<void(bool)>; |
156 | 163 |
157 // Checks protected media identifier permission for the given | 164 // Checks protected media identifier permission for the given |
(...skipping 28 matching lines...) Expand all Loading... |
186 const std::string& session_id, | 193 const std::string& session_id, |
187 scoped_ptr<media::NewSessionCdmPromise> promise, | 194 scoped_ptr<media::NewSessionCdmPromise> promise, |
188 bool permission_was_allowed); | 195 bool permission_was_allowed); |
189 | 196 |
190 const int render_process_id_; | 197 const int render_process_id_; |
191 | 198 |
192 // TaskRunner to dispatch all CDM messages to. If it's NULL, all messages are | 199 // TaskRunner to dispatch all CDM messages to. If it's NULL, all messages are |
193 // dispatched to the browser UI thread. | 200 // dispatched to the browser UI thread. |
194 scoped_refptr<base::TaskRunner> task_runner_; | 201 scoped_refptr<base::TaskRunner> task_runner_; |
195 | 202 |
| 203 scoped_ptr<media::CdmFactory> cdm_factory_; |
| 204 |
196 // The key in the following maps is a combination of |render_frame_id| and | 205 // The key in the following maps is a combination of |render_frame_id| and |
197 // |cdm_id|. | 206 // |cdm_id|. |
198 | 207 |
199 // Map of managed CDMs. | 208 // Map of managed CDMs. |
200 typedef std::map<uint64, scoped_refptr<media::MediaKeys>> CdmMap; | 209 typedef std::map<uint64, scoped_refptr<media::MediaKeys>> CdmMap; |
201 CdmMap cdm_map_; | 210 CdmMap cdm_map_; |
202 | 211 |
203 // Map of CDM's security origin. | 212 // Map of CDM's security origin. |
204 std::map<uint64, GURL> cdm_security_origin_map_; | 213 std::map<uint64, GURL> cdm_security_origin_map_; |
205 | 214 |
206 base::WeakPtrFactory<BrowserCdmManager> weak_ptr_factory_; | 215 base::WeakPtrFactory<BrowserCdmManager> weak_ptr_factory_; |
207 | 216 |
208 DISALLOW_COPY_AND_ASSIGN(BrowserCdmManager); | 217 DISALLOW_COPY_AND_ASSIGN(BrowserCdmManager); |
209 }; | 218 }; |
210 | 219 |
211 } // namespace content | 220 } // namespace content |
212 | 221 |
213 #endif // CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 222 #endif // CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
OLD | NEW |