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

Side by Side Diff: media/capture/video/win/video_capture_device_win.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
« no previous file with comments | « media/capture/video/win/video_capture_device_win.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/win/video_capture_device_win.h" 5 #include "media/capture/video/win/video_capture_device_win.h"
6 6
7 #include <ks.h> 7 #include <ks.h>
8 #include <ksmedia.h> 8 #include <ksmedia.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <list> 11 #include <list>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #include "base/win/scoped_co_mem.h" 16 #include "base/win/scoped_co_mem.h"
17 #include "base/win/scoped_variant.h" 17 #include "base/win/scoped_variant.h"
18 #include "media/base/timestamp_constants.h"
18 19
19 using base::win::ScopedCoMem; 20 using base::win::ScopedCoMem;
20 using base::win::ScopedComPtr; 21 using base::win::ScopedComPtr;
21 using base::win::ScopedVariant; 22 using base::win::ScopedVariant;
22 23
23 namespace media { 24 namespace media {
24 25
25 // Check if a Pin matches a category. 26 // Check if a Pin matches a category.
26 bool PinMatchesCategory(IPin* pin, REFGUID category) { 27 bool PinMatchesCategory(IPin* pin, REFGUID category) {
27 DCHECK(pin); 28 DCHECK(pin);
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 graph_builder_->Disconnect(output_capture_pin_.get()); 445 graph_builder_->Disconnect(output_capture_pin_.get());
445 graph_builder_->Disconnect(input_sink_pin_.get()); 446 graph_builder_->Disconnect(input_sink_pin_.get());
446 447
447 client_.reset(); 448 client_.reset();
448 state_ = kIdle; 449 state_ = kIdle;
449 } 450 }
450 451
451 // Implements SinkFilterObserver::SinkFilterObserver. 452 // Implements SinkFilterObserver::SinkFilterObserver.
452 void VideoCaptureDeviceWin::FrameReceived(const uint8_t* buffer, 453 void VideoCaptureDeviceWin::FrameReceived(const uint8_t* buffer,
453 int length, 454 int length,
454 base::TimeTicks timestamp) { 455 base::TimeDelta timestamp) {
456 if (first_ref_time_.is_null())
457 first_ref_time_ = base::TimeTicks::Now();
458
459 // There is a chance that the platform does not provide us with the timestamp,
460 // in which case, we use reference time to calculate a timestamp.
461 if (timestamp == media::kNoTimestamp())
462 timestamp = base::TimeTicks::Now() - first_ref_time_;
463
455 client_->OnIncomingCapturedData(buffer, length, capture_format_, 0, 464 client_->OnIncomingCapturedData(buffer, length, capture_format_, 0,
456 timestamp); 465 base::TimeTicks::Now(), timestamp);
457 } 466 }
458 467
459 bool VideoCaptureDeviceWin::CreateCapabilityMap() { 468 bool VideoCaptureDeviceWin::CreateCapabilityMap() {
460 DCHECK(thread_checker_.CalledOnValidThread()); 469 DCHECK(thread_checker_.CalledOnValidThread());
461 ScopedComPtr<IAMStreamConfig> stream_config; 470 ScopedComPtr<IAMStreamConfig> stream_config;
462 HRESULT hr = output_capture_pin_.QueryInterface(stream_config.Receive()); 471 HRESULT hr = output_capture_pin_.QueryInterface(stream_config.Receive());
463 if (FAILED(hr)) { 472 if (FAILED(hr)) {
464 DPLOG(ERROR) << "Failed to get IAMStreamConfig interface from " 473 DPLOG(ERROR) << "Failed to get IAMStreamConfig interface from "
465 "capture device: " << logging::SystemErrorCodeToString(hr); 474 "capture device: " << logging::SystemErrorCodeToString(hr);
466 return false; 475 return false;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } 584 }
576 585
577 void VideoCaptureDeviceWin::SetErrorState( 586 void VideoCaptureDeviceWin::SetErrorState(
578 const tracked_objects::Location& from_here, 587 const tracked_objects::Location& from_here,
579 const std::string& reason) { 588 const std::string& reason) {
580 DCHECK(thread_checker_.CalledOnValidThread()); 589 DCHECK(thread_checker_.CalledOnValidThread());
581 state_ = kError; 590 state_ = kError;
582 client_->OnError(from_here, reason); 591 client_->OnError(from_here, reason);
583 } 592 }
584 } // namespace media 593 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/win/video_capture_device_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698