blob: d51131024ed7d64f133c9188ec6f206c3e847221 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/callback.h"
#include "base/macros.h"
#include "media/base/media_export.h"
#include "ui/gfx/geometry/rect.h"
namespace media {
class AndroidOverlay;
// Configuration used to create an overlay.
struct MEDIA_EXPORT AndroidOverlayConfig {
// Called when the overlay is ready for use, via |GetJavaSurface()|.
using ReadyCB = base::OnceCallback<void(AndroidOverlay*)>;
// Called when overlay has failed before |ReadyCB| is called. Will not be
// called after ReadyCB. It will be the last callback for the overlay, except
// for any DeletedCB.
using FailedCB = base::OnceCallback<void(AndroidOverlay*)>;
// Called when the surface has been destroyed. This will not be called unless
// ReadyCB has been called. It will be the last callback for the overlay,
// except for any DeletedCB. In response, the client is expected to quit
// using the surface and delete the overlay object.
using DestroyedCB = base::OnceCallback<void(AndroidOverlay*)>;
// Called when the overlay object has been deleted. This is unrelated to
// any DestroyedCB, which informs us when the surface is no longer usable and
// that we should delete the AndroidOverlay object. DeletedCB is called when
// the AndroidOverlay object is deleted for any reason. It is guaranteed that
// the overlay pointer will still be a valid pointer, but it is not safe to
// access it. It's provided just to make it easier to tell which overlay is
// being deleted.
using DeletedCB = base::OnceCallback<void(AndroidOverlay*)>;
// Optional callback to find out about the power-efficient state of the
// overlay. Called with true if the overlay is power-efficient, and false
// if it isn't. To receive these callbacks, one must set |power_efficient|.
using PowerEfficientCB = base::RepeatingCallback<void(AndroidOverlay*, bool)>;
// Configuration used to create an overlay.
// Initial rectangle for the overlay. May be changed via ScheduleLayout().
gfx::Rect rect;
// Require a secure overlay?
bool secure = false;
// Require that the overlay is power efficient? In other words, don't get
// an overlay if it (for example) pushes the device into GLES composition. If
// an overlay is provided, but it later becomes not power efficient, then it
// will not be destroyed. Use PowerEfficientCB to determine that this has
// happened, since that lets the client handle it more gracefully rather than
// looking like the surface was lost.
bool power_efficient = false;
// Convenient helpers since the syntax is weird.
void is_ready(AndroidOverlay* overlay) {
if (ready_cb)
void is_failed(AndroidOverlay* overlay) {
if (failed_cb)
ReadyCB ready_cb;
FailedCB failed_cb;
// Optional, may be empty.
PowerEfficientCB power_cb;
// Common factory type.
using AndroidOverlayFactoryCB =
} // namespace media