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 "base/id_map.h" |
| 9 #include "base/memory/ref_counted.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" |
| 15 |
| 16 struct AcceleratedJpegDecoderMsg_Decode_Params; |
| 17 |
| 18 namespace base { |
| 19 class SingleThreadTaskRunner; |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 class GpuChannel; |
| 24 |
| 25 class GpuJpegDecodeAccelerator : public IPC::Listener, |
| 26 public IPC::Sender, |
| 27 public base::NonThreadSafe { |
| 28 public: |
| 29 // |channel| must outlive this object. |
| 30 GpuJpegDecodeAccelerator( |
| 31 GpuChannel* channel, |
| 32 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| 33 ~GpuJpegDecodeAccelerator() override; |
| 34 |
| 35 void AddClient(int32 route_id, IPC::Message* reply_msg); |
| 36 |
| 37 // IPC::Listener implementation. |
| 38 bool OnMessageReceived(const IPC::Message& message) override; |
| 39 |
| 40 void NotifyDecodeStatus(int32 route_id, |
| 41 int32_t bitstream_buffer_id, |
| 42 media::JpegDecodeAccelerator::Error error); |
| 43 |
| 44 // Function to delegate sending to actual sender. |
| 45 bool Send(IPC::Message* message) override; |
| 46 |
| 47 private: |
| 48 class Client; |
| 49 class MessageFilter; |
| 50 |
| 51 // Removes the client with |route_id|. |
| 52 void RemoveClient(int32 route_id); |
| 53 |
| 54 // The lifetime of objects of this class is managed by a GpuChannel. The |
| 55 // GpuChannels destroy all the GpuJpegDecodeAccelerator that they own when |
| 56 // they are destroyed. So a raw pointer is safe. |
| 57 GpuChannel* channel_; |
| 58 |
| 59 // The message filter to run JpegDecodeAccelerator::Decode on IO thread. |
| 60 scoped_refptr<MessageFilter> filter_; |
| 61 |
| 62 // GPU child task runner. |
| 63 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; |
| 64 |
| 65 // GPU IO task runner. |
| 66 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 67 |
| 68 // A map from route id to Client. |
| 69 IDMap<Client, IDMapOwnPointer> client_map_; |
| 70 |
| 71 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator); |
| 72 }; |
| 73 |
| 74 } // namespace content |
| 75 |
| 76 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_ |
OLD | NEW |