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

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: 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 base::TimeTicks now = base::TimeTicks::Now();
394 if (first_ref_time_.is_null())
395 first_ref_time_ = now;
miu 2016/05/18 22:35:40 The |buffer| has a |timestamp| field you can trans
qiangchen 2016/05/20 17:55:14 Done.
393 client_->OnIncomingCapturedData( 396 client_->OnIncomingCapturedData(
394 buffer_tracker->start(), buffer_tracker->payload_size(), 397 buffer_tracker->start(), buffer_tracker->payload_size(),
395 capture_format_, rotation_, base::TimeTicks::Now()); 398 capture_format_, rotation_, now, now - first_ref_time_);
396 399
397 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QBUF, &buffer)) < 0) { 400 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QBUF, &buffer)) < 0) {
398 SetErrorState(FROM_HERE, "Failed to enqueue capture buffer"); 401 SetErrorState(FROM_HERE, "Failed to enqueue capture buffer");
399 return; 402 return;
400 } 403 }
401 } 404 }
402 405
403 v4l2_task_runner_->PostTask( 406 v4l2_task_runner_->PostTask(
404 FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, this)); 407 FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, this));
405 } 408 }
(...skipping 25 matching lines...) Expand all
431 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace"; 434 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace";
432 return false; 435 return false;
433 } 436 }
434 start_ = static_cast<uint8_t*>(start); 437 start_ = static_cast<uint8_t*>(start);
435 length_ = buffer.length; 438 length_ = buffer.length;
436 payload_size_ = 0; 439 payload_size_ = 0;
437 return true; 440 return true;
438 } 441 }
439 442
440 } // namespace media 443 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698