| Index: media/gpu/android_video_decode_accelerator.h
|
| diff --git a/media/gpu/android_video_decode_accelerator.h b/media/gpu/android_video_decode_accelerator.h
|
| index 0cf5918b85b8a3406640ad96464d96e00e3633fd..8470efaa40a18870e08009a19cc27b3e10bd1ad4 100644
|
| --- a/media/gpu/android_video_decode_accelerator.h
|
| +++ b/media/gpu/android_video_decode_accelerator.h
|
| @@ -9,9 +9,7 @@
|
|
|
| #include <list>
|
| #include <map>
|
| -#include <memory>
|
| #include <queue>
|
| -#include <string>
|
| #include <vector>
|
|
|
| #include "base/compiler_specific.h"
|
| @@ -22,6 +20,7 @@
|
| #include "media/base/android/media_drm_bridge_cdm_context.h"
|
| #include "media/base/android/sdk_media_codec_bridge.h"
|
| #include "media/base/media_keys.h"
|
| +#include "media/gpu/avda_picture_buffer_manager.h"
|
| #include "media/gpu/avda_state_provider.h"
|
| #include "media/gpu/avda_surface_tracker.h"
|
| #include "media/gpu/gpu_video_decode_accelerator_helpers.h"
|
| @@ -34,92 +33,16 @@ class SurfaceTexture;
|
| }
|
|
|
| namespace media {
|
| -
|
| class SharedMemoryRegion;
|
|
|
| -// A VideoDecodeAccelerator implementation for Android.
|
| -// This class decodes the input encoded stream by using Android's MediaCodec
|
| -// class. http://developer.android.com/reference/android/media/MediaCodec.html
|
| -// It delegates attaching pictures to PictureBuffers to a BackingStrategy, but
|
| -// otherwise handles the work of transferring data to / from MediaCodec.
|
| +// A VideoDecodeAccelerator implementation for Android. This class decodes the
|
| +// encded input stream using Android's MediaCodec. It handles the work of
|
| +// transferring data to and from MediaCodec, and delegates attaching MediaCodec
|
| +// output buffers to PictureBuffers to AVDAPictureBufferManager.
|
| class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
|
| : public VideoDecodeAccelerator,
|
| public AVDAStateProvider {
|
| public:
|
| - using OutputBufferMap = std::map<int32_t, PictureBuffer>;
|
| -
|
| - // A BackingStrategy is responsible for making a PictureBuffer's texture
|
| - // contain the image that a MediaCodec decoder buffer tells it to.
|
| - class BackingStrategy {
|
| - public:
|
| - virtual ~BackingStrategy() {}
|
| -
|
| - // Must be called before anything else. If surface_view_id is not equal to
|
| - // |kNoSurfaceID| it refers to a SurfaceView that the strategy must render
|
| - // to.
|
| - // Returns the Java surface to configure MediaCodec with.
|
| - virtual gl::ScopedJavaSurface Initialize(int surface_view_id) = 0;
|
| -
|
| - // Called before the AVDA does any Destroy() work. The strategy should
|
| - // release any pending codec buffers, for example.
|
| - virtual void BeginCleanup(bool have_context,
|
| - const OutputBufferMap& buffer_map) = 0;
|
| -
|
| - // Called before the AVDA closes up entirely. This will be
|
| - // the last call that the BackingStrategy receives.
|
| - virtual void EndCleanup() = 0;
|
| -
|
| - // This returns the SurfaceTexture created by Initialize, or nullptr if
|
| - // the strategy was initialized with a SurfaceView.
|
| - virtual scoped_refptr<gl::SurfaceTexture> GetSurfaceTexture() const = 0;
|
| -
|
| - // Return the GL texture target that the PictureBuffer textures use.
|
| - virtual uint32_t GetTextureTarget() const = 0;
|
| -
|
| - // Return the size to use when requesting picture buffers.
|
| - virtual gfx::Size GetPictureBufferSize() const = 0;
|
| -
|
| - // Make the provided PictureBuffer draw the image that is represented by
|
| - // the decoded output buffer at codec_buffer_index.
|
| - virtual void UseCodecBufferForPictureBuffer(
|
| - int32_t codec_buffer_index,
|
| - const PictureBuffer& picture_buffer) = 0;
|
| -
|
| - // Notify strategy that a picture buffer has been assigned.
|
| - virtual void AssignOnePictureBuffer(const PictureBuffer& picture_buffer,
|
| - bool have_context) {}
|
| -
|
| - // Notify strategy that a picture buffer has been reused.
|
| - virtual void ReuseOnePictureBuffer(const PictureBuffer& picture_buffer) {}
|
| -
|
| - // Release MediaCodec buffers.
|
| - virtual void ReleaseCodecBuffers(
|
| - const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) {}
|
| -
|
| - // Attempts to free up codec output buffers by rendering early.
|
| - virtual void MaybeRenderEarly() {}
|
| -
|
| - // Notify strategy that we have a new android MediaCodec instance. This
|
| - // happens when we're starting up or re-configuring mid-stream. Any
|
| - // previously provided codec should no longer be referenced.
|
| - virtual void CodecChanged(VideoCodecBridge* codec) = 0;
|
| -
|
| - // Notify the strategy that a frame is available. This callback can happen
|
| - // on any thread at any time.
|
| - virtual void OnFrameAvailable() = 0;
|
| -
|
| - // Whether the pictures produced by this backing strategy are overlayable.
|
| - virtual bool ArePicturesOverlayable() = 0;
|
| -
|
| - // Size may have changed due to resolution change since the last time this
|
| - // PictureBuffer was used. Update the size of the picture buffer to
|
| - // |new_size| and also update any size-dependent state (e.g. size of
|
| - // associated texture). Callers should set the correct GL context prior to
|
| - // calling.
|
| - virtual void UpdatePictureBufferSize(PictureBuffer* picture_buffer,
|
| - const gfx::Size& new_size) = 0;
|
| - };
|
| -
|
| AndroidVideoDecodeAccelerator(
|
| const MakeGLContextCurrentCallback& make_context_current_cb,
|
| const GetGLES2DecoderCallback& get_gles2_decoder_cb);
|
| @@ -141,22 +64,13 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
|
|
|
| // AVDAStateProvider implementation:
|
| const gfx::Size& GetSize() const override;
|
| - const base::ThreadChecker& ThreadChecker() const override;
|
| base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override;
|
| - gpu::gles2::TextureRef* GetTextureForPicture(
|
| - const PictureBuffer& picture_buffer) override;
|
| - scoped_refptr<gl::SurfaceTexture> CreateAttachedSurfaceTexture(
|
| - GLuint* service_id) override;
|
| void PostError(const ::tracked_objects::Location& from_here,
|
| VideoDecodeAccelerator::Error error) override;
|
|
|
| static VideoDecodeAccelerator::Capabilities GetCapabilities(
|
| const gpu::GpuPreferences& gpu_preferences);
|
|
|
| - // Notifies about SurfaceTexture::OnFrameAvailable. This can happen on any
|
| - // thread at any time!
|
| - void OnFrameAvailable();
|
| -
|
| private:
|
| friend class AVDAManager;
|
|
|
| @@ -195,8 +109,7 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
|
| // Whether encryption scheme requires to use protected surface.
|
| bool needs_protected_surface_ = false;
|
|
|
| - // The surface that MediaCodec is configured to output to. It's created by
|
| - // the backing strategy.
|
| + // The surface that MediaCodec is configured to output to.
|
| gl::ScopedJavaSurface surface_;
|
|
|
| // The MediaCrypto object is used in the MediaCodec.configure() in case of
|
| @@ -225,12 +138,12 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
|
| // if initialization should stop.
|
| void OnSurfaceAvailable(bool success);
|
|
|
| - // Finish initialization of the strategy. This is to be called when the
|
| + // Initialize of the picture buffer manager. This is to be called when the
|
| // SurfaceView in |surface_id_|, if any, is no longer busy. It will return
|
| // false on failure, and true if initialization was successful. This includes
|
| // synchronous and asynchronous init; the AVDA might not yet have a codec on
|
| // success, but async init will at least be in progress.
|
| - bool InitializeStrategy();
|
| + bool InitializePictureBufferManager();
|
|
|
| // A part of destruction process that is sometimes postponed after the drain.
|
| void ActualDestroy();
|
| @@ -355,10 +268,6 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
|
| // this.
|
| void OnDestroyingSurface(int surface_id);
|
|
|
| - // Returns true if and only if we should use deferred rendering.
|
| - static bool UseDeferredRenderingStrategy(
|
| - const gpu::GpuPreferences& gpu_preferences);
|
| -
|
| // Indicates if MediaCodec should not be used for software decoding since we
|
| // have safer versions elsewhere.
|
| bool IsMediaCodecSoftwareDecodingForbidden() const;
|
| @@ -379,9 +288,8 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
|
| // error state.
|
| State state_;
|
|
|
| - // This map maintains the picture buffers passed to the client for decoding.
|
| - // The key is the picture buffer id.
|
| - OutputBufferMap output_picture_buffers_;
|
| + // The assigned picture buffers by picture buffer id.
|
| + AVDAPictureBufferManager::PictureBufferMap output_picture_buffers_;
|
|
|
| // This keeps the free picture buffer ids which can be used for sending
|
| // decoded frames to the client.
|
| @@ -424,12 +332,7 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
|
| // NotifyEndOfBitstreamBuffer() before getting output from the bitstream.
|
| std::list<int32_t> bitstreams_notified_in_advance_;
|
|
|
| - // Backing strategy that we'll use to connect PictureBuffers to frames.
|
| - std::unique_ptr<BackingStrategy> strategy_;
|
| -
|
| - // Helper class that manages asynchronous OnFrameAvailable callbacks.
|
| - class OnFrameAvailableHandler;
|
| - scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_;
|
| + AVDAPictureBufferManager picture_buffer_manager_;
|
|
|
| // Time at which we last did useful work on io_timer_.
|
| base::TimeTicks most_recent_work_;
|
|
|