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 DWORD dll_ref
= 0;
34 /* For the moment, do nothing here. */
35 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
37 if (fdwReason
== DLL_PROCESS_DETACH
)
38 video_unregister_windowclass();
39 return QUARTZ_DllMain( hInstDLL
, fdwReason
, lpv
);
42 HRESULT
SeekingPassThru_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
44 return PosPassThru_Construct(pUnkOuter
,ppObj
); /* from strmbase */
47 /******************************************************************************
48 * DirectShow ClassFactory
51 IClassFactory ITF_IClassFactory
;
54 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
57 struct object_creation_info
60 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
63 static const struct object_creation_info object_creation
[] =
65 { &CLSID_SeekingPassThru
, SeekingPassThru_create
},
66 { &CLSID_FilterGraph
, FilterGraph_create
},
67 { &CLSID_FilterGraphNoThread
, FilterGraphNoThread_create
},
68 { &CLSID_FilterMapper
, FilterMapper_create
},
69 { &CLSID_FilterMapper2
, FilterMapper2_create
},
70 { &CLSID_AsyncReader
, AsyncReader_create
},
71 { &CLSID_MemoryAllocator
, StdMemAllocator_create
},
72 { &CLSID_AviSplitter
, AVISplitter_create
},
73 { &CLSID_MPEG1Splitter
, MPEGSplitter_create
},
74 { &CLSID_VideoRenderer
, VideoRenderer_create
},
75 { &CLSID_NullRenderer
, NullRenderer_create
},
76 { &CLSID_VideoRendererDefault
, VideoRendererDefault_create
},
77 { &CLSID_DSoundRender
, DSoundRender_create
},
78 { &CLSID_AudioRender
, DSoundRender_create
},
79 { &CLSID_AVIDec
, AVIDec_create
},
80 { &CLSID_SystemClock
, QUARTZ_CreateSystemClock
},
81 { &CLSID_ACMWrapper
, ACMWrapper_create
},
82 { &CLSID_WAVEParser
, WAVEParser_create
}
86 DSCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
88 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
90 if (IsEqualGUID(riid
, &IID_IUnknown
)
91 || IsEqualGUID(riid
, &IID_IClassFactory
))
93 IClassFactory_AddRef(iface
);
99 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
100 return E_NOINTERFACE
;
103 static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface
)
105 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
106 return InterlockedIncrement(&This
->ref
);
109 static ULONG WINAPI
DSCF_Release(LPCLASSFACTORY iface
)
111 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
113 ULONG ref
= InterlockedDecrement(&This
->ref
);
122 static HRESULT WINAPI
DSCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
123 REFIID riid
, LPVOID
*ppobj
)
125 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
129 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
132 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
133 if (SUCCEEDED(hres
)) {
134 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
135 IUnknown_Release(punk
);
140 static HRESULT WINAPI
DSCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
142 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
143 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
147 static const IClassFactoryVtbl DSCF_Vtbl
=
156 /*******************************************************************************
157 * DllGetClassObject [QUARTZ.@]
158 * Retrieves class object from a DLL object
161 * Docs say returns STDAPI
164 * rclsid [I] CLSID for the class object
165 * riid [I] Reference to identifier of interface for class object
166 * ppv [O] Address of variable to receive interface pointer for riid
170 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
173 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
177 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
179 if (IsEqualGUID( &IID_IClassFactory
, riid
) || IsEqualGUID( &IID_IUnknown
, riid
))
181 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
183 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
185 IClassFactoryImpl
*factory
= CoTaskMemAlloc(sizeof(*factory
));
186 if (factory
== NULL
) return E_OUTOFMEMORY
;
188 factory
->ITF_IClassFactory
.lpVtbl
= &DSCF_Vtbl
;
191 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
193 *ppv
= &factory
->ITF_IClassFactory
;
198 return QUARTZ_DllGetClassObject( rclsid
, riid
, ppv
);
201 /***********************************************************************
202 * DllCanUnloadNow (QUARTZ.@)
204 HRESULT WINAPI
DllCanUnloadNow(void)
206 if (dll_ref
) return S_FALSE
;
207 return QUARTZ_DllCanUnloadNow();
211 #define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
212 { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } , #name },
214 static const struct {
220 { { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL
}
223 /***********************************************************************
226 HRESULT CALLBACK
ICaptureGraphBuilder_FindInterface_Proxy( ICaptureGraphBuilder
*This
,
227 const GUID
*pCategory
,
232 return ICaptureGraphBuilder_RemoteFindInterface_Proxy( This
, pCategory
, pf
,
233 riid
, (IUnknown
**)ppint
);
236 HRESULT __RPC_STUB
ICaptureGraphBuilder_FindInterface_Stub( ICaptureGraphBuilder
*This
,
237 const GUID
*pCategory
,
242 return ICaptureGraphBuilder_FindInterface( This
, pCategory
, pf
, riid
, (void **)ppint
);
245 HRESULT CALLBACK
ICaptureGraphBuilder2_FindInterface_Proxy( ICaptureGraphBuilder2
*This
,
246 const GUID
*pCategory
,
252 return ICaptureGraphBuilder2_RemoteFindInterface_Proxy( This
, pCategory
, pType
,
253 pf
, riid
, (IUnknown
**)ppint
);
256 HRESULT __RPC_STUB
ICaptureGraphBuilder2_FindInterface_Stub( ICaptureGraphBuilder2
*This
,
257 const GUID
*pCategory
,
263 return ICaptureGraphBuilder2_FindInterface( This
, pCategory
, pType
, pf
, riid
, (void **)ppint
);
266 /***********************************************************************
267 * qzdebugstr_guid (internal)
269 * Gives a text version of DirectShow GUIDs
271 const char * qzdebugstr_guid( const GUID
* id
)
276 for (i
=0;InterfaceDesc
[i
].name
&& !name
;i
++) {
277 if (IsEqualGUID(&InterfaceDesc
[i
].riid
, id
)) return InterfaceDesc
[i
].name
;
279 return debugstr_guid(id
);
282 LONG WINAPI
AmpFactorToDB(LONG ampfactor
)
284 FIXME("(%d) Stub!\n", ampfactor
);
288 LONG WINAPI
DBToAmpFactor(LONG db
)
290 FIXME("(%d) Stub!\n", db
);
291 /* Avoid divide by zero (probably during range computation) in Windows Media Player 6.4 */
297 /***********************************************************************
298 * AMGetErrorTextA (QUARTZ.@)
300 DWORD WINAPI
AMGetErrorTextA(HRESULT hr
, LPSTR buffer
, DWORD maxlen
)
303 WCHAR errorW
[MAX_ERROR_TEXT_LEN
];
305 TRACE("(%x,%p,%d)\n", hr
, buffer
, maxlen
);
309 res
= AMGetErrorTextW(hr
, errorW
, sizeof(errorW
)/sizeof(*errorW
));
310 return WideCharToMultiByte(CP_ACP
, 0, errorW
, res
, buffer
, maxlen
, 0, 0);
313 /***********************************************************************
314 * AMGetErrorTextW (QUARTZ.@)
316 DWORD WINAPI
AMGetErrorTextW(HRESULT hr
, LPWSTR buffer
, DWORD maxlen
)
319 static const WCHAR format
[] = {'E','r','r','o','r',':',' ','0','x','%','l','x',0};
320 WCHAR error
[MAX_ERROR_TEXT_LEN
];
322 FIXME("(%x,%p,%d) stub\n", hr
, buffer
, maxlen
);
324 if (!buffer
) return 0;
325 wsprintfW(error
, format
, hr
);
326 if ((len
= strlenW(error
)) >= maxlen
) return 0;
327 lstrcpyW(buffer
, error
);