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

Unified Diff: media/video/capture/win/video_capture_device_factory_win.cc

Issue 377803004: Fixes for re-enabling more MSVC level 4 warnings: media/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
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 a158dc8c33b0749f3910af8c16eb6d151ff04070..75ee59d3bf495be332468550d2bb9ef22a16ef5d 100644
--- a/media/video/capture/win/video_capture_device_factory_win.cc
+++ b/media/video/capture/win/video_capture_device_factory_win.cc
@@ -167,23 +167,26 @@ static void GetDeviceNamesMediaFoundation(
if (!EnumerateVideoDevicesMediaFoundation(&devices, &count))
return;
- HRESULT hr;
for (UINT32 i = 0; i < count; ++i) {
- UINT32 name_size, id_size;
- ScopedCoMem<wchar_t> name, id;
- if (SUCCEEDED(hr = devices[i]->GetAllocatedString(
- MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &name, &name_size)) &&
- SUCCEEDED(hr = devices[i]->GetAllocatedString(
- MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, &id,
- &id_size))) {
- std::wstring name_w(name, name_size), id_w(id, id_size);
- VideoCaptureDevice::Name device(base::SysWideToUTF8(name_w),
- base::SysWideToUTF8(id_w),
- VideoCaptureDevice::Name::MEDIA_FOUNDATION);
- device_names->push_back(device);
- } else {
- DLOG(WARNING) << "GetAllocatedString failed: " << std::hex << hr;
+ ScopedCoMem<wchar_t> name;
+ UINT32 name_size;
+ HRESULT hr = devices[i]->GetAllocatedString(
+ MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &name, &name_size);
+ if (SUCCEEDED(hr)) {
+ ScopedCoMem<wchar_t> id;
+ UINT32 id_size;
+ hr = devices[i]->GetAllocatedString(
+ MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, &id,
+ &id_size);
+ if (SUCCEEDED(hr)) {
+ device_names->push_back(VideoCaptureDevice::Name(
+ base::SysWideToUTF8(std::wstring(name, name_size)),
+ base::SysWideToUTF8(std::wstring(id, id_size)),
+ VideoCaptureDevice::Name::MEDIA_FOUNDATION));
+ }
}
+ if (FAILED(hr))
+ DLOG(WARNING) << "GetAllocatedString failed: " << std::hex << hr;
devices[i]->Release();
}
}
@@ -286,18 +289,21 @@ static void GetDeviceSupportedFormatsMediaFoundation(
return;
}
- HRESULT hr;
base::win::ScopedComPtr<IMFSourceReader> reader;
- if (FAILED(hr = MFCreateSourceReaderFromMediaSource(source, NULL,
- reader.Receive()))) {
+ HRESULT hr =
+ MFCreateSourceReaderFromMediaSource(source, NULL, reader.Receive());
+ if (FAILED(hr)) {
DLOG(ERROR) << "MFCreateSourceReaderFromMediaSource: " << std::hex << hr;
return;
}
DWORD stream_index = 0;
ScopedComPtr<IMFMediaType> type;
- while (SUCCEEDED(hr = reader->GetNativeMediaType(
- MF_SOURCE_READER_FIRST_VIDEO_STREAM, stream_index, type.Receive()))) {
+ for (hr = reader->GetNativeMediaType(kFirstVideoStream, stream_index,
+ type.Receive());
+ SUCCEEDED(hr);
+ hr = reader->GetNativeMediaType(kFirstVideoStream, stream_index,
+ type.Receive())) {
UINT32 width, height;
hr = MFGetAttributeSize(type, MF_MT_FRAME_SIZE, &width, &height);
if (FAILED(hr)) {
@@ -380,14 +386,13 @@ scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactoryWin::Create(
}
if (!static_cast<VideoCaptureDeviceMFWin*>(device.get())->Init(source))
device.reset();
- } else if (device_name.capture_api_type() ==
- VideoCaptureDevice::Name::DIRECT_SHOW) {
+ } else {
+ DCHECK_EQ(device_name.capture_api_type(),
+ VideoCaptureDevice::Name::DIRECT_SHOW);
device.reset(new VideoCaptureDeviceWin(device_name));
DVLOG(1) << " DirectShow Device: " << device_name.name();
if (!static_cast<VideoCaptureDeviceWin*>(device.get())->Init())
device.reset();
- } else {
- NOTREACHED() << " Couldn't recognize VideoCaptureDevice type";
}
return device.Pass();
}
« no previous file with comments | « media/cast/rtp_receiver/rtp_parser/rtp_parser_unittest.cc ('k') | media/video/capture/win/video_capture_device_mf_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698