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 const float kMinFrameRate = 1.0f; |
tommi (sloooow) - chröme
2014/08/13 12:42:29
can you add documentation for these constants? I'
mcasas
2014/08/13 14:04:52
Done.
| |
47 const int kMaxFrameRate = 30; | 47 const float kMaxFrameRate = 30.0f; |
48 | 48 |
49 // 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. |
50 const size_t kVidPidSize = 4; | 50 const size_t kVidPidSize = 4; |
51 | 51 |
52 const struct Resolution { | 52 const struct Resolution { |
53 const int width; | 53 const int width; |
54 const int height; | 54 const int height; |
55 } kQVGA = { 320, 240 }, | 55 } kQVGA = { 320, 240 }, |
56 kVGA = { 640, 480 }, | 56 kVGA = { 640, 480 }, |
57 kHD = { 1280, 720 }; | 57 kHD = { 1280, 720 }; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 return id_vendor + ":" + id_product; | 343 return id_vendor + ":" + id_product; |
344 } | 344 } |
345 | 345 |
346 VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name) | 346 VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name) |
347 : device_name_(device_name), | 347 : device_name_(device_name), |
348 tried_to_square_pixels_(false), | 348 tried_to_square_pixels_(false), |
349 task_runner_(base::MessageLoopProxy::current()), | 349 task_runner_(base::MessageLoopProxy::current()), |
350 state_(kNotInitialized), | 350 state_(kNotInitialized), |
351 capture_device_(nil), | 351 capture_device_(nil), |
352 weak_factory_(this) { | 352 weak_factory_(this) { |
353 final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported(); | 353 // Avoid reconfiguring AVFoundation or blacklisted devices. |
354 final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported() || | |
355 device_name.is_blacklisted(); | |
354 } | 356 } |
355 | 357 |
356 VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { | 358 VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { |
357 DCHECK(task_runner_->BelongsToCurrentThread()); | 359 DCHECK(task_runner_->BelongsToCurrentThread()); |
358 [capture_device_ release]; | 360 [capture_device_ release]; |
359 } | 361 } |
360 | 362 |
361 void VideoCaptureDeviceMac::AllocateAndStart( | 363 void VideoCaptureDeviceMac::AllocateAndStart( |
362 const VideoCaptureParams& params, | 364 const VideoCaptureParams& params, |
363 scoped_ptr<VideoCaptureDevice::Client> client) { | 365 scoped_ptr<VideoCaptureDevice::Client> client) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 client_->OnError(reason); | 564 client_->OnError(reason); |
563 } | 565 } |
564 | 566 |
565 void VideoCaptureDeviceMac::LogMessage(const std::string& message) { | 567 void VideoCaptureDeviceMac::LogMessage(const std::string& message) { |
566 DCHECK(task_runner_->BelongsToCurrentThread()); | 568 DCHECK(task_runner_->BelongsToCurrentThread()); |
567 if (client_) | 569 if (client_) |
568 client_->OnLog(message); | 570 client_->OnLog(message); |
569 } | 571 } |
570 | 572 |
571 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { | 573 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { |
572 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 574 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
573 width:capture_format_.frame_size.width() | 575 width:capture_format_.frame_size.width() |
574 frameRate:capture_format_.frame_rate]) { | 576 frameRate:capture_format_.frame_rate]) { |
575 ReceiveError("Could not configure capture device."); | 577 ReceiveError("Could not configure capture device."); |
576 return false; | 578 return false; |
577 } | 579 } |
578 return true; | 580 return true; |
579 } | 581 } |
580 | 582 |
581 } // namespace media | 583 } // namespace media |
OLD | NEW |