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
20 #include "wine/debug.h"
22 #include "quartz_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
26 extern HRESULT WINAPI
QUARTZ_DllGetClassObject(REFCLSID
, REFIID
, LPVOID
*);
27 extern BOOL WINAPI
QUARTZ_DllMain(HINSTANCE
, DWORD
, LPVOID
);
29 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
31 if (reason
== DLL_PROCESS_DETACH
&& !reserved
)
33 video_window_unregister_class();
34 strmbase_release_typelibs();
36 return QUARTZ_DllMain(instance
, reason
, reserved
);
39 /******************************************************************************
40 * DirectShow ClassFactory
43 IClassFactory IClassFactory_iface
;
45 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
48 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
50 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
53 struct object_creation_info
56 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
59 static const struct object_creation_info object_creation
[] =
61 { &CLSID_ACMWrapper
, acm_wrapper_create
},
62 { &CLSID_AsyncReader
, async_reader_create
},
63 { &CLSID_AudioRender
, dsound_render_create
},
64 { &CLSID_AVIDec
, avi_dec_create
},
65 { &CLSID_DSoundRender
, dsound_render_create
},
66 { &CLSID_FilterGraph
, filter_graph_create
},
67 { &CLSID_FilterGraphNoThread
, filter_graph_no_thread_create
},
68 { &CLSID_FilterMapper
, filter_mapper_create
},
69 { &CLSID_FilterMapper2
, filter_mapper_create
},
70 { &CLSID_MemoryAllocator
, mem_allocator_create
},
71 { &CLSID_SeekingPassThru
, seeking_passthrough_create
},
72 { &CLSID_SystemClock
, system_clock_create
},
73 { &CLSID_VideoRenderer
, video_renderer_create
},
74 { &CLSID_VideoMixingRenderer
, vmr7_create
},
75 { &CLSID_VideoMixingRenderer9
, vmr9_create
},
76 { &CLSID_VideoRendererDefault
, video_renderer_default_create
},
79 static HRESULT WINAPI
DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
81 if (IsEqualGUID(riid
, &IID_IUnknown
)
82 || IsEqualGUID(riid
, &IID_IClassFactory
))
84 IClassFactory_AddRef(iface
);
90 WARN("(%p)->(%s,%p), not found\n", iface
, debugstr_guid(riid
), ppobj
);
94 static ULONG WINAPI
DSCF_AddRef(IClassFactory
*iface
)
96 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
97 return InterlockedIncrement(&This
->ref
);
100 static ULONG WINAPI
DSCF_Release(IClassFactory
*iface
)
102 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
103 ULONG ref
= InterlockedDecrement(&This
->ref
);
112 static HRESULT WINAPI
DSCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
113 REFIID riid
, void **ppobj
)
115 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
119 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
122 if(pOuter
&& !IsEqualGUID(&IID_IUnknown
, riid
))
123 return E_NOINTERFACE
;
125 if (SUCCEEDED(hres
= This
->create_instance(pOuter
, &punk
)))
127 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
128 IUnknown_Release(punk
);
133 static HRESULT WINAPI
DSCF_LockServer(IClassFactory
*iface
, BOOL lock
)
135 FIXME("iface %p, lock %d, stub!\n", iface
, lock
);
139 static const IClassFactoryVtbl DSCF_Vtbl
=
148 /*******************************************************************************
149 * DllGetClassObject [QUARTZ.@]
150 * Retrieves class object from a DLL object
153 * Docs say returns STDAPI
156 * rclsid [I] CLSID for the class object
157 * riid [I] Reference to identifier of interface for class object
158 * ppv [O] Address of variable to receive interface pointer for riid
162 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
165 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
169 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
171 if (IsEqualGUID( &IID_IClassFactory
, riid
) || IsEqualGUID( &IID_IUnknown
, riid
))
173 for (i
= 0; i
< ARRAY_SIZE(object_creation
); i
++)
175 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
177 IClassFactoryImpl
*factory
= CoTaskMemAlloc(sizeof(*factory
));
178 if (factory
== NULL
) return E_OUTOFMEMORY
;
180 factory
->IClassFactory_iface
.lpVtbl
= &DSCF_Vtbl
;
183 factory
->create_instance
= object_creation
[i
].create_instance
;
185 *ppv
= &factory
->IClassFactory_iface
;
190 return QUARTZ_DllGetClassObject( rclsid
, riid
, ppv
);
193 #define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
194 { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } , #name },
196 static const struct {
202 { { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL
}
205 /***********************************************************************
208 HRESULT CALLBACK
ICaptureGraphBuilder_FindInterface_Proxy( ICaptureGraphBuilder
*This
,
209 const GUID
*pCategory
,
214 return ICaptureGraphBuilder_RemoteFindInterface_Proxy( This
, pCategory
, pf
,
215 riid
, (IUnknown
**)ppint
);
218 HRESULT __RPC_STUB
ICaptureGraphBuilder_FindInterface_Stub( ICaptureGraphBuilder
*This
,
219 const GUID
*pCategory
,
224 return ICaptureGraphBuilder_FindInterface( This
, pCategory
, pf
, riid
, (void **)ppint
);
227 HRESULT CALLBACK
ICaptureGraphBuilder2_FindInterface_Proxy( ICaptureGraphBuilder2
*This
,
228 const GUID
*pCategory
,
234 return ICaptureGraphBuilder2_RemoteFindInterface_Proxy( This
, pCategory
, pType
,
235 pf
, riid
, (IUnknown
**)ppint
);
238 HRESULT __RPC_STUB
ICaptureGraphBuilder2_FindInterface_Stub( ICaptureGraphBuilder2
*This
,
239 const GUID
*pCategory
,
245 return ICaptureGraphBuilder2_FindInterface( This
, pCategory
, pType
, pf
, riid
, (void **)ppint
);
248 /***********************************************************************
249 * qzdebugstr_guid (internal)
251 * Gives a text version of DirectShow GUIDs
253 const char * qzdebugstr_guid( const GUID
* id
)
257 for (i
=0; InterfaceDesc
[i
].name
; i
++)
258 if (IsEqualGUID(&InterfaceDesc
[i
].riid
, id
)) return InterfaceDesc
[i
].name
;
260 return debugstr_guid(id
);
263 int WINAPI
AmpFactorToDB(int ampfactor
)
265 FIXME("(%d) Stub!\n", ampfactor
);
269 int WINAPI
DBToAmpFactor(int db
)
271 FIXME("(%d) Stub!\n", db
);
272 /* Avoid divide by zero (probably during range computation) in Windows Media Player 6.4 */
278 /***********************************************************************
279 * AMGetErrorTextA (QUARTZ.@)
281 DWORD WINAPI
AMGetErrorTextA(HRESULT hr
, LPSTR buffer
, DWORD maxlen
)
284 WCHAR errorW
[MAX_ERROR_TEXT_LEN
];
286 TRACE("hr %#lx, buffer %p, maxlen %lu.\n", hr
, buffer
, maxlen
);
291 res
= AMGetErrorTextW(hr
, errorW
, ARRAY_SIZE(errorW
));
295 res
= WideCharToMultiByte(CP_ACP
, 0, errorW
, -1, NULL
, 0, 0, 0);
296 if (res
> maxlen
|| !res
)
298 return WideCharToMultiByte(CP_ACP
, 0, errorW
, -1, buffer
, maxlen
, 0, 0) - 1;
301 /***********************************************************************
302 * AMGetErrorTextW (QUARTZ.@)
304 DWORD WINAPI
AMGetErrorTextW(HRESULT hr
, LPWSTR buffer
, DWORD maxlen
)
307 WCHAR error
[MAX_ERROR_TEXT_LEN
];
309 TRACE("hr %#lx, buffer %p, maxlen %lu.\n", hr
, buffer
, maxlen
);
311 if (!buffer
) return 0;
312 swprintf(error
, ARRAY_SIZE(error
), L
"Error: 0x%lx", hr
);
313 if ((len
= wcslen(error
)) >= maxlen
)
315 wcscpy(buffer
, error
);