2002-10-11 01:31:13 +02:00
|
|
|
/*
|
2008-10-18 19:19:02 +02:00
|
|
|
* Copyright 2002 Michael Günnewig
|
2002-10-11 01:31:13 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-10-11 01:31:13 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-10-11 01:31:13 +02:00
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-10-11 01:31:13 +02:00
|
|
|
#include "winbase.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
2002-10-11 01:31:13 +02:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "ole2.h"
|
2010-12-08 11:51:15 +01:00
|
|
|
#include "rpcproxy.h"
|
2008-02-19 20:09:19 +01:00
|
|
|
|
|
|
|
#include "initguid.h"
|
2002-10-11 01:31:13 +02:00
|
|
|
#include "vfw.h"
|
2008-02-19 20:09:19 +01:00
|
|
|
#include "avifile_private.h"
|
2002-10-11 01:31:13 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(avifile);
|
|
|
|
|
2003-01-15 00:43:41 +01:00
|
|
|
HMODULE AVIFILE_hModule = NULL;
|
2002-10-11 01:31:13 +02:00
|
|
|
|
2007-01-28 14:07:18 +01:00
|
|
|
static BOOL AVIFILE_bLocked;
|
|
|
|
static UINT AVIFILE_uUseCount;
|
2002-10-11 01:31:13 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj);
|
|
|
|
static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface);
|
|
|
|
static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface);
|
|
|
|
static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj);
|
|
|
|
static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock);
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IClassFactoryVtbl iclassfact = {
|
2002-10-11 01:31:13 +02:00
|
|
|
IClassFactory_fnQueryInterface,
|
|
|
|
IClassFactory_fnAddRef,
|
|
|
|
IClassFactory_fnRelease,
|
|
|
|
IClassFactory_fnCreateInstance,
|
|
|
|
IClassFactory_fnLockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* IUnknown fields */
|
2010-12-04 22:12:18 +01:00
|
|
|
IClassFactory IClassFactory_iface;
|
2002-10-11 01:31:13 +02:00
|
|
|
DWORD dwRef;
|
|
|
|
|
|
|
|
CLSID clsid;
|
|
|
|
} IClassFactoryImpl;
|
|
|
|
|
2010-12-04 22:12:18 +01:00
|
|
|
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
2002-10-11 01:31:13 +02:00
|
|
|
static HRESULT AVIFILE_CreateClassFactory(const CLSID *pclsid, const IID *riid,
|
|
|
|
LPVOID *ppv)
|
|
|
|
{
|
|
|
|
IClassFactoryImpl *pClassFactory = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
2006-03-11 06:41:37 +01:00
|
|
|
pClassFactory = HeapAlloc(GetProcessHeap(), 0, sizeof(*pClassFactory));
|
2002-10-11 01:31:13 +02:00
|
|
|
if (pClassFactory == NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2010-12-04 22:12:18 +01:00
|
|
|
pClassFactory->IClassFactory_iface.lpVtbl = &iclassfact;
|
2002-10-11 01:31:13 +02:00
|
|
|
pClassFactory->dwRef = 0;
|
2008-02-11 21:48:51 +01:00
|
|
|
pClassFactory->clsid = *pclsid;
|
2002-10-11 01:31:13 +02:00
|
|
|
|
2010-12-04 22:12:18 +01:00
|
|
|
hr = IClassFactory_QueryInterface(&pClassFactory->IClassFactory_iface, riid, ppv);
|
2002-10-11 01:31:13 +02:00
|
|
|
if (FAILED(hr)) {
|
2006-03-11 06:41:37 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, pClassFactory);
|
2002-10-11 01:31:13 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,
|
|
|
|
REFIID riid,LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%p)\n", iface, riid, ppobj);
|
|
|
|
|
|
|
|
if ((IsEqualGUID(&IID_IUnknown, riid)) ||
|
|
|
|
(IsEqualGUID(&IID_IClassFactory, riid))) {
|
|
|
|
*ppobj = iface;
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
2010-12-04 22:12:18 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2002-10-11 01:31:13 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
|
|
|
|
return ++(This->dwRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
|
|
|
|
{
|
2010-12-04 22:12:18 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2002-10-11 01:31:13 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
if ((--(This->dwRef)) > 0)
|
|
|
|
return This->dwRef;
|
|
|
|
|
2006-03-11 06:41:37 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
|
2002-10-11 01:31:13 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pOuter,
|
|
|
|
REFIID riid,LPVOID *ppobj)
|
|
|
|
{
|
2010-12-04 22:12:18 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2002-10-11 01:31:13 +02:00
|
|
|
|
2002-10-22 01:41:01 +02:00
|
|
|
TRACE("(%p,%p,%s,%p)\n", iface, pOuter, debugstr_guid(riid),
|
2002-10-18 02:24:41 +02:00
|
|
|
ppobj);
|
2002-10-11 01:31:13 +02:00
|
|
|
|
2013-03-07 00:45:08 +01:00
|
|
|
if (!ppobj)
|
|
|
|
return E_INVALIDARG;
|
2002-10-11 01:31:13 +02:00
|
|
|
*ppobj = NULL;
|
|
|
|
|
2013-03-07 00:45:08 +01:00
|
|
|
if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2002-10-11 01:31:13 +02:00
|
|
|
if (IsEqualGUID(&CLSID_AVIFile, &This->clsid))
|
2013-03-07 00:45:08 +01:00
|
|
|
return AVIFILE_CreateAVIFile(pOuter, riid, ppobj);
|
|
|
|
|
|
|
|
if (pOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2002-10-22 01:41:01 +02:00
|
|
|
if (IsEqualGUID(&CLSID_ICMStream, &This->clsid))
|
|
|
|
return AVIFILE_CreateICMStream(riid,ppobj);
|
2002-10-18 02:24:41 +02:00
|
|
|
if (IsEqualGUID(&CLSID_WAVFile, &This->clsid))
|
|
|
|
return AVIFILE_CreateWAVFile(riid,ppobj);
|
2002-10-22 01:41:01 +02:00
|
|
|
if (IsEqualGUID(&CLSID_ACMStream, &This->clsid))
|
|
|
|
return AVIFILE_CreateACMStream(riid,ppobj);
|
2002-10-11 01:31:13 +02:00
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%d)\n",iface,dolock);
|
|
|
|
|
|
|
|
AVIFILE_bLocked = dolock;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2002-10-18 02:24:41 +02:00
|
|
|
LPCWSTR AVIFILE_BasenameW(LPCWSTR szPath)
|
|
|
|
{
|
|
|
|
#define SLASH(w) ((w) == '/' || (w) == '\\')
|
|
|
|
|
|
|
|
LPCWSTR szCur;
|
|
|
|
|
|
|
|
for (szCur = szPath + lstrlenW(szPath);
|
|
|
|
szCur > szPath && !SLASH(*szCur) && *szCur != ':';)
|
|
|
|
szCur--;
|
|
|
|
|
|
|
|
if (szCur == szPath)
|
|
|
|
return szCur;
|
|
|
|
else
|
|
|
|
return szCur + 1;
|
|
|
|
|
|
|
|
#undef SLASH
|
|
|
|
}
|
2002-10-11 01:31:13 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllGetClassObject (AVIFIL32.@)
|
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID pclsid, REFIID piid, LPVOID *ppv)
|
2002-10-11 01:31:13 +02:00
|
|
|
{
|
|
|
|
TRACE("(%s,%s,%p)\n", debugstr_guid(pclsid), debugstr_guid(piid), ppv);
|
|
|
|
|
|
|
|
if (pclsid == NULL || piid == NULL || ppv == NULL)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
return AVIFILE_CreateClassFactory(pclsid,piid,ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* DllCanUnloadNow (AVIFIL32.@)
|
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
2002-10-11 01:31:13 +02:00
|
|
|
{
|
|
|
|
return ((AVIFILE_bLocked || AVIFILE_uUseCount) ? S_FALSE : S_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2002-11-05 00:53:41 +01:00
|
|
|
* DllMain [AVIFIL32.init]
|
2002-10-11 01:31:13 +02:00
|
|
|
*/
|
2002-11-05 00:53:41 +01:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
|
2002-10-11 01:31:13 +02:00
|
|
|
{
|
2006-10-10 01:07:06 +02:00
|
|
|
TRACE("(%p,%d,%p)\n", hInstDll, fdwReason, lpvReserved);
|
2002-10-11 01:31:13 +02:00
|
|
|
|
|
|
|
switch (fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2003-06-30 22:53:48 +02:00
|
|
|
DisableThreadLibraryCalls(hInstDll);
|
2007-12-29 16:37:24 +01:00
|
|
|
AVIFILE_hModule = hInstDll;
|
2002-10-11 01:31:13 +02:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-12-08 11:51:15 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (AVIFIL32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
2011-08-02 15:51:55 +02:00
|
|
|
return __wine_register_resources( AVIFILE_hModule );
|
2010-12-08 11:51:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllUnregisterServer (AVIFIL32.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
2011-08-02 15:51:55 +02:00
|
|
|
return __wine_unregister_resources( AVIFILE_hModule );
|
2010-12-08 11:51:15 +01:00
|
|
|
}
|