Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / common / gpu / media / gpu_jpeg_decode_accelerator.h
blobed5c7c36f7c465a70fe647b6aee01bcb2c51a163
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/synchronization/waitable_event.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "ipc/ipc_listener.h"
13 #include "ipc/ipc_sender.h"
14 #include "media/video/jpeg_decode_accelerator.h"
16 namespace base {
17 class SingleThreadTaskRunner;
20 namespace content {
21 class GpuChannel;
23 class GpuJpegDecodeAccelerator
24 : public IPC::Sender,
25 public base::NonThreadSafe,
26 public base::SupportsWeakPtr<GpuJpegDecodeAccelerator> {
27 public:
28 // |channel| must outlive this object.
29 GpuJpegDecodeAccelerator(
30 GpuChannel* channel,
31 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
32 ~GpuJpegDecodeAccelerator() override;
34 void AddClient(int32 route_id, IPC::Message* reply_msg);
36 void NotifyDecodeStatus(int32 route_id,
37 int32_t bitstream_buffer_id,
38 media::JpegDecodeAccelerator::Error error);
40 // Function to delegate sending to actual sender.
41 bool Send(IPC::Message* message) override;
43 // Static query for JPEG supported. This query calls the appropriate
44 // platform-specific version.
45 static bool IsSupported();
47 private:
48 using CreateJDAFp = scoped_ptr<media::JpegDecodeAccelerator> (*)(
49 const scoped_refptr<base::SingleThreadTaskRunner>&);
51 class Client;
52 class MessageFilter;
54 void ClientRemoved();
56 static scoped_ptr<media::JpegDecodeAccelerator> CreateV4L2JDA(
57 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
58 static scoped_ptr<media::JpegDecodeAccelerator> CreateVaapiJDA(
59 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
61 // The lifetime of objects of this class is managed by a GpuChannel. The
62 // GpuChannels destroy all the GpuJpegDecodeAccelerator that they own when
63 // they are destroyed. So a raw pointer is safe.
64 GpuChannel* channel_;
66 // The message filter to run JpegDecodeAccelerator::Decode on IO thread.
67 scoped_refptr<MessageFilter> filter_;
69 // GPU child task runner.
70 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_;
72 // GPU IO task runner.
73 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
75 // Number of clients added to |filter_|.
76 int client_number_;
78 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator);
81 } // namespace content
83 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_