- Remove stub for ordinal 394 and replace with forward to
[wine] / dlls / avifil32 / avifile.c
1 /*
2  * Copyright 1999 Marcus Meissner
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include <string.h>
20 #include <stdio.h>
21 #include <assert.h>
22
23 #include "winbase.h"
24 #include "winnls.h"
25 #include "mmsystem.h"
26 #include "winerror.h"
27 #include "vfw.h"
28 #include "wine/debug.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(avifile);
31
32 static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj);
33 static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface);
34 static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface);
35 static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size);
36 static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam);
37 static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi);
38 static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size);
39 static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size);
40 static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface);
41 static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam);
42
43 struct ICOM_VTABLE(IAVIFile) iavift = {
44     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
45     IAVIFile_fnQueryInterface,
46     IAVIFile_fnAddRef,
47     IAVIFile_fnRelease,
48     IAVIFile_fnInfo,
49     IAVIFile_fnGetStream,
50     IAVIFile_fnCreateStream,
51     IAVIFile_fnWriteData,
52     IAVIFile_fnReadData,
53     IAVIFile_fnEndRecord,
54     IAVIFile_fnDeleteStream
55 };
56
57 static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj);
58 static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface);
59 static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface);
60 static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2);
61 static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size);
62 static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags);
63 static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize);
64 static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize);
65 static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread);
66 static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten);
67 static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples);
68 static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread);
69 static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size);
70 static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen);
71
72 struct ICOM_VTABLE(IAVIStream) iavist = {
73     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
74     IAVIStream_fnQueryInterface,
75     IAVIStream_fnAddRef,
76     IAVIStream_fnRelease,
77     IAVIStream_fnCreate,
78     IAVIStream_fnInfo,
79     IAVIStream_fnFindSample,
80     IAVIStream_fnReadFormat,
81     IAVIStream_fnSetFormat,
82     IAVIStream_fnRead,
83     IAVIStream_fnWrite,
84     IAVIStream_fnDelete,
85     IAVIStream_fnReadData,
86     IAVIStream_fnWriteData,
87     IAVIStream_fnSetInfo
88 };
89
90 typedef struct IAVIStreamImpl {
91         /* IUnknown stuff */
92         ICOM_VFIELD(IAVIStream);
93         DWORD           ref;
94         /* IAVIStream stuff */
95         LPVOID          lpInputFormat;
96         DWORD           inputformatsize;
97         BOOL            iscompressing;
98         DWORD           curframe;
99
100             /* Compressor stuff */
101             HIC hic;
102             LPVOID      lpCompressFormat;
103             ICINFO      icinfo;
104             DWORD       compbufsize;
105             LPVOID      compbuffer;
106
107             DWORD       decompbufsize;
108             LPVOID      decompbuffer;
109             LPVOID      decompformat;
110             AVICOMPRESSOPTIONS  aco;
111
112             LPVOID      lpPrev; /* pointer to decompressed frame later */
113             LPVOID      lpPrevFormat; /* pointer to decompressed info later */
114 } IAVIStreamImpl;
115
116 /***********************************************************************
117  *              AVIFileInit (AVIFIL32.@)
118  *              AVIFileInit (AVIFILE.100)
119  */
120 void WINAPI
121 AVIFileInit(void) {
122         FIXME("(),stub!\n");
123 }
124
125 typedef struct IAVIFileImpl {
126         /* IUnknown stuff */
127         ICOM_VFIELD(IAVIFile);
128         DWORD                           ref;
129         /* IAVIFile stuff... */
130 } IAVIFileImpl;
131
132 static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj) {
133         ICOM_THIS(IAVIFileImpl,iface);
134
135         TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
136         if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
137                 !memcmp(&IID_IAVIFile,refiid,sizeof(IID_IAVIFile))
138         ) {
139                 *obj = iface;
140                 return S_OK;
141         }
142         return OLE_E_ENUM_NOMORE;
143 }
144
145 static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface) {
146         ICOM_THIS(IAVIFileImpl,iface);
147
148         FIXME("(%p)->AddRef()\n",iface);
149         return ++(This->ref);
150 }
151
152 static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface) {
153         ICOM_THIS(IAVIFileImpl,iface);
154
155         FIXME("(%p)->Release()\n",iface);
156         if (!--(This->ref)) {
157                 HeapFree(GetProcessHeap(),0,iface);
158                 return 0;
159         }
160         return This->ref;
161 }
162
163 static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size) {
164         FIXME("(%p)->Info(%p,%ld)\n",iface,afi,size);
165
166         /* FIXME: fill out struct? */
167         return E_FAIL;
168 }
169
170 static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam) {
171         FIXME("(%p)->GetStream(%p,0x%08lx,%ld)\n",iface,avis,fccType,lParam);
172         /* FIXME: create interface etc. */
173         return E_FAIL;
174 }
175
176 static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi) {
177         ICOM_THIS(IAVIStreamImpl,iface);
178         char            fcc[5];
179         IAVIStreamImpl  *istream;
180
181         FIXME("(%p,%p,%p)\n",This,avis,asi);
182         istream = (IAVIStreamImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IAVIStreamImpl));
183         istream->ref = 1;
184         ICOM_VTBL(istream) = &iavist;
185         fcc[4]='\0';
186         memcpy(fcc,(char*)&(asi->fccType),4);
187         FIXME("\tfccType '%s'\n",fcc);
188         memcpy(fcc,(char*)&(asi->fccHandler),4);
189         FIXME("\tfccHandler '%s'\n",fcc);
190         FIXME("\tdwFlags 0x%08lx\n",asi->dwFlags);
191         FIXME("\tdwCaps 0x%08lx\n",asi->dwCaps);
192         FIXME("\tname %s\n",debugstr_w(asi->szName));
193
194         istream->curframe = 0;
195         *avis = (PAVISTREAM)istream;
196         return S_OK;
197 }
198
199 static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size) {
200         FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",iface,ckid,lpData,size);
201         /* FIXME: write data to file */
202         return E_FAIL;
203 }
204
205 static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size) {
206         FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",iface,ckid,lpData,size);
207         /* FIXME: read at most size bytes from file */
208         return E_FAIL;
209 }
210
211 static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface) {
212         FIXME("(%p)->EndRecord()\n",iface);
213         /* FIXME: end record? */
214         return E_FAIL;
215 }
216
217 static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam) {
218         FIXME("(%p)->DeleteStream(0x%08lx,%ld)\n",iface,fccType,lParam);
219         /* FIXME: delete stream? */
220         return E_FAIL;
221 }
222
223 /***********************************************************************
224  *              AVIFileOpenA (AVIFIL32.@)
225  *              AVIFileOpen  (AVIFILE.102)
226  */
227 HRESULT WINAPI AVIFileOpenA(
228         PAVIFILE * ppfile,LPCSTR szFile,UINT uMode,LPCLSID lpHandler
229 ) {
230         IAVIFileImpl    *iavi;
231
232         FIXME("(%p,%s,0x%08lx,%s),stub!\n",ppfile,szFile,(DWORD)uMode,debugstr_guid(lpHandler));
233         iavi = (IAVIFileImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IAVIFileImpl));
234         iavi->ref = 1;
235         ICOM_VTBL(iavi) = &iavift;
236         *ppfile = (LPVOID)iavi;
237         return S_OK;
238 }
239
240 static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj) {
241         ICOM_THIS(IAVIStreamImpl,iface);
242
243         TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
244         if (    !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
245                 !memcmp(&IID_IAVIStream,refiid,sizeof(IID_IAVIStream))
246         ) {
247                 *obj = This;
248                 return S_OK;
249         }
250         /* can return IGetFrame interface too */
251         return OLE_E_ENUM_NOMORE;
252 }
253
254 static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface) {
255         ICOM_THIS(IAVIStreamImpl,iface);
256
257         FIXME("(%p)->AddRef()\n",iface);
258         return ++(This->ref);
259 }
260
261 static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface) {
262         ICOM_THIS(IAVIStreamImpl,iface);
263
264         FIXME("(%p)->Release()\n",iface);
265         if (!--(This->ref)) {
266                 HeapFree(GetProcessHeap(),0,This);
267                 return 0;
268         }
269         return This->ref;
270 }
271
272 static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2) {
273         FIXME("(%p)->Create(0x%08lx,0x%08lx)\n",iface,lParam1,lParam2);
274         return E_FAIL;
275 }
276
277 static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size) {
278         FIXME("(%p)->Info(%p,%ld)\n",iface,psi,size);
279         return E_FAIL;
280 }
281
282 static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags) {
283         FIXME("(%p)->FindSample(%ld,0x%08lx)\n",iface,pos,flags);
284         return E_FAIL;
285 }
286
287 static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize) {
288         FIXME("(%p)->ReadFormat(%ld,%p,%p)\n",iface,pos,format,formatsize);
289         return E_FAIL;
290 }
291
292 /***********************************************************************
293  *              IAVIStream::SetFormat
294  */
295 static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize) {
296         IAVIStreamImpl  *as = (IAVIStreamImpl*)iface;
297
298         FIXME("(%p)->SetFormat(%ld,%p,%ld)\n",iface,pos,format,formatsize);
299         if (as->lpInputFormat) HeapFree(GetProcessHeap(),0,as->lpInputFormat);
300         as->inputformatsize = formatsize;
301         as->lpInputFormat = HeapAlloc(GetProcessHeap(),0,formatsize);
302         memcpy(as->lpInputFormat,format,formatsize);
303         if (as->iscompressing) {
304                 int     xsize;
305                 /* Set up the Compressor part */
306                 xsize = ICCompressGetFormatSize(as->hic,as->lpInputFormat);
307                 as->lpCompressFormat = HeapAlloc(GetProcessHeap(),0,xsize);
308                 ICCompressGetFormat(as->hic,as->lpInputFormat,as->lpCompressFormat);
309                 ICCompressBegin(as->hic,as->lpInputFormat,as->lpCompressFormat);
310                 as->compbufsize = ICCompressGetSize(as->hic,as->lpInputFormat,as->lpCompressFormat);
311                 as->compbuffer = HeapAlloc(GetProcessHeap(),0,as->compbufsize);
312
313                 /* Set up the Decompressor part (for prev frames?) */
314                 xsize=ICDecompressGetFormatSize(as->hic,as->lpCompressFormat);
315                 as->decompformat = HeapAlloc(GetProcessHeap(),0,xsize);
316                 ICDecompressGetFormat(as->hic,as->lpCompressFormat,as->decompformat);
317                 as->decompbufsize=((LPBITMAPINFOHEADER)as->decompbuffer)->biSizeImage;
318                 as->decompbuffer = HeapReAlloc(GetProcessHeap(),0,as->decompbuffer,as->decompbufsize);
319                 memset(as->decompbuffer,0xff,as->decompbufsize);
320                 assert(HeapValidate(GetProcessHeap(),0,NULL));
321
322                 ICDecompressGetFormat(as->hic,as->lpCompressFormat,as->decompformat);
323                 ICDecompressBegin(as->hic,as->lpCompressFormat,as->decompformat);
324                 as->lpPrev = as->lpPrevFormat = NULL;
325         }
326         return S_OK;
327 }
328
329 static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) {
330         FIXME("(%p)->Read(%ld,%ld,%p,%ld,%p,%p)\n",iface,start,samples,buffer,buffersize,bytesread,samplesread);
331         return E_FAIL;
332 }
333
334 static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) {
335         IAVIStreamImpl  *as = (IAVIStreamImpl*)iface;
336         DWORD           ckid,xflags;
337
338         FIXME("(%p)->Write(%ld,%ld,%p,%ld,0x%08lx,%p,%p)\n",iface,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
339
340         ICCompress(
341                 as->hic,flags,
342                 as->lpCompressFormat,
343                 as->compbuffer,
344                 as->lpInputFormat,buffer,
345                 &ckid,&xflags,
346                 as->curframe,0xffffff/*framesize*/,as->aco.dwQuality,
347                 as->lpPrevFormat,as->lpPrev
348         );
349         ICDecompress(
350                 as->hic,
351                 flags,  /* FIXME: check */
352                 as->lpCompressFormat,
353                 as->compbuffer,
354                 as->decompformat,
355                 as->decompbuffer
356         );
357         /* We now have a prev format for the next compress ... */
358         as->lpPrevFormat = as->decompformat;
359         as->lpPrev = as->decompbuffer;
360         return S_OK;
361 }
362
363 static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples) {
364         FIXME("(%p)->Delete(%ld,%ld)\n",iface,start,samples);
365         return E_FAIL;
366 }
367 static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread) {
368         FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",iface,fcc,lp,lpread);
369         return E_FAIL;
370 }
371
372 static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size) {
373         FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",iface,fcc,lp,size);
374         return E_FAIL;
375 }
376
377 static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen) {
378         FIXME("(%p)->SetInfo(%p,%ld)\n",iface,info,infolen);
379         return E_FAIL;
380 }
381
382 /***********************************************************************
383  *              AVIFileCreateStreamA (AVIFIL32.@)
384  */
385 HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE iface,PAVISTREAM *ppavi,AVISTREAMINFOA * psi) {
386         AVISTREAMINFOW  psiw;
387
388         /* Only the szName at the end is different */
389         memcpy(&psiw,psi,sizeof(*psi)-sizeof(psi->szName));
390         MultiByteToWideChar( CP_ACP, 0, psi->szName, -1,
391                              psiw.szName, sizeof(psiw.szName) / sizeof(WCHAR) );
392         return IAVIFile_CreateStream(iface,ppavi,&psiw);
393 }
394
395 /***********************************************************************
396  *              AVIFileCreateStreamW (AVIFIL32.@)
397  */
398 HRESULT WINAPI AVIFileCreateStreamW(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi) {
399         return IAVIFile_CreateStream(iface,avis,asi);
400 }
401
402
403 /***********************************************************************
404  *              AVIFileGetStream (AVIFIL32.@)
405  *              AVIFileGetStream (AVIFILE.143)
406  */
407 HRESULT WINAPI AVIFileGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam) {
408         return IAVIFile_GetStream(iface,avis,fccType,lParam);
409 }
410
411 /***********************************************************************
412  *              AVIFileInfoA (AVIFIL32.@)
413  */
414 HRESULT WINAPI AVIFileInfoA(PAVIFILE iface,LPAVIFILEINFOA afi,LONG size) {
415         AVIFILEINFOW    afiw;
416         HRESULT         hres;
417
418         if (size < sizeof(AVIFILEINFOA))
419                 return AVIERR_BADSIZE;
420         hres = IAVIFile_Info(iface,&afiw,sizeof(afiw));
421         memcpy(afi,&afiw,sizeof(*afi)-sizeof(afi->szFileType));
422         WideCharToMultiByte( CP_ACP, 0, afiw.szFileType, -1,
423                              afi->szFileType, sizeof(afi->szFileType), NULL, NULL );
424         afi->szFileType[sizeof(afi->szFileType)-1] = 0;
425         return hres;
426 }
427
428 /***********************************************************************
429  *              AVIStreamInfoW (AVIFIL32.@)
430  */
431 HRESULT WINAPI AVIStreamInfoW(PAVISTREAM iface,AVISTREAMINFOW *asi,LONG
432  size) {
433         return IAVIFile_Info(iface,asi,size);
434 }
435
436 /***********************************************************************
437  *              AVIStreamInfoA (AVIFIL32.@)
438  */
439 HRESULT WINAPI AVIStreamInfoA(PAVISTREAM iface,AVISTREAMINFOA *asi,LONG
440  size) {
441         AVISTREAMINFOW  asiw;
442         HRESULT                 hres;
443
444         if (size<sizeof(AVISTREAMINFOA))
445                 return AVIERR_BADSIZE;
446         hres = IAVIFile_Info(iface,&asiw,sizeof(asiw));
447         memcpy(asi,&asiw,sizeof(asiw)-sizeof(asiw.szName));
448         WideCharToMultiByte( CP_ACP, 0, asiw.szName, -1,
449                              asi->szName, sizeof(asi->szName), NULL, NULL );
450         asi->szName[sizeof(asi->szName)-1] = 0;
451         return hres;
452 }
453
454 /***********************************************************************
455  *              AVIFileInfoW (AVIFIL32.@)
456  */
457 HRESULT WINAPI AVIFileInfoW(PAVIFILE iface,LPAVIFILEINFOW afi,LONG size) {
458         return IAVIFile_Info(iface,afi,size);
459 }
460
461 /***********************************************************************
462  *              AVIMakeCompressedStream (AVIFIL32.@)
463  */
464 HRESULT WINAPI AVIMakeCompressedStream(PAVISTREAM *ppsCompressed,PAVISTREAM ppsSource,AVICOMPRESSOPTIONS *aco,CLSID *pclsidHandler) {
465         char                    fcc[5];
466         IAVIStreamImpl  *as;
467         FIXME("(%p,%p,%p,%p)\n",ppsCompressed,ppsSource,aco,pclsidHandler);
468         fcc[4]='\0';
469         memcpy(fcc,&(aco->fccType),4);
470         FIXME("\tfccType: '%s'\n",fcc);
471         memcpy(fcc,&(aco->fccHandler),4);
472         FIXME("\tfccHandler: '%s'\n",fcc);
473         FIXME("\tdwFlags: 0x%08lx\n",aco->dwFlags);
474
475         /* we just create a duplicate for now */
476         IAVIStream_AddRef(ppsSource);
477         *ppsCompressed = ppsSource;
478         as = (IAVIStreamImpl*)ppsSource;
479
480         /* this is where the fun begins. Open a compressor and prepare it. */
481         as->hic = ICOpen(aco->fccType,aco->fccHandler,ICMODE_COMPRESS);
482
483         /* May happen. for instance if the codec is not able to compress */
484         if (!as->hic)
485                 return AVIERR_UNSUPPORTED;
486
487         ICGetInfo(as->hic,&(as->icinfo),sizeof(ICINFO));
488         FIXME("Opened compressor: %s %s\n",debugstr_w(as->icinfo.szName),debugstr_w(as->icinfo.szDescription));
489         as->iscompressing = TRUE;
490         memcpy(&(as->aco),aco,sizeof(*aco));
491         if (as->icinfo.dwFlags & VIDCF_COMPRESSFRAMES) {
492                 ICCOMPRESSFRAMES        icf;
493
494                 /* now what to fill in there ... Hmm */
495                 memset(&icf,0,sizeof(icf));
496                 icf.lDataRate   = aco->dwBytesPerSecond;
497                 icf.lQuality    = aco->dwQuality;
498                 icf.lKeyRate    = aco->dwKeyFrameEvery;
499
500                 icf.GetData = (void *)0xdead4242;
501                 icf.PutData = (void *)0xdead4243;
502                 ICSendMessage(as->hic,ICM_COMPRESS_FRAMES_INFO,(LPARAM)&icf,sizeof(icf));
503         }
504         return S_OK;
505 }
506
507 /***********************************************************************
508  *              AVIStreamSetFormat (AVIFIL32.@)
509  */
510 HRESULT WINAPI AVIStreamSetFormat(PAVISTREAM iface,LONG pos,LPVOID format,LONG formatsize) {
511         return IAVIStream_SetFormat(iface,pos,format,formatsize);
512 }
513
514 /***********************************************************************
515  *              AVIStreamReadFormat (AVIFIL32.@)
516  */
517 HRESULT WINAPI AVIStreamReadFormat(PAVISTREAM iface,LONG pos,LPVOID format,LONG *formatsize) {
518         return IAVIStream_ReadFormat(iface,pos,format,formatsize);
519 }
520
521 /***********************************************************************
522  *              AVIStreamWrite (AVIFIL32.@)
523  */
524 HRESULT WINAPI AVIStreamWrite(PAVISTREAM iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) {
525         return IAVIStream_Write(iface,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
526 }
527
528 /***********************************************************************
529  *              AVIStreamRead (AVIFIL32.@)
530  */
531 HRESULT WINAPI AVIStreamRead(PAVISTREAM iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) {
532         return IAVIStream_Read(iface,start,samples,buffer,buffersize,bytesread,samplesread);
533 }
534
535 /***********************************************************************
536  *              AVIStreamWriteData (AVIFIL32.@)
537  */
538 HRESULT WINAPI AVIStreamWriteData(PAVISTREAM iface,DWORD fcc,LPVOID lp,LONG size) {
539         return IAVIStream_WriteData(iface,fcc,lp,size);
540 }
541
542 /***********************************************************************
543  *              AVIStreamReadData (AVIFIL32.@)
544  */
545 HRESULT WINAPI AVIStreamReadData(PAVISTREAM iface,DWORD fcc,LPVOID lp,LONG *lpread) {
546         return IAVIStream_ReadData(iface,fcc,lp,lpread);
547 }
548
549 /***********************************************************************
550  *              AVIStreamStart (AVIFIL32.@)
551  */
552 LONG WINAPI AVIStreamStart(PAVISTREAM iface) {
553         AVISTREAMINFOW  si;
554
555         IAVIStream_Info(iface,&si,sizeof(si));
556         return si.dwStart;
557 }
558
559 /***********************************************************************
560  *              AVIStreamLength (AVIFIL32.@)
561  */
562 LONG WINAPI AVIStreamLength(PAVISTREAM iface) {
563         AVISTREAMINFOW  si;
564         HRESULT                 ret;
565
566         ret = IAVIStream_Info(iface,&si,sizeof(si));
567         if (ret) /* error */
568                 return 1;
569         return si.dwLength;
570 }
571
572 /***********************************************************************
573  *              AVIStreamRelease (AVIFIL32.@)
574  */
575 ULONG WINAPI AVIStreamRelease(PAVISTREAM iface) {
576         return IAVIStream_Release(iface);
577 }
578
579 /***********************************************************************
580  *              AVIStreamGetFrameOpen (AVIFIL32.@)
581  */
582 PGETFRAME WINAPI AVIStreamGetFrameOpen(PAVISTREAM iface,LPBITMAPINFOHEADER bmi) {
583         FIXME("(%p)->(%p),stub!\n",iface,bmi);
584         return NULL;
585 }
586
587 /***********************************************************************
588  *              AVIStreamGetFrame (AVIFIL32.@)
589  */
590 LPVOID WINAPI AVIStreamGetFrame(PGETFRAME pg,LONG pos) {
591         return IGetFrame_GetFrame(pg,pos);
592 }
593
594 /***********************************************************************
595  *              AVIStreamGetFrameClose (AVIFIL32.@)
596  */
597 HRESULT WINAPI AVIStreamGetFrameClose(PGETFRAME pg) {
598         if (pg) IGetFrame_Release(pg);
599         return 0;
600 }
601
602 /***********************************************************************
603  *              AVIFileRelease (AVIFIL32.@)
604  *              AVIFileRelease (AVIFILE.141)
605  */
606 ULONG WINAPI AVIFileRelease(PAVIFILE iface) {
607         return IAVIFile_Release(iface);
608 }
609
610 /***********************************************************************
611  *              AVIFileExit (AVIFIL32.@)
612  *              AVIFileExit (AVIFILE.101)
613  */
614 void WINAPI AVIFileExit(void) {
615         FIXME("(), stub.\n");
616 }