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_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/threading/non_thread_safe.h" |
| 10 #include "media/video/jpeg_decode_accelerator.h" |
| 11 |
| 12 namespace base { |
| 13 class SingleThreadTaskRunner; |
| 14 } |
| 15 |
| 16 namespace IPC { |
| 17 class Listener; |
| 18 class Message; |
| 19 } |
| 20 |
| 21 namespace content { |
| 22 class GpuChannelHost; |
| 23 |
| 24 // This class is used to talk to JpegDecodeAccelerator in the GPU process |
| 25 // through IPC messages. |
| 26 class GpuJpegDecodeAcceleratorHost : public media::JpegDecodeAccelerator, |
| 27 public base::NonThreadSafe { |
| 28 public: |
| 29 // GpuJpegDecoder owns |this| and |channel|. And GpuJpegDecoder delete |this| |
| 30 // before |channel|. So |this| is guaranteed not to outlive |channel|. |
| 31 GpuJpegDecodeAcceleratorHost( |
| 32 GpuChannelHost* channel, |
| 33 int32 route_id, |
| 34 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| 35 ~GpuJpegDecodeAcceleratorHost() override; |
| 36 |
| 37 // media::JpegDecodeAccelerator implementation. |
| 38 // |client| is called on the IO thread, but is never called into after the |
| 39 // GpuJpegDecodeAcceleratorHost is destroyed. |
| 40 bool Initialize(media::JpegDecodeAccelerator::Client* client) override; |
| 41 void Decode(const media::BitstreamBuffer& bitstream_buffer, |
| 42 const scoped_refptr<media::VideoFrame>& video_frame) override; |
| 43 |
| 44 base::WeakPtr<IPC::Listener> GetReceiver(); |
| 45 |
| 46 private: |
| 47 class Receiver; |
| 48 |
| 49 void Send(IPC::Message* message); |
| 50 |
| 51 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU |
| 52 // process. |
| 53 GpuChannelHost* channel_; |
| 54 |
| 55 // Route ID for the associated decoder in the GPU process. |
| 56 int32 decoder_route_id_; |
| 57 |
| 58 // GPU IO task runner. |
| 59 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 60 |
| 61 scoped_ptr<Receiver> receiver_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(GpuJpegDecodeAcceleratorHost); |
| 64 }; |
| 65 |
| 66 } // namespace content |
| 67 |
| 68 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
OLD | NEW |