Index: content/common/gpu/media/android_video_decode_accelerator.h |
diff --git a/content/common/gpu/media/android_video_decode_accelerator.h b/content/common/gpu/media/android_video_decode_accelerator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3bb4d9477426754ce5777dc2aae3ed0456e80a87 |
--- /dev/null |
+++ b/content/common/gpu/media/android_video_decode_accelerator.h |
@@ -0,0 +1,103 @@ |
+// Copyright (c) 2013 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_ |
+ |
+#include <dlfcn.h> |
+#include <map> |
+#include <queue> |
+#include <set> |
+#include <string> |
+#include <utility> |
+#include <vector> |
+ |
+#include "base/compiler_specific.h" |
+#include "base/logging.h" |
+#include "base/message_loop.h" |
+#include "base/shared_memory.h" |
+#include "content/common/android/surface_texture_bridge.h" |
+#include "content/common/content_export.h" |
+#include "media/video/video_decode_accelerator.h" |
+ |
+namespace media { |
+class MediaCodecBridge; |
+} |
+ |
+namespace content { |
+ |
+class Gles2ExternalTextureCopier; |
+ |
+typedef std::map<int32, media::PictureBuffer> PictureMap; |
+ |
+// 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 |
+class CONTENT_EXPORT AndroidVideoDecodeAccelerator : |
+ public media::VideoDecodeAccelerator { |
+ public: |
+ // Does not take ownership of |client| which must outlive |*this|. |
+ AndroidVideoDecodeAccelerator( |
+ media::VideoDecodeAccelerator::Client* client, |
+ const base::Callback<bool(void)>& make_context_current); |
+ virtual ~AndroidVideoDecodeAccelerator(); |
+ |
+ // media::VideoDecodeAccelerator implementation. |
+ bool Initialize(media::VideoCodecProfile profile) OVERRIDE; |
+ void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
+ virtual void AssignPictureBuffers( |
+ const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
+ void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
+ void Flush() OVERRIDE; |
+ void Reset() OVERRIDE; |
+ void Destroy() OVERRIDE; |
+ |
+ private: |
+ enum Codec { |
+ UNKNOWN, |
+ H264, |
+ VP8 |
+ }; |
+ |
+ void SendCurrentSurfaceToClient(); |
+ void CopyCurrentFrameToPictureBuffer( |
+ int32 picture_buffer_id, float transfrom_matrix[16]); |
+ |
+ void DoDecode(); |
+ void ConfigureMediaCodec(); |
+ void QueueInput(); |
+ void DequeueOutput(); |
+ |
+ MessageLoop* message_loop_; |
+ |
+ // To expose client callbacks from VideoDecodeAccelerator. |
+ // NOTE: all calls to this object *MUST* be executed in message_loop_. |
+ Client* client_; |
+ |
+ base::Callback<bool(void)> make_context_current_; |
+ |
+ // These members are only used during Initialization. |
+ Codec codec_; |
+ |
+ PictureMap picture_map_; |
+ std::queue<int32> free_picture_ids_; |
+ scoped_ptr<media::MediaCodecBridge> media_codec_; |
+ scoped_refptr<SurfaceTextureBridge> surface_texture_; |
+ uint32 surface_texture_id_; |
+ bool picturebuffer_requested_; |
+ |
+ typedef std::queue<media::BitstreamBuffer> BitstreamBufferList; |
+ BitstreamBufferList pending_bitstream_buffers_; |
+ |
+ int32 color_format_; |
+ int32 width_; |
+ int32 height_; |
+ int32 current_bitstream_id_; |
+ |
+ scoped_ptr<Gles2ExternalTextureCopier> texture_copier_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |