Chromium Code Reviews| 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..bbbe9f804273efbcda05370dba228bce5b1c26f8 |
| --- /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/compiler_specific.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/shared_memory.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 MessageLoopProxy; |
| +} |
| + |
| +namespace content { |
| +class GpuChannel; |
| + |
| +class GpuJpegDecodeAccelerator : public IPC::Listener, |
| + public IPC::Sender, |
| + public media::JpegDecodeAccelerator::Client { |
| + public: |
| + // Each of the arguments to the constructor must outlive this object. |
|
wuchengli
2015/04/15 07:11:58
Just say "|channel| must outlive this object". |ho
kcwu
2015/04/16 14:38:28
Done.
|
| + GpuJpegDecodeAccelerator( |
| + GpuChannel* channel, |
| + int32 host_route_id, |
| + const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
| + |
| + 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; |
| + |
| + bool Initialize(); |
| + |
| + 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 GpuCommandBufferStubs that they own when they |
|
wuchengli
2015/04/15 07:11:58
update the comment
kcwu
2015/04/20 17:47:59
Done.
|
| + // 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 JDA::Decode on IO thread. |
| + scoped_refptr<MessageFilter> filter_; |
| + |
| + // Used to wait on for |filter_| to be removed, before we can safely |
| + // destroy the JDA. |
| + base::WaitableEvent filter_removed_; |
| + |
| + // GPU child message loop. |
| + scoped_refptr<base::MessageLoopProxy> child_message_loop_; |
| + |
| + // GPU IO message loop. |
| + scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| + |
| + 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_ |