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