2003-06-13 18:06:44 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-06-13 18:06:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2003-01-02 17:55:45 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2003-06-13 18:06:44 +00:00
|
|
|
#include "quartz_private.h"
|
2008-11-04 22:22:53 +00:00
|
|
|
#include "wine/unicode.h"
|
2003-01-02 17:55:45 +00:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
2009-09-11 11:40:17 +00: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;
|
|
|
|
|
2003-06-13 18:06:44 +00:00
|
|
|
/* For the moment, do nothing here. */
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
|
|
|
|
{
|
2009-09-11 11:40:17 +00:00
|
|
|
return QUARTZ_DllMain( hInstDLL, fdwReason, lpv );
|
2003-06-13 18:06:44 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 06:39:55 +00:00
|
|
|
static HRESULT SeekingPassThru_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
2012-03-14 19:45:34 +00:00
|
|
|
{
|
|
|
|
return PosPassThru_Construct(pUnkOuter,ppObj); /* from strmbase */
|
|
|
|
}
|
|
|
|
|
2003-06-13 18:06:44 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* DirectShow ClassFactory
|
2003-01-02 17:55:45 +00:00
|
|
|
*/
|
2003-06-13 18:06:44 +00:00
|
|
|
typedef struct {
|
2012-08-20 10:03:14 +00:00
|
|
|
IClassFactory IClassFactory_iface;
|
2005-07-12 19:21:36 +00:00
|
|
|
LONG ref;
|
2003-06-13 18:06:44 +00:00
|
|
|
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
|
|
|
|
} IClassFactoryImpl;
|
|
|
|
|
2012-08-20 10:03:14 +00:00
|
|
|
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
2003-06-13 18:06:44 +00: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 20:12:55 +00:00
|
|
|
{ &CLSID_SeekingPassThru, SeekingPassThru_create },
|
2005-05-05 09:50:35 +00:00
|
|
|
{ &CLSID_FilterGraph, FilterGraph_create },
|
|
|
|
{ &CLSID_FilterGraphNoThread, FilterGraphNoThread_create },
|
2007-03-03 08:21:08 +00:00
|
|
|
{ &CLSID_FilterMapper, FilterMapper_create },
|
2003-07-01 04:29:48 +00:00
|
|
|
{ &CLSID_FilterMapper2, FilterMapper2_create },
|
2003-08-06 23:00:14 +00:00
|
|
|
{ &CLSID_AsyncReader, AsyncReader_create },
|
2003-09-11 21:18:36 +00:00
|
|
|
{ &CLSID_MemoryAllocator, StdMemAllocator_create },
|
2003-11-18 20:47:48 +00:00
|
|
|
{ &CLSID_AviSplitter, AVISplitter_create },
|
2007-04-24 12:28:14 +00:00
|
|
|
{ &CLSID_MPEG1Splitter, MPEGSplitter_create },
|
2004-08-24 02:28:35 +00:00
|
|
|
{ &CLSID_VideoRenderer, VideoRenderer_create },
|
2008-03-12 17:12:18 +00:00
|
|
|
{ &CLSID_NullRenderer, NullRenderer_create },
|
2013-11-05 22:59:54 +00:00
|
|
|
{ &CLSID_VideoMixingRenderer, VMR7Impl_create },
|
2012-04-03 19:37:55 +00:00
|
|
|
{ &CLSID_VideoMixingRenderer9, VMR9Impl_create },
|
2008-02-02 09:47:34 +00:00
|
|
|
{ &CLSID_VideoRendererDefault, VideoRendererDefault_create },
|
2004-08-24 02:28:35 +00:00
|
|
|
{ &CLSID_DSoundRender, DSoundRender_create },
|
2008-07-02 23:48:13 +00:00
|
|
|
{ &CLSID_AudioRender, DSoundRender_create },
|
2004-08-24 02:28:35 +00:00
|
|
|
{ &CLSID_AVIDec, AVIDec_create },
|
2008-07-06 12:00:35 +00:00
|
|
|
{ &CLSID_SystemClock, QUARTZ_CreateSystemClock },
|
|
|
|
{ &CLSID_ACMWrapper, ACMWrapper_create },
|
|
|
|
{ &CLSID_WAVEParser, WAVEParser_create }
|
2003-06-13 18:06:44 +00:00
|
|
|
};
|
|
|
|
|
2012-08-20 10:03:14 +00:00
|
|
|
static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
|
2003-01-02 17:55:45 +00:00
|
|
|
{
|
2003-06-13 18:06:44 +00:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IClassFactory))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
2012-08-20 10:03:14 +00:00
|
|
|
*ppobj = iface;
|
2003-06-13 18:06:44 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-12-13 11:14:56 +00:00
|
|
|
*ppobj = NULL;
|
2012-08-20 10:03:14 +00:00
|
|
|
WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
|
2003-06-13 18:06:44 +00:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-08-20 10:03:14 +00:00
|
|
|
static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
|
2004-09-28 19:19:27 +00:00
|
|
|
{
|
2012-08-20 10:03:14 +00:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2004-09-28 19:19:27 +00:00
|
|
|
return InterlockedIncrement(&This->ref);
|
2003-06-13 18:06:44 +00:00
|
|
|
}
|
|
|
|
|
2012-08-20 10:03:14 +00:00
|
|
|
static ULONG WINAPI DSCF_Release(IClassFactory *iface)
|
2004-09-28 19:19:27 +00:00
|
|
|
{
|
2012-08-20 10:03:14 +00:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2004-09-28 19:19:27 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2003-06-13 18:06:44 +00:00
|
|
|
|
|
|
|
if (ref == 0)
|
2007-03-08 11:03:06 +00:00
|
|
|
CoTaskMemFree(This);
|
2003-06-13 18:06:44 +00:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-20 10:03:14 +00:00
|
|
|
static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
|
|
|
|
REFIID riid, void **ppobj)
|
2004-09-28 19:19:27 +00:00
|
|
|
{
|
2012-08-20 10:03:14 +00:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2003-06-13 18:06:44 +00:00
|
|
|
HRESULT hres;
|
|
|
|
LPUNKNOWN punk;
|
2012-07-01 22:54:55 +00:00
|
|
|
|
2003-06-13 18:06:44 +00:00
|
|
|
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
|
|
|
|
|
2004-09-28 19:19:27 +00:00
|
|
|
*ppobj = NULL;
|
2012-07-01 22:54:55 +00:00
|
|
|
if(pOuter && !IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
2003-06-13 18:06:44 +00:00
|
|
|
hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
|
2004-09-28 19:19:27 +00:00
|
|
|
if (SUCCEEDED(hres)) {
|
|
|
|
hres = IUnknown_QueryInterface(punk, riid, ppobj);
|
|
|
|
IUnknown_Release(punk);
|
2003-06-13 18:06:44 +00:00
|
|
|
}
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2012-08-20 10:03:14 +00:00
|
|
|
static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
|
2004-09-28 19:19:27 +00:00
|
|
|
{
|
2012-08-20 10:03:14 +00:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2003-06-13 18:06:44 +00:00
|
|
|
FIXME("(%p)->(%d),stub!\n",This,dolock);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 19:50:35 +00:00
|
|
|
static const IClassFactoryVtbl DSCF_Vtbl =
|
2003-06-13 18:06:44 +00: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 14:41:37 +00:00
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
2003-06-13 18:06:44 +00:00
|
|
|
{
|
2004-09-22 02:46:38 +00:00
|
|
|
unsigned int i;
|
2003-06-13 18:06:44 +00:00
|
|
|
|
2009-09-11 11:40:17 +00:00
|
|
|
TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
2003-06-13 18:06:44 +00:00
|
|
|
|
2009-09-11 11:40:17 +00:00
|
|
|
if (IsEqualGUID( &IID_IClassFactory, riid ) || IsEqualGUID( &IID_IUnknown, riid))
|
2003-06-13 18:06:44 +00:00
|
|
|
{
|
2009-09-11 11:40:17 +00:00
|
|
|
for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(object_creation[i].clsid, rclsid))
|
|
|
|
{
|
|
|
|
IClassFactoryImpl *factory = CoTaskMemAlloc(sizeof(*factory));
|
|
|
|
if (factory == NULL) return E_OUTOFMEMORY;
|
|
|
|
|
2012-08-20 10:03:14 +00:00
|
|
|
factory->IClassFactory_iface.lpVtbl = &DSCF_Vtbl;
|
2009-09-11 11:40:17 +00:00
|
|
|
factory->ref = 1;
|
|
|
|
|
|
|
|
factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
|
|
|
|
|
2012-08-20 10:03:14 +00:00
|
|
|
*ppv = &factory->IClassFactory_iface;
|
2009-09-11 11:40:17 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
2003-06-13 18:06:44 +00:00
|
|
|
}
|
2009-09-11 11:40:17 +00:00
|
|
|
return QUARTZ_DllGetClassObject( rclsid, riid, ppv );
|
2003-01-02 17:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-06-13 18:06:44 +00:00
|
|
|
* DllCanUnloadNow (QUARTZ.@)
|
2003-01-02 17:55:45 +00:00
|
|
|
*/
|
2007-08-29 19:42:28 +00:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
2003-01-02 17:55:45 +00:00
|
|
|
{
|
2009-09-11 11:40:17 +00:00
|
|
|
return QUARTZ_DllCanUnloadNow();
|
2003-01-02 17:55:45 +00:00
|
|
|
}
|
2003-08-06 22:04:45 +00:00
|
|
|
|
|
|
|
|
2005-03-02 12:23:20 +00: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 10:05:43 +00:00
|
|
|
static const struct {
|
2003-08-06 22:04:45 +00:00
|
|
|
const GUID riid;
|
2003-10-07 22:54:17 +00:00
|
|
|
const char *name;
|
2003-08-06 22:04:45 +00:00
|
|
|
} InterfaceDesc[] =
|
|
|
|
{
|
2005-03-02 12:23:20 +00:00
|
|
|
#include "uuids.h"
|
|
|
|
{ { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL }
|
2003-08-06 22:04:45 +00:00
|
|
|
};
|
|
|
|
|
2009-09-11 11:40:17 +00: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-06 22:04:45 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* qzdebugstr_guid (internal)
|
|
|
|
*
|
|
|
|
* Gives a text version of DirectShow GUIDs
|
|
|
|
*/
|
|
|
|
const char * qzdebugstr_guid( const GUID * id )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2015-01-08 10:10:11 +00:00
|
|
|
for (i=0; InterfaceDesc[i].name; i++)
|
2003-08-06 22:04:45 +00:00
|
|
|
if (IsEqualGUID(&InterfaceDesc[i].riid, id)) return InterfaceDesc[i].name;
|
2015-01-08 10:10:11 +00:00
|
|
|
|
2003-08-06 22:04:45 +00:00
|
|
|
return debugstr_guid(id);
|
|
|
|
}
|
|
|
|
|
2004-10-08 21:01:44 +00:00
|
|
|
LONG WINAPI AmpFactorToDB(LONG ampfactor)
|
2004-09-06 20:23:42 +00:00
|
|
|
{
|
2006-10-12 18:57:23 +00:00
|
|
|
FIXME("(%d) Stub!\n", ampfactor);
|
2004-09-06 20:23:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-08 21:01:44 +00:00
|
|
|
LONG WINAPI DBToAmpFactor(LONG db)
|
2004-09-06 20:23:42 +00:00
|
|
|
{
|
2006-10-12 18:57:23 +00:00
|
|
|
FIXME("(%d) Stub!\n", db);
|
2004-09-06 20:23:42 +00: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 18:57:51 +00:00
|
|
|
|
2006-11-12 19:23:28 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* AMGetErrorTextA (QUARTZ.@)
|
|
|
|
*/
|
2007-09-01 00:45:48 +00:00
|
|
|
DWORD WINAPI AMGetErrorTextA(HRESULT hr, LPSTR buffer, DWORD maxlen)
|
2006-05-20 18:57:51 +00:00
|
|
|
{
|
2010-12-03 08:38:11 +00:00
|
|
|
DWORD res;
|
|
|
|
WCHAR errorW[MAX_ERROR_TEXT_LEN];
|
2006-05-20 18:57:51 +00:00
|
|
|
|
2010-12-03 08:38:11 +00:00
|
|
|
TRACE("(%x,%p,%d)\n", hr, buffer, maxlen);
|
|
|
|
if (!buffer)
|
|
|
|
return 0;
|
2006-05-20 18:57:51 +00:00
|
|
|
|
2010-12-03 08:38:11 +00:00
|
|
|
res = AMGetErrorTextW(hr, errorW, sizeof(errorW)/sizeof(*errorW));
|
|
|
|
return WideCharToMultiByte(CP_ACP, 0, errorW, res, buffer, maxlen, 0, 0);
|
2006-05-20 18:57:51 +00:00
|
|
|
}
|
|
|
|
|
2006-11-12 19:23:28 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* AMGetErrorTextW (QUARTZ.@)
|
|
|
|
*/
|
2007-09-01 00:45:48 +00:00
|
|
|
DWORD WINAPI AMGetErrorTextW(HRESULT hr, LPWSTR buffer, DWORD maxlen)
|
2006-05-20 18:57:51 +00:00
|
|
|
{
|
2008-11-04 22:22:53 +00:00
|
|
|
unsigned int len;
|
2006-05-20 18:57:51 +00:00
|
|
|
static const WCHAR format[] = {'E','r','r','o','r',':',' ','0','x','%','l','x',0};
|
|
|
|
WCHAR error[MAX_ERROR_TEXT_LEN];
|
|
|
|
|
2006-10-12 18:57:23 +00:00
|
|
|
FIXME("(%x,%p,%d) stub\n", hr, buffer, maxlen);
|
2006-05-20 18:57:51 +00:00
|
|
|
|
|
|
|
if (!buffer) return 0;
|
|
|
|
wsprintfW(error, format, hr);
|
2008-11-04 22:22:53 +00:00
|
|
|
if ((len = strlenW(error)) >= maxlen) return 0;
|
2006-05-20 18:57:51 +00:00
|
|
|
lstrcpyW(buffer, error);
|
|
|
|
return len;
|
|
|
|
}
|