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

Side by Side Diff: media/capture/video/linux/v4l2_capture_delegate.cc

Issue 2463853002: Bug Fix: Logitech C930 On Linux Results In Freezing Video (Closed)
Patch Set: Rebase Created 4 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
« no previous file with comments | « media/capture/video/linux/v4l2_capture_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/linux/v4l2_capture_delegate.h" 5 #include "media/capture/video/linux/v4l2_capture_delegate.h"
6 6
7 #include <linux/version.h> 7 #include <linux/version.h>
8 #include <poll.h> 8 #include <poll.h>
9 #include <sys/fcntl.h> 9 #include <sys/fcntl.h>
10 #include <sys/ioctl.h> 10 #include <sys/ioctl.h>
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 568
569 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_DQBUF, &buffer)) < 0) { 569 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_DQBUF, &buffer)) < 0) {
570 SetErrorState(FROM_HERE, "Failed to dequeue capture buffer"); 570 SetErrorState(FROM_HERE, "Failed to dequeue capture buffer");
571 return; 571 return;
572 } 572 }
573 573
574 buffer_tracker_pool_[buffer.index]->set_payload_size(buffer.bytesused); 574 buffer_tracker_pool_[buffer.index]->set_payload_size(buffer.bytesused);
575 const scoped_refptr<BufferTracker>& buffer_tracker = 575 const scoped_refptr<BufferTracker>& buffer_tracker =
576 buffer_tracker_pool_[buffer.index]; 576 buffer_tracker_pool_[buffer.index];
577 577
578 base::TimeDelta timestamp = 578 // There's a wide-spread issue where the kernel does not report accurate,
579 base::TimeDelta::FromSeconds(buffer.timestamp.tv_sec) + 579 // monotonically-increasing timestamps in the v4l2_buffer::timestamp
580 base::TimeDelta::FromMicroseconds(buffer.timestamp.tv_usec); 580 // field (goo.gl/Nlfamz).
581 // Until this issue is fixed, just use the reference clock as a source of
582 // media timestamps.
583 const base::TimeTicks now = base::TimeTicks::Now();
584 if (first_ref_time_.is_null())
585 first_ref_time_ = now;
586 const base::TimeDelta timestamp = now - first_ref_time_;
587
581 #ifdef V4L2_BUF_FLAG_ERROR 588 #ifdef V4L2_BUF_FLAG_ERROR
582 if (buffer.flags & V4L2_BUF_FLAG_ERROR) { 589 if (buffer.flags & V4L2_BUF_FLAG_ERROR) {
583 LOG(ERROR) << "Dequeued v4l2 buffer contains corrupted data (" 590 LOG(ERROR) << "Dequeued v4l2 buffer contains corrupted data ("
584 << buffer.bytesused << " bytes)."; 591 << buffer.bytesused << " bytes).";
585 buffer.bytesused = 0; 592 buffer.bytesused = 0;
586 } else 593 } else
587 #endif 594 #endif
588 client_->OnIncomingCapturedData( 595 client_->OnIncomingCapturedData(
589 buffer_tracker->start(), buffer_tracker->payload_size(), 596 buffer_tracker->start(), buffer_tracker->payload_size(),
590 capture_format_, rotation_, base::TimeTicks::Now(), timestamp); 597 capture_format_, rotation_, now, timestamp);
591 598
592 while (!take_photo_callbacks_.empty()) { 599 while (!take_photo_callbacks_.empty()) {
593 VideoCaptureDevice::TakePhotoCallback cb = 600 VideoCaptureDevice::TakePhotoCallback cb =
594 std::move(take_photo_callbacks_.front()); 601 std::move(take_photo_callbacks_.front());
595 take_photo_callbacks_.pop(); 602 take_photo_callbacks_.pop();
596 603
597 mojom::BlobPtr blob = 604 mojom::BlobPtr blob =
598 Blobify(buffer_tracker->start(), buffer.bytesused, capture_format_); 605 Blobify(buffer_tracker->start(), buffer.bytesused, capture_format_);
599 if (blob) 606 if (blob)
600 cb.Run(std::move(blob)); 607 cb.Run(std::move(blob));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace"; 644 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace";
638 return false; 645 return false;
639 } 646 }
640 start_ = static_cast<uint8_t*>(start); 647 start_ = static_cast<uint8_t*>(start);
641 length_ = buffer.length; 648 length_ = buffer.length;
642 payload_size_ = 0; 649 payload_size_ = 0;
643 return true; 650 return true;
644 } 651 }
645 652
646 } // namespace media 653 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/linux/v4l2_capture_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698