2003-06-13 20:06:44 +02:00
|
|
|
/* DirectShow Base Functions (QUARTZ.DLL)
|
|
|
|
*
|
|
|
|
* Copyright 2002 Lionel Ulmer
|
|
|
|
*
|
|
|
|
* 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
|
2003-06-13 20:06:44 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2003-01-02 18:55:45 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2003-06-13 20:06:44 +02:00
|
|
|
#include "quartz_private.h"
|
2008-11-04 23:22:53 +01:00
|
|
|
#include "wine/unicode.h"
|
2003-01-02 18:55:45 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
2009-09-11 13:40:17 +02:00
|
|
|
extern HRESULT WINAPI QUARTZ_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
|
|
|
|
extern HRESULT WINAPI QUARTZ_DllCanUnloadNow(void) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL WINAPI QUARTZ_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
|
|
|
|
|
2016-09-01 22:11:43 +02:00
|
|
|
static LONG server_locks = 0;
|
|
|
|
|
2003-06-13 20:06:44 +02:00
|
|
|
/* For the moment, do nothing here. */
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
|
|
|
|
{
|
2009-09-11 13:40:17 +02:00
|
|
|
return QUARTZ_DllMain( hInstDLL, fdwReason, lpv );
|
2003-06-13 20:06:44 +02:00
|
|
|
}
|
|
|
|
|
2012-04-20 08:39:55 +02:00
|
|
|
static HRESULT SeekingPassThru_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
2012-03-14 20:45:34 +01:00
|
|
|
{
|
|
|
|
return PosPassThru_Construct(pUnkOuter,ppObj); /* from strmbase */
|
|
|
|
}
|
|
|
|
|
2003-06-13 20:06:44 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* DirectShow ClassFactory
|
2003-01-02 18:55:45 +01:00
|
|
|
*/
|
2003-06-13 20:06:44 +02:00
|
|
|
typedef struct {
|
2012-08-20 12:03:14 +02:00
|
|
|
IClassFactory IClassFactory_iface;
|
2005-07-12 21:21:36 +02:00
|
|
|
LONG ref;
|
2003-06-13 20:06:44 +02:00
|
|
|
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
|
|
|
|
} IClassFactoryImpl;
|
|
|
|
|
2012-08-20 12:03:14 +02:00
|
|
|
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
2003-06-13 20:06:44 +02:00
|
|
|
struct object_creation_info
|
|
|
|
{
|
|
|
|
const CLSID *clsid;
|
|
|
|
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct object_creation_info object_creation[] =
|
|
|
|
{
|
2008-04-09 22:12:55 +02:00
|
|
|
{ &CLSID_SeekingPassThru, SeekingPassThru_create },
|
2005-05-05 11:50:35 +02:00
|
|
|
{ &CLSID_FilterGraph, FilterGraph_create },
|
|
|
|
{ &CLSID_FilterGraphNoThread, FilterGraphNoThread_create },
|
2007-03-03 09:21:08 +01:00
|
|
|
{ &CLSID_FilterMapper, FilterMapper_create },
|
2003-07-01 06:29:48 +02:00
|
|
|
{ &CLSID_FilterMapper2, FilterMapper2_create },
|
2003-08-07 01:00:14 +02:00
|
|
|
{ &CLSID_AsyncReader, AsyncReader_create },
|
2003-09-11 23:18:36 +02:00
|
|
|
{ &CLSID_MemoryAllocator, StdMemAllocator_create },
|
2003-11-18 21:47:48 +01:00
|
|
|
{ &CLSID_AviSplitter, AVISplitter_create },
|
2007-04-24 14:28:14 +02:00
|
|
|
{ &CLSID_MPEG1Splitter, MPEGSplitter_create },
|
2004-08-24 04:28:35 +02:00
|
|
|
{ &CLSID_VideoRenderer, VideoRenderer_create },
|
2008-03-12 18:12:18 +01:00
|
|
|
{ &CLSID_NullRenderer, NullRenderer_create },
|
2013-11-05 23:59:54 +01:00
|
|
|
{ &CLSID_VideoMixingRenderer, VMR7Impl_create },
|
2012-04-03 21:37:55 +02:00
|
|
|
{ &CLSID_VideoMixingRenderer9, VMR9Impl_create },
|
2008-02-02 10:47:34 +01:00
|
|
|
{ &CLSID_VideoRendererDefault, VideoRendererDefault_create },
|
2004-08-24 04:28:35 +02:00
|
|
|
{ &CLSID_DSoundRender, DSoundRender_create },
|
2008-07-03 01:48:13 +02:00
|
|
|
{ &CLSID_AudioRender, DSoundRender_create },
|
2004-08-24 04:28:35 +02:00
|
|
|
{ &CLSID_AVIDec, AVIDec_create },
|
2008-07-06 14:00:35 +02:00
|
|
|
{ &CLSID_SystemClock, QUARTZ_CreateSystemClock },
|
|
|
|
{ &CLSID_ACMWrapper, ACMWrapper_create },
|
|
|
|
{ &CLSID_WAVEParser, WAVEParser_create }
|
2003-06-13 20:06:44 +02:00
|
|
|
};
|
|
|
|
|
2012-08-20 12:03:14 +02:00
|
|
|
static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
|
2003-01-02 18:55:45 +01:00
|
|
|
{
|
2003-06-13 20:06:44 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IClassFactory))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
2012-08-20 12:03:14 +02:00
|
|
|
*ppobj = iface;
|
2003-06-13 20:06:44 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-12-13 12:14:56 +01:00
|
|
|
*ppobj = NULL;
|
2012-08-20 12:03:14 +02:00
|
|
|
WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
|
2003-06-13 20:06:44 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-08-20 12:03:14 +02:00
|
|
|
static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
|
2004-09-28 21:19:27 +02:00
|
|
|
{
|
2012-08-20 12:03:14 +02:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2004-09-28 21:19:27 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
2003-06-13 20:06:44 +02:00
|
|
|
}
|
|
|
|
|
2012-08-20 12:03:14 +02:00
|
|
|
static ULONG WINAPI DSCF_Release(IClassFactory *iface)
|
2004-09-28 21:19:27 +02:00
|
|
|
{
|
2012-08-20 12:03:14 +02:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2004-09-28 21:19:27 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2003-06-13 20:06:44 +02:00
|
|
|
|
|
|
|
if (ref == 0)
|
2007-03-08 12:03:06 +01:00
|
|
|
CoTaskMemFree(This);
|
2003-06-13 20:06:44 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-20 12:03:14 +02:00
|
|
|
static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
|
|
|
|
REFIID riid, void **ppobj)
|
2004-09-28 21:19:27 +02:00
|
|
|
{
|
2012-08-20 12:03:14 +02:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2003-06-13 20:06:44 +02:00
|
|
|
HRESULT hres;
|
|
|
|
LPUNKNOWN punk;
|
2012-07-02 00:54:55 +02:00
|
|
|
|
2003-06-13 20:06:44 +02:00
|
|
|
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
|
2004-09-28 21:19:27 +02:00
|
|
|
*ppobj = NULL;
|
2012-07-02 00:54:55 +02:00
|
|
|
if(pOuter && !IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
2003-06-13 20:06:44 +02:00
|
|
|
hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
|
2004-09-28 21:19:27 +02:00
|
|
|
if (SUCCEEDED(hres)) {
|
|
|
|
hres = IUnknown_QueryInterface(punk, riid, ppobj);
|
|
|
|
IUnknown_Release(punk);
|
2003-06-13 20:06:44 +02:00
|
|
|
}
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2012-08-20 12:03:14 +02:00
|
|
|
static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
|
2004-09-28 21:19:27 +02:00
|
|
|
{
|
2012-08-20 12:03:14 +02:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2003-06-13 20:06:44 +02:00
|
|
|
FIXME("(%p)->(%d),stub!\n",This,dolock);
|
2016-09-01 22:11:43 +02:00
|
|
|
if(dolock)
|
|
|
|
InterlockedIncrement(&server_locks);
|
|
|
|
else
|
|
|
|
InterlockedDecrement(&server_locks);
|
2003-06-13 20:06:44 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IClassFactoryVtbl DSCF_Vtbl =
|
2003-06-13 20:06:44 +02:00
|
|
|
{
|
|
|
|
DSCF_QueryInterface,
|
|
|
|
DSCF_AddRef,
|
|
|
|
DSCF_Release,
|
|
|
|
DSCF_CreateInstance,
|
|
|
|
DSCF_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* DllGetClassObject [QUARTZ.@]
|
|
|
|
* Retrieves class object from a DLL object
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Docs say returns STDAPI
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* rclsid [I] CLSID for the class object
|
|
|
|
* riid [I] Reference to identifier of interface for class object
|
|
|
|
* ppv [O] Address of variable to receive interface pointer for riid
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
|
|
|
|
* E_UNEXPECTED
|
|
|
|
*/
|
2005-05-17 16:41:37 +02:00
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
2003-06-13 20:06:44 +02:00
|
|
|
{
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2003-06-13 20:06:44 +02:00
|
|
|
|
2009-09-11 13:40:17 +02:00
|
|
|
TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
2003-06-13 20:06:44 +02:00
|
|
|
|
2009-09-11 13:40:17 +02:00
|
|
|
if (IsEqualGUID( &IID_IClassFactory, riid ) || IsEqualGUID( &IID_IUnknown, riid))
|
2003-06-13 20:06:44 +02:00
|
|
|
{
|
2018-07-17 21:20:08 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(object_creation); i++)
|
2009-09-11 13:40:17 +02:00
|
|
|
{
|
|
|
|
if (IsEqualGUID(object_creation[i].clsid, rclsid))
|
|
|
|
{
|
|
|
|
IClassFactoryImpl *factory = CoTaskMemAlloc(sizeof(*factory));
|
|
|
|
if (factory == NULL) return E_OUTOFMEMORY;
|
|
|
|
|
2012-08-20 12:03:14 +02:00
|
|
|
factory->IClassFactory_iface.lpVtbl = &DSCF_Vtbl;
|
2009-09-11 13:40:17 +02:00
|
|
|
factory->ref = 1;
|
|
|
|
|
|
|
|
factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
|
|
|
|
|
2012-08-20 12:03:14 +02:00
|
|
|
*ppv = &factory->IClassFactory_iface;
|
2009-09-11 13:40:17 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
2003-06-13 20:06:44 +02:00
|
|
|
}
|
2009-09-11 13:40:17 +02:00
|
|
|
return QUARTZ_DllGetClassObject( rclsid, riid, ppv );
|
2003-01-02 18:55:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-06-13 20:06:44 +02:00
|
|
|
* DllCanUnloadNow (QUARTZ.@)
|
2003-01-02 18:55:45 +01:00
|
|
|
*/
|
2007-08-29 21:42:28 +02:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
2003-01-02 18:55:45 +01:00
|
|
|
{
|
2016-09-01 22:11:43 +02:00
|
|
|
if(server_locks == 0 && QUARTZ_DllCanUnloadNow() == S_OK)
|
|
|
|
return S_OK;
|
|
|
|
return S_FALSE;
|
2003-01-02 18:55:45 +01:00
|
|
|
}
|
2003-08-07 00:04:45 +02:00
|
|
|
|
|
|
|
|
2005-03-02 13:23:20 +01:00
|
|
|
#define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
|
|
|
{ { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } , #name },
|
|
|
|
|
2006-11-29 11:05:43 +01:00
|
|
|
static const struct {
|
2003-08-07 00:04:45 +02:00
|
|
|
const GUID riid;
|
2003-10-08 00:54:17 +02:00
|
|
|
const char *name;
|
2003-08-07 00:04:45 +02:00
|
|
|
} InterfaceDesc[] =
|
|
|
|
{
|
2005-03-02 13:23:20 +01:00
|
|
|
#include "uuids.h"
|
|
|
|
{ { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL }
|
2003-08-07 00:04:45 +02:00
|
|
|
};
|
|
|
|
|
2009-09-11 13:40:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* proxies
|
|
|
|
*/
|
|
|
|
HRESULT CALLBACK ICaptureGraphBuilder_FindInterface_Proxy( ICaptureGraphBuilder *This,
|
|
|
|
const GUID *pCategory,
|
|
|
|
IBaseFilter *pf,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppint )
|
|
|
|
{
|
|
|
|
return ICaptureGraphBuilder_RemoteFindInterface_Proxy( This, pCategory, pf,
|
|
|
|
riid, (IUnknown **)ppint );
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __RPC_STUB ICaptureGraphBuilder_FindInterface_Stub( ICaptureGraphBuilder *This,
|
|
|
|
const GUID *pCategory,
|
|
|
|
IBaseFilter *pf,
|
|
|
|
REFIID riid,
|
|
|
|
IUnknown **ppint )
|
|
|
|
{
|
|
|
|
return ICaptureGraphBuilder_FindInterface( This, pCategory, pf, riid, (void **)ppint );
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CALLBACK ICaptureGraphBuilder2_FindInterface_Proxy( ICaptureGraphBuilder2 *This,
|
|
|
|
const GUID *pCategory,
|
|
|
|
const GUID *pType,
|
|
|
|
IBaseFilter *pf,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppint )
|
|
|
|
{
|
|
|
|
return ICaptureGraphBuilder2_RemoteFindInterface_Proxy( This, pCategory, pType,
|
|
|
|
pf, riid, (IUnknown **)ppint );
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT __RPC_STUB ICaptureGraphBuilder2_FindInterface_Stub( ICaptureGraphBuilder2 *This,
|
|
|
|
const GUID *pCategory,
|
|
|
|
const GUID *pType,
|
|
|
|
IBaseFilter *pf,
|
|
|
|
REFIID riid,
|
|
|
|
IUnknown **ppint )
|
|
|
|
{
|
|
|
|
return ICaptureGraphBuilder2_FindInterface( This, pCategory, pType, pf, riid, (void **)ppint );
|
|
|
|
}
|
|
|
|
|
2003-08-07 00:04:45 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* qzdebugstr_guid (internal)
|
|
|
|
*
|
|
|
|
* Gives a text version of DirectShow GUIDs
|
|
|
|
*/
|
|
|
|
const char * qzdebugstr_guid( const GUID * id )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2015-01-08 11:10:11 +01:00
|
|
|
for (i=0; InterfaceDesc[i].name; i++)
|
2003-08-07 00:04:45 +02:00
|
|
|
if (IsEqualGUID(&InterfaceDesc[i].riid, id)) return InterfaceDesc[i].name;
|
2015-01-08 11:10:11 +01:00
|
|
|
|
2003-08-07 00:04:45 +02:00
|
|
|
return debugstr_guid(id);
|
|
|
|
}
|
|
|
|
|
2004-10-08 23:01:44 +02:00
|
|
|
LONG WINAPI AmpFactorToDB(LONG ampfactor)
|
2004-09-06 22:23:42 +02:00
|
|
|
{
|
2006-10-12 20:57:23 +02:00
|
|
|
FIXME("(%d) Stub!\n", ampfactor);
|
2004-09-06 22:23:42 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-08 23:01:44 +02:00
|
|
|
LONG WINAPI DBToAmpFactor(LONG db)
|
2004-09-06 22:23:42 +02:00
|
|
|
{
|
2006-10-12 20:57:23 +02:00
|
|
|
FIXME("(%d) Stub!\n", db);
|
2004-09-06 22:23:42 +02:00
|
|
|
/* Avoid divide by zero (probably during range computation) in Windows Media Player 6.4 */
|
|
|
|
if (db < -1000)
|
|
|
|
return 0;
|
|
|
|
return 100;
|
|
|
|
}
|
2006-05-20 20:57:51 +02:00
|
|
|
|
2006-11-12 20:23:28 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AMGetErrorTextA (QUARTZ.@)
|
|
|
|
*/
|
2007-09-01 02:45:48 +02:00
|
|
|
DWORD WINAPI AMGetErrorTextA(HRESULT hr, LPSTR buffer, DWORD maxlen)
|
2006-05-20 20:57:51 +02:00
|
|
|
{
|
2010-12-03 09:38:11 +01:00
|
|
|
DWORD res;
|
|
|
|
WCHAR errorW[MAX_ERROR_TEXT_LEN];
|
2006-05-20 20:57:51 +02:00
|
|
|
|
2010-12-03 09:38:11 +01:00
|
|
|
TRACE("(%x,%p,%d)\n", hr, buffer, maxlen);
|
|
|
|
if (!buffer)
|
|
|
|
return 0;
|
2006-05-20 20:57:51 +02:00
|
|
|
|
2018-07-17 21:20:08 +02:00
|
|
|
res = AMGetErrorTextW(hr, errorW, ARRAY_SIZE(errorW));
|
2010-12-03 09:38:11 +01:00
|
|
|
return WideCharToMultiByte(CP_ACP, 0, errorW, res, buffer, maxlen, 0, 0);
|
2006-05-20 20:57:51 +02:00
|
|
|
}
|
|
|
|
|
2006-11-12 20:23:28 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AMGetErrorTextW (QUARTZ.@)
|
|
|
|
*/
|
2007-09-01 02:45:48 +02:00
|
|
|
DWORD WINAPI AMGetErrorTextW(HRESULT hr, LPWSTR buffer, DWORD maxlen)
|
2006-05-20 20:57:51 +02:00
|
|
|
{
|
2008-11-04 23:22:53 +01:00
|
|
|
unsigned int len;
|
2006-05-20 20:57:51 +02:00
|
|
|
static const WCHAR format[] = {'E','r','r','o','r',':',' ','0','x','%','l','x',0};
|
|
|
|
WCHAR error[MAX_ERROR_TEXT_LEN];
|
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
FIXME("(%x,%p,%d) stub\n", hr, buffer, maxlen);
|
2006-05-20 20:57:51 +02:00
|
|
|
|
|
|
|
if (!buffer) return 0;
|
|
|
|
wsprintfW(error, format, hr);
|
2008-11-04 23:22:53 +01:00
|
|
|
if ((len = strlenW(error)) >= maxlen) return 0;
|
2006-05-20 20:57:51 +02:00
|
|
|
lstrcpyW(buffer, error);
|
|
|
|
return len;
|
|
|
|
}
|