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

Unified Diff: services/video_capture/device_factory_media_to_mojo_adapter.cc

Issue 2386183002: Replace manual conversions with Mojo type mappings
Patch Set: Created 4 years, 2 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: services/video_capture/device_factory_media_to_mojo_adapter.cc
diff --git a/services/video_capture/device_factory_media_to_mojo_adapter.cc b/services/video_capture/device_factory_media_to_mojo_adapter.cc
index d69282cb6028669aeb68f98318a8787923761ba4..1062f305fd664b806d52246cd48161a6245b5a7f 100644
--- a/services/video_capture/device_factory_media_to_mojo_adapter.cc
+++ b/services/video_capture/device_factory_media_to_mojo_adapter.cc
@@ -11,7 +11,6 @@
#include "media/capture/video/fake_video_capture_device.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/video_capture/device_mock_to_media_adapter.h"
-#include "services/video_capture/mojo_media_conversions.h"
#include "services/video_capture/video_capture_device_proxy_impl.h"
namespace video_capture {
@@ -39,53 +38,41 @@ DeviceFactoryMediaToMojoAdapter::~DeviceFactoryMediaToMojoAdapter() = default;
void DeviceFactoryMediaToMojoAdapter::EnumerateDeviceDescriptors(
const EnumerateDeviceDescriptorsCallback& callback) {
- std::vector<mojom::VideoCaptureDeviceDescriptorPtr> result;
- media::VideoCaptureDeviceDescriptors descriptors;
+ std::vector<media::VideoCaptureDeviceDescriptor> descriptors;
device_factory_->GetDeviceDescriptors(&descriptors);
- for (const auto& entry : descriptors) {
- result.push_back(ConvertFromMediaToMojo(entry));
- }
- callback.Run(std::move(result));
+ callback.Run(std::move(descriptors));
}
void DeviceFactoryMediaToMojoAdapter::GetSupportedFormats(
- mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
+ const media::VideoCaptureDeviceDescriptor& descriptor,
const GetSupportedFormatsCallback& callback) {
- std::vector<mojom::VideoCaptureFormatPtr> result;
media::VideoCaptureFormats formats;
- device_factory_->GetSupportedFormats(
- ConvertFromMojoToMedia(std::move(device_descriptor)), &formats);
- for (const auto& entry : formats) {
- result.push_back(
- ConvertFromMediaToMojo(entry));
- }
- callback.Run(std::move(result));
+ device_factory_->GetSupportedFormats(std::move(descriptor), &formats);
+ callback.Run(std::move(formats));
}
void DeviceFactoryMediaToMojoAdapter::CreateDeviceProxy(
- mojom::VideoCaptureDeviceDescriptorPtr device_descriptor,
+ const media::VideoCaptureDeviceDescriptor& descriptor,
mojom::VideoCaptureDeviceProxyRequest proxy_request,
const CreateDeviceProxyCallback& callback) {
- auto media_descriptor = ConvertFromMojoToMedia(std::move(device_descriptor));
- if (active_devices_.find(media_descriptor) != active_devices_.end()) {
+ if (active_devices_.find(descriptor) != active_devices_.end()) {
// The requested device is already in use.
// Revoke the access and close the device, then bind to the new request.
- ActiveDeviceEntry& device_entry = active_devices_[media_descriptor];
+ ActiveDeviceEntry& device_entry = active_devices_[descriptor];
device_entry.binding->Unbind();
device_entry.device_proxy->Stop();
device_entry.binding->Bind(std::move(proxy_request));
device_entry.binding->set_connection_error_handler(base::Bind(
&DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose,
base::Unretained(this),
- media_descriptor));
+ descriptor));
callback.Run(mojom::DeviceAccessResultCode::SUCCESS);
return;
}
// Create device
std::unique_ptr<media::VideoCaptureDevice> media_device =
- device_factory_->CreateDevice(
- media_descriptor);
+ device_factory_->CreateDevice(descriptor);
if (media_device == nullptr) {
callback.Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND);
return;
@@ -100,8 +87,8 @@ void DeviceFactoryMediaToMojoAdapter::CreateDeviceProxy(
device_entry.device_proxy.get(), std::move(proxy_request));
device_entry.binding->set_connection_error_handler(base::Bind(
&DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose,
- base::Unretained(this), media_descriptor));
- active_devices_[media_descriptor] = std::move(device_entry);
+ base::Unretained(this), descriptor));
+ active_devices_[descriptor] = std::move(device_entry);
callback.Run(mojom::DeviceAccessResultCode::SUCCESS);
}
« no previous file with comments | « services/video_capture/device_factory_media_to_mojo_adapter.h ('k') | services/video_capture/fake_device_descriptor_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698