Chromium Code Reviews| Index: media/video/capture/win/video_capture_device_win.cc |
| diff --git a/media/video/capture/win/video_capture_device_win.cc b/media/video/capture/win/video_capture_device_win.cc |
| index 877c543cc187a34fc4b4ef7926fb7bb6628d4d44..570e41155fe89b7a078371e52c70734a5fb2b573 100644 |
| --- a/media/video/capture/win/video_capture_device_win.cc |
| +++ b/media/video/capture/win/video_capture_device_win.cc |
| @@ -223,17 +223,11 @@ VideoCaptureDeviceWin::~VideoCaptureDeviceWin() { |
| bool VideoCaptureDeviceWin::Init() { |
| DCHECK(CalledOnValidThread()); |
| - HRESULT hr = GetDeviceFilter(device_name_.id(), capture_filter_.Receive()); |
| - if (!capture_filter_) { |
| - DLOG(ERROR) << "Failed to create capture filter: " |
| - << logging::SystemErrorCodeToString(hr); |
| - return false; |
| - } |
| - output_capture_pin_ = |
| - GetPin(capture_filter_, PINDIR_OUTPUT, PIN_CATEGORY_CAPTURE); |
| - if (!output_capture_pin_) { |
| - DLOG(ERROR) << "Failed to get capture output pin"; |
| + if (!VideoCaptureDeviceWin::GetDeviceSupportedFormats(device_name_, |
| + &capture_filter_, |
| + &output_capture_pin_, |
| + &capabilities_)) { |
| return false; |
| } |
| @@ -246,8 +240,8 @@ bool VideoCaptureDeviceWin::Init() { |
| input_sink_pin_ = sink_filter_->GetPin(0); |
| - hr = graph_builder_.CreateInstance(CLSID_FilterGraph, NULL, |
| - CLSCTX_INPROC_SERVER); |
| + HRESULT hr = graph_builder_.CreateInstance( |
| + CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER); |
| if (FAILED(hr)) { |
| DLOG(ERROR) << "Failed to create graph builder: " |
| << logging::SystemErrorCodeToString(hr); |
| @@ -275,7 +269,7 @@ bool VideoCaptureDeviceWin::Init() { |
| return false; |
| } |
| - return CreateCapabilityMap(); |
| + return true; |
| } |
| void VideoCaptureDeviceWin::AllocateAndStart( |
| @@ -439,10 +433,28 @@ void VideoCaptureDeviceWin::FrameReceived(const uint8* buffer, |
| buffer, length, capture_format_, 0, base::TimeTicks::Now()); |
| } |
| -bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
| - DCHECK(CalledOnValidThread()); |
| +// static |
| +bool VideoCaptureDeviceWin::GetDeviceSupportedFormats( |
|
perkj_chrome
2014/09/19 10:04:55
It looks like this is doing much more that gettign
|
| + const Name& device, |
| + ScopedComPtr<IBaseFilter>* capture_filter, |
| + ScopedComPtr<IPin>* output_capture_pin, |
| + CapabilityList* capabilities) { |
| + HRESULT hr = GetDeviceFilter(device.id(), capture_filter->Receive()); |
| + if (!capture_filter) { |
| + DLOG(ERROR) << "Failed to create capture filter: " |
| + << logging::SystemErrorCodeToString(hr); |
| + return false; |
| + } |
| + |
| + *output_capture_pin = |
| + GetPin(*capture_filter, PINDIR_OUTPUT, PIN_CATEGORY_CAPTURE); |
| + if (!*output_capture_pin) { |
| + DLOG(ERROR) << "Failed to get capture output pin"; |
| + return false; |
| + } |
| + |
| ScopedComPtr<IAMStreamConfig> stream_config; |
| - HRESULT hr = output_capture_pin_.QueryInterface(stream_config.Receive()); |
| + hr = output_capture_pin->QueryInterface(stream_config.Receive()); |
| if (FAILED(hr)) { |
| DPLOG(ERROR) << "Failed to get IAMStreamConfig interface from " |
| "capture device: " << logging::SystemErrorCodeToString(hr); |
| @@ -451,7 +463,7 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
| // Get interface used for getting the frame rate. |
| ScopedComPtr<IAMVideoControl> video_control; |
| - hr = capture_filter_.QueryInterface(video_control.Receive()); |
| + hr = capture_filter->QueryInterface(video_control.Receive()); |
| DLOG_IF(WARNING, FAILED(hr)) << "IAMVideoControl Interface NOT SUPPORTED: " |
| << logging::SystemErrorCodeToString(hr); |
| @@ -472,7 +484,7 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
| if (hr != S_OK) { |
| DLOG(ERROR) << "Failed to GetStreamCaps: " |
| << logging::SystemErrorCodeToString(hr); |
| - return false; |
| + continue; |
| } |
| if (media_type->majortype == MEDIATYPE_Video && |
| @@ -502,7 +514,7 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
| // because GetFrameRateList array is reversed in the above camera. So |
| // a util method written. Can't assume the first value will return |
| // the max fps. |
| - hr = video_control->GetFrameRateList(output_capture_pin_, i, size, |
| + hr = video_control->GetFrameRateList(*output_capture_pin, i, size, |
| &list_size, &max_fps); |
| // Sometimes |list_size| will be > 0, but max_fps will be NULL. Some |
| // drivers may return an HRESULT of S_FALSE which SUCCEEDED() translates |
| @@ -518,16 +530,11 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
| ? (kSecondsToReferenceTime / static_cast<float>(time_per_frame)) |
| : 0.0; |
| - // DirectShow works at the moment only on integer frame_rate but the |
| - // best capability matching class works on rational frame rates. |
| - capability.frame_rate_numerator = capability.supported_format.frame_rate; |
| - capability.frame_rate_denominator = 1; |
| - |
| - capabilities_.Add(capability); |
| + capabilities->Add(capability); |
| } |
| } |
| - return !capabilities_.empty(); |
| + return !capabilities->empty(); |
| } |
| // Set the power line frequency removal in |capture_filter_| if available. |