2 * MultiMedia Streams Base Functions (AMSTREAM.DLL)
4 * Copyright 2004 Christian Costa
6 * This file contains the (internal) driver registration functions,
7 * driver enumeration APIs and DirectDraw creation functions.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
37 #include "amstream_private.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(amstream
);
44 static HINSTANCE instance
;
45 static DWORD dll_ref
= 0;
47 /* For the moment, do nothing here. */
48 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
51 case DLL_PROCESS_ATTACH
:
53 DisableThreadLibraryCalls(hInstDLL
);
55 case DLL_PROCESS_DETACH
:
61 /******************************************************************************
62 * Multimedia Streams ClassFactory
65 IClassFactory ITF_IClassFactory
;
68 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
71 struct object_creation_info
74 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
77 static const struct object_creation_info object_creation
[] =
79 { &CLSID_AMMultiMediaStream
, AM_create
},
80 { &CLSID_AMDirectDrawStream
, AM_create
},
81 { &CLSID_MediaStreamFilter
, MediaStreamFilter_create
}
85 AMCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
87 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
89 if (IsEqualGUID(riid
, &IID_IUnknown
)
90 || IsEqualGUID(riid
, &IID_IClassFactory
))
92 IClassFactory_AddRef(iface
);
97 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
101 static ULONG WINAPI
AMCF_AddRef(LPCLASSFACTORY iface
)
103 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
104 return InterlockedIncrement(&This
->ref
);
107 static ULONG WINAPI
AMCF_Release(LPCLASSFACTORY iface
)
109 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
111 ULONG ref
= InterlockedDecrement(&This
->ref
);
114 HeapFree(GetProcessHeap(), 0, This
);
120 static HRESULT WINAPI
AMCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
121 REFIID riid
, LPVOID
*ppobj
)
123 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
127 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
130 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
131 if (SUCCEEDED(hres
)) {
132 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
133 IUnknown_Release(punk
);
138 static HRESULT WINAPI
AMCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
140 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
141 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
145 static const IClassFactoryVtbl DSCF_Vtbl
=
154 /*******************************************************************************
155 * DllGetClassObject [AMSTREAM.@]
156 * Retrieves class object from a DLL object
159 * Docs say returns STDAPI
162 * rclsid [I] CLSID for the class object
163 * riid [I] Reference to identifier of interface for class object
164 * ppv [O] Address of variable to receive interface pointer for riid
168 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
171 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
174 IClassFactoryImpl
*factory
;
176 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
178 if ( !IsEqualGUID( &IID_IClassFactory
, riid
)
179 && ! IsEqualGUID( &IID_IUnknown
, riid
) )
180 return E_NOINTERFACE
;
182 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
184 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
188 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
190 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
191 return CLASS_E_CLASSNOTAVAILABLE
;
194 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
195 if (factory
== NULL
) return E_OUTOFMEMORY
;
197 factory
->ITF_IClassFactory
.lpVtbl
= &DSCF_Vtbl
;
200 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
202 *ppv
= &(factory
->ITF_IClassFactory
);
206 /***********************************************************************
207 * DllCanUnloadNow (AMSTREAM.@)
209 HRESULT WINAPI
DllCanUnloadNow(void)
211 return dll_ref
!= 0 ? S_FALSE
: S_OK
;
214 /***********************************************************************
215 * DllRegisterServer (AMSTREAM.@)
217 HRESULT WINAPI
DllRegisterServer(void)
219 return __wine_register_resources( instance
);
222 /***********************************************************************
223 * DllUnregisterServer (AMSTREAM.@)
225 HRESULT WINAPI
DllUnregisterServer(void)
227 return __wine_unregister_resources( instance
);