OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/mac/video_capture_device_mac.h" | 5 #include "media/capture/video/mac/video_capture_device_mac.h" |
6 | 6 |
7 #include <IOKit/IOCFPlugIn.h> | 7 #include <IOKit/IOCFPlugIn.h> |
8 #include <IOKit/usb/IOUSBLib.h> | 8 #include <IOKit/usb/IOUSBLib.h> |
9 #include <IOKit/usb/USBSpec.h> | 9 #include <IOKit/usb/USBSpec.h> |
| 10 #include <stdint.h> |
| 11 |
| 12 #include <limits> |
10 | 13 |
11 #include "base/bind.h" | 14 #include "base/bind.h" |
12 #include "base/location.h" | 15 #include "base/location.h" |
13 #include "base/logging.h" | 16 #include "base/logging.h" |
14 #include "base/mac/scoped_ioobject.h" | 17 #include "base/mac/scoped_ioobject.h" |
15 #include "base/mac/scoped_ioplugininterface.h" | 18 #include "base/mac/scoped_ioplugininterface.h" |
16 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
17 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
18 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 22 #include "base/time/time.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 const int kPuPowerLineFrequencyControlCommandSize = 1; | 92 const int kPuPowerLineFrequencyControlCommandSize = 1; |
90 | 93 |
91 // Addition to the IOUSB family of structures, with subtype and unit ID. | 94 // Addition to the IOUSB family of structures, with subtype and unit ID. |
92 typedef struct IOUSBInterfaceDescriptor { | 95 typedef struct IOUSBInterfaceDescriptor { |
93 IOUSBDescriptorHeader header; | 96 IOUSBDescriptorHeader header; |
94 UInt8 bDescriptorSubType; | 97 UInt8 bDescriptorSubType; |
95 UInt8 bUnitID; | 98 UInt8 bUnitID; |
96 } IOUSBInterfaceDescriptor; | 99 } IOUSBInterfaceDescriptor; |
97 | 100 |
98 static void GetBestMatchSupportedResolution(gfx::Size* resolution) { | 101 static void GetBestMatchSupportedResolution(gfx::Size* resolution) { |
99 int min_diff = kint32max; | 102 int min_diff = std::numeric_limits<int32_t>::max(); |
100 const int desired_area = resolution->GetArea(); | 103 const int desired_area = resolution->GetArea(); |
101 for (size_t i = 0; i < arraysize(kWellSupportedResolutions); ++i) { | 104 for (size_t i = 0; i < arraysize(kWellSupportedResolutions); ++i) { |
102 const int area = kWellSupportedResolutions[i]->width * | 105 const int area = kWellSupportedResolutions[i]->width * |
103 kWellSupportedResolutions[i]->height; | 106 kWellSupportedResolutions[i]->height; |
104 const int diff = std::abs(desired_area - area); | 107 const int diff = std::abs(desired_area - area); |
105 if (diff < min_diff) { | 108 if (diff < min_diff) { |
106 min_diff = diff; | 109 min_diff = diff; |
107 resolution->SetSize(kWellSupportedResolutions[i]->width, | 110 resolution->SetSize(kWellSupportedResolutions[i]->width, |
108 kWellSupportedResolutions[i]->height); | 111 kWellSupportedResolutions[i]->height); |
109 } | 112 } |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 582 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
580 width:capture_format_.frame_size.width() | 583 width:capture_format_.frame_size.width() |
581 frameRate:capture_format_.frame_rate]) { | 584 frameRate:capture_format_.frame_rate]) { |
582 ReceiveError(FROM_HERE, "Could not configure capture device."); | 585 ReceiveError(FROM_HERE, "Could not configure capture device."); |
583 return false; | 586 return false; |
584 } | 587 } |
585 return true; | 588 return true; |
586 } | 589 } |
587 | 590 |
588 } // namespace media | 591 } // namespace media |
OLD | NEW |