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

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: Change OnIncomingCapturedBuffer Sig 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 break; 251 break;
250 default: 252 default:
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);
261 base::TimeTicks now = base::TimeTicks::Now();
259 base::AutoLock lock(lock_); 262 base::AutoLock lock(lock_);
260 if (frame_receiver_) { 263 if (frame_receiver_) {
264 const BMDTimeScale micros_time_scale = base::Time::kMicrosecondsPerSecond;
265 BMDTimeValue frame_time;
266 BMDTimeValue frame_duration;
267 base::TimeDelta timestamp;
268 if (SUCCEEDED(video_frame->GetStreamTime(&frame_time, &frame_duration,
269 micros_time_scale))) {
270 timestamp = base::TimeDelta::FromMicroseconds(frame_time);
271 } else {
272 timestamp = now - first_ref_time_;
miu 2016/05/25 01:51:30 You're still going to need this code for this fall
qiangchen 2016/05/25 16:46:17 Done.
273 }
261 frame_receiver_->OnIncomingCapturedData( 274 frame_receiver_->OnIncomingCapturedData(
262 video_data, video_frame->GetRowBytes() * video_frame->GetHeight(), 275 video_data, video_frame->GetRowBytes() * video_frame->GetHeight(),
263 capture_format, 276 capture_format,
264 0, // Rotation. 277 0, // Rotation.
265 base::TimeTicks::Now()); 278 now, timestamp);
266 } 279 }
267 return S_OK; 280 return S_OK;
268 } 281 }
269 282
270 HRESULT DeckLinkCaptureDelegate::QueryInterface(REFIID iid, void** ppv) { 283 HRESULT DeckLinkCaptureDelegate::QueryInterface(REFIID iid, void** ppv) {
271 DCHECK(thread_checker_.CalledOnValidThread()); 284 DCHECK(thread_checker_.CalledOnValidThread());
272 CFUUIDBytes iunknown = CFUUIDGetUUIDBytes(IUnknownUUID); 285 CFUUIDBytes iunknown = CFUUIDGetUUIDBytes(IUnknownUUID);
273 if (memcmp(&iid, &iunknown, sizeof(REFIID)) == 0 || 286 if (memcmp(&iid, &iunknown, sizeof(REFIID)) == 0 ||
274 memcmp(&iid, &IID_IDeckLinkInputCallback, sizeof(REFIID)) == 0) { 287 memcmp(&iid, &IID_IDeckLinkInputCallback, sizeof(REFIID)) == 0) {
275 *ppv = static_cast<IDeckLinkInputCallback*>(this); 288 *ppv = static_cast<IDeckLinkInputCallback*>(this);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 457
445 VideoCaptureDeviceDeckLinkMac::~VideoCaptureDeviceDeckLinkMac() { 458 VideoCaptureDeviceDeckLinkMac::~VideoCaptureDeviceDeckLinkMac() {
446 decklink_capture_delegate_->ResetVideoCaptureDeviceReference(); 459 decklink_capture_delegate_->ResetVideoCaptureDeviceReference();
447 } 460 }
448 461
449 void VideoCaptureDeviceDeckLinkMac::OnIncomingCapturedData( 462 void VideoCaptureDeviceDeckLinkMac::OnIncomingCapturedData(
450 const uint8_t* data, 463 const uint8_t* data,
451 size_t length, 464 size_t length,
452 const VideoCaptureFormat& frame_format, 465 const VideoCaptureFormat& frame_format,
453 int rotation, // Clockwise. 466 int rotation, // Clockwise.
454 base::TimeTicks timestamp) { 467 base::TimeTicks reference_time,
468 base::TimeDelta timestamp) {
455 base::AutoLock lock(lock_); 469 base::AutoLock lock(lock_);
456 if (client_) { 470 if (client_) {
457 client_->OnIncomingCapturedData(data, length, frame_format, rotation, 471 client_->OnIncomingCapturedData(data, length, frame_format, rotation,
458 timestamp); 472 reference_time, timestamp);
459 } 473 }
460 } 474 }
461 475
462 void VideoCaptureDeviceDeckLinkMac::SendErrorString( 476 void VideoCaptureDeviceDeckLinkMac::SendErrorString(
463 const tracked_objects::Location& from_here, 477 const tracked_objects::Location& from_here,
464 const std::string& reason) { 478 const std::string& reason) {
465 DCHECK(thread_checker_.CalledOnValidThread()); 479 DCHECK(thread_checker_.CalledOnValidThread());
466 base::AutoLock lock(lock_); 480 base::AutoLock lock(lock_);
467 if (client_) 481 if (client_)
468 client_->OnError(from_here, reason); 482 client_->OnError(from_here, reason);
(...skipping 14 matching lines...) Expand all
483 if (decklink_capture_delegate_.get()) 497 if (decklink_capture_delegate_.get())
484 decklink_capture_delegate_->AllocateAndStart(params); 498 decklink_capture_delegate_->AllocateAndStart(params);
485 } 499 }
486 500
487 void VideoCaptureDeviceDeckLinkMac::StopAndDeAllocate() { 501 void VideoCaptureDeviceDeckLinkMac::StopAndDeAllocate() {
488 if (decklink_capture_delegate_.get()) 502 if (decklink_capture_delegate_.get())
489 decklink_capture_delegate_->StopAndDeAllocate(); 503 decklink_capture_delegate_->StopAndDeAllocate();
490 } 504 }
491 505
492 } // namespace media 506 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698