| 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 } | |
| 558 client_->OnIncomingCapturedData(video_frame, video_frame_length, frame_format, | 548 client_->OnIncomingCapturedData(video_frame, video_frame_length, frame_format, |
| 559 0, aligned_timestamp); | 549 0, base::TimeTicks::Now()); |
| 560 } | 550 } |
| 561 | 551 |
| 562 void VideoCaptureDeviceMac::ReceiveError( | 552 void VideoCaptureDeviceMac::ReceiveError( |
| 563 const tracked_objects::Location& from_here, | 553 const tracked_objects::Location& from_here, |
| 564 const std::string& reason) { | 554 const std::string& reason) { |
| 565 task_runner_->PostTask( | 555 task_runner_->PostTask( |
| 566 FROM_HERE, base::Bind(&VideoCaptureDeviceMac::SetErrorState, | 556 FROM_HERE, base::Bind(&VideoCaptureDeviceMac::SetErrorState, |
| 567 weak_factory_.GetWeakPtr(), from_here, reason)); | 557 weak_factory_.GetWeakPtr(), from_here, reason)); |
| 568 } | 558 } |
| 569 | 559 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 585 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 575 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
| 586 width:capture_format_.frame_size.width() | 576 width:capture_format_.frame_size.width() |
| 587 frameRate:capture_format_.frame_rate]) { | 577 frameRate:capture_format_.frame_rate]) { |
| 588 ReceiveError(FROM_HERE, "Could not configure capture device."); | 578 ReceiveError(FROM_HERE, "Could not configure capture device."); |
| 589 return false; | 579 return false; |
| 590 } | 580 } |
| 591 return true; | 581 return true; |
| 592 } | 582 } |
| 593 | 583 |
| 594 } // namespace media | 584 } // namespace media |
| OLD | NEW |