Fixed crashing in stopping parser.
[wine] / dlls / quartz / capgraph.c
1 /*
2  * Implementation of CLSID_CaptureGraphBuilder[2].
3  *
4  * Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *      FIXME - stub
21  *      FIXME - not tested
22  */
23
24 #include "config.h"
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winerror.h"
31 #include "strmif.h"
32 #include "control.h"
33 #include "uuids.h"
34
35 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
37
38 #include "quartz_private.h"
39 #include "capgraph.h"
40
41
42 /***************************************************************************
43  *
44  *      CCaptureGraph::ICaptureGraphBuilder
45  *
46  */
47
48 static HRESULT WINAPI
49 ICaptureGraphBuilder_fnQueryInterface(ICaptureGraphBuilder* iface,REFIID riid,void** ppobj)
50 {
51         CCaptureGraph_THIS(iface,capgraph1);
52
53         TRACE("(%p)->()\n",This);
54
55         return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
56 }
57
58 static ULONG WINAPI
59 ICaptureGraphBuilder_fnAddRef(ICaptureGraphBuilder* iface)
60 {
61         CCaptureGraph_THIS(iface,capgraph1);
62
63         TRACE("(%p)->()\n",This);
64
65         return IUnknown_AddRef(This->unk.punkControl);
66 }
67
68 static ULONG WINAPI
69 ICaptureGraphBuilder_fnRelease(ICaptureGraphBuilder* iface)
70 {
71         CCaptureGraph_THIS(iface,capgraph1);
72
73         TRACE("(%p)->()\n",This);
74
75         return IUnknown_Release(This->unk.punkControl);
76 }
77
78
79 static HRESULT WINAPI
80 ICaptureGraphBuilder_fnSetFiltergraph(ICaptureGraphBuilder* iface,IGraphBuilder* pgb)
81 {
82         CCaptureGraph_THIS(iface,capgraph1);
83
84         FIXME("(%p)->()\n",This);
85
86         return E_NOTIMPL;
87 }
88
89 static HRESULT WINAPI
90 ICaptureGraphBuilder_fnGetFiltergraph(ICaptureGraphBuilder* iface,IGraphBuilder** ppgb)
91 {
92         CCaptureGraph_THIS(iface,capgraph1);
93
94         FIXME("(%p)->()\n",This);
95
96         return E_NOTIMPL;
97 }
98
99 static HRESULT WINAPI
100 ICaptureGraphBuilder_fnSetOutputFileName(ICaptureGraphBuilder* iface,const GUID* pguidType,LPCOLESTR pName,IBaseFilter** ppFilter,IFileSinkFilter** ppSink)
101 {
102         CCaptureGraph_THIS(iface,capgraph1);
103
104         FIXME("(%p)->() stub!\n",This);
105
106         return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI
110 ICaptureGraphBuilder_fnFindInterface(ICaptureGraphBuilder* iface,const GUID* pguidCat,IBaseFilter* pFilter,REFIID riid,void** ppvobj)
111 {
112         CCaptureGraph_THIS(iface,capgraph1);
113
114         FIXME("(%p)->() stub!\n",This);
115
116         return E_NOTIMPL;
117 }
118
119 static HRESULT WINAPI
120 ICaptureGraphBuilder_fnRenderStream(ICaptureGraphBuilder* iface,const GUID* pguidCat,IUnknown* pSource,IBaseFilter* pCompressor,IBaseFilter* pRenderer)
121 {
122         CCaptureGraph_THIS(iface,capgraph1);
123
124         FIXME("(%p)->() stub!\n",This);
125
126         return E_NOTIMPL;
127 }
128
129 static HRESULT WINAPI
130 ICaptureGraphBuilder_fnControlStream(ICaptureGraphBuilder* iface,const GUID* pguidCat,IBaseFilter* pFilter,REFERENCE_TIME* prtStart,REFERENCE_TIME* prtStop,WORD wStartCookie,WORD wStopCookie)
131 {
132         CCaptureGraph_THIS(iface,capgraph1);
133
134         FIXME("(%p)->() stub!\n",This);
135
136         return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI
140 ICaptureGraphBuilder_fnAllocCapFile(ICaptureGraphBuilder* iface,LPCOLESTR pName,DWORDLONG llSize)
141 {
142         CCaptureGraph_THIS(iface,capgraph1);
143
144         FIXME("(%p)->()\n",This);
145
146         return E_NOTIMPL;
147 }
148
149 static HRESULT WINAPI
150 ICaptureGraphBuilder_fnCopyCaptureFile(ICaptureGraphBuilder* iface,LPOLESTR pOrgName,LPOLESTR pNewName,int fAllowEscAbort,IAMCopyCaptureFileProgress* pCallback)
151 {
152         CCaptureGraph_THIS(iface,capgraph1);
153
154         FIXME("(%p)->()\n",This);
155
156         return E_NOTIMPL;
157 }
158
159 static ICOM_VTABLE(ICaptureGraphBuilder) icapgraph1 =
160 {
161         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
162         /* IUnknown fields */
163         ICaptureGraphBuilder_fnQueryInterface,
164         ICaptureGraphBuilder_fnAddRef,
165         ICaptureGraphBuilder_fnRelease,
166         /* ICaptureGraphBuilder fields */
167         ICaptureGraphBuilder_fnSetFiltergraph,
168         ICaptureGraphBuilder_fnGetFiltergraph,
169         ICaptureGraphBuilder_fnSetOutputFileName,
170         ICaptureGraphBuilder_fnFindInterface,
171         ICaptureGraphBuilder_fnRenderStream,
172         ICaptureGraphBuilder_fnControlStream,
173         ICaptureGraphBuilder_fnAllocCapFile,
174         ICaptureGraphBuilder_fnCopyCaptureFile,
175 };
176
177
178 static HRESULT CCaptureGraph_InitICaptureGraphBuilder( CCaptureGraph* This )
179 {
180         TRACE("(%p)\n",This);
181         ICOM_VTBL(&This->capgraph1) = &icapgraph1;
182
183         return NOERROR;
184 }
185
186 static void CCaptureGraph_UninitICaptureGraphBuilder( CCaptureGraph* This )
187 {
188         TRACE("(%p)\n",This);
189 }
190
191
192 /***************************************************************************
193  *
194  *      new/delete for CCaptureGraph
195  *
196  */
197
198 /* can I use offsetof safely? - FIXME? */
199 static QUARTZ_IFEntry IFEntries[] =
200 {
201   { &IID_ICaptureGraphBuilder, offsetof(CCaptureGraph,capgraph1)-offsetof(CCaptureGraph,unk) },
202 };
203
204 static void QUARTZ_DestroyCaptureGraph(IUnknown* punk)
205 {
206         CCaptureGraph_THIS(punk,unk);
207
208         TRACE( "(%p)\n", This );
209
210         CCaptureGraph_UninitICaptureGraphBuilder(This);
211 }
212
213 HRESULT QUARTZ_CreateCaptureGraph(IUnknown* punkOuter,void** ppobj)
214 {
215         CCaptureGraph*  pcg;
216         HRESULT hr;
217
218         TRACE("(%p,%p)\n",punkOuter,ppobj);
219
220         pcg = (CCaptureGraph*)QUARTZ_AllocObj( sizeof(CCaptureGraph) );
221         if ( pcg == NULL )
222                 return E_OUTOFMEMORY;
223
224         QUARTZ_IUnkInit( &pcg->unk, punkOuter );
225         pcg->m_pfg = NULL;
226
227         hr = CCaptureGraph_InitICaptureGraphBuilder(pcg);
228
229         if ( FAILED(hr) )
230         {
231                 QUARTZ_FreeObj(pcg);
232                 return hr;
233         }
234
235         pcg->unk.pEntries = IFEntries;
236         pcg->unk.dwEntries = sizeof(IFEntries)/sizeof(IFEntries[0]);
237         pcg->unk.pOnFinalRelease = QUARTZ_DestroyCaptureGraph;
238
239         *ppobj = (void*)(&pcg->unk);
240
241         return S_OK;
242 }