Chromium Code Reviews| 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 CHROME_GPU_GPU_ARC_VIDEO_ENCODE_ACCELERATOR_H_ | |
| 6 #define CHROME_GPU_GPU_ARC_VIDEO_ENCODE_ACCELERATOR_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/files/scoped_file.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "components/arc/common/video_encode_accelerator.mojom.h" | |
| 14 #include "components/arc/video_accelerator/video_accelerator.h" | |
| 15 #include "gpu/command_buffer/service/gpu_preferences.h" | |
| 16 #include "media/video/video_encode_accelerator.h" | |
| 17 | |
| 18 namespace chromeos { | |
| 19 namespace arc { | |
| 20 | |
| 21 // GpuArcVideoEncodeAccelerator manages life-cycle and IPC message translation | |
| 22 // for ArcVideoAccelerator. | |
|
kcwu
2017/06/03 10:58:28
VideoEncodeAccelerator?
Owen Lin
2017/06/03 13:54:08
Updated. I also remove the last paragraph as it se
| |
| 23 // | |
| 24 // For each creation request from GpuArcVideoEncodeAcceleratorHost, | |
| 25 // GpuArcVideoEncodeAccelerator will create a new IPC channel. | |
| 26 class GpuArcVideoEncodeAccelerator | |
| 27 : public ::arc::mojom::VideoEncodeAccelerator, | |
| 28 public media::VideoEncodeAccelerator::Client { | |
| 29 public: | |
| 30 explicit GpuArcVideoEncodeAccelerator( | |
| 31 const gpu::GpuPreferences& gpu_preferences); | |
| 32 ~GpuArcVideoEncodeAccelerator() override; | |
| 33 | |
| 34 private: | |
| 35 using VideoPixelFormat = ::arc::mojom::VideoPixelFormat; | |
| 36 using VideoCodecProfile = ::arc::mojom::VideoCodecProfile; | |
| 37 using VideoEncodeClientPtr = ::arc::mojom::VideoEncodeClientPtr; | |
| 38 using Error = ::arc::mojom::VideoEncodeAccelerator::Error; | |
| 39 | |
| 40 // VideoEncodeAccelerator::Client implementation. | |
| 41 void RequireBitstreamBuffers(unsigned int input_count, | |
| 42 const gfx::Size& input_coded_size, | |
| 43 size_t output_buffer_size) override; | |
| 44 void BitstreamBufferReady(int32_t bitstream_buffer_id, | |
| 45 size_t payload_size, | |
| 46 bool key_frame, | |
| 47 base::TimeDelta timestamp) override; | |
| 48 void NotifyError(media::VideoEncodeAccelerator::Error error) override; | |
| 49 | |
| 50 // ::arc::mojom::VideoEncodeAccelerator implementation. | |
| 51 void GetSupportedProfiles( | |
| 52 const GetSupportedProfilesCallback& callback) override; | |
| 53 | |
| 54 void Initialize(VideoPixelFormat input_format, | |
| 55 const gfx::Size& visible_size, | |
| 56 VideoEncodeAccelerator::StorageType input_storage, | |
| 57 VideoCodecProfile output_profile, | |
| 58 uint32_t initial_bitrate, | |
| 59 VideoEncodeClientPtr client, | |
| 60 const InitializeCallback& callback) override; | |
| 61 | |
| 62 void Encode(mojo::ScopedHandle fd, | |
| 63 std::vector<::arc::VideoFramePlane> planes, | |
| 64 int64_t timestamp, | |
| 65 bool force_keyframe) override; | |
| 66 | |
| 67 void UseOutputBitstreamBuffer(int32_t bitstream_buffer_id, | |
| 68 mojo::ScopedHandle shmem_fd, | |
| 69 uint32_t offset, | |
| 70 uint32_t size) override; | |
| 71 | |
| 72 void RequestEncodingParametersChange(uint32_t bitrate, | |
| 73 uint32_t framerate) override; | |
| 74 | |
| 75 base::ScopedFD UnwrapFdFromMojoHandle(mojo::ScopedHandle handle); | |
| 76 | |
| 77 gpu::GpuPreferences gpu_preferences_; | |
| 78 std::unique_ptr<media::VideoEncodeAccelerator> accelerator_; | |
| 79 ::arc::mojom::VideoEncodeClientPtr client_; | |
| 80 gfx::Size coded_size_; | |
| 81 gfx::Size visible_size_; | |
| 82 media::VideoPixelFormat input_pixel_format_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(GpuArcVideoEncodeAccelerator); | |
| 85 }; | |
| 86 | |
| 87 } // namespace arc | |
| 88 } // namespace chromeos | |
| 89 | |
| 90 #endif // CHROME_GPU_GPU_ARC_VIDEO_ENCODE_ACCELERATOR_H_ | |
| OLD | NEW |