OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/android/renderer_media_player_manager.h" | 5 #include "content/renderer/media/android/renderer_media_player_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "content/common/media/cdm_messages.h" | 9 #include "content/common/media/cdm_messages.h" |
10 #include "content/common/media/media_player_messages_android.h" | 10 #include "content/common/media/media_player_messages_android.h" |
11 #include "content/renderer/media/android/proxy_media_keys.h" | 11 #include "content/renderer/media/android/proxy_media_keys.h" |
12 #include "content/renderer/media/android/renderer_media_player_manager.h" | 12 #include "content/renderer/media/android/renderer_media_player_manager.h" |
13 #include "content/renderer/media/android/webmediaplayer_android.h" | 13 #include "content/renderer/media/android/webmediaplayer_android.h" |
14 #include "ui/gfx/rect_f.h" | 14 #include "ui/gfx/rect_f.h" |
15 | 15 |
16 // Maximum sizes for various EME message parameters. These are checks to | 16 namespace content { |
17 // prevent unnecessarily large messages from being passed around, and the sizes | |
18 // are somewhat arbitrary as the EME specification doesn't specify any limits. | |
19 static const size_t kEmeWebSessionIdMaximum = 512; | |
20 static const size_t kEmeMessageMaximum = 10240; // 10 KB | |
21 | 17 |
22 namespace content { | 18 // Maximum sizes for various EME API parameters. These are checks to prevent |
| 19 // unnecessarily large messages from being passed around, and the sizes |
| 20 // are somewhat arbitrary as the EME spec doesn't specify any limits. |
| 21 const size_t kMaxWebSessionIdLength = 512; |
| 22 const size_t kMaxSessionMessageLength = 10240; // 10 KB |
23 | 23 |
24 RendererMediaPlayerManager::RendererMediaPlayerManager(RenderView* render_view) | 24 RendererMediaPlayerManager::RendererMediaPlayerManager(RenderView* render_view) |
25 : RenderViewObserver(render_view), | 25 : RenderViewObserver(render_view), |
26 next_media_player_id_(0), | 26 next_media_player_id_(0), |
27 fullscreen_frame_(NULL), | 27 fullscreen_frame_(NULL), |
28 pending_fullscreen_frame_(NULL) {} | 28 pending_fullscreen_frame_(NULL) {} |
29 | 29 |
30 RendererMediaPlayerManager::~RendererMediaPlayerManager() { | 30 RendererMediaPlayerManager::~RendererMediaPlayerManager() { |
31 std::map<int, WebMediaPlayerAndroid*>::iterator player_it; | 31 std::map<int, WebMediaPlayerAndroid*>::iterator player_it; |
32 for (player_it = media_players_.begin(); | 32 for (player_it = media_players_.begin(); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 Send(new MediaPlayerHostMsg_EnterFullscreen(routing_id(), player_id)); | 234 Send(new MediaPlayerHostMsg_EnterFullscreen(routing_id(), player_id)); |
235 } | 235 } |
236 | 236 |
237 void RendererMediaPlayerManager::ExitFullscreen(int player_id) { | 237 void RendererMediaPlayerManager::ExitFullscreen(int player_id) { |
238 pending_fullscreen_frame_ = NULL; | 238 pending_fullscreen_frame_ = NULL; |
239 Send(new MediaPlayerHostMsg_ExitFullscreen(routing_id(), player_id)); | 239 Send(new MediaPlayerHostMsg_ExitFullscreen(routing_id(), player_id)); |
240 } | 240 } |
241 | 241 |
242 void RendererMediaPlayerManager::InitializeCdm(int cdm_id, | 242 void RendererMediaPlayerManager::InitializeCdm(int cdm_id, |
243 ProxyMediaKeys* media_keys, | 243 ProxyMediaKeys* media_keys, |
244 const std::vector<uint8>& uuid, | 244 const std::string& key_system, |
245 const GURL& frame_url) { | 245 const GURL& frame_url) { |
246 RegisterMediaKeys(cdm_id, media_keys); | 246 RegisterMediaKeys(cdm_id, media_keys); |
247 Send(new CdmHostMsg_InitializeCdm(routing_id(), cdm_id, uuid, frame_url)); | 247 Send(new CdmHostMsg_InitializeCdm( |
| 248 routing_id(), cdm_id, key_system, frame_url)); |
248 } | 249 } |
249 | 250 |
250 void RendererMediaPlayerManager::CreateSession( | 251 void RendererMediaPlayerManager::CreateSession( |
251 int cdm_id, | 252 int cdm_id, |
252 uint32 session_id, | 253 uint32 session_id, |
253 CdmHostMsg_CreateSession_ContentType content_type, | 254 CdmHostMsg_CreateSession_ContentType content_type, |
254 const std::vector<uint8>& init_data) { | 255 const std::vector<uint8>& init_data) { |
255 Send(new CdmHostMsg_CreateSession( | 256 Send(new CdmHostMsg_CreateSession( |
256 routing_id(), cdm_id, session_id, content_type, init_data)); | 257 routing_id(), cdm_id, session_id, content_type, init_data)); |
257 } | 258 } |
(...skipping 11 matching lines...) Expand all Loading... |
269 } | 270 } |
270 | 271 |
271 void RendererMediaPlayerManager::DestroyCdm(int cdm_id) { | 272 void RendererMediaPlayerManager::DestroyCdm(int cdm_id) { |
272 Send(new CdmHostMsg_DestroyCdm(routing_id(), cdm_id)); | 273 Send(new CdmHostMsg_DestroyCdm(routing_id(), cdm_id)); |
273 } | 274 } |
274 | 275 |
275 void RendererMediaPlayerManager::OnSessionCreated( | 276 void RendererMediaPlayerManager::OnSessionCreated( |
276 int cdm_id, | 277 int cdm_id, |
277 uint32 session_id, | 278 uint32 session_id, |
278 const std::string& web_session_id) { | 279 const std::string& web_session_id) { |
279 if (web_session_id.length() > kEmeWebSessionIdMaximum) { | 280 if (web_session_id.length() > kMaxWebSessionIdLength) { |
280 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 281 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); |
281 return; | 282 return; |
282 } | 283 } |
283 | 284 |
284 ProxyMediaKeys* media_keys = GetMediaKeys(cdm_id); | 285 ProxyMediaKeys* media_keys = GetMediaKeys(cdm_id); |
285 if (media_keys) | 286 if (media_keys) |
286 media_keys->OnSessionCreated(session_id, web_session_id); | 287 media_keys->OnSessionCreated(session_id, web_session_id); |
287 } | 288 } |
288 | 289 |
289 void RendererMediaPlayerManager::OnSessionMessage( | 290 void RendererMediaPlayerManager::OnSessionMessage( |
290 int cdm_id, | 291 int cdm_id, |
291 uint32 session_id, | 292 uint32 session_id, |
292 const std::vector<uint8>& message, | 293 const std::vector<uint8>& message, |
293 const GURL& destination_url) { | 294 const GURL& destination_url) { |
294 if (message.size() > kEmeMessageMaximum) { | 295 if (message.size() > kMaxSessionMessageLength) { |
295 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 296 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); |
296 return; | 297 return; |
297 } | 298 } |
298 | 299 |
299 ProxyMediaKeys* media_keys = GetMediaKeys(cdm_id); | 300 ProxyMediaKeys* media_keys = GetMediaKeys(cdm_id); |
300 if (media_keys) | 301 if (media_keys) |
301 media_keys->OnSessionMessage(session_id, message, destination_url.spec()); | 302 media_keys->OnSessionMessage(session_id, message, destination_url.spec()); |
302 } | 303 } |
303 | 304 |
304 void RendererMediaPlayerManager::OnSessionReady(int cdm_id, uint32 session_id) { | 305 void RendererMediaPlayerManager::OnSessionReady(int cdm_id, uint32 session_id) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 427 |
427 if (player && player->hasVideo()) { | 428 if (player && player->hasVideo()) { |
428 if (player->UpdateBoundaryRectangle()) | 429 if (player->UpdateBoundaryRectangle()) |
429 (*changes)[player_it->first] = player->GetBoundaryRectangle(); | 430 (*changes)[player_it->first] = player->GetBoundaryRectangle(); |
430 } | 431 } |
431 } | 432 } |
432 } | 433 } |
433 #endif // defined(VIDEO_HOLE) | 434 #endif // defined(VIDEO_HOLE) |
434 | 435 |
435 } // namespace content | 436 } // namespace content |
OLD | NEW |