Chromium Code Reviews| Index: media/video/capture/win/video_capture_device_mf_win.cc |
| diff --git a/media/video/capture/win/video_capture_device_mf_win.cc b/media/video/capture/win/video_capture_device_mf_win.cc |
| index 0e199da26dd0dd56efe10dcc9d418f8b011a3761..dadfb8ef71019c26fd9db4b463150e7bfc355d99 100644 |
| --- a/media/video/capture/win/video_capture_device_mf_win.cc |
| +++ b/media/video/capture/win/video_capture_device_mf_win.cc |
| @@ -26,58 +26,49 @@ const char kVidPrefix[] = "vid_"; // Also contains '\0'. |
| const char kPidPrefix[] = "pid_"; // Also contains '\0'. |
| const size_t kVidPidSize = 4; |
| -static bool GetFrameSize(IMFMediaType* type, gfx::Size* frame_size) { |
| - UINT32 width32, height32; |
| - if (FAILED(MFGetAttributeSize(type, MF_MT_FRAME_SIZE, &width32, &height32))) |
| +static bool FillCapabilitiesFromType(IMFMediaType* type, |
| + VideoCaptureFormat* format) { |
| + UINT32 width, height; |
| + HRESULT hr = MFGetAttributeSize(type, MF_MT_FRAME_SIZE, &width, &height); |
| + if (FAILED(hr)) { |
| + DLOG(ERROR) << "MFGetAttributeSize failed: " |
| + << logging::SystemErrorCodeToString(hr); |
| return false; |
| - frame_size->SetSize(width32, height32); |
| - return true; |
| -} |
| + } |
| -static bool GetFrameRate(IMFMediaType* type, |
| - int* frame_rate_numerator, |
| - int* frame_rate_denominator) { |
| UINT32 numerator, denominator; |
| - if (FAILED(MFGetAttributeRatio(type, MF_MT_FRAME_RATE, &numerator, |
| - &denominator))|| |
| - !denominator) { |
| + hr = MFGetAttributeRatio(type, MF_MT_FRAME_RATE, &numerator, &denominator); |
| + if (FAILED(hr)) { |
| + DLOG(ERROR) << "MFGetAttributeSize failed: " |
| + << logging::SystemErrorCodeToString(hr); |
| return false; |
| } |
| - *frame_rate_numerator = numerator; |
| - *frame_rate_denominator = denominator; |
| - return true; |
| -} |
| -static bool FillCapabilitiesFromType(IMFMediaType* type, |
| - VideoCaptureCapabilityWin* capability) { |
| GUID type_guid; |
| - if (FAILED(type->GetGUID(MF_MT_SUBTYPE, &type_guid)) || |
| - !GetFrameSize(type, &capability->supported_format.frame_size) || |
| - !GetFrameRate(type, |
| - &capability->frame_rate_numerator, |
| - &capability->frame_rate_denominator) || |
| - !VideoCaptureDeviceMFWin::FormatFromGuid(type_guid, |
| - &capability->supported_format.pixel_format)) { |
| + hr = type->GetGUID(MF_MT_SUBTYPE, &type_guid); |
| + if (FAILED(hr)) { |
| + DLOG(ERROR) << "GetGUID failed: " << logging::SystemErrorCodeToString(hr); |
| return false; |
| } |
| - capability->supported_format.frame_rate = |
| - capability->frame_rate_numerator / capability->frame_rate_denominator; |
| + format->frame_size.SetSize(width, height); |
| + format->frame_rate = |
| + denominator ? static_cast<float>(numerator) / denominator : 0.0f; |
| + VideoCaptureDeviceMFWin::FormatFromGuid(type_guid, &format->pixel_format); |
| return true; |
| } |
| -HRESULT FillCapabilities(IMFSourceReader* source, |
| - CapabilityList* capabilities) { |
| +// static |
| +HRESULT VideoCaptureDeviceMFWin::FillCapabilities( |
| + IMFSourceReader* source, |
| + CapabilityList* capabilities) { |
| DWORD stream_index = 0; |
| ScopedComPtr<IMFMediaType> type; |
| HRESULT hr; |
| - for (hr = source->GetNativeMediaType(kFirstVideoStream, stream_index, |
| - type.Receive()); |
| - SUCCEEDED(hr); |
| - hr = source->GetNativeMediaType(kFirstVideoStream, stream_index, |
| - type.Receive())) { |
| + while (SUCCEEDED(hr = source->GetNativeMediaType( |
| + kFirstVideoStream, stream_index, type.Receive()))) { |
|
perkj_chrome
2014/09/19 10:04:55
indentation.
while (SUCCEEDED(hr = source->GetNati
|
| VideoCaptureCapabilityWin capability(stream_index++); |
| - if (FillCapabilitiesFromType(type, &capability)) |
| + if (FillCapabilitiesFromType(type, &capability.supported_format)) |
| capabilities->Add(capability); |
| type.Release(); |
| } |