2 * MultiMedia Streams Base Functions (AMSTREAM.DLL)
4 * Copyright 2004 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_NO_STATUS
22 #define WIN32_LEAN_AND_MEAN
30 //#include "winbase.h"
31 //#include "winuser.h"
32 //#include "winerror.h"
38 #include "amstream_private.h"
41 #include <wine/debug.h>
43 WINE_DEFAULT_DEBUG_CHANNEL(amstream
);
45 static HINSTANCE instance
;
46 static DWORD dll_ref
= 0;
48 /* For the moment, do nothing here. */
49 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
52 case DLL_PROCESS_ATTACH
:
54 DisableThreadLibraryCalls(hInstDLL
);
60 /******************************************************************************
61 * Multimedia Streams ClassFactory
64 IClassFactory IClassFactory_iface
;
66 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
69 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
71 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
74 struct object_creation_info
77 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
80 static const struct object_creation_info object_creation
[] =
82 { &CLSID_AMMultiMediaStream
, AM_create
},
83 { &CLSID_AMDirectDrawStream
, AM_create
},
84 { &CLSID_AMAudioData
, AMAudioData_create
},
85 { &CLSID_MediaStreamFilter
, MediaStreamFilter_create
}
88 static HRESULT WINAPI
AMCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
90 if (IsEqualGUID(riid
, &IID_IUnknown
)
91 || IsEqualGUID(riid
, &IID_IClassFactory
))
93 IClassFactory_AddRef(iface
);
99 WARN("(%p)->(%s,%p), not found\n", iface
, debugstr_guid(riid
), ppobj
);
100 return E_NOINTERFACE
;
103 static ULONG WINAPI
AMCF_AddRef(IClassFactory
*iface
)
105 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
106 return InterlockedIncrement(&This
->ref
);
109 static ULONG WINAPI
AMCF_Release(IClassFactory
*iface
)
111 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
112 ULONG ref
= InterlockedDecrement(&This
->ref
);
115 HeapFree(GetProcessHeap(), 0, This
);
121 static HRESULT WINAPI
AMCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
122 REFIID riid
, void **ppobj
)
124 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
128 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
131 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
132 if (SUCCEEDED(hres
)) {
133 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
134 IUnknown_Release(punk
);
139 static HRESULT WINAPI
AMCF_LockServer(IClassFactory
*iface
, BOOL dolock
)
141 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
142 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
146 static const IClassFactoryVtbl DSCF_Vtbl
=
155 /*******************************************************************************
156 * DllGetClassObject [AMSTREAM.@]
157 * Retrieves class object from a DLL object
160 * Docs say returns STDAPI
163 * rclsid [I] CLSID for the class object
164 * riid [I] Reference to identifier of interface for class object
165 * ppv [O] Address of variable to receive interface pointer for riid
169 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
172 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
175 IClassFactoryImpl
*factory
;
177 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
179 if ( !IsEqualGUID( &IID_IClassFactory
, riid
)
180 && ! IsEqualGUID( &IID_IUnknown
, riid
) )
181 return E_NOINTERFACE
;
183 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
185 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
189 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
191 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
192 return CLASS_E_CLASSNOTAVAILABLE
;
195 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
196 if (factory
== NULL
) return E_OUTOFMEMORY
;
198 factory
->IClassFactory_iface
.lpVtbl
= &DSCF_Vtbl
;
201 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
203 *ppv
= &factory
->IClassFactory_iface
;
207 /***********************************************************************
208 * DllCanUnloadNow (AMSTREAM.@)
210 HRESULT WINAPI
DllCanUnloadNow(void)
212 return dll_ref
!= 0 ? S_FALSE
: S_OK
;
215 /***********************************************************************
216 * DllRegisterServer (AMSTREAM.@)
218 HRESULT WINAPI
DllRegisterServer(void)
220 return __wine_register_resources( instance
);
223 /***********************************************************************
224 * DllUnregisterServer (AMSTREAM.@)
226 HRESULT WINAPI
DllUnregisterServer(void)
228 return __wine_unregister_resources( instance
);