| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "content/common/gpu/client/ipc/gpu_jpeg_decode_accelerator_host_ipc_tra
nsport.h" |
| 13 #include "media/video/jpeg_decode_accelerator.h" | 14 #include "media/video/jpeg_decode_accelerator.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 class SingleThreadTaskRunner; | 17 class SingleThreadTaskRunner; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace IPC { | |
| 20 class Listener; | |
| 21 class Message; | |
| 22 } | |
| 23 | |
| 24 namespace content { | 20 namespace content { |
| 25 class GpuChannelHost; | 21 class GpuChannelHost; |
| 26 | 22 |
| 27 // This class is used to talk to JpegDecodeAccelerator in the GPU process | 23 // This class is used to talk to JpegDecodeAccelerator in the GPU process |
| 28 // through IPC messages. | 24 // through IPC messages. |
| 29 class GpuJpegDecodeAcceleratorHost : public media::JpegDecodeAccelerator, | 25 class GpuJpegDecodeAcceleratorHost : public media::JpegDecodeAccelerator, |
| 30 public base::NonThreadSafe { | 26 public base::NonThreadSafe { |
| 31 public: | 27 public: |
| 32 // VideoCaptureGpuJpegDecoder owns |this| and |channel|. And | 28 // VideoCaptureGpuJpegDecoder owns |this| and |channel|. And |
| 33 // VideoCaptureGpuJpegDecoder delete |this| before |channel|. So |this| is | 29 // VideoCaptureGpuJpegDecoder delete |this| before |channel|. So |this| is |
| 34 // guaranteed not to outlive |channel|. | 30 // guaranteed not to outlive |channel|. |
| 35 GpuJpegDecodeAcceleratorHost( | 31 GpuJpegDecodeAcceleratorHost( |
| 36 GpuChannelHost* channel, | 32 GpuChannelHost* channel, |
| 37 int32_t route_id, | 33 scoped_ptr<GpuJpegDecodeAcceleratorHostIPCTransport> transport); |
| 38 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
| 39 ~GpuJpegDecodeAcceleratorHost() override; | 34 ~GpuJpegDecodeAcceleratorHost() override; |
| 40 | 35 |
| 41 // media::JpegDecodeAccelerator implementation. | 36 // media::JpegDecodeAccelerator implementation. |
| 42 // |client| is called on the IO thread, but is never called into after the | 37 // |client| is called on the IO thread, but is never called into after the |
| 43 // GpuJpegDecodeAcceleratorHost is destroyed. | 38 // GpuJpegDecodeAcceleratorHost is destroyed. |
| 44 bool Initialize(media::JpegDecodeAccelerator::Client* client) override; | 39 bool Initialize(media::JpegDecodeAccelerator::Client* client) override; |
| 45 void Decode(const media::BitstreamBuffer& bitstream_buffer, | 40 void Decode(const media::BitstreamBuffer& bitstream_buffer, |
| 46 const scoped_refptr<media::VideoFrame>& video_frame) override; | 41 const scoped_refptr<media::VideoFrame>& video_frame) override; |
| 47 bool IsSupported() override; | 42 bool IsSupported() override; |
| 48 | 43 |
| 49 base::WeakPtr<IPC::Listener> GetReceiver(); | |
| 50 | |
| 51 private: | 44 private: |
| 52 class Receiver; | 45 class Receiver; |
| 53 | 46 |
| 54 void Send(IPC::Message* message); | |
| 55 | |
| 56 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU | 47 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU |
| 57 // process. | 48 // process. |
| 58 GpuChannelHost* channel_; | 49 GpuChannelHost* channel_; |
| 59 | 50 |
| 60 // Route ID for the associated decoder in the GPU process. | |
| 61 int32_t decoder_route_id_; | |
| 62 | |
| 63 // GPU IO task runner. | 51 // GPU IO task runner. |
| 64 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 52 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 65 | 53 |
| 66 scoped_ptr<Receiver> receiver_; | 54 scoped_ptr<Receiver> receiver_; |
| 67 | 55 |
| 56 scoped_ptr<GpuJpegDecodeAcceleratorHostIPCTransport> transport_; |
| 57 |
| 68 DISALLOW_COPY_AND_ASSIGN(GpuJpegDecodeAcceleratorHost); | 58 DISALLOW_COPY_AND_ASSIGN(GpuJpegDecodeAcceleratorHost); |
| 69 }; | 59 }; |
| 70 | 60 |
| 71 } // namespace content | 61 } // namespace content |
| 72 | 62 |
| 73 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | 63 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| OLD | NEW |