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

Side by Side Diff: media/video/capture/win/video_capture_device_mf_win.cc

Issue 83793004: Implement IPCs and VideoCapture::Client interfaces for texture capture (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: e296ac98 Win32 bits. Created 6 years, 9 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 | Annotate | Revision Log
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/video/capture/win/video_capture_device_mf_win.h" 5 #include "media/video/capture/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/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 STDMETHOD_(ULONG, Release)() { 201 STDMETHOD_(ULONG, Release)() {
202 base::RefCountedThreadSafe<MFReaderCallback>::Release(); 202 base::RefCountedThreadSafe<MFReaderCallback>::Release();
203 return 1U; 203 return 1U;
204 } 204 }
205 205
206 STDMETHOD(OnReadSample)(HRESULT status, DWORD stream_index, 206 STDMETHOD(OnReadSample)(HRESULT status, DWORD stream_index,
207 DWORD stream_flags, LONGLONG time_stamp, IMFSample* sample) { 207 DWORD stream_flags, LONGLONG time_stamp, IMFSample* sample) {
208 base::TimeTicks stamp(base::TimeTicks::Now()); 208 base::TimeTicks stamp(base::TimeTicks::Now());
209 if (!sample) { 209 if (!sample) {
210 observer_->OnIncomingCapturedFrame(NULL, 0, stamp, 0); 210 observer_->OnIncomingCapturedData(NULL, 0, 0, stamp);
211 return S_OK; 211 return S_OK;
212 } 212 }
213 213
214 DWORD count = 0; 214 DWORD count = 0;
215 sample->GetBufferCount(&count); 215 sample->GetBufferCount(&count);
216 216
217 for (DWORD i = 0; i < count; ++i) { 217 for (DWORD i = 0; i < count; ++i) {
218 ScopedComPtr<IMFMediaBuffer> buffer; 218 ScopedComPtr<IMFMediaBuffer> buffer;
219 sample->GetBufferByIndex(i, buffer.Receive()); 219 sample->GetBufferByIndex(i, buffer.Receive());
220 if (buffer) { 220 if (buffer) {
221 DWORD length = 0, max_length = 0; 221 DWORD length = 0, max_length = 0;
222 BYTE* data = NULL; 222 BYTE* data = NULL;
223 buffer->Lock(&data, &max_length, &length); 223 buffer->Lock(&data, &max_length, &length);
224 observer_->OnIncomingCapturedFrame(data, length, stamp, 0); 224 observer_->OnIncomingCapturedData(data, length, 0, stamp);
225 buffer->Unlock(); 225 buffer->Unlock();
226 } 226 }
227 } 227 }
228 return S_OK; 228 return S_OK;
229 } 229 }
230 230
231 STDMETHOD(OnFlush)(DWORD stream_index) { 231 STDMETHOD(OnFlush)(DWORD stream_index) {
232 if (wait_event_) { 232 if (wait_event_) {
233 wait_event_->Signal(); 233 wait_event_->Signal();
234 wait_event_ = NULL; 234 wait_event_ = NULL;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 452
453 // If the device has been unplugged, the Flush() won't trigger the event 453 // If the device has been unplugged, the Flush() won't trigger the event
454 // and a timeout will happen. 454 // and a timeout will happen.
455 // TODO(tommi): Hook up the IMFMediaEventGenerator notifications API and 455 // TODO(tommi): Hook up the IMFMediaEventGenerator notifications API and
456 // do not wait at all after getting MEVideoCaptureDeviceRemoved event. 456 // do not wait at all after getting MEVideoCaptureDeviceRemoved event.
457 // See issue/226396. 457 // See issue/226396.
458 if (wait) 458 if (wait)
459 flushed.TimedWait(base::TimeDelta::FromMilliseconds(kFlushTimeOutInMs)); 459 flushed.TimedWait(base::TimeDelta::FromMilliseconds(kFlushTimeOutInMs));
460 } 460 }
461 461
462 void VideoCaptureDeviceMFWin::OnIncomingCapturedFrame( 462 void VideoCaptureDeviceMFWin::OnIncomingCapturedData(
463 const uint8* data, 463 const uint8* data,
464 int length, 464 int length,
465 const base::TimeTicks& time_stamp, 465 int rotation,
466 int rotation) { 466 const base::TimeTicks& time_stamp) {
467 base::AutoLock lock(lock_); 467 base::AutoLock lock(lock_);
468 if (data && client_.get()) 468 if (data && client_.get()) {
469 client_->OnIncomingCapturedFrame(data, 469 client_->OnIncomingCapturedData(
470 length, 470 data, length, capture_format_, rotation, time_stamp);
471 time_stamp, 471 }
472 rotation,
473 capture_format_);
474 472
475 if (capture_) { 473 if (capture_) {
476 HRESULT hr = reader_->ReadSample(MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, 474 HRESULT hr = reader_->ReadSample(MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0,
477 NULL, NULL, NULL, NULL); 475 NULL, NULL, NULL, NULL);
478 if (FAILED(hr)) { 476 if (FAILED(hr)) {
479 // If running the *VideoCap* unit tests on repeat, this can sometimes 477 // If running the *VideoCap* unit tests on repeat, this can sometimes
480 // fail with HRESULT_FROM_WINHRESULT_FROM_WIN32(ERROR_INVALID_FUNCTION). 478 // fail with HRESULT_FROM_WINHRESULT_FROM_WIN32(ERROR_INVALID_FUNCTION).
481 // It's not clear to me why this is, but it is possible that it has 479 // It's not clear to me why this is, but it is possible that it has
482 // something to do with this bug: 480 // something to do with this bug:
483 // http://support.microsoft.com/kb/979567 481 // http://support.microsoft.com/kb/979567
484 OnError(hr); 482 OnError(hr);
485 } 483 }
486 } 484 }
487 } 485 }
488 486
489 void VideoCaptureDeviceMFWin::OnError(HRESULT hr) { 487 void VideoCaptureDeviceMFWin::OnError(HRESULT hr) {
490 std::string log_msg = base::StringPrintf("VideoCaptureDeviceMFWin: %x", hr); 488 std::string log_msg = base::StringPrintf("VideoCaptureDeviceMFWin: %x", hr);
491 DLOG(ERROR) << log_msg; 489 DLOG(ERROR) << log_msg;
492 if (client_.get()) 490 if (client_.get())
493 client_->OnError(log_msg); 491 client_->OnError(log_msg);
494 } 492 }
495 493
496 } // namespace media 494 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/win/video_capture_device_mf_win.h ('k') | media/video/capture/win/video_capture_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698