| 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 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 - (int32_t)transportType { | 38 - (int32_t)transportType { |
| 39 return transportType_; | 39 return transportType_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 @end // @implementation DeviceNameAndTransportType | 42 @end // @implementation DeviceNameAndTransportType |
| 43 | 43 |
| 44 namespace media { | 44 namespace media { |
| 45 | 45 |
| 46 const int kMinFrameRate = 1; | 46 // Mac specific limits for minimum and maximum frame rate. |
| 47 const int kMaxFrameRate = 30; | 47 const float kMinFrameRate = 1.0f; |
| 48 const float kMaxFrameRate = 30.0f; |
| 48 | 49 |
| 49 // In device identifiers, the USB VID and PID are stored in 4 bytes each. | 50 // In device identifiers, the USB VID and PID are stored in 4 bytes each. |
| 50 const size_t kVidPidSize = 4; | 51 const size_t kVidPidSize = 4; |
| 51 | 52 |
| 52 const struct Resolution { | 53 const struct Resolution { |
| 53 const int width; | 54 const int width; |
| 54 const int height; | 55 const int height; |
| 55 } kQVGA = { 320, 240 }, | 56 } kQVGA = { 320, 240 }, |
| 56 kVGA = { 640, 480 }, | 57 kVGA = { 640, 480 }, |
| 57 kHD = { 1280, 720 }; | 58 kHD = { 1280, 720 }; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 return id_vendor + ":" + id_product; | 344 return id_vendor + ":" + id_product; |
| 344 } | 345 } |
| 345 | 346 |
| 346 VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name) | 347 VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name) |
| 347 : device_name_(device_name), | 348 : device_name_(device_name), |
| 348 tried_to_square_pixels_(false), | 349 tried_to_square_pixels_(false), |
| 349 task_runner_(base::MessageLoopProxy::current()), | 350 task_runner_(base::MessageLoopProxy::current()), |
| 350 state_(kNotInitialized), | 351 state_(kNotInitialized), |
| 351 capture_device_(nil), | 352 capture_device_(nil), |
| 352 weak_factory_(this) { | 353 weak_factory_(this) { |
| 353 final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported(); | 354 // Avoid reconfiguring AVFoundation or blacklisted devices. |
| 355 final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported() || |
| 356 device_name.is_blacklisted(); |
| 354 } | 357 } |
| 355 | 358 |
| 356 VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { | 359 VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { |
| 357 DCHECK(task_runner_->BelongsToCurrentThread()); | 360 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 358 [capture_device_ release]; | 361 [capture_device_ release]; |
| 359 } | 362 } |
| 360 | 363 |
| 361 void VideoCaptureDeviceMac::AllocateAndStart( | 364 void VideoCaptureDeviceMac::AllocateAndStart( |
| 362 const VideoCaptureParams& params, | 365 const VideoCaptureParams& params, |
| 363 scoped_ptr<VideoCaptureDevice::Client> client) { | 366 scoped_ptr<VideoCaptureDevice::Client> client) { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 client_->OnError(reason); | 565 client_->OnError(reason); |
| 563 } | 566 } |
| 564 | 567 |
| 565 void VideoCaptureDeviceMac::LogMessage(const std::string& message) { | 568 void VideoCaptureDeviceMac::LogMessage(const std::string& message) { |
| 566 DCHECK(task_runner_->BelongsToCurrentThread()); | 569 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 567 if (client_) | 570 if (client_) |
| 568 client_->OnLog(message); | 571 client_->OnLog(message); |
| 569 } | 572 } |
| 570 | 573 |
| 571 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { | 574 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { |
| 572 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 575 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
| 573 width:capture_format_.frame_size.width() | 576 width:capture_format_.frame_size.width() |
| 574 frameRate:capture_format_.frame_rate]) { | 577 frameRate:capture_format_.frame_rate]) { |
| 575 ReceiveError("Could not configure capture device."); | 578 ReceiveError("Could not configure capture device."); |
| 576 return false; | 579 return false; |
| 577 } | 580 } |
| 578 return true; | 581 return true; |
| 579 } | 582 } |
| 580 | 583 |
| 581 } // namespace media | 584 } // namespace media |
| OLD | NEW |