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
34 #include "amstream_private.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(amstream
);
40 /******************************************************************************
41 * Multimedia Streams ClassFactory
44 IClassFactory IClassFactory_iface
;
46 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
49 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
51 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
54 struct object_creation_info
57 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
60 static const struct object_creation_info object_creation
[] =
62 { &CLSID_AMMultiMediaStream
, multimedia_stream_create
},
63 { &CLSID_AMDirectDrawStream
, ddraw_stream_create
},
64 { &CLSID_AMAudioStream
, audio_stream_create
},
65 { &CLSID_AMAudioData
, AMAudioData_create
},
66 { &CLSID_MediaStreamFilter
, filter_create
}
69 static HRESULT WINAPI
AMCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
71 if (IsEqualGUID(riid
, &IID_IUnknown
)
72 || IsEqualGUID(riid
, &IID_IClassFactory
))
74 IClassFactory_AddRef(iface
);
80 WARN("(%p)->(%s,%p), not found\n", iface
, debugstr_guid(riid
), ppobj
);
84 static ULONG WINAPI
AMCF_AddRef(IClassFactory
*iface
)
86 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
87 return InterlockedIncrement(&This
->ref
);
90 static ULONG WINAPI
AMCF_Release(IClassFactory
*iface
)
92 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
93 ULONG ref
= InterlockedDecrement(&This
->ref
);
96 HeapFree(GetProcessHeap(), 0, This
);
102 static HRESULT WINAPI
AMCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
103 REFIID riid
, void **ppobj
)
105 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
109 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
112 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
113 if (SUCCEEDED(hres
)) {
114 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
115 IUnknown_Release(punk
);
120 static HRESULT WINAPI
AMCF_LockServer(IClassFactory
*iface
, BOOL dolock
)
122 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
123 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
127 static const IClassFactoryVtbl DSCF_Vtbl
=
136 /*******************************************************************************
137 * DllGetClassObject [AMSTREAM.@]
138 * Retrieves class object from a DLL object
141 * Docs say returns STDAPI
144 * rclsid [I] CLSID for the class object
145 * riid [I] Reference to identifier of interface for class object
146 * ppv [O] Address of variable to receive interface pointer for riid
150 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
153 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
156 IClassFactoryImpl
*factory
;
158 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
160 if ( !IsEqualGUID( &IID_IClassFactory
, riid
)
161 && ! IsEqualGUID( &IID_IUnknown
, riid
) )
162 return E_NOINTERFACE
;
164 for (i
= 0; i
< ARRAY_SIZE(object_creation
); i
++)
166 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
170 if (i
== ARRAY_SIZE(object_creation
))
172 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
173 return CLASS_E_CLASSNOTAVAILABLE
;
176 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
177 if (factory
== NULL
) return E_OUTOFMEMORY
;
179 factory
->IClassFactory_iface
.lpVtbl
= &DSCF_Vtbl
;
182 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
184 *ppv
= &factory
->IClassFactory_iface
;