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

Side by Side Diff: services/video_capture/device_factory_media_to_mojo_adapter.cc

Issue 2813343002: [Mojo Video Capture] Switch to using Mojo structs in media/capture/mojo (Closed)
Patch Set: Removed extraneous AtLeast Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/video_capture/device_factory_media_to_mojo_adapter.h" 5 #include "services/video_capture/device_factory_media_to_mojo_adapter.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "media/capture/video/fake_video_capture_device.h" 13 #include "media/capture/video/fake_video_capture_device.h"
14 #include "media/capture/video/video_capture_device_info.h"
14 #include "mojo/public/cpp/bindings/strong_binding.h" 15 #include "mojo/public/cpp/bindings/strong_binding.h"
15 #include "services/video_capture/device_media_to_mojo_adapter.h" 16 #include "services/video_capture/device_media_to_mojo_adapter.h"
16 #include "services/video_capture/public/cpp/capture_settings.h"
17 17
18 namespace video_capture { 18 namespace video_capture {
19 19
20 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry::ActiveDeviceEntry() = 20 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry::ActiveDeviceEntry() =
21 default; 21 default;
22 22
23 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry::~ActiveDeviceEntry() = 23 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry::~ActiveDeviceEntry() =
24 default; 24 default;
25 25
26 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry::ActiveDeviceEntry( 26 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry::ActiveDeviceEntry(
27 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry&& other) = default; 27 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry&& other) = default;
28 28
29 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry& 29 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry&
30 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry::operator=( 30 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry::operator=(
31 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry&& other) = default; 31 DeviceFactoryMediaToMojoAdapter::ActiveDeviceEntry&& other) = default;
32 32
33 DeviceFactoryMediaToMojoAdapter::DeviceFactoryMediaToMojoAdapter( 33 DeviceFactoryMediaToMojoAdapter::DeviceFactoryMediaToMojoAdapter(
34 std::unique_ptr<media::VideoCaptureDeviceFactory> device_factory, 34 std::unique_ptr<media::VideoCaptureDeviceFactory> device_factory,
35 const media::VideoCaptureJpegDecoderFactoryCB& 35 const media::VideoCaptureJpegDecoderFactoryCB&
36 jpeg_decoder_factory_callback) 36 jpeg_decoder_factory_callback)
37 : device_factory_(std::move(device_factory)), 37 : device_factory_(std::move(device_factory)),
38 jpeg_decoder_factory_callback_(jpeg_decoder_factory_callback) {} 38 jpeg_decoder_factory_callback_(jpeg_decoder_factory_callback) {}
39 39
40 DeviceFactoryMediaToMojoAdapter::~DeviceFactoryMediaToMojoAdapter() = default; 40 DeviceFactoryMediaToMojoAdapter::~DeviceFactoryMediaToMojoAdapter() = default;
41 41
42 void DeviceFactoryMediaToMojoAdapter::EnumerateDeviceDescriptors( 42 void DeviceFactoryMediaToMojoAdapter::GetDeviceInfos(
43 const EnumerateDeviceDescriptorsCallback& callback) { 43 const GetDeviceInfosCallback& callback) {
44 media::VideoCaptureDeviceDescriptors descriptors; 44 NOTIMPLEMENTED();
45 device_factory_->GetDeviceDescriptors(&descriptors);
46 callback.Run(std::move(descriptors));
47 }
48
49 void DeviceFactoryMediaToMojoAdapter::GetSupportedFormats(
50 const std::string& device_id,
51 const GetSupportedFormatsCallback& callback) {
52 media::VideoCaptureDeviceDescriptor descriptor;
53 media::VideoCaptureFormats media_formats;
54 if (LookupDescriptorFromId(device_id, &descriptor))
55 device_factory_->GetSupportedFormats(descriptor, &media_formats);
56 std::vector<I420CaptureFormat> result;
57 for (const auto& media_format : media_formats) {
58 // The Video Capture Service requires devices to deliver frames either in
59 // I420 or MJPEG formats.
60 // TODO(chfremer): Add support for Y16 format. See crbug.com/624436.
61 if (media_format.pixel_format != media::PIXEL_FORMAT_I420 &&
62 media_format.pixel_format != media::PIXEL_FORMAT_MJPEG) {
63 continue;
64 }
65 I420CaptureFormat format;
66 format.frame_size = media_format.frame_size;
67 format.frame_rate = media_format.frame_rate;
68 if (base::ContainsValue(result, format))
69 continue; // Result already contains this format
70 result.push_back(format);
71 }
72 callback.Run(std::move(result));
73 } 45 }
74 46
75 void DeviceFactoryMediaToMojoAdapter::CreateDevice( 47 void DeviceFactoryMediaToMojoAdapter::CreateDevice(
76 const std::string& device_id, 48 const std::string& device_id,
77 mojom::DeviceRequest device_request, 49 mojom::DeviceRequest device_request,
78 const CreateDeviceCallback& callback) { 50 const CreateDeviceCallback& callback) {
79 auto active_device_iter = active_devices_by_id_.find(device_id); 51 auto active_device_iter = active_devices_by_id_.find(device_id);
80 if (active_device_iter != active_devices_by_id_.end()) { 52 if (active_device_iter != active_devices_by_id_.end()) {
81 // The requested device is already in use. 53 // The requested device is already in use.
82 // Revoke the access and close the device, then bind to the new request. 54 // Revoke the access and close the device, then bind to the new request.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 [&device_id](const media::VideoCaptureDeviceDescriptor& descriptor) { 106 [&device_id](const media::VideoCaptureDeviceDescriptor& descriptor) {
135 return descriptor.device_id == device_id; 107 return descriptor.device_id == device_id;
136 }); 108 });
137 if (descriptor_iter == descriptors.end()) 109 if (descriptor_iter == descriptors.end())
138 return false; 110 return false;
139 *descriptor = *descriptor_iter; 111 *descriptor = *descriptor_iter;
140 return true; 112 return true;
141 } 113 }
142 114
143 } // namespace video_capture 115 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/device_factory_media_to_mojo_adapter.h ('k') | services/video_capture/device_media_to_mojo_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698