d3d10core: Implement d3d10_device_GSSetSamplers().
[wine] / dlls / quartz / nullrenderer.c
1 /*
2  * Null Renderer (Promiscuous, not rendering anything at all!)
3  *
4  * Copyright 2004 Christian Costa
5  * Copyright 2008 Maarten Lankhorst
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include "config.h"
23
24 #define NONAMELESSSTRUCT
25 #define NONAMELESSUNION
26 #include "quartz_private.h"
27 #include "pin.h"
28
29 #include "uuids.h"
30 #include "vfwmsgs.h"
31 #include "amvideo.h"
32 #include "windef.h"
33 #include "winbase.h"
34 #include "dshow.h"
35 #include "evcode.h"
36 #include "strmif.h"
37 #include "ddraw.h"
38
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
43
44 typedef struct NullRendererImpl
45 {
46     BaseRenderer renderer;
47     IUnknown IUnknown_inner;
48     IAMFilterMiscFlags IAMFilterMiscFlags_iface;
49     IUnknown *outer_unk;
50 } NullRendererImpl;
51
52 static HRESULT WINAPI NullRenderer_DoRenderSample(BaseRenderer *iface, IMediaSample *pMediaSample)
53 {
54     return S_OK;
55 }
56
57 static HRESULT WINAPI NullRenderer_CheckMediaType(BaseRenderer *iface, const AM_MEDIA_TYPE * pmt)
58 {
59     TRACE("Not a stub!\n");
60     return S_OK;
61 }
62
63 static const BaseRendererFuncTable RendererFuncTable = {
64     NullRenderer_CheckMediaType,
65     NullRenderer_DoRenderSample,
66     /**/
67     NULL,
68     NULL,
69     NULL,
70     NULL,
71     NULL,
72     NULL,
73     NULL,
74     NULL,
75     NULL,
76     NULL,
77     /**/
78     NULL,
79     NULL,
80     NULL,
81     NULL,
82     NULL,
83 };
84
85 static inline NullRendererImpl *impl_from_IUnknown(IUnknown *iface)
86 {
87     return CONTAINING_RECORD(iface, NullRendererImpl, IUnknown_inner);
88 }
89
90 static HRESULT WINAPI NullRendererInner_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
91 {
92     NullRendererImpl *This = impl_from_IUnknown(iface);
93
94     TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
95
96     *ppv = NULL;
97
98     if (IsEqualIID(riid, &IID_IUnknown))
99         *ppv = &This->IUnknown_inner;
100     else if (IsEqualIID(riid, &IID_IAMFilterMiscFlags))
101         *ppv = &This->IAMFilterMiscFlags_iface;
102     else
103     {
104         HRESULT hr;
105         hr = BaseRendererImpl_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppv);
106         if (SUCCEEDED(hr))
107             return hr;
108     }
109
110     if (*ppv)
111     {
112         IUnknown_AddRef((IUnknown *)*ppv);
113         return S_OK;
114     }
115
116     if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow))
117         FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
118
119     return E_NOINTERFACE;
120 }
121
122 static ULONG WINAPI NullRendererInner_AddRef(IUnknown *iface)
123 {
124     NullRendererImpl *This = impl_from_IUnknown(iface);
125     return BaseFilterImpl_AddRef(&This->renderer.filter.IBaseFilter_iface);
126 }
127
128 static ULONG WINAPI NullRendererInner_Release(IUnknown *iface)
129 {
130     NullRendererImpl *This = impl_from_IUnknown(iface);
131     ULONG refCount = BaseFilterImpl_Release(&This->renderer.filter.IBaseFilter_iface);
132
133     if (!refCount)
134     {
135         TRACE("Destroying Null Renderer\n");
136         CoTaskMemFree(This);
137     }
138
139     return refCount;
140 }
141
142 static const IUnknownVtbl IInner_VTable =
143 {
144     NullRendererInner_QueryInterface,
145     NullRendererInner_AddRef,
146     NullRendererInner_Release
147 };
148
149 static inline NullRendererImpl *impl_from_IBaseFilter(IBaseFilter *iface)
150 {
151     return CONTAINING_RECORD(iface, NullRendererImpl, renderer.filter.IBaseFilter_iface);
152 }
153
154 static HRESULT WINAPI NullRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
155 {
156     NullRendererImpl *This = impl_from_IBaseFilter(iface);
157     return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
158 }
159
160 static ULONG WINAPI NullRenderer_AddRef(IBaseFilter * iface)
161 {
162     NullRendererImpl *This = impl_from_IBaseFilter(iface);
163     return IUnknown_AddRef(This->outer_unk);
164 }
165
166 static ULONG WINAPI NullRenderer_Release(IBaseFilter * iface)
167 {
168     NullRendererImpl *This = impl_from_IBaseFilter(iface);
169     return IUnknown_Release(This->outer_unk);
170 }
171
172 static const IBaseFilterVtbl NullRenderer_Vtbl =
173 {
174     NullRenderer_QueryInterface,
175     NullRenderer_AddRef,
176     NullRenderer_Release,
177     BaseFilterImpl_GetClassID,
178     BaseRendererImpl_Stop,
179     BaseRendererImpl_Pause,
180     BaseRendererImpl_Run,
181     BaseRendererImpl_GetState,
182     BaseRendererImpl_SetSyncSource,
183     BaseFilterImpl_GetSyncSource,
184     BaseFilterImpl_EnumPins,
185     BaseRendererImpl_FindPin,
186     BaseFilterImpl_QueryFilterInfo,
187     BaseFilterImpl_JoinFilterGraph,
188     BaseFilterImpl_QueryVendorInfo
189 };
190
191 static NullRendererImpl *impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags *iface)
192 {
193     return CONTAINING_RECORD(iface, NullRendererImpl, IAMFilterMiscFlags_iface);
194 }
195
196 static HRESULT WINAPI AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags *iface, REFIID riid,
197         void **ppv)
198 {
199     NullRendererImpl *This = impl_from_IAMFilterMiscFlags(iface);
200     return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
201 }
202
203 static ULONG WINAPI AMFilterMiscFlags_AddRef(IAMFilterMiscFlags *iface)
204 {
205     NullRendererImpl *This = impl_from_IAMFilterMiscFlags(iface);
206     return IUnknown_AddRef(This->outer_unk);
207 }
208
209 static ULONG WINAPI AMFilterMiscFlags_Release(IAMFilterMiscFlags *iface)
210 {
211     NullRendererImpl *This = impl_from_IAMFilterMiscFlags(iface);
212     return IUnknown_Release(This->outer_unk);
213 }
214
215 static ULONG WINAPI AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags *iface)
216 {
217     return AM_FILTER_MISC_FLAGS_IS_RENDERER;
218 }
219
220 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl = {
221     AMFilterMiscFlags_QueryInterface,
222     AMFilterMiscFlags_AddRef,
223     AMFilterMiscFlags_Release,
224     AMFilterMiscFlags_GetMiscFlags
225 };
226
227 HRESULT NullRenderer_create(IUnknown *pUnkOuter, void **ppv)
228 {
229     HRESULT hr;
230     NullRendererImpl *pNullRenderer;
231
232     TRACE("(%p, %p)\n", pUnkOuter, ppv);
233
234     *ppv = NULL;
235
236     pNullRenderer = CoTaskMemAlloc(sizeof(NullRendererImpl));
237     pNullRenderer->IUnknown_inner.lpVtbl = &IInner_VTable;
238     pNullRenderer->IAMFilterMiscFlags_iface.lpVtbl = &IAMFilterMiscFlags_Vtbl;
239
240     if (pUnkOuter)
241         pNullRenderer->outer_unk = pUnkOuter;
242     else
243         pNullRenderer->outer_unk = &pNullRenderer->IUnknown_inner;
244
245     hr = BaseRenderer_Init(&pNullRenderer->renderer, &NullRenderer_Vtbl, pUnkOuter,
246             &CLSID_NullRenderer, (DWORD_PTR)(__FILE__ ": NullRendererImpl.csFilter"),
247             &RendererFuncTable);
248
249     if (FAILED(hr))
250     {
251         BaseRendererImpl_Release(&pNullRenderer->renderer.filter.IBaseFilter_iface);
252         CoTaskMemFree(pNullRenderer);
253     }
254     else
255         *ppv = &pNullRenderer->IUnknown_inner;
256
257     return S_OK;
258 }