| 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 <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 16 #include "base/win/metro.h" | |
| 17 #include "base/win/scoped_co_mem.h" | 16 #include "base/win/scoped_co_mem.h" |
| 18 #include "base/win/scoped_variant.h" | 17 #include "base/win/scoped_variant.h" |
| 19 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
| 20 #include "media/base/media_switches.h" | 19 #include "media/base/media_switches.h" |
| 21 #include "media/base/win/mf_initializer.h" | 20 #include "media/base/win/mf_initializer.h" |
| 22 #include "media/capture/video/win/video_capture_device_mf_win.h" | 21 #include "media/capture/video/win/video_capture_device_mf_win.h" |
| 23 #include "media/capture/video/win/video_capture_device_win.h" | 22 #include "media/capture/video/win/video_capture_device_win.h" |
| 24 | 23 |
| 25 using base::win::ScopedCoMem; | 24 using base::win::ScopedCoMem; |
| 26 using base::win::ScopedComPtr; | 25 using base::win::ScopedComPtr; |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 return g_dlls_available; | 370 return g_dlls_available; |
| 372 } | 371 } |
| 373 | 372 |
| 374 VideoCaptureDeviceFactoryWin::VideoCaptureDeviceFactoryWin() { | 373 VideoCaptureDeviceFactoryWin::VideoCaptureDeviceFactoryWin() { |
| 375 // Use Media Foundation for Metro processes (after and including Win8) and | 374 // Use Media Foundation for Metro processes (after and including Win8) and |
| 376 // DirectShow for any other versions, unless forced via flag. Media Foundation | 375 // DirectShow for any other versions, unless forced via flag. Media Foundation |
| 377 // can also be forced if appropriate flag is set and we are in Windows 7 or | 376 // can also be forced if appropriate flag is set and we are in Windows 7 or |
| 378 // 8 in non-Metro mode. | 377 // 8 in non-Metro mode. |
| 379 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 378 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 380 use_media_foundation_ = | 379 use_media_foundation_ = |
| 381 (base::win::IsMetroProcess() && | 380 base::win::GetVersion() >= base::win::VERSION_WIN7 && |
| 382 !cmd_line->HasSwitch(switches::kForceDirectShowVideoCapture)) || | 381 cmd_line->HasSwitch(switches::kForceMediaFoundationVideoCapture); |
| 383 (base::win::GetVersion() >= base::win::VERSION_WIN7 && | |
| 384 cmd_line->HasSwitch(switches::kForceMediaFoundationVideoCapture)); | |
| 385 } | 382 } |
| 386 | 383 |
| 387 scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactoryWin::Create( | 384 scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactoryWin::Create( |
| 388 const Name& device_name) { | 385 const Name& device_name) { |
| 389 DCHECK(thread_checker_.CalledOnValidThread()); | 386 DCHECK(thread_checker_.CalledOnValidThread()); |
| 390 scoped_ptr<VideoCaptureDevice> device; | 387 scoped_ptr<VideoCaptureDevice> device; |
| 391 if (device_name.capture_api_type() == Name::MEDIA_FOUNDATION) { | 388 if (device_name.capture_api_type() == Name::MEDIA_FOUNDATION) { |
| 392 DCHECK(PlatformSupportsMediaFoundation()); | 389 DCHECK(PlatformSupportsMediaFoundation()); |
| 393 device.reset(new VideoCaptureDeviceMFWin(device_name)); | 390 device.reset(new VideoCaptureDeviceMFWin(device_name)); |
| 394 DVLOG(1) << " MediaFoundation Device: " << device_name.name(); | 391 DVLOG(1) << " MediaFoundation Device: " << device_name.name(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 } | 425 } |
| 429 | 426 |
| 430 // static | 427 // static |
| 431 VideoCaptureDeviceFactory* | 428 VideoCaptureDeviceFactory* |
| 432 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( | 429 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( |
| 433 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 430 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 434 return new VideoCaptureDeviceFactoryWin(); | 431 return new VideoCaptureDeviceFactoryWin(); |
| 435 } | 432 } |
| 436 | 433 |
| 437 } // namespace media | 434 } // namespace media |
| OLD | NEW |