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/mac/scoped_ioobject.h" | 14 #include "base/mac/scoped_ioobject.h" |
15 #include "base/mac/scoped_ioplugininterface.h" | 15 #include "base/mac/scoped_ioplugininterface.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/message_loop/message_loop_proxy.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/thread_task_runner_handle.h" | |
19 #include "base/time/time.h" | 18 #include "base/time/time.h" |
20 #import "media/base/mac/avfoundation_glue.h" | 19 #import "media/base/mac/avfoundation_glue.h" |
21 #import "media/video/capture/mac/platform_video_capturing_mac.h" | 20 #import "media/video/capture/mac/platform_video_capturing_mac.h" |
22 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" | 21 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" |
23 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" | 22 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" |
24 #include "ui/gfx/geometry/size.h" | 23 #include "ui/gfx/geometry/size.h" |
25 | 24 |
26 @implementation DeviceNameAndTransportType | 25 @implementation DeviceNameAndTransportType |
27 | 26 |
28 - (id)initWithName:(NSString*)deviceName transportType:(int32_t)transportType { | 27 - (id)initWithName:(NSString*)deviceName transportType:(int32_t)transportType { |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 std::string id_vendor = unique_id_.substr(vid_location, kVidPidSize); | 338 std::string id_vendor = unique_id_.substr(vid_location, kVidPidSize); |
340 const size_t pid_location = unique_id_.size() - kVidPidSize; | 339 const size_t pid_location = unique_id_.size() - kVidPidSize; |
341 std::string id_product = unique_id_.substr(pid_location, kVidPidSize); | 340 std::string id_product = unique_id_.substr(pid_location, kVidPidSize); |
342 | 341 |
343 return id_vendor + ":" + id_product; | 342 return id_vendor + ":" + id_product; |
344 } | 343 } |
345 | 344 |
346 VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name) | 345 VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name) |
347 : device_name_(device_name), | 346 : device_name_(device_name), |
348 tried_to_square_pixels_(false), | 347 tried_to_square_pixels_(false), |
349 task_runner_(base::ThreadTaskRunnerHandle::Get()), | 348 task_runner_(base::MessageLoopProxy::current()), |
350 state_(kNotInitialized), | 349 state_(kNotInitialized), |
351 capture_device_(nil), | 350 capture_device_(nil), |
352 weak_factory_(this) { | 351 weak_factory_(this) { |
353 // Avoid reconfiguring AVFoundation or blacklisted devices. | 352 // Avoid reconfiguring AVFoundation or blacklisted devices. |
354 final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported() || | 353 final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported() || |
355 device_name.is_blacklisted(); | 354 device_name.is_blacklisted(); |
356 } | 355 } |
357 | 356 |
358 VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { | 357 VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { |
359 DCHECK(task_runner_->BelongsToCurrentThread()); | 358 DCHECK(task_runner_->BelongsToCurrentThread()); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 569 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
571 width:capture_format_.frame_size.width() | 570 width:capture_format_.frame_size.width() |
572 frameRate:capture_format_.frame_rate]) { | 571 frameRate:capture_format_.frame_rate]) { |
573 ReceiveError("Could not configure capture device."); | 572 ReceiveError("Could not configure capture device."); |
574 return false; | 573 return false; |
575 } | 574 } |
576 return true; | 575 return true; |
577 } | 576 } |
578 | 577 |
579 } // namespace media | 578 } // namespace media |
OLD | NEW |