| Index: content/common/gpu/media/android_video_decode_accelerator_base.h
|
| diff --git a/content/common/gpu/media/android_video_decode_accelerator.h b/content/common/gpu/media/android_video_decode_accelerator_base.h
|
| similarity index 74%
|
| copy from content/common/gpu/media/android_video_decode_accelerator.h
|
| copy to content/common/gpu/media/android_video_decode_accelerator_base.h
|
| index d5bacfd9af136c4e25111191d92d783629ab355c..ead3df76f4e6472b5e9edc2e3c04ddb5aeabaafe 100644
|
| --- a/content/common/gpu/media/android_video_decode_accelerator.h
|
| +++ b/content/common/gpu/media/android_video_decode_accelerator_base.h
|
| @@ -1,9 +1,9 @@
|
| -// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2015 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.
|
|
|
| -#ifndef CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
|
| -#define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
|
| +#ifndef CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_BASE_H_
|
| +#define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_BASE_H_
|
|
|
| #include <list>
|
| #include <map>
|
| @@ -15,7 +15,6 @@
|
| #include "base/threading/thread_checker.h"
|
| #include "base/timer/timer.h"
|
| #include "content/common/content_export.h"
|
| -#include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
|
| #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
|
| #include "media/base/android/media_codec_bridge.h"
|
| #include "media/video/video_decode_accelerator.h"
|
| @@ -25,18 +24,20 @@ class SurfaceTexture;
|
| }
|
|
|
| namespace content {
|
| -// A VideoDecodeAccelerator implementation for Android.
|
| +// A base class for VideoDecodeAccelerator implementations for Android.
|
| // This class decodes the input encoded stream by using Android's MediaCodec
|
| // class. http://developer.android.com/reference/android/media/MediaCodec.html
|
| -class CONTENT_EXPORT AndroidVideoDecodeAccelerator
|
| +// It delegates attaching pictures to PictureBuffers to the client, but
|
| +// otherwise handles the work of transferring data to / from MediaCodec.
|
| +class CONTENT_EXPORT AndroidVideoDecodeAcceleratorBase
|
| : public media::VideoDecodeAccelerator {
|
| public:
|
| - // Does not take ownership of |client| which must outlive |*this|.
|
| - AndroidVideoDecodeAccelerator(
|
| + AndroidVideoDecodeAcceleratorBase(
|
| const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder,
|
| const base::Callback<bool(void)>& make_context_current);
|
|
|
| // media::VideoDecodeAccelerator implementation.
|
| + // Does not take ownership of |client| which must outlive |*this|.
|
| bool Initialize(media::VideoCodecProfile profile, Client* client) override;
|
| void Decode(const media::BitstreamBuffer& bitstream_buffer) override;
|
| void AssignPictureBuffers(
|
| @@ -50,6 +51,35 @@ class CONTENT_EXPORT AndroidVideoDecodeAccelerator
|
| static media::VideoDecodeAccelerator::SupportedProfiles
|
| GetSupportedProfiles();
|
|
|
| + protected:
|
| + ~AndroidVideoDecodeAcceleratorBase() override;
|
| +
|
| + // Return the number of picture buffers that the implementation would like.
|
| + // TODO(liberato): this isn't used much, and can probably be removed.
|
| + virtual uint32 GetNumPictureBuffers() const = 0;
|
| +
|
| + // Return the GL texture target that the PictureBuffers will use.
|
| + virtual uint32 GetTextureTarget() const = 0;
|
| +
|
| + // Use the provided PictureBuffer to hold the current surface.
|
| + virtual void AssignCurrentSurfaceToPictureBuffer(int32 codec_buffer_index,
|
| + const media::PictureBuffer&) = 0;
|
| +
|
| + // Misc getters for subclasses.
|
| + Client* GetClient() const;
|
| + const gfx::Size& GetSize() const;
|
| + const base::ThreadChecker& ThreadChecker() const;
|
| + gfx::SurfaceTexture* GetSurfaceTexture() const;
|
| + uint32 GetSurfaceTextureId() const;
|
| + gpu::gles2::GLES2Decoder* GetGlDecoder() const;
|
| + media::VideoCodecBridge* GetMediaCodec();
|
| +
|
| + // Helper function to report an error condition. Will post NotifyError(),
|
| + // and transition to the error state. This is meant to be called from
|
| + // the RETURN_ON_FAILURE macro.
|
| + void PostError(const ::tracked_objects::Location& from_here,
|
| + media::VideoDecodeAccelerator::Error error);
|
| +
|
| private:
|
| enum State {
|
| NO_ERROR,
|
| @@ -58,13 +88,11 @@ class CONTENT_EXPORT AndroidVideoDecodeAccelerator
|
|
|
| static const base::TimeDelta kDecodePollDelay;
|
|
|
| - ~AndroidVideoDecodeAccelerator() override;
|
| -
|
| // Configures |media_codec_| with the given codec parameters from the client.
|
| bool ConfigureMediaCodec();
|
|
|
| // Sends the current picture on the surface to the client.
|
| - void SendCurrentSurfaceToClient(int32 bitstream_id);
|
| + void SendCurrentSurfaceToClient(int32 codec_buffer_index, int32 bitstream_id);
|
|
|
| // Does pending IO tasks if any. Once this is called, it polls |media_codec_|
|
| // until it finishes pending tasks. For the polling, |kDecodePollDelay| is
|
| @@ -157,18 +185,15 @@ class CONTENT_EXPORT AndroidVideoDecodeAccelerator
|
| // Owner of the GL context. Used to restore the context state.
|
| base::WeakPtr<gpu::gles2::GLES2Decoder> gl_decoder_;
|
|
|
| - // Used for copy the texture from |surface_texture_| to picture buffers.
|
| - scoped_ptr<gpu::CopyTextureCHROMIUMResourceManager> copier_;
|
| -
|
| // Repeating timer responsible for draining pending IO to the codec.
|
| - base::RepeatingTimer<AndroidVideoDecodeAccelerator> io_timer_;
|
| + base::RepeatingTimer<AndroidVideoDecodeAcceleratorBase> io_timer_;
|
|
|
| // WeakPtrFactory for posting tasks back to |this|.
|
| - base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_;
|
| + base::WeakPtrFactory<AndroidVideoDecodeAcceleratorBase> weak_this_factory_;
|
|
|
| friend class AndroidVideoDecodeAcceleratorTest;
|
| };
|
|
|
| } // namespace content
|
|
|
| -#endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
|
| +#endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_BASE_H_
|
|
|