Index: media/video/capture/win/video_capture_device_factory_win.cc |
diff --git a/media/video/capture/win/video_capture_device_factory_win.cc b/media/video/capture/win/video_capture_device_factory_win.cc |
index 920126df09e2558b16048b0081d1669b68205f2e..f94f0cc3ae56c01dfef1eca48e13ba16475831ba 100644 |
--- a/media/video/capture/win/video_capture_device_factory_win.cc |
+++ b/media/video/capture/win/video_capture_device_factory_win.cc |
@@ -219,13 +219,22 @@ static void GetDeviceSupportedFormatsDirectShow( |
continue; |
} |
+ std::string id; |
device_id.Reset(); |
hr = prop_bag->Read(L"DevicePath", device_id.Receive(), 0); |
- if (FAILED(hr)) { |
- DVLOG(1) << "Couldn't read a device's DevicePath."; |
- return; |
+ if (FAILED(hr) || device_id.type() != VT_BSTR) { |
+ // If there is no clear DevicePath, try with Description and FriendlyName. |
tommi (sloooow) - chröme
2014/06/10 07:36:29
Is fetching the Description before FriendlyName th
mcasas
2014/06/10 15:01:14
The idea/sinppet comes from l.128-l.130 of this fi
|
+ ScopedVariant name; |
+ if (SUCCEEDED(prop_bag->Read(L"Description", name.Receive(), 0)) || |
+ SUCCEEDED(prop_bag->Read(L"FriendlyName", name.Receive(), 0))) { |
+ id = base::SysWideToUTF8(V_BSTR(&name)); |
+ } |
+ } else { |
+ DCHECK_EQ(device_id.type(), VT_BSTR); |
+ id = base::SysWideToUTF8(V_BSTR(&device_id)); |
} |
- if (device.id() == base::SysWideToUTF8(V_BSTR(&device_id))) |
+ |
+ if (device.id() == id) |
break; |
moniker.Release(); |
} |
@@ -288,8 +297,9 @@ static void GetDeviceSupportedFormatsDirectShow( |
h->bmiHeader.biHeight); |
// Trust the frame rate from the VIDEOINFOHEADER. |
format.frame_rate = (h->AvgTimePerFrame > 0) ? |
- static_cast<int>(kSecondsToReferenceTime / h->AvgTimePerFrame) : |
- 0; |
+ (kSecondsToReferenceTime / static_cast<float>(h->AvgTimePerFrame)) : |
tommi (sloooow) - chröme
2014/06/10 07:36:29
nit: extra parenthesis aren't needed
mcasas
2014/06/10 15:01:14
Done.
|
+ 0.0; |
+ |
formats->push_back(format); |
DVLOG(1) << device.name() << " resolution: " |
<< format.frame_size.ToString() << ", fps: " << format.frame_rate |
@@ -336,7 +346,8 @@ static void GetDeviceSupportedFormatsMediaFoundation( |
DLOG(ERROR) << "MFGetAttributeSize: " << std::hex << hr; |
return; |
} |
- capture_format.frame_rate = denominator ? numerator / denominator : 0; |
+ capture_format.frame_rate = denominator ? |
+ numerator / static_cast<float>(denominator) : 0.0f; |
GUID type_guid; |
hr = type->GetGUID(MF_MT_SUBTYPE, &type_guid); |