| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/capture/video/win/video_capture_device_factory_win.h" | 5 #include "media/capture/video/win/video_capture_device_factory_win.h" |
| 6 | 6 |
| 7 #include <mfapi.h> | 7 #include <mfapi.h> |
| 8 #include <mferror.h> | 8 #include <mferror.h> |
| 9 #include <objbase.h> | 9 #include <objbase.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 const std::string id_product = | 149 const std::string id_product = |
| 150 device_id.substr(pid_location + pid_prefix_size, kVidPidSize); | 150 device_id.substr(pid_location + pid_prefix_size, kVidPidSize); |
| 151 return id_vendor + ":" + id_product; | 151 return id_vendor + ":" + id_product; |
| 152 } | 152 } |
| 153 | 153 |
| 154 static void GetDeviceDescriptorsDirectShow(Descriptors* device_descriptors) { | 154 static void GetDeviceDescriptorsDirectShow(Descriptors* device_descriptors) { |
| 155 DCHECK(device_descriptors); | 155 DCHECK(device_descriptors); |
| 156 DVLOG(1) << __func__; | 156 DVLOG(1) << __func__; |
| 157 | 157 |
| 158 ScopedComPtr<ICreateDevEnum> dev_enum; | 158 ScopedComPtr<ICreateDevEnum> dev_enum; |
| 159 HRESULT hr = | 159 HRESULT hr = ::CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, |
| 160 dev_enum.CreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC); | 160 IID_PPV_ARGS(&dev_enum)); |
| 161 if (FAILED(hr)) | 161 if (FAILED(hr)) |
| 162 return; | 162 return; |
| 163 | 163 |
| 164 ScopedComPtr<IEnumMoniker> enum_moniker; | 164 ScopedComPtr<IEnumMoniker> enum_moniker; |
| 165 hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, | 165 hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, |
| 166 enum_moniker.GetAddressOf(), 0); | 166 enum_moniker.GetAddressOf(), 0); |
| 167 // CreateClassEnumerator returns S_FALSE on some Windows OS | 167 // CreateClassEnumerator returns S_FALSE on some Windows OS |
| 168 // when no camera exist. Therefore the FAILED macro can't be used. | 168 // when no camera exist. Therefore the FAILED macro can't be used. |
| 169 if (hr != S_OK) | 169 if (hr != S_OK) |
| 170 return; | 170 return; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 << logging::SystemErrorCodeToString(hr); | 240 << logging::SystemErrorCodeToString(hr); |
| 241 devices[i]->Release(); | 241 devices[i]->Release(); |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 | 244 |
| 245 static void GetDeviceSupportedFormatsDirectShow(const Descriptor& descriptor, | 245 static void GetDeviceSupportedFormatsDirectShow(const Descriptor& descriptor, |
| 246 VideoCaptureFormats* formats) { | 246 VideoCaptureFormats* formats) { |
| 247 DVLOG(1) << "GetDeviceSupportedFormatsDirectShow for " | 247 DVLOG(1) << "GetDeviceSupportedFormatsDirectShow for " |
| 248 << descriptor.display_name; | 248 << descriptor.display_name; |
| 249 ScopedComPtr<ICreateDevEnum> dev_enum; | 249 ScopedComPtr<ICreateDevEnum> dev_enum; |
| 250 HRESULT hr = | 250 HRESULT hr = ::CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, |
| 251 dev_enum.CreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC); | 251 IID_PPV_ARGS(&dev_enum)); |
| 252 if (FAILED(hr)) | 252 if (FAILED(hr)) |
| 253 return; | 253 return; |
| 254 | 254 |
| 255 ScopedComPtr<IEnumMoniker> enum_moniker; | 255 ScopedComPtr<IEnumMoniker> enum_moniker; |
| 256 hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, | 256 hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, |
| 257 enum_moniker.GetAddressOf(), 0); | 257 enum_moniker.GetAddressOf(), 0); |
| 258 // CreateClassEnumerator returns S_FALSE on some Windows OS when no camera | 258 // CreateClassEnumerator returns S_FALSE on some Windows OS when no camera |
| 259 // exists. Therefore the FAILED macro can't be used. | 259 // exists. Therefore the FAILED macro can't be used. |
| 260 if (hr != S_OK) | 260 if (hr != S_OK) |
| 261 return; | 261 return; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 464 } |
| 465 | 465 |
| 466 // static | 466 // static |
| 467 VideoCaptureDeviceFactory* | 467 VideoCaptureDeviceFactory* |
| 468 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( | 468 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( |
| 469 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 469 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 470 return new VideoCaptureDeviceFactoryWin(); | 470 return new VideoCaptureDeviceFactoryWin(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 } // namespace media | 473 } // namespace media |
| OLD | NEW |