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