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

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

Issue 1983193002: Decouple capture timestamp and reference time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve Comments Created 4 years, 7 months 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 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 <poll.h> 7 #include <poll.h>
8 #include <sys/fcntl.h> 8 #include <sys/fcntl.h>
9 #include <sys/ioctl.h> 9 #include <sys/ioctl.h>
10 #include <sys/mman.h> 10 #include <sys/mman.h>
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 FillV4L2Buffer(&buffer, 0); 383 FillV4L2Buffer(&buffer, 0);
384 384
385 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_DQBUF, &buffer)) < 0) { 385 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_DQBUF, &buffer)) < 0) {
386 SetErrorState(FROM_HERE, "Failed to dequeue capture buffer"); 386 SetErrorState(FROM_HERE, "Failed to dequeue capture buffer");
387 return; 387 return;
388 } 388 }
389 389
390 buffer_tracker_pool_[buffer.index]->set_payload_size(buffer.bytesused); 390 buffer_tracker_pool_[buffer.index]->set_payload_size(buffer.bytesused);
391 const scoped_refptr<BufferTracker>& buffer_tracker = 391 const scoped_refptr<BufferTracker>& buffer_tracker =
392 buffer_tracker_pool_[buffer.index]; 392 buffer_tracker_pool_[buffer.index];
393
394 base::TimeDelta timestamp =
395 base::TimeDelta::FromSeconds(buffer.timestamp.tv_sec) +
396 base::TimeDelta::FromMicroseconds(buffer.timestamp.tv_usec);
393 client_->OnIncomingCapturedData( 397 client_->OnIncomingCapturedData(
394 buffer_tracker->start(), buffer_tracker->payload_size(), 398 buffer_tracker->start(), buffer_tracker->payload_size(),
395 capture_format_, rotation_, base::TimeTicks::Now()); 399 capture_format_, rotation_, base::TimeTicks::Now(), timestamp);
396 400
397 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QBUF, &buffer)) < 0) { 401 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QBUF, &buffer)) < 0) {
398 SetErrorState(FROM_HERE, "Failed to enqueue capture buffer"); 402 SetErrorState(FROM_HERE, "Failed to enqueue capture buffer");
399 return; 403 return;
400 } 404 }
401 } 405 }
402 406
403 v4l2_task_runner_->PostTask( 407 v4l2_task_runner_->PostTask(
404 FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, this)); 408 FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, this));
405 } 409 }
(...skipping 25 matching lines...) Expand all
431 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace"; 435 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace";
432 return false; 436 return false;
433 } 437 }
434 start_ = static_cast<uint8_t*>(start); 438 start_ = static_cast<uint8_t*>(start);
435 length_ = buffer.length; 439 length_ = buffer.length;
436 payload_size_ = 0; 440 payload_size_ = 0;
437 return true; 441 return true;
438 } 442 }
439 443
440 } // namespace media 444 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/file_video_capture_device.cc ('k') | media/capture/video/mac/video_capture_device_decklink_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698