| 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 MEDIA_GPU_IPC_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | 5 #ifndef MEDIA_GPU_IPC_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| 6 #define MEDIA_GPU_IPC_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | 6 #define MEDIA_GPU_IPC_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/sequence_checker.h" | 14 #include "base/sequence_checker.h" |
| 15 #include "media/gpu/mojo/common/jpeg_decoder.mojom.h" |
| 15 #include "media/video/jpeg_decode_accelerator.h" | 16 #include "media/video/jpeg_decode_accelerator.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class SingleThreadTaskRunner; | 19 class SingleThreadTaskRunner; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace gpu { | |
| 22 class GpuChannelHost; | |
| 23 } | |
| 24 | |
| 25 namespace IPC { | |
| 26 class Listener; | |
| 27 class Message; | |
| 28 } | |
| 29 | |
| 30 namespace media { | 22 namespace media { |
| 31 | 23 |
| 32 // TODO(c.padhi): Move GpuJpegDecodeAcceleratorHost to media/gpu/mojo, see | |
| 33 // http://crbug.com/699255. | |
| 34 // This class is used to talk to JpegDecodeAccelerator in the GPU process | 24 // This class is used to talk to JpegDecodeAccelerator in the GPU process |
| 35 // through IPC messages. | 25 // through Mojo messages. |
| 36 class GpuJpegDecodeAcceleratorHost : public JpegDecodeAccelerator { | 26 class GpuJpegDecodeAcceleratorHost : public JpegDecodeAccelerator { |
| 37 public: | 27 public: |
| 38 GpuJpegDecodeAcceleratorHost( | 28 GpuJpegDecodeAcceleratorHost( |
| 39 scoped_refptr<gpu::GpuChannelHost> channel, | 29 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 40 int32_t route_id, | 30 mojom::GpuJpegDecodeAcceleratorPtrInfo jpeg_decoder_info); |
| 41 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | |
| 42 ~GpuJpegDecodeAcceleratorHost() override; | 31 ~GpuJpegDecodeAcceleratorHost() override; |
| 43 | 32 |
| 44 // JpegDecodeAccelerator implementation. | 33 // JpegDecodeAccelerator implementation. |
| 45 // |client| is called on the IO thread, but is never called into after the | 34 // |client| is called on the IO thread, but is never called into after the |
| 46 // GpuJpegDecodeAcceleratorHost is destroyed. | 35 // GpuJpegDecodeAcceleratorHost is destroyed. |
| 47 bool Initialize(JpegDecodeAccelerator::Client* client) override; | 36 bool Initialize(JpegDecodeAccelerator::Client* client) override; |
| 48 void Decode(const BitstreamBuffer& bitstream_buffer, | 37 void Decode(const BitstreamBuffer& bitstream_buffer, |
| 49 const scoped_refptr<VideoFrame>& video_frame) override; | 38 const scoped_refptr<VideoFrame>& video_frame) override; |
| 50 bool IsSupported() override; | 39 bool IsSupported() override; |
| 51 | 40 |
| 52 base::WeakPtr<IPC::Listener> GetReceiver(); | |
| 53 | |
| 54 private: | 41 private: |
| 55 class Receiver; | 42 void OnDecodeAck(int32_t bitstream_buffer_id, mojom::Error error); |
| 56 | 43 void OnDecodeAckOnIOThread(int32_t bitstream_buffer_id, mojom::Error error); |
| 57 void Send(IPC::Message* message); | |
| 58 | |
| 59 scoped_refptr<gpu::GpuChannelHost> channel_; | |
| 60 | |
| 61 // Route ID for the associated decoder in the GPU process. | |
| 62 int32_t decoder_route_id_; | |
| 63 | 44 |
| 64 // GPU IO task runner. | 45 // GPU IO task runner. |
| 65 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 46 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 66 | 47 |
| 67 std::unique_ptr<Receiver> receiver_; | 48 Client* client_; |
| 49 |
| 50 mojom::GpuJpegDecodeAcceleratorPtr jpeg_decoder_; |
| 68 | 51 |
| 69 SEQUENCE_CHECKER(sequence_checker_); | 52 SEQUENCE_CHECKER(sequence_checker_); |
| 70 | 53 |
| 71 DISALLOW_COPY_AND_ASSIGN(GpuJpegDecodeAcceleratorHost); | 54 DISALLOW_COPY_AND_ASSIGN(GpuJpegDecodeAcceleratorHost); |
| 72 }; | 55 }; |
| 73 | 56 |
| 74 } // namespace media | 57 } // namespace media |
| 75 | 58 |
| 76 #endif // MEDIA_GPU_IPC_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | 59 #endif // MEDIA_GPU_IPC_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| OLD | NEW |