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