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

Side by Side Diff: content/browser/media/android/browser_media_player_manager.cc

Issue 100323004: Update Android IPC messages to EME WD (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nit Created 7 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 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/browser/media/android/browser_media_player_manager.h" 5 #include "content/browser/media/android/browser_media_player_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/android/content_view_core_impl.h" 8 #include "content/browser/android/content_view_core_impl.h"
9 #include "content/browser/media/android/browser_demuxer_android.h" 9 #include "content/browser/media/android/browser_demuxer_android.h"
10 #include "content/browser/media/android/media_resource_getter_impl.h" 10 #include "content/browser/media/android/media_resource_getter_impl.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Start, OnStart) 116 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Start, OnStart)
117 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Seek, OnSeek) 117 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Seek, OnSeek)
118 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Pause, OnPause) 118 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Pause, OnPause)
119 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_SetVolume, OnSetVolume) 119 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_SetVolume, OnSetVolume)
120 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Release, OnReleaseResources) 120 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Release, OnReleaseResources)
121 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyMediaPlayer, OnDestroyPlayer) 121 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyMediaPlayer, OnDestroyPlayer)
122 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyAllMediaPlayers, 122 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyAllMediaPlayers,
123 DestroyAllMediaPlayers) 123 DestroyAllMediaPlayers)
124 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_InitializeCDM, 124 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_InitializeCDM,
125 OnInitializeCDM) 125 OnInitializeCDM)
126 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_GenerateKeyRequest, 126 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_CreateSession, OnCreateSession)
127 OnGenerateKeyRequest) 127 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_UpdateSession, OnUpdateSession)
128 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_AddKey, OnAddKey) 128 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_ReleaseSession, OnReleaseSession)
129 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_CancelKeyRequest,
130 OnCancelKeyRequest)
131 #if defined(GOOGLE_TV) 129 #if defined(GOOGLE_TV)
132 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyExternalSurface, 130 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyExternalSurface,
133 OnNotifyExternalSurface) 131 OnNotifyExternalSurface)
134 #endif 132 #endif
135 IPC_MESSAGE_UNHANDLED(handled = false) 133 IPC_MESSAGE_UNHANDLED(handled = false)
136 IPC_END_MESSAGE_MAP() 134 IPC_END_MESSAGE_MAP()
137 return handled; 135 return handled;
138 } 136 }
139 137
140 void BrowserMediaPlayerManager::FullscreenPlayerPlay() { 138 void BrowserMediaPlayerManager::FullscreenPlayerPlay() {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 pending_fullscreen_player_id_ = player_id; 346 pending_fullscreen_player_id_ = player_id;
349 return; 347 return;
350 } 348 }
351 349
352 // Send an IPC to the render process to request the video element to enter 350 // Send an IPC to the render process to request the video element to enter
353 // fullscreen. OnEnterFullscreen() will be called later on success. 351 // fullscreen. OnEnterFullscreen() will be called later on success.
354 // This guarantees the fullscreen video will be rendered correctly. 352 // This guarantees the fullscreen video will be rendered correctly.
355 // During the process, DisableFullscreenEncryptedMediaPlayback() may get 353 // During the process, DisableFullscreenEncryptedMediaPlayback() may get
356 // called before or after OnEnterFullscreen(). If it is called before 354 // called before or after OnEnterFullscreen(). If it is called before
357 // OnEnterFullscreen(), the player will not enter fullscreen. And it will 355 // OnEnterFullscreen(), the player will not enter fullscreen. And it will
358 // retry the process once the GenerateKeyRequest is allowed to proceed 356 // retry the process once CreateSession() is allowed to proceed.
359 // TODO(qinmin): make this flag default on android. 357 // TODO(qinmin): make this flag default on android.
360 if (CommandLine::ForCurrentProcess()->HasSwitch( 358 if (CommandLine::ForCurrentProcess()->HasSwitch(
361 switches::kDisableGestureRequirementForMediaFullscreen)) { 359 switches::kDisableGestureRequirementForMediaFullscreen)) {
362 Send(new MediaPlayerMsg_RequestFullscreen(routing_id(), player_id)); 360 Send(new MediaPlayerMsg_RequestFullscreen(routing_id(), player_id));
363 } 361 }
364 } 362 }
365 363
366 // The following 5 functions are EME MediaKeySession events. 364 // The following 5 functions are EME MediaKeySession events.
367 365
368 void BrowserMediaPlayerManager::OnSessionCreated( 366 void BrowserMediaPlayerManager::OnSessionCreated(
369 int media_keys_id, 367 int media_keys_id,
370 uint32 reference_id, 368 uint32 reference_id,
371 const std::string& session_id) { 369 const std::string& web_session_id) {
372 Send(new MediaKeysMsg_SetSessionId( 370 Send(new MediaKeysMsg_SessionCreated(
373 routing_id(), media_keys_id, reference_id, session_id)); 371 routing_id(), media_keys_id, reference_id, web_session_id));
374 } 372 }
375 373
376 void BrowserMediaPlayerManager::OnSessionMessage( 374 void BrowserMediaPlayerManager::OnSessionMessage(
377 int media_keys_id, 375 int media_keys_id,
378 uint32 reference_id, 376 uint32 reference_id,
379 const std::vector<uint8>& message, 377 const std::vector<uint8>& message,
380 const std::string& destination_url) { 378 const std::string& destination_url) {
381 Send(new MediaKeysMsg_KeyMessage( 379 Send(new MediaKeysMsg_SessionMessage(
382 routing_id(), media_keys_id, reference_id, message, destination_url)); 380 routing_id(), media_keys_id, reference_id, message, destination_url));
383 } 381 }
384 382
385 void BrowserMediaPlayerManager::OnSessionReady(int media_keys_id, 383 void BrowserMediaPlayerManager::OnSessionReady(int media_keys_id,
386 uint32 reference_id) { 384 uint32 reference_id) {
387 Send(new MediaKeysMsg_KeyAdded(routing_id(), media_keys_id, reference_id)); 385 Send(new MediaKeysMsg_SessionReady(
386 routing_id(), media_keys_id, reference_id));
388 } 387 }
389 388
390 void BrowserMediaPlayerManager::OnSessionClosed(int media_keys_id, 389 void BrowserMediaPlayerManager::OnSessionClosed(int media_keys_id,
391 uint32 reference_id) { 390 uint32 reference_id) {
392 // TODO(jrummell): Update Android calls and IPC names. 391 Send(new MediaKeysMsg_SessionClosed(
392 routing_id(), media_keys_id, reference_id));
393 } 393 }
394 394
395 void BrowserMediaPlayerManager::OnSessionError( 395 void BrowserMediaPlayerManager::OnSessionError(
396 int media_keys_id, 396 int media_keys_id,
397 uint32 reference_id, 397 uint32 reference_id,
398 media::MediaKeys::KeyError error_code, 398 media::MediaKeys::KeyError error_code,
399 int system_code) { 399 int system_code) {
400 Send(new MediaKeysMsg_KeyError(routing_id(), media_keys_id, 400 Send(new MediaKeysMsg_SessionError(
401 reference_id, error_code, system_code)); 401 routing_id(), media_keys_id, reference_id, error_code, system_code));
402 } 402 }
403 403
404 #if defined(GOOGLE_TV) 404 #if defined(GOOGLE_TV)
405 void BrowserMediaPlayerManager::AttachExternalVideoSurface(int player_id, 405 void BrowserMediaPlayerManager::AttachExternalVideoSurface(int player_id,
406 jobject surface) { 406 jobject surface) {
407 MediaPlayerAndroid* player = GetPlayer(player_id); 407 MediaPlayerAndroid* player = GetPlayer(player_id);
408 if (player) { 408 if (player) {
409 player->SetVideoSurface( 409 player->SetVideoSurface(
410 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); 410 gfx::ScopedJavaSurface::AcquireExternalSurface(surface));
411 } 411 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 void BrowserMediaPlayerManager::OnInitializeCDM( 545 void BrowserMediaPlayerManager::OnInitializeCDM(
546 int media_keys_id, 546 int media_keys_id,
547 const std::vector<uint8>& uuid, 547 const std::vector<uint8>& uuid,
548 const GURL& frame_url) { 548 const GURL& frame_url) {
549 AddDrmBridge(media_keys_id, uuid, frame_url); 549 AddDrmBridge(media_keys_id, uuid, frame_url);
550 // In EME v0.1b MediaKeys lives in the media element. So the |media_keys_id| 550 // In EME v0.1b MediaKeys lives in the media element. So the |media_keys_id|
551 // is the same as the |player_id|. 551 // is the same as the |player_id|.
552 OnSetMediaKeys(media_keys_id, media_keys_id); 552 OnSetMediaKeys(media_keys_id, media_keys_id);
553 } 553 }
554 554
555 void BrowserMediaPlayerManager::OnGenerateKeyRequest( 555 void BrowserMediaPlayerManager::OnCreateSession(
556 int media_keys_id, 556 int media_keys_id,
557 uint32 reference_id, 557 uint32 reference_id,
558 const std::string& type, 558 const std::string& type,
559 const std::vector<uint8>& init_data) { 559 const std::vector<uint8>& init_data) {
560 if (CommandLine::ForCurrentProcess() 560 if (CommandLine::ForCurrentProcess()
561 ->HasSwitch(switches::kDisableInfobarForProtectedMediaIdentifier)) { 561 ->HasSwitch(switches::kDisableInfobarForProtectedMediaIdentifier)) {
562 GenerateKeyIfAllowed(media_keys_id, reference_id, type, init_data, true); 562 GenerateKeyIfAllowed(media_keys_id, reference_id, type, init_data, true);
563 return; 563 return;
564 } 564 }
565 565
(...skipping 13 matching lines...) Expand all
579 web_contents(), 579 web_contents(),
580 drm_bridge->frame_url(), 580 drm_bridge->frame_url(),
581 base::Bind(&BrowserMediaPlayerManager::GenerateKeyIfAllowed, 581 base::Bind(&BrowserMediaPlayerManager::GenerateKeyIfAllowed,
582 weak_ptr_factory_.GetWeakPtr(), 582 weak_ptr_factory_.GetWeakPtr(),
583 media_keys_id, 583 media_keys_id,
584 reference_id, 584 reference_id,
585 type, 585 type,
586 init_data)); 586 init_data));
587 } 587 }
588 588
589 void BrowserMediaPlayerManager::OnAddKey(int media_keys_id, 589 void BrowserMediaPlayerManager::OnUpdateSession(
590 uint32 reference_id, 590 int media_keys_id,
591 const std::vector<uint8>& key, 591 uint32 reference_id,
592 const std::vector<uint8>& init_data) { 592 const std::vector<uint8>& response) {
593 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id); 593 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id);
594 if (!drm_bridge) { 594 if (!drm_bridge) {
595 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found"; 595 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
596 OnSessionError( 596 OnSessionError(
597 media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0); 597 media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
598 return; 598 return;
599 } 599 }
600 600
601 DCHECK(init_data.empty()); 601 drm_bridge->UpdateSession(reference_id, &response[0], response.size());
palmer 2013/12/06 19:07:32 Validate the value of response.size() ? What if it
jrummell 2013/12/06 23:36:12 0 is valid (although we don't currently have a use
602 drm_bridge->UpdateSession(reference_id, &key[0], key.size());
603 // In EME v0.1b MediaKeys lives in the media element. So the |media_keys_id| 602 // In EME v0.1b MediaKeys lives in the media element. So the |media_keys_id|
604 // is the same as the |player_id|. 603 // is the same as the |player_id|.
605 // TODO(xhwang): Separate |media_keys_id| and |player_id|. 604 // TODO(xhwang): Separate |media_keys_id| and |player_id|.
606 MediaPlayerAndroid* player = GetPlayer(media_keys_id); 605 MediaPlayerAndroid* player = GetPlayer(media_keys_id);
607 if (player) 606 if (player)
608 player->OnKeyAdded(); 607 player->OnKeyAdded();
609 } 608 }
610 609
611 void BrowserMediaPlayerManager::OnCancelKeyRequest( 610 void BrowserMediaPlayerManager::OnReleaseSession(
612 int media_keys_id, 611 int media_keys_id,
613 uint32 reference_id) { 612 uint32 reference_id) {
614 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id); 613 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id);
615 if (!drm_bridge) { 614 if (!drm_bridge) {
616 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found"; 615 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
617 OnSessionError( 616 OnSessionError(
618 media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0); 617 media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
619 return; 618 return;
620 } 619 }
621 620
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 if (pending_fullscreen_player_id_ != media_keys_id) 739 if (pending_fullscreen_player_id_ != media_keys_id)
741 return; 740 return;
742 741
743 pending_fullscreen_player_id_ = -1; 742 pending_fullscreen_player_id_ = -1;
744 MediaPlayerAndroid* player = GetPlayer(media_keys_id); 743 MediaPlayerAndroid* player = GetPlayer(media_keys_id);
745 if (player->IsPlaying()) 744 if (player->IsPlaying())
746 OnProtectedSurfaceRequested(media_keys_id); 745 OnProtectedSurfaceRequested(media_keys_id);
747 } 746 }
748 747
749 } // namespace content 748 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698