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_mf_win.h" | 5 #include "media/capture/video/win/video_capture_device_mf_win.h" |
6 | 6 |
7 #include <mfapi.h> | 7 #include <mfapi.h> |
8 #include <mferror.h> | 8 #include <mferror.h> |
9 | 9 |
| 10 #include "base/location.h" |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
12 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
13 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
14 #include "base/win/scoped_co_mem.h" | 15 #include "base/win/scoped_co_mem.h" |
15 #include "base/win/windows_version.h" | 16 #include "base/win/windows_version.h" |
16 #include "media/capture/video/win/capability_list_win.h" | 17 #include "media/capture/video/win/capability_list_win.h" |
17 | 18 |
18 using base::win::ScopedCoMem; | 19 using base::win::ScopedCoMem; |
19 using base::win::ScopedComPtr; | 20 using base::win::ScopedComPtr; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 if (SUCCEEDED(hr)) { | 254 if (SUCCEEDED(hr)) { |
254 capture_format_ = found_capability.supported_format; | 255 capture_format_ = found_capability.supported_format; |
255 capture_ = true; | 256 capture_ = true; |
256 return; | 257 return; |
257 } | 258 } |
258 } | 259 } |
259 } | 260 } |
260 } | 261 } |
261 } | 262 } |
262 | 263 |
263 OnError(hr); | 264 OnError(FROM_HERE, hr); |
264 } | 265 } |
265 | 266 |
266 void VideoCaptureDeviceMFWin::StopAndDeAllocate() { | 267 void VideoCaptureDeviceMFWin::StopAndDeAllocate() { |
267 DCHECK(CalledOnValidThread()); | 268 DCHECK(CalledOnValidThread()); |
268 base::WaitableEvent flushed(false, false); | 269 base::WaitableEvent flushed(false, false); |
269 const int kFlushTimeOutInMs = 1000; | 270 const int kFlushTimeOutInMs = 1000; |
270 bool wait = false; | 271 bool wait = false; |
271 { | 272 { |
272 base::AutoLock lock(lock_); | 273 base::AutoLock lock(lock_); |
273 if (capture_) { | 274 if (capture_) { |
(...skipping 30 matching lines...) Expand all Loading... |
304 | 305 |
305 if (capture_) { | 306 if (capture_) { |
306 HRESULT hr = | 307 HRESULT hr = |
307 reader_->ReadSample(kFirstVideoStream, 0, NULL, NULL, NULL, NULL); | 308 reader_->ReadSample(kFirstVideoStream, 0, NULL, NULL, NULL, NULL); |
308 if (FAILED(hr)) { | 309 if (FAILED(hr)) { |
309 // If running the *VideoCap* unit tests on repeat, this can sometimes | 310 // If running the *VideoCap* unit tests on repeat, this can sometimes |
310 // fail with HRESULT_FROM_WINHRESULT_FROM_WIN32(ERROR_INVALID_FUNCTION). | 311 // fail with HRESULT_FROM_WINHRESULT_FROM_WIN32(ERROR_INVALID_FUNCTION). |
311 // It's not clear to me why this is, but it is possible that it has | 312 // It's not clear to me why this is, but it is possible that it has |
312 // something to do with this bug: | 313 // something to do with this bug: |
313 // http://support.microsoft.com/kb/979567 | 314 // http://support.microsoft.com/kb/979567 |
314 OnError(hr); | 315 OnError(FROM_HERE, hr); |
315 } | 316 } |
316 } | 317 } |
317 } | 318 } |
318 | 319 |
319 void VideoCaptureDeviceMFWin::OnError(HRESULT hr) { | 320 void VideoCaptureDeviceMFWin::OnError( |
| 321 const tracked_objects::Location& from_here, |
| 322 HRESULT hr) { |
320 if (client_.get()) { | 323 if (client_.get()) { |
321 client_->OnError( | 324 client_->OnError( |
| 325 from_here, |
322 base::StringPrintf("VideoCaptureDeviceMFWin: %s", | 326 base::StringPrintf("VideoCaptureDeviceMFWin: %s", |
323 logging::SystemErrorCodeToString(hr).c_str())); | 327 logging::SystemErrorCodeToString(hr).c_str())); |
324 } | 328 } |
325 } | 329 } |
326 | 330 |
327 } // namespace media | 331 } // namespace media |
OLD | NEW |