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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 static void TranslateDeviceInfos( | 29 static void TranslateDeviceInfos( |
30 const video_capture::mojom::DeviceFactory::GetDeviceInfosCallback& callback, | 30 const video_capture::mojom::DeviceFactory::GetDeviceInfosCallback& callback, |
31 const std::vector<media::VideoCaptureDeviceInfo>& device_infos) { | 31 const std::vector<media::VideoCaptureDeviceInfo>& device_infos) { |
32 std::vector<media::VideoCaptureDeviceInfo> translated_device_infos; | 32 std::vector<media::VideoCaptureDeviceInfo> translated_device_infos; |
33 for (const auto& device_info : device_infos) { | 33 for (const auto& device_info : device_infos) { |
34 media::VideoCaptureDeviceInfo translated_device_info; | 34 media::VideoCaptureDeviceInfo translated_device_info; |
35 translated_device_info.descriptor = device_info.descriptor; | 35 translated_device_info.descriptor = device_info.descriptor; |
36 for (const auto& format : device_info.supported_formats) { | 36 for (const auto& format : device_info.supported_formats) { |
37 media::VideoCaptureFormat translated_format; | 37 media::VideoCaptureFormat translated_format; |
38 switch (format.pixel_format) { | 38 switch (format.pixel_format) { |
39 case media::PIXEL_FORMAT_I420: | 39 case media::PIXEL_FORMAT_Y16: |
40 case media::PIXEL_FORMAT_MJPEG: | 40 translated_format.pixel_format = media::PIXEL_FORMAT_Y16; |
41 break; | |
42 default: | |
43 // Any other format gets converted to I420. | |
41 translated_format.pixel_format = media::PIXEL_FORMAT_I420; | 44 translated_format.pixel_format = media::PIXEL_FORMAT_I420; |
42 break; | 45 break; |
43 case media::PIXEL_FORMAT_Y16: | |
44 translated_format.pixel_format = media::PIXEL_FORMAT_Y16; | |
45 default: | |
46 // Any other format cannot be consumed by VideoCaptureDeviceClient. | |
47 continue; | |
48 } | 46 } |
mcasas
2017/05/10 02:33:33
translated_format.pixel_format =
format.pi
chfremer
2017/05/10 17:59:40
Done.
| |
49 translated_format.frame_size = format.frame_size; | 47 translated_format.frame_size = format.frame_size; |
50 translated_format.frame_rate = format.frame_rate; | 48 translated_format.frame_rate = format.frame_rate; |
51 translated_format.pixel_storage = media::PIXEL_STORAGE_CPU; | 49 translated_format.pixel_storage = media::PIXEL_STORAGE_CPU; |
52 if (base::ContainsValue(translated_device_info.supported_formats, | 50 if (base::ContainsValue(translated_device_info.supported_formats, |
53 translated_format)) | 51 translated_format)) |
54 continue; | 52 continue; |
55 translated_device_info.supported_formats.push_back(translated_format); | 53 translated_device_info.supported_formats.push_back(translated_format); |
56 } | 54 } |
57 if (translated_device_info.supported_formats.empty()) | 55 if (translated_device_info.supported_formats.empty()) |
58 continue; | 56 continue; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); | 161 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); |
164 } | 162 } |
165 | 163 |
166 void DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose( | 164 void DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose( |
167 const std::string& device_id) { | 165 const std::string& device_id) { |
168 active_devices_by_id_[device_id].device->Stop(); | 166 active_devices_by_id_[device_id].device->Stop(); |
169 active_devices_by_id_.erase(device_id); | 167 active_devices_by_id_.erase(device_id); |
170 } | 168 } |
171 | 169 |
172 } // namespace video_capture | 170 } // namespace video_capture |
OLD | NEW |