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
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>
67 #undef GetCurrentThread
70 #undef GetCurrentProcess
93 #undef IsWindowVisible
106 #undef STDMETHODCALLTYPE
112 #define NONAMELESSSTRUCT
113 #define NONAMELESSUNION
124 #include "wine/unicode.h"
125 #include "wine/debug.h"
127 #include "qtprivate.h"
129 WINE_DEFAULT_DEBUG_CHANNEL(qtdatahandler);
131 static ComponentDescription myType =
140 typedef struct DHData
142 WineDataRefRecord dataRef;
146 DataHCompletionUPP AsyncCompletionRtn;
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,
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;
173 static pascal ComponentResult myDataHSetDataRef ( DataHandler dh, Handle dataRef)
175 Handle storage = GetComponentInstanceStorage(dh);
176 DHData *data = (DHData*)*storage;
177 WineDataRefRecord* newRef = (WineDataRefRecord*)(*dataRef);
179 if (newRef->pReader != data->dataRef.pReader)
180 IAsyncReader_AddRef(newRef->pReader);
181 data->dataRef = *newRef;
185 static pascal ComponentResult myDataHGetAvailableFileSize ( DataHandler dh,
188 Handle storage = GetComponentInstanceStorage(dh);
189 DHData *data = (DHData*)*storage;
195 IAsyncReader_Length(data->dataRef.pReader,&total,&avaliable);
196 *fileSize = avaliable;
200 static pascal ComponentResult myDataHGetFileSize ( DataHandler dh, long *fileSize)
202 Handle storage = GetComponentInstanceStorage(dh);
203 DHData *data = (DHData*)*storage;
209 IAsyncReader_Length(data->dataRef.pReader,&total,&avaliable);
214 static pascal ComponentResult myDataHScheduleData ( DataHandler dh,
215 Ptr PlaceToPutDataPtr,
219 DataHSchedulePtr scheduleRec,
220 DataHCompletionUPP CompletionRtn)
222 Handle storage = GetComponentInstanceStorage(dh);
223 DHData *data = (DHData*)*storage;
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);
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;
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)
251 if (!PlaceToPutDataPtr || PlaceToPutDataPtr == data->AsyncPtr)
254 InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
255 data->AsyncPtr = NULL;
256 data->AsyncRefCon = 0;
257 data->AsyncCompletionRtn = NULL;
262 static pascal ComponentResult myDataHGetData ( DataHandler dh,
268 Handle storage = GetComponentInstanceStorage(dh);
269 DHData *data = (DHData*)*storage;
270 BYTE *target = (BYTE*)*h;
271 LONGLONG off = offset;
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);
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;
289 ptr1 = (WineDataRefRecord*)dataRef;
291 *equal = (ptr1->pReader == data->dataRef.pReader);
295 static pascal ComponentResult myDataHGetDataRef ( DataHandler dh, Handle *dataRef)
297 Handle storage = GetComponentInstanceStorage(dh);
304 static pascal ComponentResult myDataHGetScheduleAheadTime ( DataHandler dh,
312 static pascal ComponentResult myDataHGetInfoFlags ( DataHandler dh, UInt32 *flags)
319 static pascal ComponentResult myDataHGetFileTypeOrdering ( DataHandler dh,
320 DataHFileTypeOrderingHandle *orderingListHandle)
322 OSType orderlist[1] = {kDataHFileTypeExtension};
324 PtrToHand( &orderlist, (Handle*)orderingListHandle, sizeof(OSType));
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);
345 return badComponentSelector;
350 static pascal ComponentResult myDataHOpenForRead(DataHandler dh)
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;
372 static pascal ComponentResult myDataHPlaybackHints(DataHandler dh, long flags,
373 unsigned long minFileOffset, unsigned long maxFileOffset,
376 TRACE("%lu %lu %li\n",minFileOffset, maxFileOffset, bytesPerSecond);
380 static pascal ComponentResult myDataHGetFileSize64(DataHandler dh, wide * fileSize)
382 Handle storage = GetComponentInstanceStorage(dh);
383 DHData *data = (DHData*)*storage;
390 IAsyncReader_Length(data->dataRef.pReader,&total,&avaliable);
392 *fileSize = SInt64ToWide(total64);
396 static pascal ComponentResult myDataHGetAvailableFileSize64(DataHandler dh, wide * fileSize)
398 Handle storage = GetComponentInstanceStorage(dh);
399 DHData *data = (DHData*)*storage;
406 IAsyncReader_Length(data->dataRef.pReader,&total,&avaliable);
408 *fileSize = SInt64ToWide(total64);
412 static pascal ComponentResult myDataHScheduleData64( DataHandler dh,
413 Ptr PlaceToPutDataPtr,
414 const wide * FileOffset,
417 DataHSchedulePtr scheduleRec,
418 DataHCompletionUPP CompletionRtn)
420 Handle storage = GetComponentInstanceStorage(dh);
421 DHData *data = (DHData*)*storage;
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);
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;
444 static const struct { LPVOID proc; ProcInfoType type;} componentFunctions[] =
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 */
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)
638 ZeroMemory(&myData,sizeof(DHData));
639 PtrToHand( &myData, &storage, sizeof(DHData));
640 SetComponentInstanceStorage(self,storage);
645 static pascal ComponentResult myComponentClose(ComponentInstance ci, ComponentInstance self)
647 Handle storage = GetComponentInstanceStorage(self);
651 data = (DHData*)*storage;
652 if (data && data->dataRef.pReader != NULL)
653 IAsyncReader_Release(data->dataRef.pReader);
654 DisposeHandle(storage);
655 SetComponentInstanceStorage(self,NULL);
660 static pascal ComponentResult myComponentCanDo(ComponentInstance ci, SInt16 ftnNumber)
662 TRACE("test 0x%x\n",ftnNumber);
663 if (ftnNumber <= kComponentOpenSelect && ftnNumber >= kComponentCanDoSelect)
665 if (ftnNumber == kDataHPlaybackHintsSelect)
667 if (ftnNumber > kDataHGetDataAvailability64Select)
669 TRACE("impl? %i\n",(componentFunctions[ftnNumber].proc != NULL));
670 return (componentFunctions[ftnNumber].proc != NULL);
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);
686 static pascal ComponentResult myComponentRoutineProc ( ComponentParameters * cp,
687 Handle componentStorage)
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;