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

Unified Diff: chrome/gpu/gpu_arc_video_encode_accelerator.h

Issue 2892863002: ArcBridge: Add VideoEncodeAccelerator implementation. (Closed)
Patch Set: Created 3 years, 7 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..8f8d7653e89b81d500fbaa8baac5ac6f58de819e
--- /dev/null
+++ b/chrome/gpu/gpu_arc_video_encode_accelerator.h
@@ -0,0 +1,90 @@
+// 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
Luis Héctor Chávez 2017/05/19 15:14:44 nit: lifecycle is much more common (472 instances)
+// for ArcVideoAccelerator.
+//
+// For each creation request from GpuArcVideoEncodeAcceleratorHost,
+// GpuArcVideoEncodeAccelerator will create a new IPC channel.
+class GpuArcVideoEncodeAccelerator
+ : public ::arc::mojom::VideoEncodeAccelerator,
+ public media::VideoEncodeAccelerator::Client {
+ public:
+ explicit GpuArcVideoEncodeAccelerator(
+ const gpu::GpuPreferences& gpu_preferences);
+ ~GpuArcVideoEncodeAccelerator() override;
+
+ private:
+ using VideoPixelFormat = ::arc::mojom::VideoPixelFormat;
+ using VideoCodecProfile = ::arc::mojom::VideoCodecProfile;
+ using VideoEncodeClientPtr = ::arc::mojom::VideoEncodeClientPtr;
+ using Error = ::arc::mojom::VideoEncodeAccelerator::Error;
+
+ // 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(media::VideoEncodeAccelerator::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,
+ const gfx::Size& visible_size,
+ 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;
+
+ base::ScopedFD UnwrapFdFromMojoHandle(mojo::ScopedHandle handle);
+
+ gpu::GpuPreferences gpu_preferences_;
+ std::unique_ptr<media::VideoEncodeAccelerator> accelerator_;
+ ::arc::mojom::VideoEncodeClientPtr client_;
+ gfx::Size input_coded_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