1 /* DirectShow Base Functions (QUARTZ.DLL)
3 * Copyright 2002 Lionel Ulmer
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/debug.h"
23 #include "quartz_private.h"
24 #include "wine/unicode.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
28 extern HRESULT WINAPI
QUARTZ_DllGetClassObject(REFCLSID
, REFIID
, LPVOID
*) DECLSPEC_HIDDEN
;
29 extern HRESULT WINAPI
QUARTZ_DllCanUnloadNow(void) DECLSPEC_HIDDEN
;
30 extern BOOL WINAPI
QUARTZ_DllMain(HINSTANCE
, DWORD
, LPVOID
) DECLSPEC_HIDDEN
;
32 static LONG server_locks
= 0;
34 /* For the moment, do nothing here. */
35 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
37 return QUARTZ_DllMain( hInstDLL
, fdwReason
, lpv
);
40 static HRESULT
SeekingPassThru_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
42 return PosPassThru_Construct(pUnkOuter
,ppObj
); /* from strmbase */
45 /******************************************************************************
46 * DirectShow ClassFactory
49 IClassFactory IClassFactory_iface
;
51 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
54 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
56 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
59 struct object_creation_info
62 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
65 static const struct object_creation_info object_creation
[] =
67 { &CLSID_SeekingPassThru
, SeekingPassThru_create
},
68 { &CLSID_FilterGraph
, FilterGraph_create
},
69 { &CLSID_FilterGraphNoThread
, FilterGraphNoThread_create
},
70 { &CLSID_FilterMapper
, FilterMapper_create
},
71 { &CLSID_FilterMapper2
, FilterMapper2_create
},
72 { &CLSID_AsyncReader
, AsyncReader_create
},
73 { &CLSID_MemoryAllocator
, StdMemAllocator_create
},
74 { &CLSID_AviSplitter
, AVISplitter_create
},
75 { &CLSID_MPEG1Splitter
, MPEGSplitter_create
},
76 { &CLSID_VideoRenderer
, VideoRenderer_create
},
77 { &CLSID_NullRenderer
, NullRenderer_create
},
78 { &CLSID_VideoMixingRenderer
, VMR7Impl_create
},
79 { &CLSID_VideoMixingRenderer9
, VMR9Impl_create
},
80 { &CLSID_VideoRendererDefault
, VideoRendererDefault_create
},
81 { &CLSID_DSoundRender
, DSoundRender_create
},
82 { &CLSID_AudioRender
, DSoundRender_create
},
83 { &CLSID_AVIDec
, AVIDec_create
},
84 { &CLSID_SystemClock
, QUARTZ_CreateSystemClock
},
85 { &CLSID_ACMWrapper
, ACMWrapper_create
},
86 { &CLSID_WAVEParser
, WAVEParser_create
}
89 static HRESULT WINAPI
DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
91 if (IsEqualGUID(riid
, &IID_IUnknown
)
92 || IsEqualGUID(riid
, &IID_IClassFactory
))
94 IClassFactory_AddRef(iface
);
100 WARN("(%p)->(%s,%p), not found\n", iface
, debugstr_guid(riid
), ppobj
);
101 return E_NOINTERFACE
;
104 static ULONG WINAPI
DSCF_AddRef(IClassFactory
*iface
)
106 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
107 return InterlockedIncrement(&This
->ref
);
110 static ULONG WINAPI
DSCF_Release(IClassFactory
*iface
)
112 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
113 ULONG ref
= InterlockedDecrement(&This
->ref
);
122 static HRESULT WINAPI
DSCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
123 REFIID riid
, void **ppobj
)
125 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
129 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
132 if(pOuter
&& !IsEqualGUID(&IID_IUnknown
, riid
))
133 return E_NOINTERFACE
;
135 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
136 if (SUCCEEDED(hres
)) {
137 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
138 IUnknown_Release(punk
);
143 static HRESULT WINAPI
DSCF_LockServer(IClassFactory
*iface
, BOOL dolock
)
145 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
146 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
148 InterlockedIncrement(&server_locks
);
150 InterlockedDecrement(&server_locks
);
154 static const IClassFactoryVtbl DSCF_Vtbl
=
163 /*******************************************************************************
164 * DllGetClassObject [QUARTZ.@]
165 * Retrieves class object from a DLL object
168 * Docs say returns STDAPI
171 * rclsid [I] CLSID for the class object
172 * riid [I] Reference to identifier of interface for class object
173 * ppv [O] Address of variable to receive interface pointer for riid
177 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
180 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
184 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
186 if (IsEqualGUID( &IID_IClassFactory
, riid
) || IsEqualGUID( &IID_IUnknown
, riid
))
188 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
190 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
192 IClassFactoryImpl
*factory
= CoTaskMemAlloc(sizeof(*factory
));
193 if (factory
== NULL
) return E_OUTOFMEMORY
;
195 factory
->IClassFactory_iface
.lpVtbl
= &DSCF_Vtbl
;
198 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
200 *ppv
= &factory
->IClassFactory_iface
;
205 return QUARTZ_DllGetClassObject( rclsid
, riid
, ppv
);
208 /***********************************************************************
209 * DllCanUnloadNow (QUARTZ.@)
211 HRESULT WINAPI
DllCanUnloadNow(void)
213 if(server_locks
== 0 && QUARTZ_DllCanUnloadNow() == S_OK
)
219 #define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
220 { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } , #name },
222 static const struct {
228 { { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL
}
231 /***********************************************************************
234 HRESULT CALLBACK
ICaptureGraphBuilder_FindInterface_Proxy( ICaptureGraphBuilder
*This
,
235 const GUID
*pCategory
,
240 return ICaptureGraphBuilder_RemoteFindInterface_Proxy( This
, pCategory
, pf
,
241 riid
, (IUnknown
**)ppint
);
244 HRESULT __RPC_STUB
ICaptureGraphBuilder_FindInterface_Stub( ICaptureGraphBuilder
*This
,
245 const GUID
*pCategory
,
250 return ICaptureGraphBuilder_FindInterface( This
, pCategory
, pf
, riid
, (void **)ppint
);
253 HRESULT CALLBACK
ICaptureGraphBuilder2_FindInterface_Proxy( ICaptureGraphBuilder2
*This
,
254 const GUID
*pCategory
,
260 return ICaptureGraphBuilder2_RemoteFindInterface_Proxy( This
, pCategory
, pType
,
261 pf
, riid
, (IUnknown
**)ppint
);
264 HRESULT __RPC_STUB
ICaptureGraphBuilder2_FindInterface_Stub( ICaptureGraphBuilder2
*This
,
265 const GUID
*pCategory
,
271 return ICaptureGraphBuilder2_FindInterface( This
, pCategory
, pType
, pf
, riid
, (void **)ppint
);
274 /***********************************************************************
275 * qzdebugstr_guid (internal)
277 * Gives a text version of DirectShow GUIDs
279 const char * qzdebugstr_guid( const GUID
* id
)
283 for (i
=0; InterfaceDesc
[i
].name
; i
++)
284 if (IsEqualGUID(&InterfaceDesc
[i
].riid
, id
)) return InterfaceDesc
[i
].name
;
286 return debugstr_guid(id
);
289 LONG WINAPI
AmpFactorToDB(LONG ampfactor
)
291 FIXME("(%d) Stub!\n", ampfactor
);
295 LONG WINAPI
DBToAmpFactor(LONG db
)
297 FIXME("(%d) Stub!\n", db
);
298 /* Avoid divide by zero (probably during range computation) in Windows Media Player 6.4 */
304 /***********************************************************************
305 * AMGetErrorTextA (QUARTZ.@)
307 DWORD WINAPI
AMGetErrorTextA(HRESULT hr
, LPSTR buffer
, DWORD maxlen
)
310 WCHAR errorW
[MAX_ERROR_TEXT_LEN
];
312 TRACE("(%x,%p,%d)\n", hr
, buffer
, maxlen
);
316 res
= AMGetErrorTextW(hr
, errorW
, sizeof(errorW
)/sizeof(*errorW
));
317 return WideCharToMultiByte(CP_ACP
, 0, errorW
, res
, buffer
, maxlen
, 0, 0);
320 /***********************************************************************
321 * AMGetErrorTextW (QUARTZ.@)
323 DWORD WINAPI
AMGetErrorTextW(HRESULT hr
, LPWSTR buffer
, DWORD maxlen
)
326 static const WCHAR format
[] = {'E','r','r','o','r',':',' ','0','x','%','l','x',0};
327 WCHAR error
[MAX_ERROR_TEXT_LEN
];
329 FIXME("(%x,%p,%d) stub\n", hr
, buffer
, maxlen
);
331 if (!buffer
) return 0;
332 wsprintfW(error
, format
, hr
);
333 if ((len
= strlenW(error
)) >= maxlen
) return 0;
334 lstrcpyW(buffer
, error
);