OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 MEDIA_GPU_FAKE_JPEG_DECODE_ACCELERATOR_H_ |
| 6 #define MEDIA_GPU_FAKE_JPEG_DECODE_ACCELERATOR_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <memory> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/threading/thread.h" |
| 15 #include "media/base/bitstream_buffer.h" |
| 16 #include "media/gpu/media_gpu_export.h" |
| 17 #include "media/video/jpeg_decode_accelerator.h" |
| 18 |
| 19 namespace base { |
| 20 class SingleThreadTaskRunner; |
| 21 } |
| 22 |
| 23 namespace media { |
| 24 |
| 25 class SharedMemoryRegion; |
| 26 |
| 27 // Uses software-based decoding. The purpose of this class is to enable testing |
| 28 // of communication to the JpegDecodeAccelerator without requiring an actual |
| 29 // hardware decoder. |
| 30 class MEDIA_GPU_EXPORT FakeJpegDecodeAccelerator |
| 31 : public JpegDecodeAccelerator { |
| 32 public: |
| 33 FakeJpegDecodeAccelerator( |
| 34 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| 35 ~FakeJpegDecodeAccelerator() override; |
| 36 |
| 37 // JpegDecodeAccelerator implementation. |
| 38 bool Initialize(JpegDecodeAccelerator::Client* client) override; |
| 39 void Decode(const BitstreamBuffer& bitstream_buffer, |
| 40 const scoped_refptr<VideoFrame>& video_frame) override; |
| 41 bool IsSupported() override; |
| 42 |
| 43 private: |
| 44 void DecodeOnDecoderThread(const BitstreamBuffer& bitstream_buffer, |
| 45 const scoped_refptr<VideoFrame>& video_frame, |
| 46 std::unique_ptr<SharedMemoryRegion> src_shm); |
| 47 void NotifyError(int32_t bitstream_buffer_id, Error error); |
| 48 void NotifyErrorOnClientThread(int32_t bitstream_buffer_id, Error error); |
| 49 void OnDecodeDoneOnClientThread(int32_t input_buffer_id); |
| 50 |
| 51 // Task runner for calls to |client_|. |
| 52 const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_; |
| 53 |
| 54 // GPU IO task runner. |
| 55 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 56 |
| 57 Client* client_ = nullptr; |
| 58 |
| 59 base::Thread decoder_thread_; |
| 60 scoped_refptr<base::SingleThreadTaskRunner> decoder_task_runner_; |
| 61 |
| 62 base::WeakPtrFactory<FakeJpegDecodeAccelerator> weak_factory_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(FakeJpegDecodeAccelerator); |
| 65 }; |
| 66 |
| 67 } // namespace media |
| 68 |
| 69 #endif // MEDIA_GPU_FAKE_JPEG_DECODE_ACCELERATOR_H_ |
OLD | NEW |