Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7562)

Unified Diff: chrome/gpu/gpu_arc_video_encode_accelerator.h

Issue 2892863002: ArcBridge: Add VideoEncodeAccelerator implementation. (Closed)
Patch Set: Address Kcwu's comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/gpu/gpu_arc_video_encode_accelerator.h
diff --git a/chrome/gpu/gpu_arc_video_encode_accelerator.h b/chrome/gpu/gpu_arc_video_encode_accelerator.h
new file mode 100644
index 0000000000000000000000000000000000000000..44bf76fcc8d5f11dc57f94f8e71519f10f0b5e3b
--- /dev/null
+++ b/chrome/gpu/gpu_arc_video_encode_accelerator.h
@@ -0,0 +1,87 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_GPU_GPU_ARC_VIDEO_ENCODE_ACCELERATOR_H_
+#define CHROME_GPU_GPU_ARC_VIDEO_ENCODE_ACCELERATOR_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/files/scoped_file.h"
+#include "base/macros.h"
+#include "components/arc/common/video_encode_accelerator.mojom.h"
+#include "components/arc/video_accelerator/video_accelerator.h"
+#include "gpu/command_buffer/service/gpu_preferences.h"
+#include "media/video/video_encode_accelerator.h"
+
+namespace chromeos {
+namespace arc {
+
+// GpuArcVideoEncodeAccelerator manages life-cycle and IPC message translation
+// for media::VideoEncodeAccelerator.
+class GpuArcVideoEncodeAccelerator
+ : public ::arc::mojom::VideoEncodeAccelerator,
+ public media::VideoEncodeAccelerator::Client {
+ public:
+ explicit GpuArcVideoEncodeAccelerator(
+ const gpu::GpuPreferences& gpu_preferences);
+ ~GpuArcVideoEncodeAccelerator() override;
+
+ private:
+ using VideoPixelFormat = media::VideoPixelFormat;
+ using VideoCodecProfile = media::VideoCodecProfile;
+ using Error = media::VideoEncodeAccelerator::Error;
+ using VideoEncodeClientPtr = ::arc::mojom::VideoEncodeClientPtr;
+
+ // VideoEncodeAccelerator::Client implementation.
+ void RequireBitstreamBuffers(unsigned int input_count,
+ const gfx::Size& input_coded_size,
+ size_t output_buffer_size) override;
+ void BitstreamBufferReady(int32_t bitstream_buffer_id,
+ size_t payload_size,
+ bool key_frame,
+ base::TimeDelta timestamp) override;
+ void NotifyError(Error error) override;
+
+ // ::arc::mojom::VideoEncodeAccelerator implementation.
+ void GetSupportedProfiles(
+ const GetSupportedProfilesCallback& callback) override;
+
+ void Initialize(VideoPixelFormat input_format,
+ const gfx::Size& visible_size,
+ VideoEncodeAccelerator::StorageType input_storage,
+ VideoCodecProfile output_profile,
+ uint32_t initial_bitrate,
+ VideoEncodeClientPtr client,
+ const InitializeCallback& callback) override;
+
+ void Encode(mojo::ScopedHandle fd,
+ std::vector<::arc::VideoFramePlane> planes,
+ int64_t timestamp,
+ bool force_keyframe) override;
+
+ void UseOutputBitstreamBuffer(int32_t bitstream_buffer_id,
+ mojo::ScopedHandle shmem_fd,
+ uint32_t offset,
+ uint32_t size) override;
+
+ void RequestEncodingParametersChange(uint32_t bitrate,
+ uint32_t framerate) override;
Luis Héctor Chávez 2017/06/07 16:02:37 Can you remove blank lines in L58, 63, 68? That wa
Owen Lin 2017/06/08 04:15:47 Done.
+
+ base::ScopedFD UnwrapFdFromMojoHandle(mojo::ScopedHandle handle);
Luis Héctor Chávez 2017/06/07 16:02:36 Can you add a small comment?
Owen Lin 2017/06/08 04:15:47 Done.
+
+ gpu::GpuPreferences gpu_preferences_;
+ std::unique_ptr<media::VideoEncodeAccelerator> accelerator_;
+ ::arc::mojom::VideoEncodeClientPtr client_;
+ gfx::Size coded_size_;
+ gfx::Size visible_size_;
+ media::VideoPixelFormat input_pixel_format_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuArcVideoEncodeAccelerator);
+};
+
+} // namespace arc
+} // namespace chromeos
+
+#endif // CHROME_GPU_GPU_ARC_VIDEO_ENCODE_ACCELERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698