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