Index: content/common/gpu/media/gpu_jpeg_decode_accelerator.h |
diff --git a/content/common/gpu/media/gpu_jpeg_decode_accelerator.h b/content/common/gpu/media/gpu_jpeg_decode_accelerator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f2202dfa669b80ff1d2a965f5ecde4b1096398a6 |
--- /dev/null |
+++ b/content/common/gpu/media/gpu_jpeg_decode_accelerator.h |
@@ -0,0 +1,105 @@ |
+// Copyright 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_GPU_JPEG_DECODE_ACCELERATOR_H_ |
+#define CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/synchronization/waitable_event.h" |
+#include "ipc/ipc_listener.h" |
+#include "ipc/ipc_sender.h" |
+#include "media/video/jpeg_decode_accelerator.h" |
+ |
+struct AcceleratedJpegDecoderMsg_Decode_Params; |
+ |
+namespace base { |
+class SingleThreadTaskRunner; |
+} |
+ |
+namespace content { |
+class GpuChannel; |
+ |
+class GpuJpegDecodeAccelerator : public IPC::Listener, |
+ public IPC::Sender, |
+ public media::JpegDecodeAccelerator::Client { |
+ public: |
+ // |channel| must outlive this object. |
+ GpuJpegDecodeAccelerator( |
+ GpuChannel* channel, |
+ int32 host_route_id, |
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
+ |
+ // Creates and initializes JpegDecodeAccelerator. |
+ bool Initialize(); |
+ |
+ // Destroys and deletes itself. |
+ void Destroy(); |
+ |
+ // IPC::Listener implementation. |
+ bool OnMessageReceived(const IPC::Message& message) override; |
+ |
+ // media::JpegDecodeAccelerator::Client implementation. |
+ void VideoFrameReady(int32_t bitstream_buffer_id) override; |
+ void NotifyError(int32_t bitstream_buffer_id, |
+ media::JpegDecodeAccelerator::Error error) override; |
+ |
+ // Function to delegate sending to actual sender. |
+ bool Send(IPC::Message* message) override; |
+ |
+ private: |
+ ~GpuJpegDecodeAccelerator(); |
+ class MessageFilter; |
+ |
+ // Handlers for IPC messages. |
+ void OnDecode(const AcceleratedJpegDecoderMsg_Decode_Params& params); |
+ void OnDestroy(); |
+ |
+ // Called on IO thread when |filter_| has been removed. |
+ void OnFilterRemoved(); |
+ |
+ // The lifetime of objects of this class is managed by a GpuChannel. The |
+ // GpuChannels destroy all the GpuJpegDecodeAccelerator that they own when |
+ // they are destroyed. So a raw pointer is safe. |
+ GpuChannel* channel_; |
+ |
+ // Route ID to communicate with the host. |
+ int32 host_route_id_; |
+ |
+ // The underlying JpegDecodeAccelerator. |
+ scoped_ptr<media::JpegDecodeAccelerator> jpeg_decode_accelerator_; |
+ |
+ // The message filter to run JpegDecodeAccelerator::Decode on IO thread. |
+ scoped_refptr<MessageFilter> filter_; |
+ |
+ // Used to wait on for |filter_| to be removed, before we can safely |
+ // destroy the JpegDecodeAccelerator. |
+ base::WaitableEvent filter_removed_; |
+ |
+ // GPU child task runner. |
+ scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; |
+ |
+ // GPU IO task runner. |
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
+ |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator); |
+}; |
+ |
+} // namespace content |
+ |
+namespace base { |
+ |
+template <class T> |
+struct DefaultDeleter; |
+ |
+// Specialize DefaultDeleter so that scoped_ptr<GpuJpegDecodeAccelerator> always |
+// uses "Destroy()" instead of trying to use the destructor. |
+template <> |
+struct MEDIA_EXPORT DefaultDeleter<content::GpuJpegDecodeAccelerator> { |
+ public: |
+ void operator()(void* jpeg_decode_accelerator) const; |
+}; |
+ |
+} // namespace base |
+ |
+#endif // CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ |