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

Side by Side Diff: media/capture/video/win/video_capture_device_factory_win.cc

Issue 2909943003: Removing useless Win7 checks + standardize its use (Closed)
Patch Set: Fix reversed conditionnal Created 3 years, 6 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 // 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>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
18 #include "base/win/scoped_co_mem.h" 18 #include "base/win/scoped_co_mem.h"
19 #include "base/win/scoped_variant.h" 19 #include "base/win/scoped_variant.h"
20 #include "base/win/windows_version.h"
21 #include "media/base/media_switches.h" 20 #include "media/base/media_switches.h"
22 #include "media/base/win/mf_initializer.h" 21 #include "media/base/win/mf_initializer.h"
23 #include "media/capture/video/win/video_capture_device_mf_win.h" 22 #include "media/capture/video/win/video_capture_device_mf_win.h"
24 #include "media/capture/video/win/video_capture_device_win.h" 23 #include "media/capture/video/win/video_capture_device_win.h"
25 24
26 using base::win::ScopedCoMem; 25 using base::win::ScopedCoMem;
27 using base::win::ScopedComPtr; 26 using base::win::ScopedComPtr;
28 using base::win::ScopedVariant; 27 using base::win::ScopedVariant;
29 using Descriptor = media::VideoCaptureDeviceDescriptor; 28 using Descriptor = media::VideoCaptureDeviceDescriptor;
30 using Descriptors = media::VideoCaptureDeviceDescriptors; 29 using Descriptors = media::VideoCaptureDeviceDescriptors;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 394 }
396 } 395 }
397 396
398 // Returns true iff the current platform supports the Media Foundation API 397 // Returns true iff the current platform supports the Media Foundation API
399 // and that the DLLs are available. On Vista this API is an optional download 398 // and that the DLLs are available. On Vista this API is an optional download
400 // but the API is advertised as a part of Windows 7 and onwards. However, 399 // but the API is advertised as a part of Windows 7 and onwards. However,
401 // we've seen that the required DLLs are not available in some Win7 400 // we've seen that the required DLLs are not available in some Win7
402 // distributions such as Windows 7 N and Windows 7 KN. 401 // distributions such as Windows 7 N and Windows 7 KN.
403 // static 402 // static
404 bool VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() { 403 bool VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() {
405 // Even though the DLLs might be available on Vista, we get crashes
406 // when running our tests on the build bots.
407 if (base::win::GetVersion() < base::win::VERSION_WIN7)
408 return false;
409
410 static bool g_dlls_available = LoadMediaFoundationDlls(); 404 static bool g_dlls_available = LoadMediaFoundationDlls();
411 return g_dlls_available; 405 return g_dlls_available;
412 } 406 }
413 407
414 VideoCaptureDeviceFactoryWin::VideoCaptureDeviceFactoryWin() 408 VideoCaptureDeviceFactoryWin::VideoCaptureDeviceFactoryWin()
415 : use_media_foundation_(base::win::GetVersion() >= 409 : use_media_foundation_(base::CommandLine::ForCurrentProcess()->HasSwitch(
416 base::win::VERSION_WIN7 &&
417 base::CommandLine::ForCurrentProcess()->HasSwitch(
418 switches::kForceMediaFoundationVideoCapture)) {} 410 switches::kForceMediaFoundationVideoCapture)) {}
419 411
420 std::unique_ptr<VideoCaptureDevice> VideoCaptureDeviceFactoryWin::CreateDevice( 412 std::unique_ptr<VideoCaptureDevice> VideoCaptureDeviceFactoryWin::CreateDevice(
421 const Descriptor& device_descriptor) { 413 const Descriptor& device_descriptor) {
422 DCHECK(thread_checker_.CalledOnValidThread()); 414 DCHECK(thread_checker_.CalledOnValidThread());
423 std::unique_ptr<VideoCaptureDevice> device; 415 std::unique_ptr<VideoCaptureDevice> device;
424 if (device_descriptor.capture_api == VideoCaptureApi::WIN_MEDIA_FOUNDATION) { 416 if (device_descriptor.capture_api == VideoCaptureApi::WIN_MEDIA_FOUNDATION) {
425 DCHECK(PlatformSupportsMediaFoundation()); 417 DCHECK(PlatformSupportsMediaFoundation());
426 device.reset(new VideoCaptureDeviceMFWin(device_descriptor)); 418 device.reset(new VideoCaptureDeviceMFWin(device_descriptor));
427 DVLOG(1) << " MediaFoundation Device: " << device_descriptor.display_name; 419 DVLOG(1) << " MediaFoundation Device: " << device_descriptor.display_name;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } 456 }
465 457
466 // static 458 // static
467 VideoCaptureDeviceFactory* 459 VideoCaptureDeviceFactory*
468 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( 460 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory(
469 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 461 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
470 return new VideoCaptureDeviceFactoryWin(); 462 return new VideoCaptureDeviceFactoryWin();
471 } 463 }
472 464
473 } // namespace media 465 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698