OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ | |
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "base/synchronization/waitable_event.h" | |
14 #include "base/threading/non_thread_safe.h" | |
15 #include "ipc/ipc_listener.h" | |
16 #include "ipc/ipc_sender.h" | |
17 #include "media/video/jpeg_decode_accelerator.h" | |
18 | |
19 namespace base { | |
20 class SingleThreadTaskRunner; | |
21 } | |
22 | |
23 namespace gpu { | |
24 class GpuChannel; | |
25 } | |
26 | |
27 namespace content { | |
28 class GpuJpegDecodeAccelerator | |
29 : public IPC::Sender, | |
30 public base::NonThreadSafe, | |
31 public base::SupportsWeakPtr<GpuJpegDecodeAccelerator> { | |
32 public: | |
33 // |channel| must outlive this object. | |
34 GpuJpegDecodeAccelerator( | |
35 gpu::GpuChannel* channel, | |
36 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
37 ~GpuJpegDecodeAccelerator() override; | |
38 | |
39 void AddClient(int32_t route_id, base::Callback<void(bool)> response); | |
40 | |
41 void NotifyDecodeStatus(int32_t route_id, | |
42 int32_t bitstream_buffer_id, | |
43 media::JpegDecodeAccelerator::Error error); | |
44 | |
45 // Function to delegate sending to actual sender. | |
46 bool Send(IPC::Message* message) override; | |
47 | |
48 // Static query for JPEG supported. This query calls the appropriate | |
49 // platform-specific version. | |
50 static bool IsSupported(); | |
51 | |
52 private: | |
53 using CreateJDAFp = std::unique_ptr<media::JpegDecodeAccelerator> (*)( | |
54 const scoped_refptr<base::SingleThreadTaskRunner>&); | |
55 | |
56 class Client; | |
57 class MessageFilter; | |
58 | |
59 void ClientRemoved(); | |
60 | |
61 static std::unique_ptr<media::JpegDecodeAccelerator> CreateV4L2JDA( | |
62 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
63 static std::unique_ptr<media::JpegDecodeAccelerator> CreateVaapiJDA( | |
64 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
65 | |
66 // The lifetime of objects of this class is managed by a gpu::GpuChannel. The | |
67 // GpuChannels destroy all the GpuJpegDecodeAccelerator that they own when | |
68 // they are destroyed. So a raw pointer is safe. | |
69 gpu::GpuChannel* channel_; | |
70 | |
71 // The message filter to run JpegDecodeAccelerator::Decode on IO thread. | |
72 scoped_refptr<MessageFilter> filter_; | |
73 | |
74 // GPU child task runner. | |
75 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; | |
76 | |
77 // GPU IO task runner. | |
78 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
79 | |
80 // Number of clients added to |filter_|. | |
81 int client_number_; | |
82 | |
83 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator); | |
84 }; | |
85 | |
86 } // namespace content | |
87 | |
88 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ | |
OLD | NEW |