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
|
|
|
*/
|
|
|
|
|
2003-01-02 18:55:45 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2003-06-13 20:06:44 +02:00
|
|
|
#include "quartz_private.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;
|
|
|
|
|
2020-03-13 03:34:12 +01:00
|
|
|
LONG object_locks = 0;
|
2016-09-01 22:11:43 +02:00
|
|
|
|
2020-03-12 03:10:13 +01:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
|
2003-06-13 20:06:44 +02:00
|
|
|
{
|
2020-06-08 00:23:29 +02:00
|
|
|
if (reason == DLL_PROCESS_DETACH && !reserved)
|
|
|
|
{
|
2020-03-12 03:10:13 +01:00
|
|
|
video_window_unregister_class();
|
2020-06-08 00:23:29 +02:00
|
|
|
strmbase_release_typelibs();
|
|
|
|
}
|
2020-03-12 03:10:13 +01:00
|
|
|
return QUARTZ_DllMain(instance, reason, reserved);
|
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;
|
2020-03-12 03:10:10 +01:00
|
|
|
HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
|
2003-06-13 20:06:44 +02:00
|
|
|
} 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;
|
2020-03-12 03:10:10 +01:00
|
|
|
HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
|
2003-06-13 20:06:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct object_creation_info object_creation[] =
|
|
|
|
{
|
2020-03-12 03:10:10 +01:00
|
|
|
{ &CLSID_ACMWrapper, acm_wrapper_create },
|
|
|
|
{ &CLSID_AsyncReader, async_reader_create },
|
|
|
|
{ &CLSID_AudioRender, dsound_render_create },
|
|
|
|
{ &CLSID_AVIDec, avi_dec_create },
|
|
|
|
{ &CLSID_DSoundRender, dsound_render_create },
|
2019-10-03 05:01:06 +02:00
|
|
|
{ &CLSID_FilterGraph, filter_graph_create },
|
|
|
|
{ &CLSID_FilterGraphNoThread, filter_graph_no_thread_create },
|
2020-03-12 03:10:10 +01:00
|
|
|
{ &CLSID_FilterMapper, filter_mapper_create },
|
|
|
|
{ &CLSID_FilterMapper2, filter_mapper_create },
|
|
|
|
{ &CLSID_MemoryAllocator, mem_allocator_create },
|
|
|
|
{ &CLSID_SeekingPassThru, seeking_passthrough_create },
|
|
|
|
{ &CLSID_SystemClock, system_clock_create },
|
|
|
|
{ &CLSID_VideoRenderer, video_renderer_create },
|
|
|
|
{ &CLSID_VideoMixingRenderer, vmr7_create },
|
|
|
|
{ &CLSID_VideoMixingRenderer9, vmr9_create },
|
|
|
|
{ &CLSID_VideoRendererDefault, video_renderer_default_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;
|
|
|
|
|
2020-03-12 03:10:10 +01:00
|
|
|
if (SUCCEEDED(hres = This->create_instance(pOuter, &punk)))
|
|
|
|
{
|
2020-03-13 03:34:12 +01:00
|
|
|
InterlockedIncrement(&object_locks);
|
2004-09-28 21:19:27 +02:00
|
|
|
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)
|
2020-03-13 03:34:12 +01:00
|
|
|
InterlockedIncrement(&object_locks);
|
2016-09-01 22:11:43 +02:00
|
|
|
else
|
2020-03-13 03:34:12 +01:00
|
|
|
InterlockedDecrement(&object_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;
|
|
|
|
|
2020-03-12 03:10:10 +01:00
|
|
|
factory->create_instance = object_creation[i].create_instance;
|
2009-09-11 13:40:17 +02:00
|
|
|
|
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
|
|
|
{
|
2020-03-13 03:34:12 +01:00
|
|
|
if (!object_locks && QUARTZ_DllCanUnloadNow() == S_OK)
|
2016-09-01 22:11:43 +02:00
|
|
|
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));
|
2019-05-30 15:58:09 +02:00
|
|
|
if (!res)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
res = WideCharToMultiByte(CP_ACP, 0, errorW, -1, NULL, 0, 0, 0);
|
|
|
|
if (res > maxlen || !res)
|
|
|
|
return 0;
|
|
|
|
return WideCharToMultiByte(CP_ACP, 0, errorW, -1, buffer, maxlen, 0, 0) - 1;
|
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
|
|
|
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;
|
2020-01-22 23:30:53 +01:00
|
|
|
swprintf(error, ARRAY_SIZE(error), L"Error: 0x%lx", hr);
|
|
|
|
if ((len = wcslen(error)) >= maxlen)
|
|
|
|
return 0;
|
|
|
|
wcscpy(buffer, error);
|
2006-05-20 20:57:51 +02:00
|
|
|
return len;
|
|
|
|
}
|