OLD | NEW |
---|---|
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 Loading... | |
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 if (media_format.pixel_format != media::PIXEL_FORMAT_I420 && | |
57 media_format.pixel_format != media::PIXEL_FORMAT_MJPEG) | |
mcasas
2016/11/09 23:50:29
Y16 was added very recently to FakeVCD and Win [1]
chfremer
2016/11/10 00:28:48
Thanks for the heads up.
I have already seen and
mcasas
2016/11/10 01:21:25
Alright. If it's in a few places (ideally, one), j
chfremer
2016/11/10 04:41:35
Done.
| |
58 continue; | |
59 VideoCaptureFormat format; | |
60 format.frame_size = media_format.frame_size; | |
61 format.frame_rate = media_format.frame_rate; | |
62 if (std::find(std::begin(result), std::end(result), format) != | |
63 std::end(result)) | |
64 continue; // Result already contains this format | |
mcasas
2016/11/09 23:50:29
{} because the if() condition expands > 1 line.
chfremer
2016/11/10 00:28:48
Done.
| |
65 result.push_back(format); | |
66 } | |
52 callback.Run(std::move(result)); | 67 callback.Run(std::move(result)); |
53 } | 68 } |
54 | 69 |
55 void DeviceFactoryMediaToMojoAdapter::CreateDeviceProxy( | 70 void DeviceFactoryMediaToMojoAdapter::CreateDeviceProxy( |
56 const media::VideoCaptureDeviceDescriptor& device_descriptor, | 71 const media::VideoCaptureDeviceDescriptor& device_descriptor, |
57 mojom::VideoCaptureDeviceProxyRequest proxy_request, | 72 mojom::VideoCaptureDeviceProxyRequest proxy_request, |
58 const CreateDeviceProxyCallback& callback) { | 73 const CreateDeviceProxyCallback& callback) { |
59 if (active_devices_.find(device_descriptor) != active_devices_.end()) { | 74 if (active_devices_.find(device_descriptor) != active_devices_.end()) { |
60 // The requested device is already in use. | 75 // The requested device is already in use. |
61 // Revoke the access and close the device, then bind to the new request. | 76 // Revoke the access and close the device, then bind to the new request. |
(...skipping 30 matching lines...) Expand all Loading... | |
92 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); | 107 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); |
93 } | 108 } |
94 | 109 |
95 void DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose( | 110 void DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose( |
96 const media::VideoCaptureDeviceDescriptor& descriptor) { | 111 const media::VideoCaptureDeviceDescriptor& descriptor) { |
97 active_devices_[descriptor].device_proxy->Stop(); | 112 active_devices_[descriptor].device_proxy->Stop(); |
98 active_devices_.erase(descriptor); | 113 active_devices_.erase(descriptor); |
99 } | 114 } |
100 | 115 |
101 } // namespace video_capture | 116 } // namespace video_capture |
OLD | NEW |