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

Unified Diff: media/gpu/avda_codec_allocator.h

Issue 2692863011: Add ContentVideoViewOverlay to AVDA. (Closed)
Patch Set: keep |overlay| longer in UpdateSurface, comments Created 3 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 side-by-side diff with in-line comments
Download patch
Index: media/gpu/avda_codec_allocator.h
diff --git a/media/gpu/avda_codec_allocator.h b/media/gpu/avda_codec_allocator.h
index b1b9a405d3de2e01d9cf9b7e30494cb6d751f51a..44dac6266c995f874a4e3f42a5290b41125fabca 100644
--- a/media/gpu/avda_codec_allocator.h
+++ b/media/gpu/avda_codec_allocator.h
@@ -19,6 +19,7 @@
#include "base/threading/thread_checker.h"
#include "base/time/tick_clock.h"
#include "base/trace_event/trace_event.h"
+#include "media/base/android/android_overlay.h"
#include "media/base/android/media_codec_bridge_impl.h"
#include "media/base/android/media_drm_bridge_cdm_context.h"
#include "media/base/media.h"
@@ -49,14 +50,30 @@ class CodecConfig : public base::RefCountedThreadSafe<CodecConfig> {
VideoCodec codec = kUnknownVideoCodec;
- // The surface that MediaCodec is configured to output to.
- gl::ScopedJavaSurface surface;
+ // The surface that MediaCodec is configured to output to. This can be either
+ // a SurfaceTexture or other Surface provider.
+ // TODO(liberato): it would be nice if we had an abstraction that included
+ // SurfaceTexture and Overlay, but we don't right now.
+ const base::android::JavaRef<jobject>& j_surface() const {
+ if (overlay)
+ return overlay->j_surface();
+ else
+ return surface_texture_surface.j_surface();
+ }
+
+ // Surface ID, if we're using a ContentVideoViewOverlay.
int surface_id = SurfaceManager::kNoSurfaceID;
- // The SurfaceTexture attached to |surface|, or nullptr if |surface| is
- // SurfaceView backed.
+ // If |overlay| is non-null, then |overlay| owns |surface|.
+ std::unique_ptr<AndroidOverlay> overlay;
+
+ // The SurfaceTexture attached to |surface_texture_surface|, or nullptr if
+ // this is SurfaceView backed.
scoped_refptr<gl::SurfaceTexture> surface_texture;
+ // If |surface_texture| is not null, then this is the surface for it.
+ gl::ScopedJavaSurface surface_texture_surface;
+
// The MediaCrypto that MediaCodec is configured with for an encrypted stream.
MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto;
@@ -84,7 +101,7 @@ class CodecConfig : public base::RefCountedThreadSafe<CodecConfig> {
DISALLOW_COPY_AND_ASSIGN(CodecConfig);
};
-class AVDACodecAllocatorClient {
+class AVDASurfaceAllocatorClient {
public:
// Called when the requested SurfaceView becomes available after a call to
// AllocateSurface()
@@ -96,9 +113,16 @@ class AVDACodecAllocatorClient {
// need to call DeallocateSurface();
virtual void OnSurfaceDestroyed() = 0;
+ protected:
+ ~AVDASurfaceAllocatorClient() {}
+};
+
+class AVDACodecAllocatorClient {
+ public:
// Called on the main thread when a new MediaCodec is configured.
// |media_codec| will be null if configuration failed.
virtual void OnCodecConfigured(
+ scoped_refptr<CodecConfig> codec_config,
std::unique_ptr<VideoCodecBridge> media_codec) = 0;
protected:
@@ -126,13 +150,13 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Returns true if the caller now owns the surface, or false if someone else
// owns the surface. |client| will be notified when the surface is available
// via OnSurfaceAvailable().
- bool AllocateSurface(AVDACodecAllocatorClient* client, int surface_id);
+ bool AllocateSurface(AVDASurfaceAllocatorClient* client, int surface_id);
// Relinquish ownership of the surface or stop waiting for it to be available.
// The caller must guarantee that when calling this the surface is either no
// longer attached to a MediaCodec, or the MediaCodec it was attached to is
// was released with ReleaseMediaCodec().
- void DeallocateSurface(AVDACodecAllocatorClient* client, int surface_id);
+ void DeallocateSurface(AVDASurfaceAllocatorClient* client, int surface_id);
// Create and configure a MediaCodec synchronously.
std::unique_ptr<VideoCodecBridge> CreateMediaCodecSync(
@@ -180,8 +204,8 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
friend class AVDACodecAllocatorTest;
struct OwnerRecord {
- AVDACodecAllocatorClient* owner = nullptr;
- AVDACodecAllocatorClient* waiter = nullptr;
+ AVDASurfaceAllocatorClient* owner = nullptr;
+ AVDASurfaceAllocatorClient* waiter = nullptr;
};
class HangDetector : public base::MessageLoop::TaskObserver {

Powered by Google App Engine
This is Rietveld 408576698