Added a framework for testing CreateProcess and a few tests.
[wine] / dlls / quartz / mpvdec.c
1 /*
2  * Implements MPEG Video Decoder(CLSID_CMpegVideoCodec)
3  *
4  *      FIXME - what library can we use? SMPEG??
5  *
6  *      FIXME - stub
7  *
8  * Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23  */
24
25 #include "config.h"
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winerror.h"
32 #include "strmif.h"
33 #include "control.h"
34 #include "amvideo.h"
35 #include "vfwmsgs.h"
36 #include "uuids.h"
37
38 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
40
41 #include "quartz_private.h"
42 #include "xform.h"
43 #include "mtype.h"
44
45 static const WCHAR CMPEGVideoDecoderImpl_FilterName[] =
46 {'M','P','E','G',' ','V','i','d','e','o',' ','D','e','c','o','d','e','r',0};
47
48
49 typedef struct CMPEGVideoDecoderImpl
50 {
51         AM_MEDIA_TYPE*  pmt;
52         DWORD           cmt;
53
54 } CMPEGVideoDecoderImpl;
55
56
57 /*****************************************************************************
58  *
59  *      codec-dependent stuffs  - no codec
60  *
61  */
62
63 #define NO_CODEC_IMPL
64
65 static void Codec_OnConstruct(CMPEGVideoDecoderImpl* This)
66 {
67 }
68
69 static void Codec_OnCleanup(CMPEGVideoDecoderImpl* This)
70 {
71 }
72
73 static HRESULT Codec_BeginTransform(CTransformBaseImpl* pImpl,CMPEGVideoDecoderImpl* This)
74 {
75         FIXME("no codec\n");
76         return E_NOTIMPL;
77 }
78
79 static HRESULT Codec_ProcessReceive(CTransformBaseImpl* pImpl,CMPEGVideoDecoderImpl* This,IMediaSample* pSampIn)
80 {
81         FIXME("no codec\n");
82         return E_NOTIMPL;
83 }
84
85 static HRESULT Codec_EndTransform(CTransformBaseImpl* pImpl,CMPEGVideoDecoderImpl* This)
86 {
87         FIXME("no codec\n");
88         return E_NOTIMPL;
89 }
90
91
92
93 /***************************************************************************
94  *
95  *      CMPEGVideoDecoderImpl methods
96  *
97  */
98
99 static void CMPEGVideoDecoderImpl_CleanupOutTypes(CMPEGVideoDecoderImpl* This)
100 {
101         DWORD   i;
102
103         if ( This->pmt != NULL )
104         {
105                 for ( i = 0; i < This->cmt; i++ )
106                 {
107                         QUARTZ_MediaType_Free(&This->pmt[i]);
108                 }
109                 QUARTZ_FreeMem(This->pmt);
110                 This->pmt = NULL;
111         }
112         This->cmt = 0;
113 }
114
115 static HRESULT CMPEGVideoDecoderImpl_Init( CTransformBaseImpl* pImpl )
116 {
117         CMPEGVideoDecoderImpl*  This = pImpl->m_pUserData;
118
119         TRACE("(%p)\n",This);
120
121         if ( This != NULL )
122                 return NOERROR;
123
124         This = (CMPEGVideoDecoderImpl*)QUARTZ_AllocMem( sizeof(CMPEGVideoDecoderImpl) );
125         if ( This == NULL )
126                 return E_OUTOFMEMORY;
127         ZeroMemory( This, sizeof(CMPEGVideoDecoderImpl) );
128         pImpl->m_pUserData = This;
129
130         /* construct */
131         This->pmt = NULL;
132         This->cmt = 0;
133         Codec_OnConstruct(This);
134
135         return S_OK;
136 }
137
138 static HRESULT CMPEGVideoDecoderImpl_Cleanup( CTransformBaseImpl* pImpl )
139 {
140         CMPEGVideoDecoderImpl*  This = pImpl->m_pUserData;
141
142         TRACE("(%p)\n",This);
143
144         if ( This == NULL )
145                 return S_OK;
146
147         /* destruct */
148         Codec_OnCleanup(This);
149         CMPEGVideoDecoderImpl_CleanupOutTypes(This);
150
151         QUARTZ_FreeMem( This );
152         pImpl->m_pUserData = NULL;
153
154         return S_OK;
155 }
156
157 static HRESULT CMPEGVideoDecoderImpl_CheckMediaType( CTransformBaseImpl* pImpl, const AM_MEDIA_TYPE* pmtIn, const AM_MEDIA_TYPE* pmtOut )
158 {
159         CMPEGVideoDecoderImpl*  This = pImpl->m_pUserData;
160
161         TRACE("(%p)\n",This);
162         if ( This == NULL )
163                 return E_UNEXPECTED;
164
165
166
167 #ifdef  NO_CODEC_IMPL
168         WARN("no codec implementation\n");
169         return E_NOTIMPL;
170 #else
171         return S_OK;
172 #endif
173 }
174
175 static HRESULT CMPEGVideoDecoderImpl_GetOutputTypes( CTransformBaseImpl* pImpl, const AM_MEDIA_TYPE* pmtIn, const AM_MEDIA_TYPE** ppmtAcceptTypes, ULONG* pcAcceptTypes )
176 {
177         CMPEGVideoDecoderImpl*  This = pImpl->m_pUserData;
178         HRESULT hr;
179
180         FIXME("(%p)\n",This);
181         if ( This == NULL )
182                 return E_UNEXPECTED;
183
184         hr = CMPEGVideoDecoderImpl_CheckMediaType( pImpl, pmtIn, NULL );
185         if ( FAILED(hr) )
186                 return hr;
187
188         CMPEGVideoDecoderImpl_CleanupOutTypes(This);
189
190         return E_NOTIMPL;
191 }
192
193 static HRESULT CMPEGVideoDecoderImpl_GetAllocProp( CTransformBaseImpl* pImpl, const AM_MEDIA_TYPE* pmtIn, const AM_MEDIA_TYPE* pmtOut, ALLOCATOR_PROPERTIES* pProp, BOOL* pbTransInPlace, BOOL* pbTryToReuseSample )
194 {
195         CMPEGVideoDecoderImpl*  This = pImpl->m_pUserData;
196         HRESULT hr;
197
198         FIXME("(%p)\n",This);
199         if ( This == NULL )
200                 return E_UNEXPECTED;
201
202         hr = CMPEGVideoDecoderImpl_CheckMediaType( pImpl, pmtIn, pmtOut );
203         if ( FAILED(hr) )
204                 return hr;
205
206         return E_NOTIMPL;
207 }
208
209 static HRESULT CMPEGVideoDecoderImpl_BeginTransform( CTransformBaseImpl* pImpl, const AM_MEDIA_TYPE* pmtIn, const AM_MEDIA_TYPE* pmtOut, BOOL bReuseSample )
210 {
211         CMPEGVideoDecoderImpl*  This = pImpl->m_pUserData;
212         HRESULT hr;
213
214         FIXME("(%p,%p,%p,%d)\n",This,pmtIn,pmtOut,bReuseSample);
215         if ( This == NULL )
216                 return E_UNEXPECTED;
217
218         hr = CMPEGVideoDecoderImpl_CheckMediaType( pImpl, pmtIn, pmtOut );
219         if ( FAILED(hr) )
220                 return hr;
221
222         return Codec_BeginTransform(pImpl,This);
223 }
224
225 static HRESULT CMPEGVideoDecoderImpl_ProcessReceive( CTransformBaseImpl* pImpl, IMediaSample* pSampIn )
226 {
227         CMPEGVideoDecoderImpl*  This = pImpl->m_pUserData;
228
229         FIXME("(%p)\n",This);
230         if ( This == NULL )
231                 return E_UNEXPECTED;
232
233         return Codec_ProcessReceive(pImpl,This,pSampIn);
234 }
235
236 static HRESULT CMPEGVideoDecoderImpl_EndTransform( CTransformBaseImpl* pImpl )
237 {
238         CMPEGVideoDecoderImpl*  This = pImpl->m_pUserData;
239         HRESULT hr;
240
241         FIXME("(%p)\n",This);
242         if ( This == NULL )
243                 return E_UNEXPECTED;
244
245         hr = Codec_EndTransform(pImpl,This);
246         if ( FAILED(hr) )
247                 return hr;
248
249         return S_OK;
250 }
251
252 static const TransformBaseHandlers transhandlers =
253 {
254         CMPEGVideoDecoderImpl_Init,
255         CMPEGVideoDecoderImpl_Cleanup,
256         CMPEGVideoDecoderImpl_CheckMediaType,
257         CMPEGVideoDecoderImpl_GetOutputTypes,
258         CMPEGVideoDecoderImpl_GetAllocProp,
259         CMPEGVideoDecoderImpl_BeginTransform,
260         CMPEGVideoDecoderImpl_ProcessReceive,
261         NULL,
262         CMPEGVideoDecoderImpl_EndTransform,
263 };
264
265 HRESULT QUARTZ_CreateCMpegVideoCodec(IUnknown* punkOuter,void** ppobj)
266 {
267         return QUARTZ_CreateTransformBase(
268                 punkOuter,ppobj,
269                 &CLSID_CMpegVideoCodec,
270                 CMPEGVideoDecoderImpl_FilterName,
271                 NULL, NULL,
272                 &transhandlers );
273 }
274
275
276