summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-10 21:42:51 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-10 21:42:51 +0000
commit341bcdd5e29de8319583e72438326f9967b958b8 (patch)
tree74eaf2744b03a16675345a5d50153e2c2e553503 /media
parent2339bbef0ba0308b89d67725b8f9824f91ff3a3e (diff)
downloadchromium_src-341bcdd5e29de8319583e72438326f9967b958b8.zip
chromium_src-341bcdd5e29de8319583e72438326f9967b958b8.tar.gz
chromium_src-341bcdd5e29de8319583e72438326f9967b958b8.tar.bz2
Re-land fix for Media Foundation crash. Remove Vista support.
Original description: Do a thorough check for the availability of the Media Foundation DLLs. Comments from code: On Vista this API is an optional download but the API is advertised as a part of Windows 7 and onwards. However, we've seen that the required DLLs are not available in some Win7 distributions such as Windows 7 N and Windows 7 KN. BUG=164654 TEST=Run media_unittests. See more details in the bug report. TBR=mflodman Review URL: https://chromiumcodereview.appspot.com/11500009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172132 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/video/capture/win/video_capture_device_mf_win.cc29
-rw-r--r--media/video/capture/win/video_capture_device_mf_win.h7
-rw-r--r--media/video/capture/win/video_capture_device_win.cc12
3 files changed, 38 insertions, 10 deletions
diff --git a/media/video/capture/win/video_capture_device_mf_win.cc b/media/video/capture/win/video_capture_device_mf_win.cc
index 131bc7e..96bfdb2 100644
--- a/media/video/capture/win/video_capture_device_mf_win.cc
+++ b/media/video/capture/win/video_capture_device_mf_win.cc
@@ -12,6 +12,7 @@
#include "base/synchronization/waitable_event.h"
#include "base/sys_string_conversions.h"
#include "base/win/scoped_co_mem.h"
+#include "base/win/windows_version.h"
#include "media/video/capture/win/capability_list_win.h"
using base::win::ScopedCoMem;
@@ -143,6 +144,23 @@ HRESULT FillCapabilities(IMFSourceReader* source,
return (hr == MF_E_NO_MORE_TYPES) ? S_OK : hr;
}
+bool LoadMediaFoundationDlls() {
+ static const wchar_t* const kMfDLLs[] = {
+ L"%WINDIR%\\system32\\mf.dll",
+ L"%WINDIR%\\system32\\mfplat.dll",
+ L"%WINDIR%\\system32\\mfreadwrite.dll",
+ };
+
+ for (int i = 0; i < arraysize(kMfDLLs); ++i) {
+ wchar_t path[MAX_PATH] = {0};
+ ExpandEnvironmentStringsW(kMfDLLs[i], path, arraysize(path));
+ if (!LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH))
+ return false;
+ }
+
+ return true;
+}
+
} // namespace
class MFReaderCallback
@@ -222,6 +240,17 @@ class MFReaderCallback
};
// static
+bool VideoCaptureDeviceMFWin::PlatformSupported() {
+ // Even though the DLLs might be available on Vista, we get crashes
+ // when running our tests on the build bots.
+ if (base::win::GetVersion() < base::win::VERSION_WIN7)
+ return false;
+
+ static bool g_dlls_available = LoadMediaFoundationDlls();
+ return g_dlls_available;
+}
+
+// static
void VideoCaptureDeviceMFWin::GetDeviceNames(Names* device_names) {
ScopedCoMem<IMFActivate*> devices;
UINT32 count;
diff --git a/media/video/capture/win/video_capture_device_mf_win.h b/media/video/capture/win/video_capture_device_mf_win.h
index 6f229b05..773b1ed 100644
--- a/media/video/capture/win/video_capture_device_mf_win.h
+++ b/media/video/capture/win/video_capture_device_mf_win.h
@@ -46,6 +46,13 @@ class VideoCaptureDeviceMFWin
virtual void DeAllocate() OVERRIDE;
virtual const Name& device_name() OVERRIDE;
+ // Returns true iff the current platform supports the Media Foundation API
+ // and that the DLLs are available. On Vista this API is an optional download
+ // but the API is advertised as a part of Windows 7 and onwards. However,
+ // we've seen that the required DLLs are not available in some Win7
+ // distributions such as Windows 7 N and Windows 7 KN.
+ static bool PlatformSupported();
+
static void GetDeviceNames(Names* device_names);
// Captured a new video frame.
diff --git a/media/video/capture/win/video_capture_device_win.cc b/media/video/capture/win/video_capture_device_win.cc
index e83b15e6d..875ca00 100644
--- a/media/video/capture/win/video_capture_device_win.cc
+++ b/media/video/capture/win/video_capture_device_win.cc
@@ -10,7 +10,6 @@
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/win/scoped_variant.h"
-#include "base/win/windows_version.h"
#include "media/video/capture/win/video_capture_device_mf_win.h"
using base::win::ScopedComPtr;
@@ -144,20 +143,13 @@ void DeleteMediaType(AM_MEDIA_TYPE* mt) {
}
}
-bool ShouldUseMediaFoundationAPI() {
- // Although Media Foundation is supported on Vista, it requires a special
- // update to be available. For now we don't risk it and use DirectShow
- // on Vista but MF on Win7 and higher.
- return base::win::GetVersion() >= base::win::VERSION_WIN7;
-}
-
} // namespace
namespace media {
// static
void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
- if (ShouldUseMediaFoundationAPI()) {
+ if (VideoCaptureDeviceMFWin::PlatformSupported()) {
VideoCaptureDeviceMFWin::GetDeviceNames(device_names);
} else {
VideoCaptureDeviceWin::GetDeviceNames(device_names);
@@ -167,7 +159,7 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
// static
VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
VideoCaptureDevice* ret = NULL;
- if (ShouldUseMediaFoundationAPI()) {
+ if (VideoCaptureDeviceMFWin::PlatformSupported()) {
scoped_ptr<VideoCaptureDeviceMFWin> device(
new VideoCaptureDeviceMFWin(device_name));
if (device->Init())