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

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

Issue 2486543002: [Mojo Video Capture] Add test ReceiveFramesFromFakeCaptureDevice (Closed)
Patch Set: mcasas comments mk2 Created 4 years, 1 month 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
« no previous file with comments | « services/video_capture/BUILD.gn ('k') | services/video_capture/fake_device_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 30 matching lines...) Expand all
41 const EnumerateDeviceDescriptorsCallback& callback) { 41 const EnumerateDeviceDescriptorsCallback& callback) {
42 media::VideoCaptureDeviceDescriptors descriptors; 42 media::VideoCaptureDeviceDescriptors descriptors;
43 device_factory_->GetDeviceDescriptors(&descriptors); 43 device_factory_->GetDeviceDescriptors(&descriptors);
44 callback.Run(descriptors); 44 callback.Run(descriptors);
45 } 45 }
46 46
47 void DeviceFactoryMediaToMojoAdapter::GetSupportedFormats( 47 void DeviceFactoryMediaToMojoAdapter::GetSupportedFormats(
48 const media::VideoCaptureDeviceDescriptor& device_descriptor, 48 const media::VideoCaptureDeviceDescriptor& device_descriptor,
49 const GetSupportedFormatsCallback& callback) { 49 const GetSupportedFormatsCallback& callback) {
50 std::vector<VideoCaptureFormat> result; 50 std::vector<VideoCaptureFormat> result;
51 NOTIMPLEMENTED(); 51 std::vector<media::VideoCaptureFormat> media_formats;
52 device_factory_->GetSupportedFormats(device_descriptor, &media_formats);
53 for (const auto& media_format : media_formats) {
54 // The Video Capture Service requires devices to deliver frames either in
55 // I420 or MJPEG formats.
56 // TODO(chfremer): Add support for Y16 format. See crbug.com/624436.
57 if (media_format.pixel_format != media::PIXEL_FORMAT_I420 &&
58 media_format.pixel_format != media::PIXEL_FORMAT_MJPEG) {
59 continue;
60 }
61 VideoCaptureFormat format;
62 format.frame_size = media_format.frame_size;
63 format.frame_rate = media_format.frame_rate;
64 if (base::ContainsValue(result, format))
65 continue; // Result already contains this format
66 result.push_back(format);
67 }
52 callback.Run(std::move(result)); 68 callback.Run(std::move(result));
53 } 69 }
54 70
55 void DeviceFactoryMediaToMojoAdapter::CreateDeviceProxy( 71 void DeviceFactoryMediaToMojoAdapter::CreateDeviceProxy(
56 const media::VideoCaptureDeviceDescriptor& device_descriptor, 72 const media::VideoCaptureDeviceDescriptor& device_descriptor,
57 mojom::VideoCaptureDeviceProxyRequest proxy_request, 73 mojom::VideoCaptureDeviceProxyRequest proxy_request,
58 const CreateDeviceProxyCallback& callback) { 74 const CreateDeviceProxyCallback& callback) {
59 if (active_devices_.find(device_descriptor) != active_devices_.end()) { 75 if (active_devices_.find(device_descriptor) != active_devices_.end()) {
60 // The requested device is already in use. 76 // The requested device is already in use.
61 // Revoke the access and close the device, then bind to the new request. 77 // Revoke the access and close the device, then bind to the new request.
(...skipping 30 matching lines...) Expand all
92 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); 108 callback.Run(mojom::DeviceAccessResultCode::SUCCESS);
93 } 109 }
94 110
95 void DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose( 111 void DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose(
96 const media::VideoCaptureDeviceDescriptor& descriptor) { 112 const media::VideoCaptureDeviceDescriptor& descriptor) {
97 active_devices_[descriptor].device_proxy->Stop(); 113 active_devices_[descriptor].device_proxy->Stop();
98 active_devices_.erase(descriptor); 114 active_devices_.erase(descriptor);
99 } 115 }
100 116
101 } // namespace video_capture 117 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/BUILD.gn ('k') | services/video_capture/fake_device_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698