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/video/capture/mac/video_capture_device_mac.h" | 5 #include "media/video/capture/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 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop/message_loop_proxy.h" | 14 #include "base/message_loop/message_loop_proxy.h" |
15 #include "base/mac/scoped_ioobject.h" | 15 #include "base/mac/scoped_ioobject.h" |
16 #include "base/mac/scoped_ioplugininterface.h" | 16 #include "base/mac/scoped_ioplugininterface.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #import "media/video/capture/mac/avfoundation_glue.h" | 19 #import "media/video/capture/mac/avfoundation_glue.h" |
20 #import "media/video/capture/mac/platform_video_capturing_mac.h" | 20 #import "media/video/capture/mac/platform_video_capturing_mac.h" |
21 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" | 21 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" |
22 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" | 22 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" |
23 | 23 |
| 24 @implementation DeviceNameAndTransportType |
| 25 |
| 26 - (id)initWithName:(NSString*)deviceName transportType:(int32_t)transportType { |
| 27 if (self = [super init]) { |
| 28 deviceName_.reset([deviceName copy]); |
| 29 transportType_ = transportType; |
| 30 } |
| 31 return self; |
| 32 } |
| 33 |
| 34 - (NSString*)deviceName { |
| 35 return deviceName_; |
| 36 } |
| 37 |
| 38 - (int32_t)transportType { |
| 39 return transportType_; |
| 40 } |
| 41 |
| 42 @end // @implementation DeviceNameAndTransportType |
| 43 |
24 namespace media { | 44 namespace media { |
25 | 45 |
26 const int kMinFrameRate = 1; | 46 const int kMinFrameRate = 1; |
27 const int kMaxFrameRate = 30; | 47 const int kMaxFrameRate = 30; |
28 | 48 |
29 // In device identifiers, the USB VID and PID are stored in 4 bytes each. | 49 // In device identifiers, the USB VID and PID are stored in 4 bytes each. |
30 const size_t kVidPidSize = 4; | 50 const size_t kVidPidSize = 4; |
31 | 51 |
32 const struct Resolution { | 52 const struct Resolution { |
33 const int width; | 53 const int width; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 return; | 320 return; |
301 } | 321 } |
302 base::mac::ScopedIOPluginInterface<IOCFPlugInInterface> | 322 base::mac::ScopedIOPluginInterface<IOCFPlugInInterface> |
303 plugin_interface_ref(video_control_interface); | 323 plugin_interface_ref(video_control_interface); |
304 | 324 |
305 SetAntiFlickerInVideoControlInterface(video_control_interface, frequency); | 325 SetAntiFlickerInVideoControlInterface(video_control_interface, frequency); |
306 } | 326 } |
307 } | 327 } |
308 | 328 |
309 const std::string VideoCaptureDevice::Name::GetModel() const { | 329 const std::string VideoCaptureDevice::Name::GetModel() const { |
| 330 // Skip the AVFoundation's not USB nor built-in devices. |
| 331 if (capture_api_type() == AVFOUNDATION && transport_type() != USB_OR_BUILT_IN) |
| 332 return ""; |
310 // Both PID and VID are 4 characters. | 333 // Both PID and VID are 4 characters. |
311 if (unique_id_.size() < 2 * kVidPidSize) { | 334 if (unique_id_.size() < 2 * kVidPidSize) |
312 return ""; | 335 return ""; |
313 } | |
314 | 336 |
315 // The last characters of device id is a concatenation of VID and then PID. | 337 // The last characters of device id is a concatenation of VID and then PID. |
316 const size_t vid_location = unique_id_.size() - 2 * kVidPidSize; | 338 const size_t vid_location = unique_id_.size() - 2 * kVidPidSize; |
317 std::string id_vendor = unique_id_.substr(vid_location, kVidPidSize); | 339 std::string id_vendor = unique_id_.substr(vid_location, kVidPidSize); |
318 const size_t pid_location = unique_id_.size() - kVidPidSize; | 340 const size_t pid_location = unique_id_.size() - kVidPidSize; |
319 std::string id_product = unique_id_.substr(pid_location, kVidPidSize); | 341 std::string id_product = unique_id_.substr(pid_location, kVidPidSize); |
320 | 342 |
321 return id_vendor + ":" + id_product; | 343 return id_vendor + ":" + id_product; |
322 } | 344 } |
323 | 345 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 572 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
551 width:capture_format_.frame_size.width() | 573 width:capture_format_.frame_size.width() |
552 frameRate:capture_format_.frame_rate]) { | 574 frameRate:capture_format_.frame_rate]) { |
553 ReceiveError("Could not configure capture device."); | 575 ReceiveError("Could not configure capture device."); |
554 return false; | 576 return false; |
555 } | 577 } |
556 return true; | 578 return true; |
557 } | 579 } |
558 | 580 |
559 } // namespace media | 581 } // namespace media |
OLD | NEW |