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

Side by Side Diff: webrtc/modules/video_capture/windows/device_info_ds.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 30 matching lines...) Expand all
41 }, 41 },
42 }; 42 };
43 43
44 // static 44 // static
45 DeviceInfoDS* DeviceInfoDS::Create() 45 DeviceInfoDS* DeviceInfoDS::Create()
46 { 46 {
47 DeviceInfoDS* dsInfo = new DeviceInfoDS(); 47 DeviceInfoDS* dsInfo = new DeviceInfoDS();
48 if (!dsInfo || dsInfo->Init() != 0) 48 if (!dsInfo || dsInfo->Init() != 0)
49 { 49 {
50 delete dsInfo; 50 delete dsInfo;
51 dsInfo = NULL; 51 dsInfo = nullptr;
52 } 52 }
53 return dsInfo; 53 return dsInfo;
54 } 54 }
55 55
56 DeviceInfoDS::DeviceInfoDS() 56 DeviceInfoDS::DeviceInfoDS()
57 : _dsDevEnum(NULL), _dsMonikerDevEnum(NULL), 57 : _dsDevEnum(nullptr),
58 _CoUninitializeIsRequired(true) 58 _dsMonikerDevEnum(nullptr),
59 { 59 _CoUninitializeIsRequired(true) {
60 // 1) Initialize the COM library (make Windows load the DLLs). 60 // 1) Initialize the COM library (make Windows load the DLLs).
61 // 61 //
62 // CoInitializeEx must be called at least once, and is usually called only o nce, 62 // CoInitializeEx must be called at least once, and is usually called only
63 // for each thread that uses the COM library. Multiple calls to CoInitialize Ex 63 // once,
64 // by the same thread are allowed as long as they pass the same concurrency flag, 64 // for each thread that uses the COM library. Multiple calls to CoInitializeEx
65 // but subsequent valid calls return S_FALSE. 65 // by the same thread are allowed as long as they pass the same concurrency
66 // To close the COM library gracefully on a thread, each successful call to 66 // flag,
67 // CoInitializeEx, including any call that returns S_FALSE, must be balanced 67 // but subsequent valid calls return S_FALSE.
68 // by a corresponding call to CoUninitialize. 68 // To close the COM library gracefully on a thread, each successful call to
69 // 69 // CoInitializeEx, including any call that returns S_FALSE, must be balanced
70 // by a corresponding call to CoUninitialize.
71 //
70 72
71 /*Apartment-threading, while allowing for multiple threads of execution, 73 /*Apartment-threading, while allowing for multiple threads of execution,
72 serializes all incoming calls by requiring that calls to methods of objects created by this thread always run on the same thread 74 serializes all incoming calls by requiring that calls to methods of objects
73 the apartment/thread that created them. In addition, calls can arrive only at message-queue boundaries (i.e., only during a 75 created by this thread always run on the same thread
74 PeekMessage, SendMessage, DispatchMessage, etc.). Because of this serializa tion, it is not typically necessary to write concurrency control into 76 the apartment/thread that created them. In addition, calls can arrive only at
75 the code for the object, other than to avoid calls to PeekMessage and SendM essage during processing that must not be interrupted by other method 77 message-queue boundaries (i.e., only during a
76 invocations or calls to other objects in the same apartment/thread.*/ 78 PeekMessage, SendMessage, DispatchMessage, etc.). Because of this
79 serialization, it is not typically necessary to write concurrency control
80 into
81 the code for the object, other than to avoid calls to PeekMessage and
82 SendMessage during processing that must not be interrupted by other method
83 invocations or calls to other objects in the same apartment/thread.*/
77 84
78 ///CoInitializeEx(NULL, COINIT_APARTMENTTHREADED ); //| COINIT_SPEED_OVER_ME MORY 85 /// CoInitializeEx(null, COINIT_APARTMENTTHREADED ); //|
79 HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); // Use COINIT_MULTI THREADED since Voice Engine uses COINIT_MULTITHREADED 86 /// COINIT_SPEED_OVER_MEMORY
80 if (FAILED(hr)) 87 HRESULT hr = CoInitializeEx(
81 { 88 nullptr, COINIT_MULTITHREADED); // Use COINIT_MULTITHREADED since Voice
82 // Avoid calling CoUninitialize() since CoInitializeEx() failed. 89 // Engine uses COINIT_MULTITHREADED
83 _CoUninitializeIsRequired = FALSE; 90 if (FAILED(hr)) {
91 // Avoid calling CoUninitialize() since CoInitializeEx() failed.
92 _CoUninitializeIsRequired = FALSE;
84 93
85 if (hr == RPC_E_CHANGED_MODE) 94 if (hr == RPC_E_CHANGED_MODE) {
86 { 95 // Calling thread has already initialized COM to be used in a
87 // Calling thread has already initialized COM to be used in a single -threaded 96 // single-threaded
88 // apartment (STA). We are then prevented from using STA. 97 // apartment (STA). We are then prevented from using STA.
89 // Details: hr = 0x80010106 <=> "Cannot change thread mode after it is set". 98 // Details: hr = 0x80010106 <=> "Cannot change thread mode after it is
90 // 99 // set".
91 WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCapture, 0, 100 //
92 "VideoCaptureWindowsDSInfo::VideoCaptureWindowsDSInfo " 101 WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCapture, 0,
93 "CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) => " 102 "VideoCaptureWindowsDSInfo::VideoCaptureWindowsDSInfo "
94 "RPC_E_CHANGED_MODE, error 0x%x", 103 "CoInitializeEx(null, COINIT_APARTMENTTHREADED) => "
95 hr); 104 "RPC_E_CHANGED_MODE, error 0x%x",
96 } 105 hr);
97 } 106 }
107 }
98 } 108 }
99 109
100 DeviceInfoDS::~DeviceInfoDS() 110 DeviceInfoDS::~DeviceInfoDS()
101 { 111 {
102 RELEASE_AND_CLEAR(_dsMonikerDevEnum); 112 RELEASE_AND_CLEAR(_dsMonikerDevEnum);
103 RELEASE_AND_CLEAR(_dsDevEnum); 113 RELEASE_AND_CLEAR(_dsDevEnum);
104 if (_CoUninitializeIsRequired) 114 if (_CoUninitializeIsRequired)
105 { 115 {
106 CoUninitialize(); 116 CoUninitialize();
107 } 117 }
108 } 118 }
109 119
110 int32_t DeviceInfoDS::Init() 120 int32_t DeviceInfoDS::Init()
111 { 121 {
112 HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, 122 HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC,
113 IID_ICreateDevEnum, (void **) &_dsDevEnum); 123 IID_ICreateDevEnum, (void**)&_dsDevEnum);
114 if (hr != NOERROR) 124 if (hr != NOERROR) {
115 { 125 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0,
116 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0, 126 "Failed to create CLSID_SystemDeviceEnum, error 0x%x", hr);
117 "Failed to create CLSID_SystemDeviceEnum, error 0x%x", hr); 127 return -1;
118 return -1;
119 } 128 }
120 return 0; 129 return 0;
121 } 130 }
122 uint32_t DeviceInfoDS::NumberOfDevices() 131 uint32_t DeviceInfoDS::NumberOfDevices()
123 { 132 {
124 ReadLockScoped cs(_apiLock); 133 ReadLockScoped cs(_apiLock);
125 return GetDeviceInfo(0, 0, 0, 0, 0, 0, 0); 134 return GetDeviceInfo(0, 0, 0, 0, 0, 0, 0);
126 } 135 }
127 136
128 int32_t DeviceInfoDS::GetDeviceName( 137 int32_t DeviceInfoDS::GetDeviceName(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 VARIANT varName; 191 VARIANT varName;
183 VariantInit(&varName); 192 VariantInit(&varName);
184 hr = pBag->Read(L"Description", &varName, 0); 193 hr = pBag->Read(L"Description", &varName, 0);
185 if (FAILED(hr)) 194 if (FAILED(hr))
186 { 195 {
187 hr = pBag->Read(L"FriendlyName", &varName, 0); 196 hr = pBag->Read(L"FriendlyName", &varName, 0);
188 } 197 }
189 if (SUCCEEDED(hr)) 198 if (SUCCEEDED(hr))
190 { 199 {
191 // ignore all VFW drivers 200 // ignore all VFW drivers
192 if ((wcsstr(varName.bstrVal, (L"(VFW)")) == NULL) && 201 if ((wcsstr(varName.bstrVal, (L"(VFW)")) == nullptr) &&
193 (_wcsnicmp(varName.bstrVal, (L"Google Camera Adapter"),21) 202 (_wcsnicmp(varName.bstrVal, (L"Google Camera Adapter"),
194 != 0)) 203 21) != 0)) {
195 { 204 // Found a valid device.
196 // Found a valid device. 205 if (index == static_cast<int>(deviceNumber)) {
197 if (index == static_cast<int>(deviceNumber)) 206 int convResult = 0;
198 { 207 if (deviceNameLength > 0) {
199 int convResult = 0; 208 convResult = WideCharToMultiByte(
200 if (deviceNameLength > 0) 209 CP_UTF8, 0, varName.bstrVal, -1,
201 { 210 (char*)deviceNameUTF8, deviceNameLength, nullptr,
202 convResult = WideCharToMultiByte(CP_UTF8, 0, 211 nullptr);
203 varName.bstrVal, -1 , 212 if (convResult == 0) {
204 (char*) deviceNameU TF8, 213 WEBRTC_TRACE(
205 deviceNameLength, N ULL, 214 webrtc::kTraceError, webrtc::kTraceVideoCapture, 0,
206 NULL); 215 "Failed to convert device name to UTF8. %d",
207 if (convResult == 0) 216 GetLastError());
208 { 217 return -1;
209 WEBRTC_TRACE(webrtc::kTraceError, 218 }
210 webrtc::kTraceVideoCapture, 0, 219 }
211 "Failed to convert device name to U TF8. %d", 220 if (deviceUniqueIdUTF8Length > 0) {
212 GetLastError()); 221 hr = pBag->Read(L"DevicePath", &varName, 0);
213 return -1; 222 if (FAILED(hr)) {
214 } 223 strncpy_s((char*)deviceUniqueIdUTF8,
224 deviceUniqueIdUTF8Length,
225 (char*)deviceNameUTF8, convResult);
226 WEBRTC_TRACE(webrtc::kTraceError,
227 webrtc::kTraceVideoCapture, 0,
228 "Failed to get deviceUniqueIdUTF8 using "
229 "deviceNameUTF8");
230 } else {
231 convResult = WideCharToMultiByte(
232 CP_UTF8, 0, varName.bstrVal, -1,
233 (char*)deviceUniqueIdUTF8, deviceUniqueIdUTF8Length,
234 nullptr, nullptr);
235 if (convResult == 0) {
236 WEBRTC_TRACE(
237 webrtc::kTraceError, webrtc::kTraceVideoCapture,
238 0, "Failed to convert device name to UTF8. %d",
239 GetLastError());
240 return -1;
215 } 241 }
216 if (deviceUniqueIdUTF8Length > 0) 242 if (productUniqueIdUTF8 &&
217 { 243 productUniqueIdUTF8Length > 0) {
218 hr = pBag->Read(L"DevicePath", &varName, 0); 244 GetProductId(deviceUniqueIdUTF8, productUniqueIdUTF8,
219 if (FAILED(hr)) 245 productUniqueIdUTF8Length);
220 {
221 strncpy_s((char *) deviceUniqueIdUTF8,
222 deviceUniqueIdUTF8Length,
223 (char *) deviceNameUTF8, convResult);
224 WEBRTC_TRACE(webrtc::kTraceError,
225 webrtc::kTraceVideoCapture, 0,
226 "Failed to get deviceUniqueIdUTF8 u sing deviceNameUTF8");
227 }
228 else
229 {
230 convResult = WideCharToMultiByte(
231 CP_UTF8,
232 0,
233 varName.bstrVal,
234 -1,
235 (char*) deviceUniqueId UTF8,
236 deviceUniqueIdUTF8Leng th,
237 NULL, NULL);
238 if (convResult == 0)
239 {
240 WEBRTC_TRACE(webrtc::kTraceError,
241 webrtc::kTraceVideoCapture, 0,
242 "Failed to convert device name to UTF8. %d",
243 GetLastError());
244 return -1;
245 }
246 if (productUniqueIdUTF8
247 && productUniqueIdUTF8Length > 0)
248 {
249 GetProductId(deviceUniqueIdUTF8,
250 productUniqueIdUTF8,
251 productUniqueIdUTF8Length);
252 }
253 }
254 } 246 }
255 247 }
256 } 248 }
257 ++index; // increase the number of valid devices 249 }
250 ++index; // increase the number of valid devices
258 } 251 }
259 } 252 }
260 VariantClear(&varName); 253 VariantClear(&varName);
261 pBag->Release(); 254 pBag->Release();
262 pM->Release(); 255 pM->Release();
263 } 256 }
264 257
265 } 258 }
266 if (deviceNameLength) 259 if (deviceNameLength)
267 { 260 {
268 WEBRTC_TRACE(webrtc::kTraceDebug, 261 WEBRTC_TRACE(webrtc::kTraceDebug,
269 webrtc::kTraceVideoCapture, 0, "%s %s", 262 webrtc::kTraceVideoCapture, 0, "%s %s",
270 __FUNCTION__, deviceNameUTF8); 263 __FUNCTION__, deviceNameUTF8);
271 } 264 }
272 return index; 265 return index;
273 } 266 }
274 267
275 IBaseFilter * DeviceInfoDS::GetDeviceFilter( 268 IBaseFilter * DeviceInfoDS::GetDeviceFilter(
276 const char* deviceUniqueIdUTF8, 269 const char* deviceUniqueIdUTF8,
277 char* productUniqueIdUTF8, 270 char* productUniqueIdUTF8,
278 uint32_t productUniqueIdUTF8Length) 271 uint32_t productUniqueIdUTF8Length)
279 { 272 {
280 273 const int32_t deviceUniqueIdUTF8Length = (int32_t)strlen(
281 const int32_t deviceUniqueIdUTF8Length = 274 (char*)deviceUniqueIdUTF8); // UTF8 is also nullptr terminated
282 (int32_t) strlen((char*) deviceUniqueIdUTF8); // UTF8 is also NULL termi nated 275 if (deviceUniqueIdUTF8Length > kVideoCaptureUniqueNameLength) {
283 if (deviceUniqueIdUTF8Length > kVideoCaptureUniqueNameLength) 276 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0,
284 { 277 "Device name too long");
285 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0, 278 return nullptr;
286 "Device name too long");
287 return NULL;
288 } 279 }
289 280
290 // enumerate all video capture devices 281 // enumerate all video capture devices
291 RELEASE_AND_CLEAR(_dsMonikerDevEnum); 282 RELEASE_AND_CLEAR(_dsMonikerDevEnum);
292 HRESULT hr = _dsDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategor y, 283 HRESULT hr = _dsDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategor y,
293 &_dsMonikerDevEnum, 0); 284 &_dsMonikerDevEnum, 0);
294 if (hr != NOERROR) 285 if (hr != NOERROR)
295 { 286 {
296 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0, 287 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0,
297 "Failed to enumerate CLSID_SystemDeviceEnum, error 0x%x." 288 "Failed to enumerate CLSID_SystemDeviceEnum, error 0x%x."
298 " No webcam exist?", hr); 289 " No webcam exist?", hr);
299 return 0; 290 return 0;
300 } 291 }
301 _dsMonikerDevEnum->Reset(); 292 _dsMonikerDevEnum->Reset();
302 ULONG cFetched; 293 ULONG cFetched;
303 IMoniker *pM; 294 IMoniker *pM;
304 295
305 IBaseFilter *captureFilter = NULL; 296 IBaseFilter* captureFilter = nullptr;
306 bool deviceFound = false; 297 bool deviceFound = false;
307 while (S_OK == _dsMonikerDevEnum->Next(1, &pM, &cFetched) && !deviceFound) 298 while (S_OK == _dsMonikerDevEnum->Next(1, &pM, &cFetched) && !deviceFound)
308 { 299 {
309 IPropertyBag *pBag; 300 IPropertyBag *pBag;
310 hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **) &pBag); 301 hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **) &pBag);
311 if (S_OK == hr) 302 if (S_OK == hr)
312 { 303 {
313 // Find the description or friendly name. 304 // Find the description or friendly name.
314 VARIANT varName; 305 VARIANT varName;
315 VariantInit(&varName); 306 VariantInit(&varName);
316 if (deviceUniqueIdUTF8Length > 0) 307 if (deviceUniqueIdUTF8Length > 0)
317 { 308 {
318 hr = pBag->Read(L"DevicePath", &varName, 0); 309 hr = pBag->Read(L"DevicePath", &varName, 0);
319 if (FAILED(hr)) 310 if (FAILED(hr))
320 { 311 {
321 hr = pBag->Read(L"Description", &varName, 0); 312 hr = pBag->Read(L"Description", &varName, 0);
322 if (FAILED(hr)) 313 if (FAILED(hr))
323 { 314 {
324 hr = pBag->Read(L"FriendlyName", &varName, 0); 315 hr = pBag->Read(L"FriendlyName", &varName, 0);
325 } 316 }
326 } 317 }
327 if (SUCCEEDED(hr)) 318 if (SUCCEEDED(hr))
328 { 319 {
329 char tempDevicePathUTF8[256]; 320 char tempDevicePathUTF8[256];
330 tempDevicePathUTF8[0] = 0; 321 tempDevicePathUTF8[0] = 0;
331 WideCharToMultiByte(CP_UTF8, 0, varName.bstrVal, -1, 322 WideCharToMultiByte(
332 tempDevicePathUTF8, 323 CP_UTF8, 0, varName.bstrVal, -1, tempDevicePathUTF8,
333 sizeof(tempDevicePathUTF8), NULL, 324 sizeof(tempDevicePathUTF8), nullptr, nullptr);
334 NULL);
335 if (strncmp(tempDevicePathUTF8, 325 if (strncmp(tempDevicePathUTF8,
336 (const char*) deviceUniqueIdUTF8, 326 (const char*) deviceUniqueIdUTF8,
337 deviceUniqueIdUTF8Length) == 0) 327 deviceUniqueIdUTF8Length) == 0)
338 { 328 {
339 // We have found the requested device 329 // We have found the requested device
340 deviceFound = true; 330 deviceFound = true;
341 hr = pM->BindToObject(0, 0, IID_IBaseFilter, 331 hr = pM->BindToObject(0, 0, IID_IBaseFilter,
342 (void**) &captureFilter); 332 (void**) &captureFilter);
343 if FAILED(hr) 333 if FAILED(hr)
344 { 334 {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (!captureDevice) 399 if (!captureDevice)
410 return -1; 400 return -1;
411 IPin* outputCapturePin = GetOutputPin(captureDevice, GUID_NULL); 401 IPin* outputCapturePin = GetOutputPin(captureDevice, GUID_NULL);
412 if (!outputCapturePin) 402 if (!outputCapturePin)
413 { 403 {
414 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0, 404 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0,
415 "Failed to get capture device output pin"); 405 "Failed to get capture device output pin");
416 RELEASE_AND_CLEAR(captureDevice); 406 RELEASE_AND_CLEAR(captureDevice);
417 return -1; 407 return -1;
418 } 408 }
419 IAMExtDevice* extDevice = NULL; 409 IAMExtDevice* extDevice = nullptr;
420 HRESULT hr = captureDevice->QueryInterface(IID_IAMExtDevice, 410 HRESULT hr = captureDevice->QueryInterface(IID_IAMExtDevice,
421 (void **) &extDevice); 411 (void **) &extDevice);
422 if (SUCCEEDED(hr) && extDevice) 412 if (SUCCEEDED(hr) && extDevice)
423 { 413 {
424 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, 0, 414 WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, 0,
425 "This is an external device"); 415 "This is an external device");
426 extDevice->Release(); 416 extDevice->Release();
427 } 417 }
428 418
429 IAMStreamConfig* streamConfig = NULL; 419 IAMStreamConfig* streamConfig = nullptr;
430 hr = outputCapturePin->QueryInterface(IID_IAMStreamConfig, 420 hr = outputCapturePin->QueryInterface(IID_IAMStreamConfig,
431 (void**) &streamConfig); 421 (void**) &streamConfig);
432 if (FAILED(hr)) 422 if (FAILED(hr))
433 { 423 {
434 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0, 424 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0,
435 "Failed to get IID_IAMStreamConfig interface from capture d evice"); 425 "Failed to get IID_IAMStreamConfig interface from capture d evice");
436 return -1; 426 return -1;
437 } 427 }
438 428
439 // this gets the FPS 429 // this gets the FPS
440 IAMVideoControl* videoControlConfig = NULL; 430 IAMVideoControl* videoControlConfig = nullptr;
441 HRESULT hrVC = captureDevice->QueryInterface(IID_IAMVideoControl, 431 HRESULT hrVC = captureDevice->QueryInterface(IID_IAMVideoControl,
442 (void**) &videoControlConfig); 432 (void**) &videoControlConfig);
443 if (FAILED(hrVC)) 433 if (FAILED(hrVC))
444 { 434 {
445 WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCapture, 0, 435 WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideoCapture, 0,
446 "IID_IAMVideoControl Interface NOT SUPPORTED"); 436 "IID_IAMVideoControl Interface NOT SUPPORTED");
447 } 437 }
448 438
449 AM_MEDIA_TYPE *pmt = NULL; 439 AM_MEDIA_TYPE* pmt = nullptr;
450 VIDEO_STREAM_CONFIG_CAPS caps; 440 VIDEO_STREAM_CONFIG_CAPS caps;
451 int count, size; 441 int count, size;
452 442
453 hr = streamConfig->GetNumberOfCapabilities(&count, &size); 443 hr = streamConfig->GetNumberOfCapabilities(&count, &size);
454 if (FAILED(hr)) 444 if (FAILED(hr))
455 { 445 {
456 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0, 446 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, 0,
457 "Failed to GetNumberOfCapabilities"); 447 "Failed to GetNumberOfCapabilities");
458 RELEASE_AND_CLEAR(videoControlConfig); 448 RELEASE_AND_CLEAR(videoControlConfig);
459 RELEASE_AND_CLEAR(streamConfig); 449 RELEASE_AND_CLEAR(streamConfig);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 capability.width, 656 capability.width,
667 capability.height); 657 capability.height);
668 _captureCapabilities.push_back(capability); 658 _captureCapabilities.push_back(capability);
669 _captureCapabilitiesWindows.push_back(capability); 659 _captureCapabilitiesWindows.push_back(capability);
670 WEBRTC_TRACE( webrtc::kTraceInfo, webrtc::kTraceVideoCapture, 0, 660 WEBRTC_TRACE( webrtc::kTraceInfo, webrtc::kTraceVideoCapture, 0,
671 "Camera capability, width:%d height:%d type:%d fps:%d", 661 "Camera capability, width:%d height:%d type:%d fps:%d",
672 capability.width, capability.height, 662 capability.width, capability.height,
673 capability.rawType, capability.maxFPS); 663 capability.rawType, capability.maxFPS);
674 } 664 }
675 DeleteMediaType(pmt); 665 DeleteMediaType(pmt);
676 pmt = NULL; 666 pmt = nullptr;
677 } 667 }
678 RELEASE_AND_CLEAR(streamConfig); 668 RELEASE_AND_CLEAR(streamConfig);
679 RELEASE_AND_CLEAR(videoControlConfig); 669 RELEASE_AND_CLEAR(videoControlConfig);
680 RELEASE_AND_CLEAR(outputCapturePin); 670 RELEASE_AND_CLEAR(outputCapturePin);
681 RELEASE_AND_CLEAR(captureDevice); // Release the capture device 671 RELEASE_AND_CLEAR(captureDevice); // Release the capture device
682 672
683 // Store the new used device name 673 // Store the new used device name
684 _lastUsedDeviceNameLength = deviceUniqueIdUTF8Length; 674 _lastUsedDeviceNameLength = deviceUniqueIdUTF8Length;
685 _lastUsedDeviceName = (char*) realloc(_lastUsedDeviceName, 675 _lastUsedDeviceName = (char*) realloc(_lastUsedDeviceName,
686 _lastUsedDeviceNameLength 676 _lastUsedDeviceNameLength
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 int32_t DeviceInfoDS::DisplayCaptureSettingsDialogBox( 731 int32_t DeviceInfoDS::DisplayCaptureSettingsDialogBox(
742 const char* deviceUniqueIdUTF8, 732 const char* deviceUniqueIdUTF8,
743 const char* dialogTitleUTF8, 733 const char* dialogTitleUTF8,
744 void* parentWindow, 734 void* parentWindow,
745 uint32_t positionX, 735 uint32_t positionX,
746 uint32_t positionY) 736 uint32_t positionY)
747 { 737 {
748 ReadLockScoped cs(_apiLock); 738 ReadLockScoped cs(_apiLock);
749 HWND window = (HWND) parentWindow; 739 HWND window = (HWND) parentWindow;
750 740
751 IBaseFilter* filter = GetDeviceFilter(deviceUniqueIdUTF8, NULL, 0); 741 IBaseFilter* filter = GetDeviceFilter(deviceUniqueIdUTF8, nullptr, 0);
752 if (!filter) 742 if (!filter)
753 return -1; 743 return -1;
754 744
755 ISpecifyPropertyPages* pPages = NULL; 745 ISpecifyPropertyPages* pPages = nullptr;
756 CAUUID uuid; 746 CAUUID uuid;
757 HRESULT hr = S_OK; 747 HRESULT hr = S_OK;
758 748
759 hr = filter->QueryInterface(IID_ISpecifyPropertyPages, (LPVOID*) &pPages); 749 hr = filter->QueryInterface(IID_ISpecifyPropertyPages, (LPVOID*) &pPages);
760 if (!SUCCEEDED(hr)) 750 if (!SUCCEEDED(hr))
761 { 751 {
762 filter->Release(); 752 filter->Release();
763 return -1; 753 return -1;
764 } 754 }
765 hr = pPages->GetPages(&uuid); 755 hr = pPages->GetPages(&uuid);
766 if (!SUCCEEDED(hr)) 756 if (!SUCCEEDED(hr))
767 { 757 {
768 filter->Release(); 758 filter->Release();
769 return -1; 759 return -1;
770 } 760 }
771 761
772 WCHAR tempDialogTitleWide[256]; 762 WCHAR tempDialogTitleWide[256];
773 tempDialogTitleWide[0] = 0; 763 tempDialogTitleWide[0] = 0;
774 int size = 255; 764 int size = 255;
775 765
776 // UTF-8 to wide char 766 // UTF-8 to wide char
777 MultiByteToWideChar(CP_UTF8, 0, (char*) dialogTitleUTF8, -1, 767 MultiByteToWideChar(CP_UTF8, 0, (char*) dialogTitleUTF8, -1,
778 tempDialogTitleWide, size); 768 tempDialogTitleWide, size);
779 769
780 // Invoke a dialog box to display. 770 // Invoke a dialog box to display.
781 771
782 hr = OleCreatePropertyFrame(window, // You must create the parent window. 772 hr = OleCreatePropertyFrame(
783 positionX, // Horizontal position for the dialog box. 773 window, // You must create the parent window.
784 positionY, // Vertical position for the dialog b ox. 774 positionX, // Horizontal position for the dialog box.
785 tempDialogTitleWide,// String used for the dialo g box caption. 775 positionY, // Vertical position for the dialog box.
786 1, // Number of pointers passed in pPlugin. 776 tempDialogTitleWide, // String used for the dialog box caption.
787 (LPUNKNOWN*) &filter, // Pointer to the filter. 777 1, // Number of pointers passed in pPlugin.
788 uuid.cElems, // Number of property pages. 778 (LPUNKNOWN*)&filter, // Pointer to the filter.
789 uuid.pElems, // Array of property page CLSIDs. 779 uuid.cElems, // Number of property pages.
790 LOCALE_USER_DEFAULT, // Locale ID for the dialog box. 780 uuid.pElems, // Array of property page CLSIDs.
791 0, NULL); // Reserved 781 LOCALE_USER_DEFAULT, // Locale ID for the dialog box.
782 0, nullptr); // Reserved
792 // Release memory. 783 // Release memory.
793 if (uuid.pElems) 784 if (uuid.pElems)
794 { 785 {
795 CoTaskMemFree(uuid.pElems); 786 CoTaskMemFree(uuid.pElems);
796 } 787 }
797 filter->Release(); 788 filter->Release();
798 return 0; 789 return 0;
799 } 790 }
800 } // namespace videocapturemodule 791 } // namespace videocapturemodule
801 } // namespace webrtc 792 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698