| 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/sink_input_pin_win.h" | 5 #include "media/capture/video/win/sink_input_pin_win.h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 | 8 |
| 9 // Avoid including strsafe.h via dshow as it will cause build warnings. | 9 // Avoid including strsafe.h via dshow as it will cause build warnings. |
| 10 #define NO_DSHOW_STRSAFE | 10 #define NO_DSHOW_STRSAFE |
| 11 #include <dshow.h> | 11 #include <dshow.h> |
| 12 #include <stdint.h> | 12 #include <stdint.h> |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "media/base/timestamp_constants.h" |
| 16 | 17 |
| 17 namespace media { | 18 namespace media { |
| 18 | 19 |
| 19 const REFERENCE_TIME kSecondsToReferenceTime = 10000000; | 20 const REFERENCE_TIME kSecondsToReferenceTime = 10000000; |
| 20 | 21 |
| 21 static DWORD GetArea(const BITMAPINFOHEADER& info_header) { | 22 static DWORD GetArea(const BITMAPINFOHEADER& info_header) { |
| 22 return info_header.biWidth * info_header.biHeight; | 23 return info_header.biWidth * info_header.biHeight; |
| 23 } | 24 } |
| 24 | 25 |
| 25 SinkInputPin::SinkInputPin(IBaseFilter* filter, SinkFilterObserver* observer) | 26 SinkInputPin::SinkInputPin(IBaseFilter* filter, SinkFilterObserver* observer) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 195 |
| 195 if (length <= 0) { | 196 if (length <= 0) { |
| 196 DLOG(WARNING) << "Media sample length is 0 or less."; | 197 DLOG(WARNING) << "Media sample length is 0 or less."; |
| 197 return S_FALSE; | 198 return S_FALSE; |
| 198 } | 199 } |
| 199 | 200 |
| 200 if (FAILED(sample->GetPointer(&buffer))) | 201 if (FAILED(sample->GetPointer(&buffer))) |
| 201 return S_FALSE; | 202 return S_FALSE; |
| 202 | 203 |
| 203 REFERENCE_TIME start_time, end_time; | 204 REFERENCE_TIME start_time, end_time; |
| 204 base::TimeTicks timestamp; | 205 base::TimeDelta timestamp = media::kNoTimestamp(); |
| 205 if (SUCCEEDED(sample->GetTime(&start_time, &end_time))) { | 206 if (SUCCEEDED(sample->GetTime(&start_time, &end_time))) { |
| 206 DCHECK(start_time <= end_time); | 207 DCHECK(start_time <= end_time); |
| 207 timestamp += base::TimeDelta::FromMicroseconds(start_time / 10); | 208 timestamp = base::TimeDelta::FromMicroseconds(start_time / 10); |
| 208 } else { | |
| 209 timestamp = base::TimeTicks::Now(); | |
| 210 } | 209 } |
| 211 | 210 |
| 212 | |
| 213 observer_->FrameReceived(buffer, length, timestamp); | 211 observer_->FrameReceived(buffer, length, timestamp); |
| 214 return S_OK; | 212 return S_OK; |
| 215 } | 213 } |
| 216 | 214 |
| 217 SinkInputPin::~SinkInputPin() { | 215 SinkInputPin::~SinkInputPin() { |
| 218 } | 216 } |
| 219 | 217 |
| 220 } // namespace media | 218 } // namespace media |
| OLD | NEW |