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/containers/scoped_ptr_hash_map.h" | 14 #include "base/containers/scoped_ptr_hash_map.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
18 #include "content/common/media/cdm_messages.h" | 18 #include "content/common/media/cdm_messages.h" |
19 #include "content/common/media/cdm_messages_enums.h" | 19 #include "content/common/media/cdm_messages_enums.h" |
20 #include "content/public/browser/browser_message_filter.h" | 20 #include "content/public/browser/browser_message_filter.h" |
21 #include "content/public/common/permission_status.mojom.h" | 21 #include "content/public/common/permission_status.mojom.h" |
22 #include "ipc/ipc_message.h" | 22 #include "ipc/ipc_message.h" |
23 #include "media/base/cdm_promise.h" | 23 #include "media/base/cdm_promise.h" |
24 #include "media/base/eme_constants.h" | 24 #include "media/base/eme_constants.h" |
25 #include "media/base/media_keys.h" | 25 #include "media/base/media_keys.h" |
26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
27 | 27 |
| 28 struct CdmHostMsg_CreateSessionAndGenerateRequest_Params; |
| 29 |
28 namespace media { | 30 namespace media { |
29 class BrowserCdm; | 31 class BrowserCdm; |
30 } | 32 } |
31 | 33 |
32 namespace content { | 34 namespace content { |
33 | 35 |
34 // This class manages all CDM objects. It receives control operations from the | 36 // This class manages all CDM objects. It receives control operations from the |
35 // the render process, and forwards them to corresponding CDM object. Callbacks | 37 // the render process, and forwards them to corresponding CDM object. Callbacks |
36 // from CDM objects are converted to IPCs and then sent to the render process. | 38 // from CDM objects are converted to IPCs and then sent to the render process. |
37 class CONTENT_EXPORT BrowserCdmManager : public BrowserMessageFilter { | 39 class CONTENT_EXPORT BrowserCdmManager : public BrowserMessageFilter { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // Message handlers. | 111 // Message handlers. |
110 void OnInitializeCdm(int render_frame_id, | 112 void OnInitializeCdm(int render_frame_id, |
111 int cdm_id, | 113 int cdm_id, |
112 uint32_t promise_id, | 114 uint32_t promise_id, |
113 const CdmHostMsg_InitializeCdm_Params& params); | 115 const CdmHostMsg_InitializeCdm_Params& params); |
114 void OnSetServerCertificate(int render_frame_id, | 116 void OnSetServerCertificate(int render_frame_id, |
115 int cdm_id, | 117 int cdm_id, |
116 uint32_t promise_id, | 118 uint32_t promise_id, |
117 const std::vector<uint8_t>& certificate); | 119 const std::vector<uint8_t>& certificate); |
118 void OnCreateSessionAndGenerateRequest( | 120 void OnCreateSessionAndGenerateRequest( |
| 121 const CdmHostMsg_CreateSessionAndGenerateRequest_Params& params); |
| 122 void OnLoadSession( |
119 int render_frame_id, | 123 int render_frame_id, |
120 int cdm_id, | 124 int cdm_id, |
121 uint32_t promise_id, | 125 uint32_t promise_id, |
122 CdmHostMsg_CreateSession_InitDataType init_data_type, | 126 media::MediaKeys::SessionType session_type, |
123 const std::vector<uint8>& init_data); | 127 const std::string& session_id); |
124 void OnUpdateSession(int render_frame_id, | 128 void OnUpdateSession(int render_frame_id, |
125 int cdm_id, | 129 int cdm_id, |
126 uint32_t promise_id, | 130 uint32_t promise_id, |
127 const std::string& session_id, | 131 const std::string& session_id, |
128 const std::vector<uint8>& response); | 132 const std::vector<uint8>& response); |
129 void OnCloseSession(int render_frame_id, | 133 void OnCloseSession(int render_frame_id, |
130 int cdm_id, | 134 int cdm_id, |
131 uint32_t promise_id, | 135 uint32_t promise_id, |
132 const std::string& session_id); | 136 const std::string& session_id); |
| 137 void OnRemoveSession(int render_frame_id, |
| 138 int cdm_id, |
| 139 uint32_t promise_id, |
| 140 const std::string& session_id); |
133 void OnDestroyCdm(int render_frame_id, int cdm_id); | 141 void OnDestroyCdm(int render_frame_id, int cdm_id); |
134 | 142 |
135 // Adds a new CDM identified by |cdm_id| for the given |key_system| and | 143 // Adds a new CDM identified by |cdm_id| for the given |key_system| and |
136 // |security_origin|. | 144 // |security_origin|. |
137 void AddCdm(int render_frame_id, | 145 void AddCdm(int render_frame_id, |
138 int cdm_id, | 146 int cdm_id, |
139 uint32_t promise_id, | 147 uint32_t promise_id, |
140 const std::string& key_system, | 148 const std::string& key_system, |
141 const GURL& security_origin, | 149 const GURL& security_origin, |
142 bool use_hw_secure_codecs); | 150 bool use_hw_secure_codecs); |
(...skipping 17 matching lines...) Expand all Loading... |
160 void CheckPermissionStatusOnUIThread( | 168 void CheckPermissionStatusOnUIThread( |
161 int render_frame_id, | 169 int render_frame_id, |
162 const GURL& security_origin, | 170 const GURL& security_origin, |
163 const PermissionStatusCB& permission_status_cb); | 171 const PermissionStatusCB& permission_status_cb); |
164 | 172 |
165 // Calls CreateSessionAndGenerateRequest() on the CDM if | 173 // Calls CreateSessionAndGenerateRequest() on the CDM if |
166 // |permission_was_allowed| is true. Otherwise rejects the |promise|. | 174 // |permission_was_allowed| is true. Otherwise rejects the |promise|. |
167 void CreateSessionAndGenerateRequestIfPermitted( | 175 void CreateSessionAndGenerateRequestIfPermitted( |
168 int render_frame_id, | 176 int render_frame_id, |
169 int cdm_id, | 177 int cdm_id, |
| 178 media::MediaKeys::SessionType session_type, |
170 media::EmeInitDataType init_data_type, | 179 media::EmeInitDataType init_data_type, |
171 const std::vector<uint8>& init_data, | 180 const std::vector<uint8>& init_data, |
172 scoped_ptr<media::NewSessionCdmPromise> promise, | 181 scoped_ptr<media::NewSessionCdmPromise> promise, |
173 bool permission_was_allowed); | 182 bool permission_was_allowed); |
174 | 183 |
| 184 // Calls LoadSession() on the CDM if |permission_was_allowed| is true. |
| 185 // Otherwise rejects |promise|. |
| 186 void LoadSessionIfPermitted(int render_frame_id, |
| 187 int cdm_id, |
| 188 media::MediaKeys::SessionType session_type, |
| 189 const std::string& session_id, |
| 190 scoped_ptr<media::NewSessionCdmPromise> promise, |
| 191 bool permission_was_allowed); |
| 192 |
175 const int render_process_id_; | 193 const int render_process_id_; |
176 | 194 |
177 // TaskRunner to dispatch all CDM messages to. If it's NULL, all messages are | 195 // TaskRunner to dispatch all CDM messages to. If it's NULL, all messages are |
178 // dispatched to the browser UI thread. | 196 // dispatched to the browser UI thread. |
179 scoped_refptr<base::TaskRunner> task_runner_; | 197 scoped_refptr<base::TaskRunner> task_runner_; |
180 | 198 |
181 // The key in the following maps is a combination of |render_frame_id| and | 199 // The key in the following maps is a combination of |render_frame_id| and |
182 // |cdm_id|. | 200 // |cdm_id|. |
183 | 201 |
184 // Map of managed BrowserCdms. | 202 // Map of managed BrowserCdms. |
185 typedef base::ScopedPtrHashMap<uint64, scoped_ptr<media::BrowserCdm>> CdmMap; | 203 typedef base::ScopedPtrHashMap<uint64, scoped_ptr<media::BrowserCdm>> CdmMap; |
186 CdmMap cdm_map_; | 204 CdmMap cdm_map_; |
187 | 205 |
188 // Map of CDM's security origin. | 206 // Map of CDM's security origin. |
189 std::map<uint64, GURL> cdm_security_origin_map_; | 207 std::map<uint64, GURL> cdm_security_origin_map_; |
190 | 208 |
191 base::WeakPtrFactory<BrowserCdmManager> weak_ptr_factory_; | 209 base::WeakPtrFactory<BrowserCdmManager> weak_ptr_factory_; |
192 | 210 |
193 DISALLOW_COPY_AND_ASSIGN(BrowserCdmManager); | 211 DISALLOW_COPY_AND_ASSIGN(BrowserCdmManager); |
194 }; | 212 }; |
195 | 213 |
196 } // namespace content | 214 } // namespace content |
197 | 215 |
198 #endif // CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ | 216 #endif // CONTENT_BROWSER_MEDIA_CDM_BROWSER_CDM_MANAGER_H_ |
OLD | NEW |