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

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

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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_decklink_mac.h" 5 #include "media/capture/video/mac/video_capture_device_decklink_mac.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // Weak reference to the captured frames client, used also for error messages 85 // Weak reference to the captured frames client, used also for error messages
86 // and logging. Initialized on construction and used until cleared by calling 86 // and logging. Initialized on construction and used until cleared by calling
87 // ResetVideoCaptureDeviceReference(). 87 // ResetVideoCaptureDeviceReference().
88 media::VideoCaptureDeviceDeckLinkMac* frame_receiver_; 88 media::VideoCaptureDeviceDeckLinkMac* frame_receiver_;
89 89
90 // This is used to control the video capturing device input interface. 90 // This is used to control the video capturing device input interface.
91 ScopedDeckLinkPtr<IDeckLinkInput> decklink_input_; 91 ScopedDeckLinkPtr<IDeckLinkInput> decklink_input_;
92 // |decklink_| represents a physical device attached to the host. 92 // |decklink_| represents a physical device attached to the host.
93 ScopedDeckLinkPtr<IDeckLink> decklink_; 93 ScopedDeckLinkPtr<IDeckLink> decklink_;
94 94
95 base::TimeTicks first_ref_time_;
96
95 // Checks for Device (a.k.a. Audio) thread. 97 // Checks for Device (a.k.a. Audio) thread.
96 base::ThreadChecker thread_checker_; 98 base::ThreadChecker thread_checker_;
97 99
98 friend class scoped_refptr<DeckLinkCaptureDelegate>; 100 friend class scoped_refptr<DeckLinkCaptureDelegate>;
99 friend class base::RefCountedThreadSafe<DeckLinkCaptureDelegate>; 101 friend class base::RefCountedThreadSafe<DeckLinkCaptureDelegate>;
100 102
101 ~DeckLinkCaptureDelegate() override; 103 ~DeckLinkCaptureDelegate() override;
102 104
103 DISALLOW_COPY_AND_ASSIGN(DeckLinkCaptureDelegate); 105 DISALLOW_COPY_AND_ASSIGN(DeckLinkCaptureDelegate);
104 }; 106 };
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 SendErrorString(FROM_HERE, "Unsupported pixel format"); 253 SendErrorString(FROM_HERE, "Unsupported pixel format");
252 break; 254 break;
253 } 255 }
254 256
255 const media::VideoCaptureFormat capture_format( 257 const media::VideoCaptureFormat capture_format(
256 gfx::Size(video_frame->GetWidth(), video_frame->GetHeight()), 258 gfx::Size(video_frame->GetWidth(), video_frame->GetHeight()),
257 0.0f, // Frame rate is not needed for captured data callback. 259 0.0f, // Frame rate is not needed for captured data callback.
258 pixel_format); 260 pixel_format);
259 base::AutoLock lock(lock_); 261 base::AutoLock lock(lock_);
260 if (frame_receiver_) { 262 if (frame_receiver_) {
263 base::TimeTicks now = base::TimeTicks::Now();
miu 2016/05/18 22:35:40 The call to TimeTicks::Now() should be moved to th
qiangchen 2016/05/20 17:55:14 Done.
264 if (first_ref_time_.is_null())
265 first_ref_time_ = now;
miu 2016/05/18 22:35:40 BTW--You can get the timestamp from the |video_fra
qiangchen 2016/05/20 17:55:14 Done.
261 frame_receiver_->OnIncomingCapturedData( 266 frame_receiver_->OnIncomingCapturedData(
262 video_data, video_frame->GetRowBytes() * video_frame->GetHeight(), 267 video_data, video_frame->GetRowBytes() * video_frame->GetHeight(),
263 capture_format, 268 capture_format,
264 0, // Rotation. 269 0, // Rotation.
265 base::TimeTicks::Now()); 270 now, now - first_ref_time_);
266 } 271 }
267 return S_OK; 272 return S_OK;
268 } 273 }
269 274
270 HRESULT DeckLinkCaptureDelegate::QueryInterface(REFIID iid, void** ppv) { 275 HRESULT DeckLinkCaptureDelegate::QueryInterface(REFIID iid, void** ppv) {
271 DCHECK(thread_checker_.CalledOnValidThread()); 276 DCHECK(thread_checker_.CalledOnValidThread());
272 CFUUIDBytes iunknown = CFUUIDGetUUIDBytes(IUnknownUUID); 277 CFUUIDBytes iunknown = CFUUIDGetUUIDBytes(IUnknownUUID);
273 if (memcmp(&iid, &iunknown, sizeof(REFIID)) == 0 || 278 if (memcmp(&iid, &iunknown, sizeof(REFIID)) == 0 ||
274 memcmp(&iid, &IID_IDeckLinkInputCallback, sizeof(REFIID)) == 0) { 279 memcmp(&iid, &IID_IDeckLinkInputCallback, sizeof(REFIID)) == 0) {
275 *ppv = static_cast<IDeckLinkInputCallback*>(this); 280 *ppv = static_cast<IDeckLinkInputCallback*>(this);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 449
445 VideoCaptureDeviceDeckLinkMac::~VideoCaptureDeviceDeckLinkMac() { 450 VideoCaptureDeviceDeckLinkMac::~VideoCaptureDeviceDeckLinkMac() {
446 decklink_capture_delegate_->ResetVideoCaptureDeviceReference(); 451 decklink_capture_delegate_->ResetVideoCaptureDeviceReference();
447 } 452 }
448 453
449 void VideoCaptureDeviceDeckLinkMac::OnIncomingCapturedData( 454 void VideoCaptureDeviceDeckLinkMac::OnIncomingCapturedData(
450 const uint8_t* data, 455 const uint8_t* data,
451 size_t length, 456 size_t length,
452 const VideoCaptureFormat& frame_format, 457 const VideoCaptureFormat& frame_format,
453 int rotation, // Clockwise. 458 int rotation, // Clockwise.
454 base::TimeTicks timestamp) { 459 base::TimeTicks reference_time,
460 base::TimeDelta timestamp) {
455 base::AutoLock lock(lock_); 461 base::AutoLock lock(lock_);
456 if (client_) { 462 if (client_) {
457 client_->OnIncomingCapturedData(data, length, frame_format, rotation, 463 client_->OnIncomingCapturedData(data, length, frame_format, rotation,
458 timestamp); 464 reference_time, timestamp);
459 } 465 }
460 } 466 }
461 467
462 void VideoCaptureDeviceDeckLinkMac::SendErrorString( 468 void VideoCaptureDeviceDeckLinkMac::SendErrorString(
463 const tracked_objects::Location& from_here, 469 const tracked_objects::Location& from_here,
464 const std::string& reason) { 470 const std::string& reason) {
465 DCHECK(thread_checker_.CalledOnValidThread()); 471 DCHECK(thread_checker_.CalledOnValidThread());
466 base::AutoLock lock(lock_); 472 base::AutoLock lock(lock_);
467 if (client_) 473 if (client_)
468 client_->OnError(from_here, reason); 474 client_->OnError(from_here, reason);
(...skipping 14 matching lines...) Expand all
483 if (decklink_capture_delegate_.get()) 489 if (decklink_capture_delegate_.get())
484 decklink_capture_delegate_->AllocateAndStart(params); 490 decklink_capture_delegate_->AllocateAndStart(params);
485 } 491 }
486 492
487 void VideoCaptureDeviceDeckLinkMac::StopAndDeAllocate() { 493 void VideoCaptureDeviceDeckLinkMac::StopAndDeAllocate() {
488 if (decklink_capture_delegate_.get()) 494 if (decklink_capture_delegate_.get())
489 decklink_capture_delegate_->StopAndDeAllocate(); 495 decklink_capture_delegate_->StopAndDeAllocate();
490 } 496 }
491 497
492 } // namespace media 498 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698