| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/capture/video/fake_video_capture_device_factory.h" | 5 #include "media/capture/video/fake_video_capture_device_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "media/base/media_switches.h" | 14 #include "media/base/media_switches.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 static const size_t kDepthDeviceIndex = 1; |
| 19 static const char kDepthDeviceId[] = "/dev/video1"; |
| 20 |
| 18 // Factory has one device by default; I420. If there are more, the second device | 21 // Factory has one device by default; I420. If there are more, the second device |
| 19 // is of Y16 format while the rest are I420. | 22 // is of Y16 format while the rest are I420. |
| 20 media::VideoPixelFormat GetPixelFormat(const std::string& device_id) { | 23 media::VideoPixelFormat GetPixelFormat(const std::string& device_id) { |
| 21 return (device_id == "/dev/video1") ? media::PIXEL_FORMAT_Y16 | 24 return (device_id == kDepthDeviceId) ? media::PIXEL_FORMAT_Y16 |
| 22 : media::PIXEL_FORMAT_I420; | 25 : media::PIXEL_FORMAT_I420; |
| 23 } | 26 } |
| 24 } | 27 } |
| 25 | 28 |
| 26 namespace media { | 29 namespace media { |
| 27 | 30 |
| 28 // Cap the frame rate command line input to reasonable values. | 31 // Cap the frame rate command line input to reasonable values. |
| 29 static const float kFakeCaptureMinFrameRate = 5.0f; | 32 static const float kFakeCaptureMinFrameRate = 5.0f; |
| 30 static const float kFakeCaptureMaxFrameRate = 60.0f; | 33 static const float kFakeCaptureMaxFrameRate = 60.0f; |
| 31 // Default rate if none is specified as part of the command line. | 34 // Default rate if none is specified as part of the command line. |
| 32 static const float kFakeCaptureDefaultFrameRate = 20.0f; | 35 static const float kFakeCaptureDefaultFrameRate = 20.0f; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE | 78 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE |
| 76 #elif defined(OS_MACOSX) | 79 #elif defined(OS_MACOSX) |
| 77 VideoCaptureApi::MACOSX_AVFOUNDATION | 80 VideoCaptureApi::MACOSX_AVFOUNDATION |
| 78 #elif defined(OS_WIN) | 81 #elif defined(OS_WIN) |
| 79 VideoCaptureApi::WIN_DIRECT_SHOW | 82 VideoCaptureApi::WIN_DIRECT_SHOW |
| 80 #elif defined(OS_ANDROID) | 83 #elif defined(OS_ANDROID) |
| 81 VideoCaptureApi::ANDROID_API2_LEGACY | 84 VideoCaptureApi::ANDROID_API2_LEGACY |
| 82 #endif | 85 #endif |
| 83 ); | 86 ); |
| 84 } | 87 } |
| 88 |
| 89 // Video device on index 1 (kDepthDeviceIndex) is depth video capture device. |
| 90 // Fill the camera calibration information only for it. |
| 91 if (device_descriptors->size() <= kDepthDeviceIndex) |
| 92 return; |
| 93 VideoCaptureDeviceDescriptor& depth_device( |
| 94 (*device_descriptors)[kDepthDeviceIndex]); |
| 95 depth_device.camera_calibration.emplace(); |
| 96 depth_device.camera_calibration->focal_length_x = 135.0; |
| 97 depth_device.camera_calibration->focal_length_y = 135.6; |
| 98 depth_device.camera_calibration->depth_near = 0.0; |
| 99 depth_device.camera_calibration->depth_far = 65.535; |
| 85 } | 100 } |
| 86 | 101 |
| 87 void FakeVideoCaptureDeviceFactory::GetSupportedFormats( | 102 void FakeVideoCaptureDeviceFactory::GetSupportedFormats( |
| 88 const VideoCaptureDeviceDescriptor& device_descriptor, | 103 const VideoCaptureDeviceDescriptor& device_descriptor, |
| 89 VideoCaptureFormats* supported_formats) { | 104 VideoCaptureFormats* supported_formats) { |
| 90 DCHECK(thread_checker_.CalledOnValidThread()); | 105 DCHECK(thread_checker_.CalledOnValidThread()); |
| 91 const gfx::Size supported_sizes[] = { | 106 const gfx::Size supported_sizes[] = { |
| 92 gfx::Size(96, 96), gfx::Size(320, 240), gfx::Size(640, 480), | 107 gfx::Size(96, 96), gfx::Size(320, 240), gfx::Size(640, 480), |
| 93 gfx::Size(1280, 720), gfx::Size(1920, 1080)}; | 108 gfx::Size(1280, 720), gfx::Size(1920, 1080)}; |
| 94 supported_formats->clear(); | 109 supported_formats->clear(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 if (base::StringToUint(param.back(), &count)) { | 151 if (base::StringToUint(param.back(), &count)) { |
| 137 number_of_devices_ = std::min( | 152 number_of_devices_ = std::min( |
| 138 kFakeCaptureMaxDeviceCount, | 153 kFakeCaptureMaxDeviceCount, |
| 139 std::max(kFakeCaptureMinDeviceCount, static_cast<int>(count))); | 154 std::max(kFakeCaptureMinDeviceCount, static_cast<int>(count))); |
| 140 } | 155 } |
| 141 } | 156 } |
| 142 } | 157 } |
| 143 } | 158 } |
| 144 | 159 |
| 145 } // namespace media | 160 } // namespace media |
| OLD | NEW |