winhttp/tests: Initialize a variant with a known value.
[wine/multimedia.git] / dlls / wineqtdecoder / qtdatahandler.c
blob4cca607282cf745306f662edcdc32cc79e84608b
1 /*
2 * QuickTime Data Handler
4 * Copyright 2011 Aric Stewart for CodeWeavers
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #define ULONG CoreFoundation_ULONG
24 #define HRESULT CoreFoundation_HRESULT
26 #define LoadResource __carbon_LoadResource
27 #define CompareString __carbon_CompareString
28 #define GetCurrentThread __carbon_GetCurrentThread
29 #define GetCurrentProcess __carbon_GetCurrentProcess
30 #define AnimatePalette __carbon_AnimatePalette
31 #define EqualRgn __carbon_EqualRgn
32 #define FillRgn __carbon_FillRgn
33 #define FrameRgn __carbon_FrameRgn
34 #define GetPixel __carbon_GetPixel
35 #define InvertRgn __carbon_InvertRgn
36 #define LineTo __carbon_LineTo
37 #define OffsetRgn __carbon_OffsetRgn
38 #define PaintRgn __carbon_PaintRgn
39 #define Polygon __carbon_Polygon
40 #define ResizePalette __carbon_ResizePalette
41 #define SetRectRgn __carbon_SetRectRgn
43 #define CheckMenuItem __carbon_CheckMenuItem
44 #define DeleteMenu __carbon_DeleteMenu
45 #define DrawMenuBar __carbon_DrawMenuBar
46 #define EnableMenuItem __carbon_EnableMenuItem
47 #define EqualRect __carbon_EqualRect
48 #define FillRect __carbon_FillRect
49 #define FrameRect __carbon_FrameRect
50 #define GetCursor __carbon_GetCursor
51 #define GetMenu __carbon_GetMenu
52 #define InvertRect __carbon_InvertRect
53 #define IsWindowVisible __carbon_IsWindowVisible
54 #define MoveWindow __carbon_MoveWindow
55 #define OffsetRect __carbon_OffsetRect
56 #define PtInRect __carbon_PtInRect
57 #define SetCursor __carbon_SetCursor
58 #define SetRect __carbon_SetRect
59 #define ShowCursor __carbon_ShowCursor
60 #define ShowWindow __carbon_ShowWindow
61 #define UnionRect __carbon_UnionRect
63 #include <QuickTime/QuickTimeComponents.h>
65 #undef LoadResource
66 #undef CompareString
67 #undef GetCurrentThread
68 #undef _CDECL
69 #undef DPRINTF
70 #undef GetCurrentProcess
71 #undef AnimatePalette
72 #undef EqualRgn
73 #undef FillRgn
74 #undef FrameRgn
75 #undef GetPixel
76 #undef InvertRgn
77 #undef LineTo
78 #undef OffsetRgn
79 #undef PaintRgn
80 #undef Polygon
81 #undef ResizePalette
82 #undef SetRectRgn
83 #undef CheckMenuItem
84 #undef DeleteMenu
85 #undef DrawMenuBar
86 #undef EnableMenuItem
87 #undef EqualRect
88 #undef FillRect
89 #undef FrameRect
90 #undef GetCursor
91 #undef GetMenu
92 #undef InvertRect
93 #undef IsWindowVisible
94 #undef MoveWindow
95 #undef OffsetRect
96 #undef PtInRect
97 #undef SetCursor
98 #undef SetRect
99 #undef ShowCursor
100 #undef ShowWindow
101 #undef UnionRect
103 #undef ULONG
104 #undef HRESULT
105 #undef DPRINTF
106 #undef STDMETHODCALLTYPE
108 #include <assert.h>
109 #include <stdio.h>
110 #include <stdarg.h>
112 #define NONAMELESSSTRUCT
113 #define NONAMELESSUNION
114 #define COBJMACROS
116 #include "windef.h"
117 #include "winbase.h"
118 #include "wtypes.h"
119 #include "winuser.h"
120 #include "dshow.h"
122 #include <assert.h>
124 #include "wine/unicode.h"
125 #include "wine/debug.h"
127 #include "qtprivate.h"
129 WINE_DEFAULT_DEBUG_CHANNEL(qtdatahandler);
131 static ComponentDescription myType =
133 'dhlr',
134 'WINE',
135 'WINE',
140 typedef struct DHData
142 WineDataRefRecord dataRef;
144 Ptr AsyncPtr;
145 long AsyncRefCon;
146 DataHCompletionUPP AsyncCompletionRtn;
147 } DHData;
149 static pascal ComponentResult myComponentRoutineProc ( ComponentParameters *
150 cp, Handle componentStorage);
152 void RegisterWineDataHandler( void )
154 ComponentRoutineUPP MyComponentRoutineUPP;
156 MyComponentRoutineUPP = NewComponentRoutineUPP(&myComponentRoutineProc);
157 RegisterComponent( &myType , MyComponentRoutineUPP, 0, NULL, NULL, NULL);
160 static pascal ComponentResult myDataHCanUseDataRef ( DataHandler dh,
161 Handle dataRef,
162 long *useFlags
165 WineDataRefRecord *record = (WineDataRefRecord*)(*dataRef);
166 TRACE("%p %p %p\n",dh,dataRef,useFlags);
167 if (record->pReader == NULL)
168 return badComponentSelector;
169 *useFlags = kDataHCanRead;
170 return noErr;
173 static pascal ComponentResult myDataHSetDataRef ( DataHandler dh, Handle dataRef)
175 Handle storage = GetComponentInstanceStorage(dh);
176 DHData *data = (DHData*)*storage;
177 WineDataRefRecord* newRef = (WineDataRefRecord*)(*dataRef);
178 TRACE("\n");
179 if (newRef->pReader != data->dataRef.pReader)
180 IAsyncReader_AddRef(newRef->pReader);
181 data->dataRef = *newRef;
182 return noErr;
185 static pascal ComponentResult myDataHGetAvailableFileSize ( DataHandler dh,
186 long *fileSize)
188 Handle storage = GetComponentInstanceStorage(dh);
189 DHData *data = (DHData*)*storage;
190 LONGLONG total;
191 LONGLONG avaliable;
193 TRACE("%p\n",dh);
195 IAsyncReader_Length(data->dataRef.pReader,&total,&avaliable);
196 *fileSize = avaliable;
197 return noErr;
200 static pascal ComponentResult myDataHGetFileSize ( DataHandler dh, long *fileSize)
202 Handle storage = GetComponentInstanceStorage(dh);
203 DHData *data = (DHData*)*storage;
204 LONGLONG total;
205 LONGLONG avaliable;
207 TRACE("%p\n",dh);
209 IAsyncReader_Length(data->dataRef.pReader,&total,&avaliable);
210 *fileSize = total;
211 return noErr;
214 static pascal ComponentResult myDataHScheduleData ( DataHandler dh,
215 Ptr PlaceToPutDataPtr,
216 long FileOffset,
217 long DataSize,
218 long RefCon,
219 DataHSchedulePtr scheduleRec,
220 DataHCompletionUPP CompletionRtn)
222 Handle storage = GetComponentInstanceStorage(dh);
223 DHData *data = (DHData*)*storage;
224 HRESULT hr;
225 LONGLONG offset = FileOffset;
226 BYTE* buffer = (BYTE*)PlaceToPutDataPtr;
228 TRACE("%p %p %li %li %li %p %p\n",dh, PlaceToPutDataPtr, FileOffset, DataSize, RefCon, scheduleRec, CompletionRtn);
230 hr = IAsyncReader_SyncRead(data->dataRef.pReader, offset, DataSize, buffer);
231 TRACE("result %x\n",hr);
232 if (CompletionRtn)
234 if (data->AsyncCompletionRtn)
235 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
237 data->AsyncPtr = PlaceToPutDataPtr;
238 data->AsyncRefCon = RefCon;
239 data->AsyncCompletionRtn = CompletionRtn;
242 return noErr;
245 static pascal ComponentResult myDataHFinishData (DataHandler dh, Ptr PlaceToPutDataPtr, Boolean Cancel)
247 Handle storage = GetComponentInstanceStorage(dh);
248 DHData *data = (DHData*)*storage;
249 if (!data->AsyncCompletionRtn)
250 return noErr;
251 if (!PlaceToPutDataPtr || PlaceToPutDataPtr == data->AsyncPtr)
253 if (!Cancel)
254 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
255 data->AsyncPtr = NULL;
256 data->AsyncRefCon = 0;
257 data->AsyncCompletionRtn = NULL;
259 return noErr;
262 static pascal ComponentResult myDataHGetData ( DataHandler dh,
263 Handle h,
264 long hOffset,
265 long offset,
266 long size)
268 Handle storage = GetComponentInstanceStorage(dh);
269 DHData *data = (DHData*)*storage;
270 BYTE *target = (BYTE*)*h;
271 LONGLONG off = offset;
272 HRESULT hr;
274 TRACE("%p %p %li %li %li\n",dh, h, hOffset, offset, size);
275 hr = IAsyncReader_SyncRead(data->dataRef.pReader, off, size, target+hOffset);
276 TRACE("result %x\n",hr);
278 return noErr;
281 static pascal ComponentResult myDataHCompareDataRef ( DataHandler dh,
282 Handle dataRef, Boolean *equal)
284 WineDataRefRecord *ptr1;
285 Handle storage = GetComponentInstanceStorage(dh);
286 DHData *data = (DHData*)*storage;
287 TRACE("\n");
289 ptr1 = (WineDataRefRecord*)dataRef;
291 *equal = (ptr1->pReader == data->dataRef.pReader);
292 return noErr;
295 static pascal ComponentResult myDataHGetDataRef ( DataHandler dh, Handle *dataRef)
297 Handle storage = GetComponentInstanceStorage(dh);
298 TRACE("\n");
299 *dataRef = storage;
300 HandToHand(dataRef);
301 return noErr;
304 static pascal ComponentResult myDataHGetScheduleAheadTime ( DataHandler dh,
305 long *millisecs)
307 TRACE("\n");
308 *millisecs = 1000;
309 return noErr;
312 static pascal ComponentResult myDataHGetInfoFlags ( DataHandler dh, UInt32 *flags)
314 TRACE("\n");
315 *flags = 0;
316 return noErr;
319 static pascal ComponentResult myDataHGetFileTypeOrdering ( DataHandler dh,
320 DataHFileTypeOrderingHandle *orderingListHandle)
322 OSType orderlist[1] = {kDataHFileTypeExtension};
323 TRACE("\n");
324 PtrToHand( &orderlist, (Handle*)orderingListHandle, sizeof(OSType));
325 return noErr;
328 static pascal ComponentResult myDataHGetFileName ( DataHandler dh, Str255 str)
330 Handle storage = GetComponentInstanceStorage(dh);
331 DHData *data = (DHData*)*storage;
332 TRACE("%p %s\n",str,debugstr_guid(&data->dataRef.streamSubtype));
334 /* Todo Expand this list */
335 if (IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_MPEG1Video) ||
336 IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_MPEG1System))
337 CFStringGetPascalString(CFSTR("video.mpg"),str,256,kCFStringEncodingMacRoman);
338 else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_Asf))
339 CFStringGetPascalString(CFSTR("video.asf"),str,256,kCFStringEncodingMacRoman);
340 else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_Avi))
341 CFStringGetPascalString(CFSTR("video.avi"),str,256,kCFStringEncodingMacRoman);
342 else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_QTMovie))
343 CFStringGetPascalString(CFSTR("video.mov"),str,256,kCFStringEncodingMacRoman);
344 else
345 return badComponentSelector;
347 return noErr;
350 static pascal ComponentResult myDataHOpenForRead(DataHandler dh)
352 TRACE("\n");
353 return noErr;
356 static pascal ComponentResult myDataHTask(DataHandler dh)
358 Handle storage = GetComponentInstanceStorage(dh);
359 DHData *data = (DHData*)*storage;
361 if (data->AsyncCompletionRtn)
363 TRACE("Sending Completion\n");
364 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
365 data->AsyncPtr = NULL;
366 data->AsyncRefCon = 0;
367 data->AsyncCompletionRtn = NULL;
369 return noErr;
372 static pascal ComponentResult myDataHPlaybackHints(DataHandler dh, long flags,
373 unsigned long minFileOffset, unsigned long maxFileOffset,
374 long bytesPerSecond)
376 TRACE("%lu %lu %li\n",minFileOffset, maxFileOffset, bytesPerSecond);
377 return noErr;
380 static pascal ComponentResult myDataHGetFileSize64(DataHandler dh, wide * fileSize)
382 Handle storage = GetComponentInstanceStorage(dh);
383 DHData *data = (DHData*)*storage;
384 LONGLONG total;
385 LONGLONG avaliable;
386 SInt64 total64;
388 TRACE("%p\n",dh);
390 IAsyncReader_Length(data->dataRef.pReader,&total,&avaliable);
391 total64 = total;
392 *fileSize = SInt64ToWide(total64);
393 return noErr;
396 static pascal ComponentResult myDataHGetAvailableFileSize64(DataHandler dh, wide * fileSize)
398 Handle storage = GetComponentInstanceStorage(dh);
399 DHData *data = (DHData*)*storage;
400 LONGLONG total;
401 LONGLONG avaliable;
402 SInt64 total64;
404 TRACE("%p\n",dh);
406 IAsyncReader_Length(data->dataRef.pReader,&total,&avaliable);
407 total64 = avaliable;
408 *fileSize = SInt64ToWide(total64);
409 return noErr;
412 static pascal ComponentResult myDataHScheduleData64( DataHandler dh,
413 Ptr PlaceToPutDataPtr,
414 const wide * FileOffset,
415 long DataSize,
416 long RefCon,
417 DataHSchedulePtr scheduleRec,
418 DataHCompletionUPP CompletionRtn)
420 Handle storage = GetComponentInstanceStorage(dh);
421 DHData *data = (DHData*)*storage;
422 HRESULT hr;
423 SInt64 fileOffset64 = WideToSInt64(*FileOffset);
424 LONGLONG offset = fileOffset64;
425 BYTE* buffer = (BYTE*)PlaceToPutDataPtr;
427 TRACE("%p %p %lli %li %li %p %p\n",dh, PlaceToPutDataPtr, offset, DataSize, RefCon, scheduleRec, CompletionRtn);
429 hr = IAsyncReader_SyncRead(data->dataRef.pReader, offset, DataSize, buffer);
430 TRACE("result %x\n",hr);
431 if (CompletionRtn)
433 if (data->AsyncCompletionRtn)
434 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
436 data->AsyncPtr = PlaceToPutDataPtr;
437 data->AsyncRefCon = RefCon;
438 data->AsyncCompletionRtn = CompletionRtn;
441 return noErr;
444 static const struct { LPVOID proc; ProcInfoType type;} componentFunctions[] =
446 {NULL, 0}, /* 0 */
447 {NULL, 0}, /* 1 */
448 {myDataHGetData, kPascalStackBased
449 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
450 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
451 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
452 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
453 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
454 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
455 }, /* kDataHGetDataSelect */
456 {NULL, 0}, /* kDataHPutDataSelect */
457 {NULL, 0}, /* kDataHFlushDataSelect */
458 {NULL, 0}, /* kDataHOpenForWriteSelect */
459 {NULL, 0}, /* kDataHCloseForWriteSelect */
460 {NULL, 0}, /* 7 */
461 {myDataHOpenForRead, kPascalStackBased
462 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
463 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
464 }, /* kDataHOpenForReadSelect
466 {NULL, 0}, /* kDataHCloseForReadSelect */
467 {myDataHSetDataRef, kPascalStackBased
468 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
469 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
470 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
471 }, /* kDataHSetDataRefSelect */
472 {myDataHGetDataRef, kPascalStackBased
473 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
474 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
475 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
476 }, /* kDataHGetDataRefSelect */
477 {myDataHCompareDataRef, kPascalStackBased
478 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
479 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
480 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
481 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean*)))
482 }, /* kDataHCompareDataRefSelect */
483 {myDataHTask, kPascalStackBased
484 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
485 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
486 }, /* kDataHTaskSelect */
487 {myDataHScheduleData, kPascalStackBased
488 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
489 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
490 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
491 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
492 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
493 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
494 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr)))
495 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP)))
496 }, /* kDataHScheduleDataSelect */
497 {myDataHFinishData, kPascalStackBased
498 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
499 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
500 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
501 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean)))
502 }, /* kDataHFinishDataSelect */
503 {NULL, 0}, /* kDataHFlushCacheSelect 0x10 */
504 {NULL, 0}, /* kDataHResolveDataRefSelect */
505 {myDataHGetFileSize, kPascalStackBased
506 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
507 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
508 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
509 }, /* kDataHGetFileSizeSelect */
510 {myDataHCanUseDataRef, kPascalStackBased
511 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
512 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
513 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
514 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long*)))
515 }, /* kDataHCanUseDataRefSelect */
516 {NULL, 0}, /* kDataHGetVolumeListSelect */
517 {NULL, 0}, /* kDataHWriteSelect */
518 {NULL, 0}, /* kDataHPreextendSelect */
519 {NULL, 0}, /* kDataHSetFileSizeSelect */
520 {NULL, 0}, /* kDataHGetFreeSpaceSelect */
521 {NULL, 0}, /* kDataHCreateFileSelect */
522 {NULL, 0}, /* kDataHGetPreferredBlockSizeSelect */
523 {NULL, 0}, /* kDataHGetDeviceIndexSelect */
524 {NULL, 0}, /* kDataHIsStreamingDataHandlerSelect */
525 {NULL, 0}, /* kDataHGetDataInBufferSelect */
526 {myDataHGetScheduleAheadTime, kPascalStackBased
527 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
528 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
529 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
530 }, /* kDataHGetScheduleAheadTimeSelect */
531 /* End of Required List */
532 {NULL, 0}, /* kDataHSetCacheSizeLimitSelect */
533 {NULL, 0}, /* kDataHGetCacheSizeLimitSelect 0x20 */
534 {NULL, 0}, /* kDataHGetMovieSelect */
535 {NULL, 0}, /* kDataHAddMovieSelect */
536 {NULL, 0}, /* kDataHUpdateMovieSelect */
537 {NULL, 0}, /* kDataHDoesBufferSelect */
538 {myDataHGetFileName, kPascalStackBased
539 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
540 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
541 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Str255*)))
542 }, /* kDataHGetFileNameSelect */
543 {myDataHGetAvailableFileSize, kPascalStackBased
544 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
545 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
546 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
547 }, /* kDataHGetAvailableFileSizeSelect */
548 {NULL, 0}, /* kDataHGetMacOSFileTypeSelect */
549 {NULL, 0}, /* kDataHGetMIMETypeSelect */
550 {NULL, 0}, /* kDataHSetDataRefWithAnchorSelect */
551 {NULL, 0}, /* kDataHGetDataRefWithAnchorSelect */
552 {NULL, 0}, /* kDataHSetMacOSFileTypeSelect */
553 {NULL, 0}, /* kDataHSetTimeBaseSelect */
554 {myDataHGetInfoFlags, kPascalStackBased
555 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
556 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
557 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(UInt32*)))
558 }, /* kDataHGetInfoFlagsSelect */
559 {myDataHScheduleData64, kPascalStackBased
560 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
561 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
562 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
563 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide*)))
564 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
565 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
566 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr)))
567 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP)))
568 }, /* kDataHScheduleData64Select */
569 {NULL, 0}, /* kDataHWrite64Select */
570 {myDataHGetFileSize64, kPascalStackBased
571 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
572 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
573 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide*)))
574 }, /* kDataHGetFileSize64Select 0x30 */
575 {NULL, 0}, /* kDataHPreextend64Select */
576 {NULL, 0}, /* kDataHSetFileSize64Select */
577 {NULL, 0}, /* kDataHGetFreeSpace64Select */
578 {NULL, 0}, /* kDataHAppend64Select */
579 {NULL, 0}, /* kDataHReadAsyncSelect */
580 {NULL, 0}, /* kDataHPollReadSelect */
581 {NULL, 0}, /* kDataHGetDataAvailabilitySelect */
582 {NULL, 0}, /* 0x0038 */
583 {NULL, 0}, /* 0x0039 */
584 {NULL, 0}, /* kDataHGetFileSizeAsyncSelect */
585 {NULL, 0}, /* kDataHGetDataRefAsTypeSelect */
586 {NULL, 0}, /* kDataHSetDataRefExtensionSelect */
587 {NULL, 0}, /* kDataHGetDataRefExtensionSelect */
588 {NULL, 0}, /* kDataHGetMovieWithFlagsSelect */
589 {NULL, 0}, /* 0x3F */
590 {myDataHGetFileTypeOrdering, kPascalStackBased
591 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
592 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
593 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DataHFileTypeOrderingHandle*)))
594 }, /* kDataHGetFileTypeOrderingSelect 0x40 */
595 {NULL, 0}, /* kDataHCreateFileWithFlagsSelect */
596 {NULL, 0}, /* kDataHGetMIMETypeAsyncSelect */
597 {NULL, 0}, /* kDataHGetInfoSelect */
598 {NULL, 0}, /* kDataHSetIdleManagerSelect */
599 {NULL, 0}, /* kDataHDeleteFileSelect */
600 {NULL, 0}, /* kDataHSetMovieUsageFlagsSelect */
601 {NULL, 0}, /* kDataHUseTemporaryDataRefSelect */
602 {NULL, 0}, /* kDataHGetTemporaryDataRefCapabilitiesSelect */
603 {NULL, 0}, /* kDataHRenameFileSelect */
604 {NULL, 0}, /* 0x4A */
605 {NULL, 0}, /* 0x4B */
606 {NULL, 0}, /* 0x4C */
607 {NULL, 0}, /* 0x4D */
608 {myDataHGetAvailableFileSize64, kPascalStackBased
609 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
610 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
611 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide*)))
612 }, /* kDataHGetAvailableFileSize64Select */
613 {NULL, 0}, /* kDataHGetDataAvailability64Select */
616 static const struct { LPVOID proc; ProcInfoType type;} componentFunctions_2[] =
618 {myDataHPlaybackHints, kPascalStackBased
619 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
620 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
621 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
622 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(unsigned long)))
623 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(unsigned long)))
624 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
625 }, /* kDataHPlaybackHintsSelect 0x103 */
626 {NULL, 0}, /* kDataHPlaybackHints64Select 0x10E */
627 {NULL, 0}, /* kDataHGetDataRateSelect 0x110 */
628 {NULL, 0}, /* kDataHSetTimeHintsSelect 0x111 */
631 /* Component Functions */
633 static pascal ComponentResult myComponentOpen(ComponentInstance ci, ComponentInstance self)
635 DHData myData;
636 Handle storage;
638 ZeroMemory(&myData,sizeof(DHData));
639 PtrToHand( &myData, &storage, sizeof(DHData));
640 SetComponentInstanceStorage(self,storage);
642 return noErr;
645 static pascal ComponentResult myComponentClose(ComponentInstance ci, ComponentInstance self)
647 Handle storage = GetComponentInstanceStorage(self);
648 DHData *data;
649 if (storage)
651 data = (DHData*)*storage;
652 if (data && data->dataRef.pReader != NULL)
653 IAsyncReader_Release(data->dataRef.pReader);
654 DisposeHandle(storage);
655 SetComponentInstanceStorage(self,NULL);
657 return noErr;
660 static pascal ComponentResult myComponentCanDo(ComponentInstance ci, SInt16 ftnNumber)
662 TRACE("test 0x%x\n",ftnNumber);
663 if (ftnNumber <= kComponentOpenSelect && ftnNumber >= kComponentCanDoSelect)
664 return TRUE;
665 if (ftnNumber == kDataHPlaybackHintsSelect)
666 return TRUE;
667 if (ftnNumber > kDataHGetDataAvailability64Select)
668 return FALSE;
669 TRACE("impl? %i\n",(componentFunctions[ftnNumber].proc != NULL));
670 return (componentFunctions[ftnNumber].proc != NULL);
673 /* Main Proc */
675 static ComponentResult callOurFunction(LPVOID proc, ProcInfoType type, ComponentParameters * cp)
677 ComponentRoutineUPP myUUP;
678 ComponentResult result;
680 myUUP = NewComponentFunctionUPP(proc, type);
681 result = CallComponentFunction(cp, myUUP);
682 DisposeComponentFunctionUPP(myUUP);
683 return result;
686 static pascal ComponentResult myComponentRoutineProc ( ComponentParameters * cp,
687 Handle componentStorage)
689 switch (cp->what)
691 case kComponentOpenSelect:
692 return callOurFunction(myComponentOpen, uppCallComponentOpenProcInfo, cp);
693 case kComponentCloseSelect:
694 return callOurFunction(myComponentClose, uppCallComponentOpenProcInfo, cp);
695 case kComponentCanDoSelect:
696 return callOurFunction(myComponentCanDo, uppCallComponentCanDoProcInfo, cp);
697 case kDataHPlaybackHintsSelect:
698 return callOurFunction(componentFunctions_2[0].proc, componentFunctions_2[0].type, cp);
701 if (cp->what > 0 && cp->what <=kDataHGetDataAvailability64Select && componentFunctions[cp->what].proc)
702 return callOurFunction(componentFunctions[cp->what].proc, componentFunctions[cp->what].type, cp);
704 FIXME("unhandled select 0x%x\n",cp->what);
705 return badComponentSelector;