Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/dlls/amstream/main.c
4389 views
1
/*
2
* MultiMedia Streams Base Functions (AMSTREAM.DLL)
3
*
4
* Copyright 2004 Christian Costa
5
*
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.
10
*
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.
15
*
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
19
*/
20
21
#include <stdarg.h>
22
#include <string.h>
23
24
#define COBJMACROS
25
26
#include "windef.h"
27
#include "winbase.h"
28
#include "winuser.h"
29
#include "winerror.h"
30
31
#include "ole2.h"
32
#include "rpcproxy.h"
33
34
#include "amstream_private.h"
35
36
#include "wine/debug.h"
37
38
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
39
40
/******************************************************************************
41
* Multimedia Streams ClassFactory
42
*/
43
typedef struct {
44
IClassFactory IClassFactory_iface;
45
LONG ref;
46
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
47
} IClassFactoryImpl;
48
49
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
50
{
51
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
52
}
53
54
struct object_creation_info
55
{
56
const CLSID *clsid;
57
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
58
};
59
60
static const struct object_creation_info object_creation[] =
61
{
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 }
67
};
68
69
static HRESULT WINAPI AMCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
70
{
71
if (IsEqualGUID(riid, &IID_IUnknown)
72
|| IsEqualGUID(riid, &IID_IClassFactory))
73
{
74
IClassFactory_AddRef(iface);
75
*ppobj = iface;
76
return S_OK;
77
}
78
79
*ppobj = NULL;
80
WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
81
return E_NOINTERFACE;
82
}
83
84
static ULONG WINAPI AMCF_AddRef(IClassFactory *iface)
85
{
86
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
87
return InterlockedIncrement(&This->ref);
88
}
89
90
static ULONG WINAPI AMCF_Release(IClassFactory *iface)
91
{
92
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
93
ULONG ref = InterlockedDecrement(&This->ref);
94
95
if (ref == 0)
96
free(This);
97
98
return ref;
99
}
100
101
102
static HRESULT WINAPI AMCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
103
REFIID riid, void **ppobj)
104
{
105
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
106
HRESULT hres;
107
IUnknown *punk;
108
109
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
110
111
*ppobj = NULL;
112
hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
113
if (SUCCEEDED(hres)) {
114
hres = IUnknown_QueryInterface(punk, riid, ppobj);
115
IUnknown_Release(punk);
116
}
117
return hres;
118
}
119
120
static HRESULT WINAPI AMCF_LockServer(IClassFactory *iface, BOOL dolock)
121
{
122
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
123
FIXME("(%p)->(%d),stub!\n",This,dolock);
124
return S_OK;
125
}
126
127
static const IClassFactoryVtbl DSCF_Vtbl =
128
{
129
AMCF_QueryInterface,
130
AMCF_AddRef,
131
AMCF_Release,
132
AMCF_CreateInstance,
133
AMCF_LockServer
134
};
135
136
/*******************************************************************************
137
* DllGetClassObject [AMSTREAM.@]
138
* Retrieves class object from a DLL object
139
*
140
* NOTES
141
* Docs say returns STDAPI
142
*
143
* PARAMS
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
147
*
148
* RETURNS
149
* Success: S_OK
150
* Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
151
* E_UNEXPECTED
152
*/
153
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
154
{
155
unsigned int i;
156
IClassFactoryImpl *factory;
157
158
TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
159
160
if ( !IsEqualGUID( &IID_IClassFactory, riid )
161
&& ! IsEqualGUID( &IID_IUnknown, riid) )
162
return E_NOINTERFACE;
163
164
for (i = 0; i < ARRAY_SIZE(object_creation); i++)
165
{
166
if (IsEqualGUID(object_creation[i].clsid, rclsid))
167
break;
168
}
169
170
if (i == ARRAY_SIZE(object_creation))
171
{
172
FIXME("%s: no class found.\n", debugstr_guid(rclsid));
173
return CLASS_E_CLASSNOTAVAILABLE;
174
}
175
176
if (!(factory = calloc(1, sizeof(*factory))))
177
return E_OUTOFMEMORY;
178
179
factory->IClassFactory_iface.lpVtbl = &DSCF_Vtbl;
180
factory->ref = 1;
181
182
factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
183
184
*ppv = &factory->IClassFactory_iface;
185
return S_OK;
186
}
187
188