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 <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <limits> | 13 #include <limits> |
| 14 #include <utility> |
14 | 15 |
15 #include "base/bind.h" | 16 #include "base/bind.h" |
16 #include "base/location.h" | 17 #include "base/location.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/mac/scoped_ioobject.h" | 19 #include "base/mac/scoped_ioobject.h" |
19 #include "base/mac/scoped_ioplugininterface.h" | 20 #include "base/mac/scoped_ioplugininterface.h" |
20 #include "base/macros.h" | 21 #include "base/macros.h" |
21 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
22 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
23 #include "base/thread_task_runner_handle.h" | 24 #include "base/thread_task_runner_handle.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 return; | 371 return; |
371 } | 372 } |
372 | 373 |
373 // QTKit API can scale captured frame to any size requested, which would lead | 374 // QTKit API can scale captured frame to any size requested, which would lead |
374 // to undesired aspect ratio changes. Try to open the camera with a known | 375 // to undesired aspect ratio changes. Try to open the camera with a known |
375 // supported format and let the client crop/pad the captured frames. | 376 // supported format and let the client crop/pad the captured frames. |
376 gfx::Size resolution = params.requested_format.frame_size; | 377 gfx::Size resolution = params.requested_format.frame_size; |
377 if (!AVFoundationGlue::IsAVFoundationSupported()) | 378 if (!AVFoundationGlue::IsAVFoundationSupported()) |
378 GetBestMatchSupportedResolution(&resolution); | 379 GetBestMatchSupportedResolution(&resolution); |
379 | 380 |
380 client_ = client.Pass(); | 381 client_ = std::move(client); |
381 if (device_name_.capture_api_type() == Name::AVFOUNDATION) | 382 if (device_name_.capture_api_type() == Name::AVFOUNDATION) |
382 LogMessage("Using AVFoundation for device: " + device_name_.name()); | 383 LogMessage("Using AVFoundation for device: " + device_name_.name()); |
383 else | 384 else |
384 LogMessage("Using QTKit for device: " + device_name_.name()); | 385 LogMessage("Using QTKit for device: " + device_name_.name()); |
385 NSString* deviceId = | 386 NSString* deviceId = |
386 [NSString stringWithUTF8String:device_name_.id().c_str()]; | 387 [NSString stringWithUTF8String:device_name_.id().c_str()]; |
387 | 388 |
388 [capture_device_ setFrameReceiver:this]; | 389 [capture_device_ setFrameReceiver:this]; |
389 | 390 |
390 if (![capture_device_ setCaptureDevice:deviceId]) { | 391 if (![capture_device_ setCaptureDevice:deviceId]) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 585 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
585 width:capture_format_.frame_size.width() | 586 width:capture_format_.frame_size.width() |
586 frameRate:capture_format_.frame_rate]) { | 587 frameRate:capture_format_.frame_rate]) { |
587 ReceiveError(FROM_HERE, "Could not configure capture device."); | 588 ReceiveError(FROM_HERE, "Could not configure capture device."); |
588 return false; | 589 return false; |
589 } | 590 } |
590 return true; | 591 return true; |
591 } | 592 } |
592 | 593 |
593 } // namespace media | 594 } // namespace media |
OLD | NEW |