winegstreamer: Flip YUV data before converting to RGB
[wine/multimedia.git] / dlls / quartz / nullrenderer.c
blob5d2680ffa1fbb4fcd30ffc36dfc9abdd677db6de
1 /*
2 * Null Renderer (Promiscuous, not rendering anything at all!)
4 * Copyright 2004 Christian Costa
5 * Copyright 2008 Maarten Lankhorst
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.
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.
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
22 #include "config.h"
24 #define NONAMELESSSTRUCT
25 #define NONAMELESSUNION
26 #include "quartz_private.h"
27 #include "pin.h"
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"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
44 static const IBaseFilterVtbl NullRenderer_Vtbl;
45 static const IUnknownVtbl IInner_VTable;
46 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl;
48 typedef struct NullRendererImpl
50 BaseRenderer renderer;
52 const IUnknownVtbl * IInner_vtbl;
53 const IAMFilterMiscFlagsVtbl *IAMFilterMiscFlags_vtbl;
55 IUnknown * pUnkOuter;
56 BOOL bUnkOuterValid;
57 BOOL bAggregatable;
58 } NullRendererImpl;
60 static HRESULT WINAPI NullRenderer_DoRenderSample(BaseRenderer *iface, IMediaSample *pMediaSample)
62 return S_OK;
65 static HRESULT WINAPI NullRenderer_CheckMediaType(BaseRenderer *iface, const AM_MEDIA_TYPE * pmt)
67 TRACE("Not a stub!\n");
68 return S_OK;
71 static const BaseRendererFuncTable RendererFuncTable = {
72 NullRenderer_CheckMediaType,
73 NullRenderer_DoRenderSample,
74 /**/
75 NULL,
76 NULL,
77 NULL,
78 NULL,
79 NULL,
80 NULL,
81 NULL,
82 NULL,
83 NULL,
84 NULL,
85 /**/
86 NULL,
87 NULL,
88 NULL,
89 NULL,
90 NULL,
93 HRESULT NullRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
95 HRESULT hr;
96 NullRendererImpl * pNullRenderer;
98 TRACE("(%p, %p)\n", pUnkOuter, ppv);
100 *ppv = NULL;
102 pNullRenderer = CoTaskMemAlloc(sizeof(NullRendererImpl));
103 pNullRenderer->pUnkOuter = pUnkOuter;
104 pNullRenderer->bUnkOuterValid = FALSE;
105 pNullRenderer->bAggregatable = FALSE;
106 pNullRenderer->IInner_vtbl = &IInner_VTable;
107 pNullRenderer->IAMFilterMiscFlags_vtbl = &IAMFilterMiscFlags_Vtbl;
109 hr = BaseRenderer_Init(&pNullRenderer->renderer, &NullRenderer_Vtbl, pUnkOuter, &CLSID_NullRenderer, (DWORD_PTR)(__FILE__ ": NullRendererImpl.csFilter"), &RendererFuncTable);
111 if (FAILED(hr))
113 BaseRendererImpl_Release(&pNullRenderer->renderer.filter.IBaseFilter_iface);
114 CoTaskMemFree(pNullRenderer);
116 else
117 *ppv = pNullRenderer;
119 return hr;
122 static HRESULT WINAPI NullRendererInner_QueryInterface(IUnknown * iface, REFIID riid, LPVOID * ppv)
124 ICOM_THIS_MULTI(NullRendererImpl, IInner_vtbl, iface);
125 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
127 if (This->bAggregatable)
128 This->bUnkOuterValid = TRUE;
130 *ppv = NULL;
132 if (IsEqualIID(riid, &IID_IUnknown))
133 *ppv = &This->IInner_vtbl;
134 else if (IsEqualIID(riid, &IID_IAMFilterMiscFlags))
135 *ppv = &This->IAMFilterMiscFlags_vtbl;
136 else
138 HRESULT hr;
139 hr = BaseRendererImpl_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppv);
140 if (SUCCEEDED(hr))
141 return hr;
144 if (*ppv)
146 IUnknown_AddRef((IUnknown *)(*ppv));
147 return S_OK;
150 if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow))
151 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
153 return E_NOINTERFACE;
156 static ULONG WINAPI NullRendererInner_AddRef(IUnknown * iface)
158 ICOM_THIS_MULTI(NullRendererImpl, IInner_vtbl, iface);
159 return BaseFilterImpl_AddRef(&This->renderer.filter.IBaseFilter_iface);
162 static ULONG WINAPI NullRendererInner_Release(IUnknown * iface)
164 ICOM_THIS_MULTI(NullRendererImpl, IInner_vtbl, iface);
165 ULONG refCount = BaseRendererImpl_Release(&This->renderer.filter.IBaseFilter_iface);
167 if (!refCount)
169 TRACE("Destroying Null Renderer\n");
170 CoTaskMemFree(This);
171 return 0;
173 else
174 return refCount;
177 static const IUnknownVtbl IInner_VTable =
179 NullRendererInner_QueryInterface,
180 NullRendererInner_AddRef,
181 NullRendererInner_Release
184 static HRESULT WINAPI NullRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
186 NullRendererImpl *This = (NullRendererImpl *)iface;
188 if (This->bAggregatable)
189 This->bUnkOuterValid = TRUE;
191 if (This->pUnkOuter)
193 if (This->bAggregatable)
194 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
196 if (IsEqualIID(riid, &IID_IUnknown))
198 HRESULT hr;
200 IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
201 hr = IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
202 IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
203 This->bAggregatable = TRUE;
204 return hr;
207 *ppv = NULL;
208 return E_NOINTERFACE;
211 return IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
214 static ULONG WINAPI NullRenderer_AddRef(IBaseFilter * iface)
216 NullRendererImpl *This = (NullRendererImpl *)iface;
218 if (This->pUnkOuter && This->bUnkOuterValid)
219 return IUnknown_AddRef(This->pUnkOuter);
220 return IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
223 static ULONG WINAPI NullRenderer_Release(IBaseFilter * iface)
225 NullRendererImpl *This = (NullRendererImpl *)iface;
227 if (This->pUnkOuter && This->bUnkOuterValid)
228 return IUnknown_Release(This->pUnkOuter);
229 return IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
232 static const IBaseFilterVtbl NullRenderer_Vtbl =
234 NullRenderer_QueryInterface,
235 NullRenderer_AddRef,
236 NullRenderer_Release,
237 BaseFilterImpl_GetClassID,
238 BaseRendererImpl_Stop,
239 BaseRendererImpl_Pause,
240 BaseRendererImpl_Run,
241 BaseRendererImpl_GetState,
242 BaseRendererImpl_SetSyncSource,
243 BaseFilterImpl_GetSyncSource,
244 BaseFilterImpl_EnumPins,
245 BaseRendererImpl_FindPin,
246 BaseFilterImpl_QueryFilterInfo,
247 BaseFilterImpl_JoinFilterGraph,
248 BaseFilterImpl_QueryVendorInfo
251 static NullRendererImpl *from_IAMFilterMiscFlags(IAMFilterMiscFlags *iface) {
252 return (NullRendererImpl*)((char*)iface - offsetof(NullRendererImpl, IAMFilterMiscFlags_vtbl));
255 static HRESULT WINAPI AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags *iface, REFIID riid, void **ppv) {
256 NullRendererImpl *This = from_IAMFilterMiscFlags(iface);
257 return IUnknown_QueryInterface((IUnknown*)This, riid, ppv);
260 static ULONG WINAPI AMFilterMiscFlags_AddRef(IAMFilterMiscFlags *iface) {
261 NullRendererImpl *This = from_IAMFilterMiscFlags(iface);
262 return IUnknown_AddRef((IUnknown*)This);
265 static ULONG WINAPI AMFilterMiscFlags_Release(IAMFilterMiscFlags *iface) {
266 NullRendererImpl *This = from_IAMFilterMiscFlags(iface);
267 return IUnknown_Release((IUnknown*)This);
270 static ULONG WINAPI AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags *iface) {
271 return AM_FILTER_MISC_FLAGS_IS_RENDERER;
274 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl = {
275 AMFilterMiscFlags_QueryInterface,
276 AMFilterMiscFlags_AddRef,
277 AMFilterMiscFlags_Release,
278 AMFilterMiscFlags_GetMiscFlags