Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: media/capture/video/mac/video_capture_device_mac.mm

Issue 1421583007: Mac Video Capture: Sending the timestamps provided by the driver to the capture pipeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 return false; 457 return false;
458 458
459 state_ = kIdle; 459 state_ = kIdle;
460 return true; 460 return true;
461 } 461 }
462 462
463 void VideoCaptureDeviceMac::ReceiveFrame(const uint8* video_frame, 463 void VideoCaptureDeviceMac::ReceiveFrame(const uint8* video_frame,
464 int video_frame_length, 464 int video_frame_length,
465 const VideoCaptureFormat& frame_format, 465 const VideoCaptureFormat& frame_format,
466 int aspect_numerator, 466 int aspect_numerator,
467 int aspect_denominator) { 467 int aspect_denominator,
468 base::TimeTicks timestamp) {
468 // This method is safe to call from a device capture thread, i.e. any thread 469 // This method is safe to call from a device capture thread, i.e. any thread
469 // controlled by QTKit/AVFoundation. 470 // controlled by QTKit/AVFoundation.
470 if (!final_resolution_selected_) { 471 if (!final_resolution_selected_) {
471 DCHECK(!AVFoundationGlue::IsAVFoundationSupported()); 472 DCHECK(!AVFoundationGlue::IsAVFoundationSupported());
472 if (capture_format_.frame_size.width() > kVGA.width || 473 if (capture_format_.frame_size.width() > kVGA.width ||
473 capture_format_.frame_size.height() > kVGA.height) { 474 capture_format_.frame_size.height() > kVGA.height) {
474 // We are requesting HD. Make sure that the picture is good, otherwise 475 // We are requesting HD. Make sure that the picture is good, otherwise
475 // drop down to VGA. 476 // drop down to VGA.
476 bool change_to_vga = false; 477 bool change_to_vga = false;
477 if (frame_format.frame_size.width() < 478 if (frame_format.frame_size.width() <
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // should not happen, it should resize internally. 530 // should not happen, it should resize internally.
530 if (!AVFoundationGlue::IsAVFoundationSupported()) { 531 if (!AVFoundationGlue::IsAVFoundationSupported()) {
531 capture_format_.frame_size = frame_format.frame_size; 532 capture_format_.frame_size = frame_format.frame_size;
532 } else if (capture_format_.frame_size != frame_format.frame_size) { 533 } else if (capture_format_.frame_size != frame_format.frame_size) {
533 ReceiveError("Captured resolution " + frame_format.frame_size.ToString() + 534 ReceiveError("Captured resolution " + frame_format.frame_size.ToString() +
534 ", and expected " + capture_format_.frame_size.ToString()); 535 ", and expected " + capture_format_.frame_size.ToString());
535 return; 536 return;
536 } 537 }
537 538
538 client_->OnIncomingCapturedData(video_frame, video_frame_length, frame_format, 539 client_->OnIncomingCapturedData(video_frame, video_frame_length, frame_format,
539 0, base::TimeTicks::Now()); 540 0, timestamp);
540 } 541 }
541 542
542 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { 543 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) {
543 task_runner_->PostTask(FROM_HERE, 544 task_runner_->PostTask(FROM_HERE,
544 base::Bind(&VideoCaptureDeviceMac::SetErrorState, 545 base::Bind(&VideoCaptureDeviceMac::SetErrorState,
545 weak_factory_.GetWeakPtr(), reason)); 546 weak_factory_.GetWeakPtr(), reason));
546 } 547 }
547 548
548 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { 549 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) {
549 DCHECK(task_runner_->BelongsToCurrentThread()); 550 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 11 matching lines...) Expand all
561 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() 562 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height()
562 width:capture_format_.frame_size.width() 563 width:capture_format_.frame_size.width()
563 frameRate:capture_format_.frame_rate]) { 564 frameRate:capture_format_.frame_rate]) {
564 ReceiveError("Could not configure capture device."); 565 ReceiveError("Could not configure capture device.");
565 return false; 566 return false;
566 } 567 }
567 return true; 568 return true;
568 } 569 }
569 570
570 } // namespace media 571 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698