| 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 17 matching lines...) Expand all Loading... |
| 28 // instead of VideoCaptureSystem. | 28 // instead of VideoCaptureSystem. |
| 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 translated_format.pixel_format = |
| 39 case media::PIXEL_FORMAT_I420: | 39 (format.pixel_format == media::PIXEL_FORMAT_Y16) |
| 40 case media::PIXEL_FORMAT_MJPEG: | 40 ? media::PIXEL_FORMAT_Y16 |
| 41 translated_format.pixel_format = media::PIXEL_FORMAT_I420; | 41 : media::PIXEL_FORMAT_I420; |
| 42 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 } | |
| 49 translated_format.frame_size = format.frame_size; | 42 translated_format.frame_size = format.frame_size; |
| 50 translated_format.frame_rate = format.frame_rate; | 43 translated_format.frame_rate = format.frame_rate; |
| 51 translated_format.pixel_storage = media::PIXEL_STORAGE_CPU; | 44 translated_format.pixel_storage = media::PIXEL_STORAGE_CPU; |
| 52 if (base::ContainsValue(translated_device_info.supported_formats, | 45 if (base::ContainsValue(translated_device_info.supported_formats, |
| 53 translated_format)) | 46 translated_format)) |
| 54 continue; | 47 continue; |
| 55 translated_device_info.supported_formats.push_back(translated_format); | 48 translated_device_info.supported_formats.push_back(translated_format); |
| 56 } | 49 } |
| 57 if (translated_device_info.supported_formats.empty()) | 50 if (translated_device_info.supported_formats.empty()) |
| 58 continue; | 51 continue; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); | 156 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); |
| 164 } | 157 } |
| 165 | 158 |
| 166 void DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose( | 159 void DeviceFactoryMediaToMojoAdapter::OnClientConnectionErrorOrClose( |
| 167 const std::string& device_id) { | 160 const std::string& device_id) { |
| 168 active_devices_by_id_[device_id].device->Stop(); | 161 active_devices_by_id_[device_id].device->Stop(); |
| 169 active_devices_by_id_.erase(device_id); | 162 active_devices_by_id_.erase(device_id); |
| 170 } | 163 } |
| 171 | 164 |
| 172 } // namespace video_capture | 165 } // namespace video_capture |
| OLD | NEW |