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

Unified Diff: media/gpu/android_video_decode_accelerator.cc

Issue 2890033002: Use AndroidOverlay in AVDA. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/android_video_decode_accelerator.cc
diff --git a/media/gpu/android_video_decode_accelerator.cc b/media/gpu/android_video_decode_accelerator.cc
index ab6b0608b83b67097e517a738504d1cfbfeee79a..9477e6966058ebe2ff7d5b7951940c8f64ff1d30 100644
--- a/media/gpu/android_video_decode_accelerator.cc
+++ b/media/gpu/android_video_decode_accelerator.cc
@@ -113,12 +113,19 @@ constexpr base::TimeDelta IdleTimerTimeOut = base::TimeDelta::FromSeconds(1);
bool ShouldDeferSurfaceCreation(
AVDACodecAllocator* codec_allocator,
int surface_id,
+ base::Optional<base::UnguessableToken> overlay_routing_token,
VideoCodec codec,
const AndroidVideoDecodeAccelerator::PlatformConfig& platform_config) {
- return platform_config.force_deferred_surface_creation ||
- (surface_id == SurfaceManager::kNoSurfaceID && codec == kCodecH264 &&
- codec_allocator->IsAnyRegisteredAVDA() &&
- platform_config.sdk_int <= 18);
+ if (platform_config.force_deferred_surface_creation)
+ return true;
+
+ // TODO(liberato): We might still want to defer if we've got a routing
+ // token. It depends on whether we want to use it right away or not.
+ if (surface_id != SurfaceManager::kNoSurfaceID || overlay_routing_token)
+ return false;
+
+ return codec == kCodecH264 && codec_allocator->IsAnyRegisteredAVDA() &&
+ platform_config.sdk_int <= 18;
}
std::unique_ptr<AndroidOverlay> CreateContentVideoViewOverlay(
@@ -352,6 +359,7 @@ bool AndroidVideoDecodeAccelerator::Initialize(const Config& config,
// If we're low on resources, we may decide to defer creation of the surface
// until the codec is actually used.
if (ShouldDeferSurfaceCreation(codec_allocator_, config_.surface_id,
+ config_.overlay_routing_token,
codec_config_->codec, platform_config_)) {
// We should never be here if a SurfaceView is required.
// TODO(liberato): This really isn't true with AndroidOverlay.
@@ -408,6 +416,7 @@ void AndroidVideoDecodeAccelerator::StartSurfaceChooser() {
// signal success optimistically.
if (during_initialize_ && !deferred_initialization_pending_) {
DCHECK_EQ(config_.surface_id, SurfaceManager::kNoSurfaceID);
+ DCHECK(!config_.overlay_routing_token);
OnSurfaceTransition(nullptr);
return;
}
@@ -416,6 +425,8 @@ void AndroidVideoDecodeAccelerator::StartSurfaceChooser() {
AndroidOverlayFactoryCB factory;
if (config_.surface_id != SurfaceManager::kNoSurfaceID)
factory = base::Bind(&CreateContentVideoViewOverlay, config_.surface_id);
+ else if (config_.overlay_routing_token && overlay_factory_cb_)
+ factory = base::Bind(overlay_factory_cb_, *config_.overlay_routing_token);
// Notify |surface_chooser_| that we've started. This guarantees that we'll
// get a callback. It might not be a synchronous callback, but we're not in
@@ -1255,12 +1266,13 @@ void AndroidVideoDecodeAccelerator::SetSurface(
// surface. In this case, just pretend that |surface_id| is the initial one.
if (state_ == BEFORE_OVERLAY_INIT) {
config_.surface_id = surface_id;
+ config_.overlay_routing_token = routing_token;
return;
}
AndroidOverlayFactoryCB factory;
- if (routing_token) {
- // TODO(liberato): do something
+ if (routing_token && overlay_factory_cb_) {
+ factory = base::Bind(overlay_factory_cb_, *routing_token);
} else if (surface_id != SurfaceManager::kNoSurfaceID) {
factory = base::Bind(&CreateContentVideoViewOverlay, surface_id);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698