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