From a85a65f1bd0a6f1a34749d8131be69a6fff3e0e2 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Thu, 13 Mar 2008 20:28:09 -0700 Subject: [PATCH] quartz: Implement detection on file extension in filesource --- dlls/quartz/Makefile.in | 2 +- dlls/quartz/filesource.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/dlls/quartz/Makefile.in b/dlls/quartz/Makefile.in index 207ea1e..f615254 100644 --- a/dlls/quartz/Makefile.in +++ b/dlls/quartz/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = quartz.dll IMPORTLIB = quartz -IMPORTS = dsound msacm32 msvfw32 ole32 oleaut32 user32 gdi32 advapi32 kernel32 +IMPORTS = dsound msacm32 msvfw32 ole32 oleaut32 user32 gdi32 advapi32 kernel32 shlwapi EXTRALIBS = -lstrmiids -luuid C_SRCS = \ diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 73c92b2..f91a5da 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -30,6 +30,7 @@ #include "vfwmsgs.h" #include "winbase.h" #include "winreg.h" +#include "shlwapi.h" #include WINE_DEFAULT_DEBUG_CHANNEL(quartz); @@ -62,10 +63,47 @@ static inline AsyncReader *impl_from_IFileSourceFilter( IFileSourceFilter *iface return (AsyncReader *)((char*)iface - FIELD_OFFSET(AsyncReader, lpVtblFSF)); } +static WCHAR const mediatype_name[11] = { + 'M', 'e', 'd', 'i', 'a', ' ', 'T', 'y', 'p', 'e', 0 }; +static WCHAR const subtype_name[8] = { + 'S', 'u', 'b', 't', 'y', 'p', 'e', 0 }; + static HRESULT process_extensions(HKEY hkeyExtensions, LPCOLESTR pszFileName, GUID * majorType, GUID * minorType) { - /* FIXME: implement */ - return E_NOTIMPL; + WCHAR *extension; + LONG l; + HKEY hsub; + WCHAR keying[39]; + DWORD size; + + if (!pszFileName) + return E_POINTER; + + /* Get the part of the name that matters */ + extension = PathFindExtensionW(pszFileName); + if (*extension != '.') + return E_FAIL; + + l = RegOpenKeyExW(hkeyExtensions, extension, 0, KEY_READ, &hsub); + if (l) + return E_FAIL; + + size = sizeof(keying); + l = RegQueryValueExW(hsub, mediatype_name, NULL, NULL, (LPBYTE)keying, &size); + if (!l) + CLSIDFromString(keying, majorType); + + size = sizeof(keying); + if (!l) + l = RegQueryValueExW(hsub, subtype_name, NULL, NULL, (LPBYTE)keying, &size); + if (!l) + CLSIDFromString(keying, minorType); + + RegCloseKey(hsub); + + if (!l) + return S_OK; + return E_FAIL; } static unsigned char byte_from_hex_char(WCHAR wHex) @@ -197,6 +235,8 @@ static HRESULT GetClassMediaFile(IAsyncReader * pReader, LPCOLESTR pszFileName, BOOL bFound = FALSE; static const WCHAR wszMediaType[] = {'M','e','d','i','a',' ','T','y','p','e',0}; + TRACE("(%p, %s, %p, %p)\n", pReader, debugstr_w(pszFileName), majorType, minorType); + CopyMemory(majorType, &GUID_NULL, sizeof(*majorType)); CopyMemory(minorType, &GUID_NULL, sizeof(*minorType)); @@ -213,7 +253,7 @@ static HRESULT GetClassMediaFile(IAsyncReader * pReader, LPCOLESTR pszFileName, WCHAR wszMajorKeyName[CHARS_IN_GUID]; DWORD dwKeyNameLength = sizeof(wszMajorKeyName) / sizeof(wszMajorKeyName[0]); static const WCHAR wszExtensions[] = {'E','x','t','e','n','s','i','o','n','s',0}; - + if (RegEnumKeyExW(hkeyMediaType, indexMajor, wszMajorKeyName, &dwKeyNameLength, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) break; if (RegOpenKeyExW(hkeyMediaType, wszMajorKeyName, 0, KEY_READ, &hkeyMajor) != ERROR_SUCCESS) -- 1.5.4.1