Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 if (timestamp == media::kNoTimestamp()) | |
|
miu
2016/05/18 22:35:40
Please add a comment that sometimes the platform d
qiangchen
2016/05/20 17:55:14
In my testing, I did not see a case that timestamp
| |
| 459 timestamp = base::TimeTicks::Now() - first_ref_time_; | |
| 455 client_->OnIncomingCapturedData(buffer, length, capture_format_, 0, | 460 client_->OnIncomingCapturedData(buffer, length, capture_format_, 0, |
| 456 timestamp); | 461 base::TimeTicks::Now(), timestamp); |
| 457 } | 462 } |
| 458 | 463 |
| 459 bool VideoCaptureDeviceWin::CreateCapabilityMap() { | 464 bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
| 460 DCHECK(thread_checker_.CalledOnValidThread()); | 465 DCHECK(thread_checker_.CalledOnValidThread()); |
| 461 ScopedComPtr<IAMStreamConfig> stream_config; | 466 ScopedComPtr<IAMStreamConfig> stream_config; |
| 462 HRESULT hr = output_capture_pin_.QueryInterface(stream_config.Receive()); | 467 HRESULT hr = output_capture_pin_.QueryInterface(stream_config.Receive()); |
| 463 if (FAILED(hr)) { | 468 if (FAILED(hr)) { |
| 464 DPLOG(ERROR) << "Failed to get IAMStreamConfig interface from " | 469 DPLOG(ERROR) << "Failed to get IAMStreamConfig interface from " |
| 465 "capture device: " << logging::SystemErrorCodeToString(hr); | 470 "capture device: " << logging::SystemErrorCodeToString(hr); |
| 466 return false; | 471 return false; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 } | 580 } |
| 576 | 581 |
| 577 void VideoCaptureDeviceWin::SetErrorState( | 582 void VideoCaptureDeviceWin::SetErrorState( |
| 578 const tracked_objects::Location& from_here, | 583 const tracked_objects::Location& from_here, |
| 579 const std::string& reason) { | 584 const std::string& reason) { |
| 580 DCHECK(thread_checker_.CalledOnValidThread()); | 585 DCHECK(thread_checker_.CalledOnValidThread()); |
| 581 state_ = kError; | 586 state_ = kError; |
| 582 client_->OnError(from_here, reason); | 587 client_->OnError(from_here, reason); |
| 583 } | 588 } |
| 584 } // namespace media | 589 } // namespace media |
| OLD | NEW |