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

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

Issue 132233042: Enable the embedded L1/EME support in WebView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added ExternalVideoSurfaceDelegate.java. Created 6 years, 10 months 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 | Annotate | Revision Log
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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 if ((*it)->IsPlayerReady() && !(*it)->IsPlaying() && 326 if ((*it)->IsPlayerReady() && !(*it)->IsPlaying() &&
327 fullscreen_player_id_ != (*it)->player_id()) { 327 fullscreen_player_id_ != (*it)->player_id()) {
328 (*it)->Release(); 328 (*it)->Release();
329 Send(new MediaPlayerMsg_MediaPlayerReleased( 329 Send(new MediaPlayerMsg_MediaPlayerReleased(
330 routing_id(), (*it)->player_id())); 330 routing_id(), (*it)->player_id()));
331 } 331 }
332 } 332 }
333 } 333 }
334 334
335 void BrowserMediaPlayerManager::ReleaseMediaResources(int player_id) { 335 void BrowserMediaPlayerManager::ReleaseMediaResources(int player_id) {
336 // Nothing needs to be done. 336 #if defined(VIDEO_HOLE)
337 WebContentsViewAndroid* view =
338 static_cast<WebContentsViewAndroid*>(web_contents_->GetView());
Ted C 2014/02/14 18:32:52 Any reason you are going through WebContentsViewAn
ycheo (away) 2014/02/18 08:35:56 After refactoring, we don't need to apply this.
339 if (view)
340 view->ReleaseExternalVideoSurface(player_id);
341 #endif // defined(VIDEO_HOLE)
337 } 342 }
338 343
339 media::MediaResourceGetter* 344 media::MediaResourceGetter*
340 BrowserMediaPlayerManager::GetMediaResourceGetter() { 345 BrowserMediaPlayerManager::GetMediaResourceGetter() {
341 if (!media_resource_getter_.get()) { 346 if (!media_resource_getter_.get()) {
342 RenderProcessHost* host = web_contents()->GetRenderProcessHost(); 347 RenderProcessHost* host = web_contents()->GetRenderProcessHost();
343 BrowserContext* context = host->GetBrowserContext(); 348 BrowserContext* context = host->GetBrowserContext();
344 StoragePartition* partition = host->GetStoragePartition(); 349 StoragePartition* partition = host->GetStoragePartition();
345 fileapi::FileSystemContext* file_system_context = 350 fileapi::FileSystemContext* file_system_context =
346 partition ? partition->GetFileSystemContext() : NULL; 351 partition ? partition->GetFileSystemContext() : NULL;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 player->SetVideoSurface(gfx::ScopedJavaSurface()); 471 player->SetVideoSurface(gfx::ScopedJavaSurface());
467 } 472 }
468 473
469 void BrowserMediaPlayerManager::OnNotifyExternalSurface( 474 void BrowserMediaPlayerManager::OnNotifyExternalSurface(
470 int player_id, bool is_request, const gfx::RectF& rect) { 475 int player_id, bool is_request, const gfx::RectF& rect) {
471 if (!web_contents_) 476 if (!web_contents_)
472 return; 477 return;
473 478
474 WebContentsViewAndroid* view = 479 WebContentsViewAndroid* view =
475 static_cast<WebContentsViewAndroid*>(web_contents_->GetView()); 480 static_cast<WebContentsViewAndroid*>(web_contents_->GetView());
476 if (view) 481 if (view) {
477 view->NotifyExternalSurface(player_id, is_request, rect); 482 if (is_request)
483 view->RequestExternalVideoSurface(player_id);
484 view->NotifyExternalVideoSurfacePositionChanged(player_id, rect);
485 }
478 } 486 }
479 #endif // defined(VIDEO_HOLE) 487 #endif // defined(VIDEO_HOLE)
480 488
481 void BrowserMediaPlayerManager::DisableFullscreenEncryptedMediaPlayback() { 489 void BrowserMediaPlayerManager::DisableFullscreenEncryptedMediaPlayback() {
482 if (fullscreen_player_id_ == -1) 490 if (fullscreen_player_id_ == -1)
483 return; 491 return;
484 492
485 // If the fullscreen player is not playing back encrypted video, do nothing. 493 // If the fullscreen player is not playing back encrypted video, do nothing.
486 MediaDrmBridge* drm_bridge = GetDrmBridge(fullscreen_player_id_); 494 MediaDrmBridge* drm_bridge = GetDrmBridge(fullscreen_player_id_);
487 if (!drm_bridge) 495 if (!drm_bridge)
488 return; 496 return;
489 497
490 // Exit fullscreen. 498 // Exit fullscreen.
491 pending_fullscreen_player_id_ = fullscreen_player_id_; 499 pending_fullscreen_player_id_ = fullscreen_player_id_;
492 OnExitFullscreen(fullscreen_player_id_); 500 OnExitFullscreen(fullscreen_player_id_);
493 } 501 }
494 502
495 void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) { 503 void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) {
496 DCHECK_EQ(fullscreen_player_id_, -1); 504 DCHECK_EQ(fullscreen_player_id_, -1);
497 if (media_keys_ids_pending_approval_.find(player_id) != 505 if (media_keys_ids_pending_approval_.find(player_id) !=
498 media_keys_ids_pending_approval_.end()) { 506 media_keys_ids_pending_approval_.end()) {
499 return; 507 return;
500 } 508 }
501 509
510 #if defined(VIDEO_HOLE)
511 WebContentsViewAndroid* view =
512 static_cast<WebContentsViewAndroid*>(web_contents_->GetView());
513 if (view)
514 view->ReleaseExternalVideoSurface(player_id);
515 #endif // defined(VIDEO_HOLE)
502 if (video_view_.get()) { 516 if (video_view_.get()) {
503 fullscreen_player_id_ = player_id; 517 fullscreen_player_id_ = player_id;
504 video_view_->OpenVideo(); 518 video_view_->OpenVideo();
505 } else if (!ContentVideoView::GetInstance()) { 519 } else if (!ContentVideoView::GetInstance()) {
506 // In Android WebView, two ContentViewCores could both try to enter 520 // In Android WebView, two ContentViewCores could both try to enter
507 // fullscreen video, we just ignore the second one. 521 // fullscreen video, we just ignore the second one.
508 fullscreen_player_id_ = player_id; 522 fullscreen_player_id_ = player_id;
509 video_view_.reset(new ContentVideoView(this)); 523 video_view_.reset(new ContentVideoView(this));
510 } 524 }
511 } 525 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 void BrowserMediaPlayerManager::OnSetVolume(int player_id, double volume) { 578 void BrowserMediaPlayerManager::OnSetVolume(int player_id, double volume) {
565 MediaPlayerAndroid* player = GetPlayer(player_id); 579 MediaPlayerAndroid* player = GetPlayer(player_id);
566 if (player) 580 if (player)
567 player->SetVolume(volume); 581 player->SetVolume(volume);
568 } 582 }
569 583
570 void BrowserMediaPlayerManager::OnReleaseResources(int player_id) { 584 void BrowserMediaPlayerManager::OnReleaseResources(int player_id) {
571 MediaPlayerAndroid* player = GetPlayer(player_id); 585 MediaPlayerAndroid* player = GetPlayer(player_id);
572 if (player) 586 if (player)
573 player->Release(); 587 player->Release();
574
575 #if defined(VIDEO_HOLE)
576 WebContentsViewAndroid* view =
577 static_cast<WebContentsViewAndroid*>(web_contents_->GetView());
578 if (view)
579 view->NotifyExternalSurface(player_id, false, gfx::RectF());
580 #endif // defined(VIDEO_HOLE)
581 } 588 }
582 589
583 void BrowserMediaPlayerManager::OnDestroyPlayer(int player_id) { 590 void BrowserMediaPlayerManager::OnDestroyPlayer(int player_id) {
584 RemovePlayer(player_id); 591 RemovePlayer(player_id);
585 if (fullscreen_player_id_ == player_id) 592 if (fullscreen_player_id_ == player_id)
586 fullscreen_player_id_ = -1; 593 fullscreen_player_id_ = -1;
587 } 594 }
588 595
589 void BrowserMediaPlayerManager::OnInitializeCDM( 596 void BrowserMediaPlayerManager::OnInitializeCDM(
590 int media_keys_id, 597 int media_keys_id,
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 if (player->IsPlaying()) 859 if (player->IsPlaying())
853 OnProtectedSurfaceRequested(media_keys_id); 860 OnProtectedSurfaceRequested(media_keys_id);
854 } 861 }
855 862
856 void BrowserMediaPlayerManager::ReleaseFullscreenPlayer( 863 void BrowserMediaPlayerManager::ReleaseFullscreenPlayer(
857 MediaPlayerAndroid* player) { 864 MediaPlayerAndroid* player) {
858 player->Release(); 865 player->Release();
859 } 866 }
860 867
861 } // namespace content 868 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698