| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 | 386 |
| 387 if (![capture_device_ setCaptureDevice:deviceId]) { | 387 if (![capture_device_ setCaptureDevice:deviceId]) { |
| 388 SetErrorState("Could not open capture device."); | 388 SetErrorState("Could not open capture device."); |
| 389 return; | 389 return; |
| 390 } | 390 } |
| 391 | 391 |
| 392 capture_format_.frame_size = resolution; | 392 capture_format_.frame_size = resolution; |
| 393 capture_format_.frame_rate = | 393 capture_format_.frame_rate = |
| 394 std::max(kMinFrameRate, | 394 std::max(kMinFrameRate, |
| 395 std::min(params.requested_format.frame_rate, kMaxFrameRate)); | 395 std::min(params.requested_format.frame_rate, kMaxFrameRate)); |
| 396 // Leave the pixel format selection to AVFoundation/QTKit. The pixel format | 396 capture_format_.pixel_format = PIXEL_FORMAT_UYVY; |
| 397 // will be passed to |ReceiveFrame|. | |
| 398 capture_format_.pixel_format = PIXEL_FORMAT_UNKNOWN; | |
| 399 | 397 |
| 400 // QTKit: Set the capture resolution only if this is VGA or smaller, otherwise | 398 // QTKit: Set the capture resolution only if this is VGA or smaller, otherwise |
| 401 // leave it unconfigured and start capturing: QTKit will produce frames at the | 399 // leave it unconfigured and start capturing: QTKit will produce frames at the |
| 402 // native resolution, allowing us to identify cameras whose native resolution | 400 // native resolution, allowing us to identify cameras whose native resolution |
| 403 // is too low for HD. This additional information comes at a cost in startup | 401 // is too low for HD. This additional information comes at a cost in startup |
| 404 // latency, because the webcam will need to be reopened if its default | 402 // latency, because the webcam will need to be reopened if its default |
| 405 // resolution is not HD or VGA. | 403 // resolution is not HD or VGA. |
| 406 // AVfoundation is configured for all resolutions. | 404 // AVfoundation is configured for all resolutions. |
| 407 if (AVFoundationGlue::IsAVFoundationSupported() || | 405 if (AVFoundationGlue::IsAVFoundationSupported() || |
| 408 resolution.width() <= kVGA.width || resolution.height() <= kVGA.height) { | 406 resolution.width() <= kVGA.width || resolution.height() <= kVGA.height) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 if (!AVFoundationGlue::IsAVFoundationSupported()) { | 532 if (!AVFoundationGlue::IsAVFoundationSupported()) { |
| 535 capture_format_.frame_size = frame_format.frame_size; | 533 capture_format_.frame_size = frame_format.frame_size; |
| 536 } else if (capture_format_.frame_size != frame_format.frame_size) { | 534 } else if (capture_format_.frame_size != frame_format.frame_size) { |
| 537 ReceiveError("Captured resolution " + frame_format.frame_size.ToString() + | 535 ReceiveError("Captured resolution " + frame_format.frame_size.ToString() + |
| 538 ", and expected " + capture_format_.frame_size.ToString()); | 536 ", and expected " + capture_format_.frame_size.ToString()); |
| 539 return; | 537 return; |
| 540 } | 538 } |
| 541 | 539 |
| 542 client_->OnIncomingCapturedData(video_frame, | 540 client_->OnIncomingCapturedData(video_frame, |
| 543 video_frame_length, | 541 video_frame_length, |
| 544 frame_format, | 542 capture_format_, |
| 545 0, | 543 0, |
| 546 base::TimeTicks::Now()); | 544 base::TimeTicks::Now()); |
| 547 } | 545 } |
| 548 | 546 |
| 549 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { | 547 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { |
| 550 task_runner_->PostTask(FROM_HERE, | 548 task_runner_->PostTask(FROM_HERE, |
| 551 base::Bind(&VideoCaptureDeviceMac::SetErrorState, | 549 base::Bind(&VideoCaptureDeviceMac::SetErrorState, |
| 552 weak_factory_.GetWeakPtr(), | 550 weak_factory_.GetWeakPtr(), |
| 553 reason)); | 551 reason)); |
| 554 } | 552 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 569 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 567 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
| 570 width:capture_format_.frame_size.width() | 568 width:capture_format_.frame_size.width() |
| 571 frameRate:capture_format_.frame_rate]) { | 569 frameRate:capture_format_.frame_rate]) { |
| 572 ReceiveError("Could not configure capture device."); | 570 ReceiveError("Could not configure capture device."); |
| 573 return false; | 571 return false; |
| 574 } | 572 } |
| 575 return true; | 573 return true; |
| 576 } | 574 } |
| 577 | 575 |
| 578 } // namespace media | 576 } // namespace media |
| OLD | NEW |