| 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..42c94e5d8271d46e618b0fceaa6e2f6ab37d8d21
|
| --- /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 MessageLoopProxy;
|
| +}
|
| +
|
| +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::MessageLoopProxy>& io_message_loop);
|
| +
|
| + // 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 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_
|
|
|