Commit 70abac55 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert Camera3CallbackOps to new Mojo types

This CL converts Camera3CallbackOps{Ptr, Request} in media to the
new Mojo type, and uses pending_remote<Camera3CallbackOps> in
camera3.mojom.

Bug: 955171
Change-Id: I2653e925a82b1c3c17d8676f3d0c13e1418676b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1862442
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarTommi <tommi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707874}
parent 39e6201a
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "media/capture/video/chromeos/camera_hal_delegate.h" #include "media/capture/video/chromeos/camera_hal_delegate.h"
#include "media/capture/video/chromeos/camera_metadata_utils.h" #include "media/capture/video/chromeos/camera_metadata_utils.h"
#include "media/capture/video/chromeos/request_manager.h" #include "media/capture/video/chromeos/request_manager.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
namespace media { namespace media {
...@@ -476,11 +477,9 @@ void CameraDeviceDelegate::Initialize() { ...@@ -476,11 +477,9 @@ void CameraDeviceDelegate::Initialize() {
DCHECK(ipc_task_runner_->BelongsToCurrentThread()); DCHECK(ipc_task_runner_->BelongsToCurrentThread());
DCHECK_EQ(device_context_->GetState(), CameraDeviceContext::State::kStarting); DCHECK_EQ(device_context_->GetState(), CameraDeviceContext::State::kStarting);
cros::mojom::Camera3CallbackOpsPtr callback_ops_ptr; mojo::PendingRemote<cros::mojom::Camera3CallbackOps> callback_ops;
cros::mojom::Camera3CallbackOpsRequest callback_ops_request =
mojo::MakeRequest(&callback_ops_ptr);
request_manager_ = std::make_unique<RequestManager>( request_manager_ = std::make_unique<RequestManager>(
std::move(callback_ops_request), callback_ops.InitWithNewPipeAndPassReceiver(),
std::make_unique<StreamCaptureInterfaceImpl>(GetWeakPtr()), std::make_unique<StreamCaptureInterfaceImpl>(GetWeakPtr()),
device_context_, chrome_capture_params_.buffer_type, device_context_, chrome_capture_params_.buffer_type,
std::make_unique<CameraBufferFactory>(), std::make_unique<CameraBufferFactory>(),
...@@ -489,7 +488,7 @@ void CameraDeviceDelegate::Initialize() { ...@@ -489,7 +488,7 @@ void CameraDeviceDelegate::Initialize() {
camera_3a_controller_ = std::make_unique<Camera3AController>( camera_3a_controller_ = std::make_unique<Camera3AController>(
static_metadata_, request_manager_.get(), ipc_task_runner_); static_metadata_, request_manager_.get(), ipc_task_runner_);
device_ops_->Initialize( device_ops_->Initialize(
std::move(callback_ops_ptr), std::move(callback_ops),
base::BindOnce(&CameraDeviceDelegate::OnInitialized, GetWeakPtr())); base::BindOnce(&CameraDeviceDelegate::OnInitialized, GetWeakPtr()));
} }
......
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
#include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h" #include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h"
#include "media/capture/video/mock_gpu_memory_buffer_manager.h" #include "media/capture/video/mock_gpu_memory_buffer_manager.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -45,13 +47,15 @@ class MockCameraDevice : public cros::mojom::Camera3DeviceOps { ...@@ -45,13 +47,15 @@ class MockCameraDevice : public cros::mojom::Camera3DeviceOps {
~MockCameraDevice() = default; ~MockCameraDevice() = default;
void Initialize(cros::mojom::Camera3CallbackOpsPtr callback_ops, void Initialize(
InitializeCallback callback) override { mojo::PendingRemote<cros::mojom::Camera3CallbackOps> callback_ops,
DoInitialize(callback_ops, callback); InitializeCallback callback) override {
DoInitialize(std::move(callback_ops), callback);
} }
MOCK_METHOD2(DoInitialize, MOCK_METHOD2(
void(cros::mojom::Camera3CallbackOpsPtr& callback_ops, DoInitialize,
InitializeCallback& callback)); void(mojo::PendingRemote<cros::mojom::Camera3CallbackOps> callback_ops,
InitializeCallback& callback));
void ConfigureStreams(cros::mojom::Camera3StreamConfigurationPtr config, void ConfigureStreams(cros::mojom::Camera3StreamConfigurationPtr config,
ConfigureStreamsCallback callback) override { ConfigureStreamsCallback callback) override {
...@@ -253,9 +257,9 @@ class CameraDeviceDelegateTest : public ::testing::Test { ...@@ -253,9 +257,9 @@ class CameraDeviceDelegateTest : public ::testing::Test {
} }
void InitializeMockCameraDevice( void InitializeMockCameraDevice(
cros::mojom::Camera3CallbackOpsPtr& callback_ops, mojo::PendingRemote<cros::mojom::Camera3CallbackOps> callback_ops,
base::OnceCallback<void(int32_t)>& callback) { base::OnceCallback<void(int32_t)>& callback) {
callback_ops_ = std::move(callback_ops); callback_ops_.Bind(std::move(callback_ops));
std::move(callback).Run(0); std::move(callback).Run(0);
} }
...@@ -472,7 +476,7 @@ class CameraDeviceDelegateTest : public ::testing::Test { ...@@ -472,7 +476,7 @@ class CameraDeviceDelegateTest : public ::testing::Test {
testing::StrictMock<MockCameraDevice> mock_camera_device_; testing::StrictMock<MockCameraDevice> mock_camera_device_;
mojo::Receiver<cros::mojom::Camera3DeviceOps> mock_camera_device_receiver_; mojo::Receiver<cros::mojom::Camera3DeviceOps> mock_camera_device_receiver_;
cros::mojom::Camera3CallbackOpsPtr callback_ops_; mojo::Remote<cros::mojom::Camera3CallbackOps> callback_ops_;
base::Thread device_delegate_thread_; base::Thread device_delegate_thread_;
......
...@@ -243,7 +243,8 @@ interface Camera3CallbackOps { ...@@ -243,7 +243,8 @@ interface Camera3CallbackOps {
interface Camera3DeviceOps { interface Camera3DeviceOps {
// Initialize() is called once after the camera device is opened to register // Initialize() is called once after the camera device is opened to register
// the Camera3CallbackOps handle. // the Camera3CallbackOps handle.
Initialize@0(Camera3CallbackOps callback_ops) => (int32 result); Initialize@0(pending_remote<Camera3CallbackOps> callback_ops)
=> (int32 result);
// ConfigureStreams() is called every time the client needs to set up new set // ConfigureStreams() is called every time the client needs to set up new set
// of streams. // of streams.
......
...@@ -34,7 +34,8 @@ constexpr std::initializer_list<StreamType> kYUVReprocessStreams = { ...@@ -34,7 +34,8 @@ constexpr std::initializer_list<StreamType> kYUVReprocessStreams = {
} // namespace } // namespace
RequestManager::RequestManager( RequestManager::RequestManager(
cros::mojom::Camera3CallbackOpsRequest callback_ops_request, mojo::PendingReceiver<cros::mojom::Camera3CallbackOps>
callback_ops_receiver,
std::unique_ptr<StreamCaptureInterface> capture_interface, std::unique_ptr<StreamCaptureInterface> capture_interface,
CameraDeviceContext* device_context, CameraDeviceContext* device_context,
VideoCaptureBufferType buffer_type, VideoCaptureBufferType buffer_type,
...@@ -42,7 +43,7 @@ RequestManager::RequestManager( ...@@ -42,7 +43,7 @@ RequestManager::RequestManager(
BlobifyCallback blobify_callback, BlobifyCallback blobify_callback,
scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner,
CameraAppDeviceImpl* camera_app_device) CameraAppDeviceImpl* camera_app_device)
: callback_ops_(this, std::move(callback_ops_request)), : callback_ops_(this, std::move(callback_ops_receiver)),
capture_interface_(std::move(capture_interface)), capture_interface_(std::move(capture_interface)),
device_context_(device_context), device_context_(device_context),
video_capture_use_gmb_(buffer_type == video_capture_use_gmb_(buffer_type ==
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
#include "media/capture/video/chromeos/request_builder.h" #include "media/capture/video/chromeos/request_builder.h"
#include "media/capture/video/chromeos/stream_buffer_manager.h" #include "media/capture/video/chromeos/stream_buffer_manager.h"
#include "media/capture/video_capture_types.h" #include "media/capture/video_capture_types.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
namespace media { namespace media {
...@@ -120,7 +121,8 @@ class CAPTURE_EXPORT RequestManager final ...@@ -120,7 +121,8 @@ class CAPTURE_EXPORT RequestManager final
base::Optional<uint64_t> input_buffer_id; base::Optional<uint64_t> input_buffer_id;
}; };
RequestManager(cros::mojom::Camera3CallbackOpsRequest callback_ops_request, RequestManager(mojo::PendingReceiver<cros::mojom::Camera3CallbackOps>
callback_ops_receiver,
std::unique_ptr<StreamCaptureInterface> capture_interface, std::unique_ptr<StreamCaptureInterface> capture_interface,
CameraDeviceContext* device_context, CameraDeviceContext* device_context,
VideoCaptureBufferType buffer_type, VideoCaptureBufferType buffer_type,
...@@ -274,7 +276,7 @@ class CAPTURE_EXPORT RequestManager final ...@@ -274,7 +276,7 @@ class CAPTURE_EXPORT RequestManager final
// SetRepeatingCaptureMetadata(), update them onto |capture_settings|. // SetRepeatingCaptureMetadata(), update them onto |capture_settings|.
void UpdateCaptureSettings(cros::mojom::CameraMetadataPtr* capture_settings); void UpdateCaptureSettings(cros::mojom::CameraMetadataPtr* capture_settings);
mojo::Binding<cros::mojom::Camera3CallbackOps> callback_ops_; mojo::Receiver<cros::mojom::Camera3CallbackOps> callback_ops_;
std::unique_ptr<StreamCaptureInterface> capture_interface_; std::unique_ptr<StreamCaptureInterface> capture_interface_;
......
...@@ -21,8 +21,10 @@ ...@@ -21,8 +21,10 @@
#include "media/capture/video/chromeos/mock_video_capture_client.h" #include "media/capture/video/chromeos/mock_video_capture_client.h"
#include "media/capture/video/chromeos/stream_buffer_manager.h" #include "media/capture/video/chromeos/stream_buffer_manager.h"
#include "media/capture/video/mock_gpu_memory_buffer_manager.h" #include "media/capture/video/mock_gpu_memory_buffer_manager.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using testing::_; using testing::_;
using testing::A; using testing::A;
using testing::AtLeast; using testing::AtLeast;
...@@ -84,13 +86,11 @@ class RequestManagerTest : public ::testing::Test { ...@@ -84,13 +86,11 @@ class RequestManagerTest : public ::testing::Test {
public: public:
void SetUp() override { void SetUp() override {
quit_ = false; quit_ = false;
cros::mojom::Camera3CallbackOpsRequest callback_ops_request =
mojo::MakeRequest(&mock_callback_ops_);
device_context_ = std::make_unique<CameraDeviceContext>( device_context_ = std::make_unique<CameraDeviceContext>(
std::make_unique<unittest_internal::MockVideoCaptureClient>()); std::make_unique<unittest_internal::MockVideoCaptureClient>());
request_manager_ = std::make_unique<RequestManager>( request_manager_ = std::make_unique<RequestManager>(
std::move(callback_ops_request), mock_callback_ops_.BindNewPipeAndPassReceiver(),
std::make_unique<MockStreamCaptureInterface>(), device_context_.get(), std::make_unique<MockStreamCaptureInterface>(), device_context_.get(),
VideoCaptureBufferType::kSharedMemory, VideoCaptureBufferType::kSharedMemory,
std::make_unique<FakeCameraBufferFactory>(), std::make_unique<FakeCameraBufferFactory>(),
...@@ -273,7 +273,7 @@ class RequestManagerTest : public ::testing::Test { ...@@ -273,7 +273,7 @@ class RequestManagerTest : public ::testing::Test {
protected: protected:
std::unique_ptr<RequestManager> request_manager_; std::unique_ptr<RequestManager> request_manager_;
cros::mojom::Camera3CallbackOpsPtr mock_callback_ops_; mojo::Remote<cros::mojom::Camera3CallbackOps> mock_callback_ops_;
std::unique_ptr<CameraDeviceContext> device_context_; std::unique_ptr<CameraDeviceContext> device_context_;
cros::mojom::Camera3StreamPtr stream; cros::mojom::Camera3StreamPtr stream;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment