| 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> |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 // should not happen, it should resize internally. | 538 // should not happen, it should resize internally. |
| 539 if (!AVFoundationGlue::IsAVFoundationSupported()) { | 539 if (!AVFoundationGlue::IsAVFoundationSupported()) { |
| 540 capture_format_.frame_size = frame_format.frame_size; | 540 capture_format_.frame_size = frame_format.frame_size; |
| 541 } else if (capture_format_.frame_size != frame_format.frame_size) { | 541 } else if (capture_format_.frame_size != frame_format.frame_size) { |
| 542 ReceiveError(FROM_HERE, | 542 ReceiveError(FROM_HERE, |
| 543 "Captured resolution " + frame_format.frame_size.ToString() + | 543 "Captured resolution " + frame_format.frame_size.ToString() + |
| 544 ", and expected " + capture_format_.frame_size.ToString()); | 544 ", and expected " + capture_format_.frame_size.ToString()); |
| 545 return; | 545 return; |
| 546 } | 546 } |
| 547 | 547 |
| 548 base::TimeTicks aligned_timestamp; |
| 549 if (timestamp == media::kNoTimestamp()) { |
| 550 aligned_timestamp = base::TimeTicks::Now(); |
| 551 } else { |
| 552 if (first_timestamp_ == media::kNoTimestamp()) { |
| 553 first_timestamp_ = timestamp; |
| 554 first_aligned_timestamp_ = base::TimeTicks::Now(); |
| 555 } |
| 556 aligned_timestamp = first_aligned_timestamp_ + timestamp - first_timestamp_; |
| 557 } |
| 548 client_->OnIncomingCapturedData(video_frame, video_frame_length, frame_format, | 558 client_->OnIncomingCapturedData(video_frame, video_frame_length, frame_format, |
| 549 0, base::TimeTicks::Now()); | 559 0, aligned_timestamp); |
| 550 } | 560 } |
| 551 | 561 |
| 552 void VideoCaptureDeviceMac::ReceiveError( | 562 void VideoCaptureDeviceMac::ReceiveError( |
| 553 const tracked_objects::Location& from_here, | 563 const tracked_objects::Location& from_here, |
| 554 const std::string& reason) { | 564 const std::string& reason) { |
| 555 task_runner_->PostTask( | 565 task_runner_->PostTask( |
| 556 FROM_HERE, base::Bind(&VideoCaptureDeviceMac::SetErrorState, | 566 FROM_HERE, base::Bind(&VideoCaptureDeviceMac::SetErrorState, |
| 557 weak_factory_.GetWeakPtr(), from_here, reason)); | 567 weak_factory_.GetWeakPtr(), from_here, reason)); |
| 558 } | 568 } |
| 559 | 569 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 575 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 585 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
| 576 width:capture_format_.frame_size.width() | 586 width:capture_format_.frame_size.width() |
| 577 frameRate:capture_format_.frame_rate]) { | 587 frameRate:capture_format_.frame_rate]) { |
| 578 ReceiveError(FROM_HERE, "Could not configure capture device."); | 588 ReceiveError(FROM_HERE, "Could not configure capture device."); |
| 579 return false; | 589 return false; |
| 580 } | 590 } |
| 581 return true; | 591 return true; |
| 582 } | 592 } |
| 583 | 593 |
| 584 } // namespace media | 594 } // namespace media |
| OLD | NEW |