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
));
329 const CFStringRef fname
;
330 const int sig_length
;
334 static const signature stream_sigs
[] = {
335 {CFSTR("video.asf"),4,{0x30,0x26,0xb2,0x75}},
336 {CFSTR("video.mov"),8,{0x00,0x00,0x00,0x14,0x66,0x74,0x79,0x70}},
337 {CFSTR("video.mp4"),8,{0x00,0x00,0x00,0x18,0x66,0x74,0x79,0x70}},
338 {CFSTR("video.m4v"),8,{0x00,0x00,0x00,0x1c,0x66,0x74,0x79,0x70}},
339 {CFSTR("video.flv"),4,{0x46,0x4C,0x56,0x01}},
340 {CFSTR("video.mpg"),3,{0x00,0x00,0x01}},
341 {CFSTR("avideo.rm"),4,{0x2E,0x52,0x4D,0x46}}
344 static pascal ComponentResult
myDataHGetFileName ( DataHandler dh
, Str255 str
)
346 Handle storage
= GetComponentInstanceStorage(dh
);
347 DHData
*data
= (DHData
*)*storage
;
348 TRACE("%p %s\n",str
,debugstr_guid(&data
->dataRef
.streamSubtype
));
350 /* Todo Expand this list */
351 if (IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_MPEG1Video
) ||
352 IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_MPEG1System
))
353 CFStringGetPascalString(CFSTR("video.mpg"),str
,256,kCFStringEncodingMacRoman
);
354 else if(IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_Asf
))
355 CFStringGetPascalString(CFSTR("video.asf"),str
,256,kCFStringEncodingMacRoman
);
356 else if(IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_Avi
))
357 CFStringGetPascalString(CFSTR("video.avi"),str
,256,kCFStringEncodingMacRoman
);
358 else if(IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_QTMovie
))
359 CFStringGetPascalString(CFSTR("video.mov"),str
,256,kCFStringEncodingMacRoman
);
362 BYTE header
[10] = {0,0,0,0,0,0,0,0,0,0};
364 IAsyncReader_SyncRead(data
->dataRef
.pReader
, 0, 8, header
);
366 for (i
=0; i
< sizeof(stream_sigs
)/sizeof(signature
); i
++)
367 if (memcmp(header
, stream_sigs
[i
].sig
, stream_sigs
[i
].sig_length
)==0)
369 CFStringGetPascalString(stream_sigs
[i
].fname
,str
,256,kCFStringEncodingMacRoman
);
373 return badComponentSelector
;
379 static pascal ComponentResult
myDataHOpenForRead(DataHandler dh
)
385 static pascal ComponentResult
myDataHTask(DataHandler dh
)
387 Handle storage
= GetComponentInstanceStorage(dh
);
388 DHData
*data
= (DHData
*)*storage
;
390 if (data
->AsyncCompletionRtn
)
392 TRACE("Sending Completion\n");
393 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
394 data
->AsyncPtr
= NULL
;
395 data
->AsyncRefCon
= 0;
396 data
->AsyncCompletionRtn
= NULL
;
401 static pascal ComponentResult
myDataHPlaybackHints(DataHandler dh
, long flags
,
402 unsigned long minFileOffset
, unsigned long maxFileOffset
,
405 TRACE("%lu %lu %li\n",minFileOffset
, maxFileOffset
, bytesPerSecond
);
409 static pascal ComponentResult
myDataHGetFileSize64(DataHandler dh
, wide
* fileSize
)
411 Handle storage
= GetComponentInstanceStorage(dh
);
412 DHData
*data
= (DHData
*)*storage
;
419 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&avaliable
);
421 *fileSize
= SInt64ToWide(total64
);
425 static pascal ComponentResult
myDataHGetAvailableFileSize64(DataHandler dh
, wide
* fileSize
)
427 Handle storage
= GetComponentInstanceStorage(dh
);
428 DHData
*data
= (DHData
*)*storage
;
435 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&avaliable
);
437 *fileSize
= SInt64ToWide(total64
);
441 static pascal ComponentResult
myDataHScheduleData64( DataHandler dh
,
442 Ptr PlaceToPutDataPtr
,
443 const wide
* FileOffset
,
446 DataHSchedulePtr scheduleRec
,
447 DataHCompletionUPP CompletionRtn
)
449 Handle storage
= GetComponentInstanceStorage(dh
);
450 DHData
*data
= (DHData
*)*storage
;
452 SInt64 fileOffset64
= WideToSInt64(*FileOffset
);
453 LONGLONG offset
= fileOffset64
;
454 BYTE
* buffer
= (BYTE
*)PlaceToPutDataPtr
;
456 TRACE("%p %p %lli %li %li %p %p\n",dh
, PlaceToPutDataPtr
, offset
, DataSize
, RefCon
, scheduleRec
, CompletionRtn
);
458 hr
= IAsyncReader_SyncRead(data
->dataRef
.pReader
, offset
, DataSize
, buffer
);
459 TRACE("result %x\n",hr
);
462 if (data
->AsyncCompletionRtn
)
463 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
465 data
->AsyncPtr
= PlaceToPutDataPtr
;
466 data
->AsyncRefCon
= RefCon
;
467 data
->AsyncCompletionRtn
= CompletionRtn
;
473 static const struct { LPVOID proc
; ProcInfoType type
;} componentFunctions
[] =
477 {myDataHGetData
, 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(long)))
482 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
483 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
484 }, /* kDataHGetDataSelect */
485 {NULL
, 0}, /* kDataHPutDataSelect */
486 {NULL
, 0}, /* kDataHFlushDataSelect */
487 {NULL
, 0}, /* kDataHOpenForWriteSelect */
488 {NULL
, 0}, /* kDataHCloseForWriteSelect */
490 {myDataHOpenForRead
, kPascalStackBased
491 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
492 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
493 }, /* kDataHOpenForReadSelect
495 {NULL
, 0}, /* kDataHCloseForReadSelect */
496 {myDataHSetDataRef
, kPascalStackBased
497 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
498 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
499 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
500 }, /* kDataHSetDataRefSelect */
501 {myDataHGetDataRef
, kPascalStackBased
502 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
503 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
504 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
505 }, /* kDataHGetDataRefSelect */
506 {myDataHCompareDataRef
, kPascalStackBased
507 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
508 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
509 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
510 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean
*)))
511 }, /* kDataHCompareDataRefSelect */
512 {myDataHTask
, kPascalStackBased
513 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
514 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
515 }, /* kDataHTaskSelect */
516 {myDataHScheduleData
, kPascalStackBased
517 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
518 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
519 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr
)))
520 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
521 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
522 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
523 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr
)))
524 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP
)))
525 }, /* kDataHScheduleDataSelect */
526 {myDataHFinishData
, 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(Ptr
)))
530 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean
)))
531 }, /* kDataHFinishDataSelect */
532 {NULL
, 0}, /* kDataHFlushCacheSelect 0x10 */
533 {NULL
, 0}, /* kDataHResolveDataRefSelect */
534 {myDataHGetFileSize
, kPascalStackBased
535 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
536 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
537 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
538 }, /* kDataHGetFileSizeSelect */
539 {myDataHCanUseDataRef
, kPascalStackBased
540 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
541 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
542 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
543 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long*)))
544 }, /* kDataHCanUseDataRefSelect */
545 {NULL
, 0}, /* kDataHGetVolumeListSelect */
546 {NULL
, 0}, /* kDataHWriteSelect */
547 {NULL
, 0}, /* kDataHPreextendSelect */
548 {NULL
, 0}, /* kDataHSetFileSizeSelect */
549 {NULL
, 0}, /* kDataHGetFreeSpaceSelect */
550 {NULL
, 0}, /* kDataHCreateFileSelect */
551 {NULL
, 0}, /* kDataHGetPreferredBlockSizeSelect */
552 {NULL
, 0}, /* kDataHGetDeviceIndexSelect */
553 {NULL
, 0}, /* kDataHIsStreamingDataHandlerSelect */
554 {NULL
, 0}, /* kDataHGetDataInBufferSelect */
555 {myDataHGetScheduleAheadTime
, kPascalStackBased
556 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
557 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
558 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
559 }, /* kDataHGetScheduleAheadTimeSelect */
560 /* End of Required List */
561 {NULL
, 0}, /* kDataHSetCacheSizeLimitSelect */
562 {NULL
, 0}, /* kDataHGetCacheSizeLimitSelect 0x20 */
563 {NULL
, 0}, /* kDataHGetMovieSelect */
564 {NULL
, 0}, /* kDataHAddMovieSelect */
565 {NULL
, 0}, /* kDataHUpdateMovieSelect */
566 {NULL
, 0}, /* kDataHDoesBufferSelect */
567 {myDataHGetFileName
, kPascalStackBased
568 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
569 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
570 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Str255
*)))
571 }, /* kDataHGetFileNameSelect */
572 {myDataHGetAvailableFileSize
, kPascalStackBased
573 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
574 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
575 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
576 }, /* kDataHGetAvailableFileSizeSelect */
577 {NULL
, 0}, /* kDataHGetMacOSFileTypeSelect */
578 {NULL
, 0}, /* kDataHGetMIMETypeSelect */
579 {NULL
, 0}, /* kDataHSetDataRefWithAnchorSelect */
580 {NULL
, 0}, /* kDataHGetDataRefWithAnchorSelect */
581 {NULL
, 0}, /* kDataHSetMacOSFileTypeSelect */
582 {NULL
, 0}, /* kDataHSetTimeBaseSelect */
583 {myDataHGetInfoFlags
, kPascalStackBased
584 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
585 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
586 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(UInt32
*)))
587 }, /* kDataHGetInfoFlagsSelect */
588 {myDataHScheduleData64
, kPascalStackBased
589 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
590 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
591 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr
)))
592 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide
*)))
593 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
594 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
595 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr
)))
596 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP
)))
597 }, /* kDataHScheduleData64Select */
598 {NULL
, 0}, /* kDataHWrite64Select */
599 {myDataHGetFileSize64
, kPascalStackBased
600 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
601 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
602 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide
*)))
603 }, /* kDataHGetFileSize64Select 0x30 */
604 {NULL
, 0}, /* kDataHPreextend64Select */
605 {NULL
, 0}, /* kDataHSetFileSize64Select */
606 {NULL
, 0}, /* kDataHGetFreeSpace64Select */
607 {NULL
, 0}, /* kDataHAppend64Select */
608 {NULL
, 0}, /* kDataHReadAsyncSelect */
609 {NULL
, 0}, /* kDataHPollReadSelect */
610 {NULL
, 0}, /* kDataHGetDataAvailabilitySelect */
611 {NULL
, 0}, /* 0x0038 */
612 {NULL
, 0}, /* 0x0039 */
613 {NULL
, 0}, /* kDataHGetFileSizeAsyncSelect */
614 {NULL
, 0}, /* kDataHGetDataRefAsTypeSelect */
615 {NULL
, 0}, /* kDataHSetDataRefExtensionSelect */
616 {NULL
, 0}, /* kDataHGetDataRefExtensionSelect */
617 {NULL
, 0}, /* kDataHGetMovieWithFlagsSelect */
618 {NULL
, 0}, /* 0x3F */
619 {myDataHGetFileTypeOrdering
, kPascalStackBased
620 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
621 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
622 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DataHFileTypeOrderingHandle
*)))
623 }, /* kDataHGetFileTypeOrderingSelect 0x40 */
624 {NULL
, 0}, /* kDataHCreateFileWithFlagsSelect */
625 {NULL
, 0}, /* kDataHGetMIMETypeAsyncSelect */
626 {NULL
, 0}, /* kDataHGetInfoSelect */
627 {NULL
, 0}, /* kDataHSetIdleManagerSelect */
628 {NULL
, 0}, /* kDataHDeleteFileSelect */
629 {NULL
, 0}, /* kDataHSetMovieUsageFlagsSelect */
630 {NULL
, 0}, /* kDataHUseTemporaryDataRefSelect */
631 {NULL
, 0}, /* kDataHGetTemporaryDataRefCapabilitiesSelect */
632 {NULL
, 0}, /* kDataHRenameFileSelect */
633 {NULL
, 0}, /* 0x4A */
634 {NULL
, 0}, /* 0x4B */
635 {NULL
, 0}, /* 0x4C */
636 {NULL
, 0}, /* 0x4D */
637 {myDataHGetAvailableFileSize64
, kPascalStackBased
638 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
639 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
640 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide
*)))
641 }, /* kDataHGetAvailableFileSize64Select */
642 {NULL
, 0}, /* kDataHGetDataAvailability64Select */
645 static const struct { LPVOID proc
; ProcInfoType type
;} componentFunctions_2
[] =
647 {myDataHPlaybackHints
, kPascalStackBased
648 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
649 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
650 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
651 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(unsigned long)))
652 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(unsigned long)))
653 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
654 }, /* kDataHPlaybackHintsSelect 0x103 */
655 {NULL
, 0}, /* kDataHPlaybackHints64Select 0x10E */
656 {NULL
, 0}, /* kDataHGetDataRateSelect 0x110 */
657 {NULL
, 0}, /* kDataHSetTimeHintsSelect 0x111 */
660 /* Component Functions */
662 static pascal ComponentResult
myComponentOpen(ComponentInstance ci
, ComponentInstance self
)
667 ZeroMemory(&myData
,sizeof(DHData
));
668 PtrToHand( &myData
, &storage
, sizeof(DHData
));
669 SetComponentInstanceStorage(self
,storage
);
674 static pascal ComponentResult
myComponentClose(ComponentInstance ci
, ComponentInstance self
)
676 Handle storage
= GetComponentInstanceStorage(self
);
680 data
= (DHData
*)*storage
;
681 if (data
&& data
->dataRef
.pReader
!= NULL
)
682 IAsyncReader_Release(data
->dataRef
.pReader
);
683 DisposeHandle(storage
);
684 SetComponentInstanceStorage(self
,NULL
);
689 static pascal ComponentResult
myComponentCanDo(ComponentInstance ci
, SInt16 ftnNumber
)
691 TRACE("test 0x%x\n",ftnNumber
);
692 if (ftnNumber
<= kComponentOpenSelect
&& ftnNumber
>= kComponentCanDoSelect
)
694 if (ftnNumber
== kDataHPlaybackHintsSelect
)
696 if (ftnNumber
> kDataHGetDataAvailability64Select
)
698 TRACE("impl? %i\n",(componentFunctions
[ftnNumber
].proc
!= NULL
));
699 return (componentFunctions
[ftnNumber
].proc
!= NULL
);
704 static ComponentResult
callOurFunction(LPVOID proc
, ProcInfoType type
, ComponentParameters
* cp
)
706 ComponentRoutineUPP myUUP
;
707 ComponentResult result
;
709 myUUP
= NewComponentFunctionUPP(proc
, type
);
710 result
= CallComponentFunction(cp
, myUUP
);
711 DisposeComponentFunctionUPP(myUUP
);
715 static pascal ComponentResult
myComponentRoutineProc ( ComponentParameters
* cp
,
716 Handle componentStorage
)
720 case kComponentOpenSelect
:
721 return callOurFunction(myComponentOpen
, uppCallComponentOpenProcInfo
, cp
);
722 case kComponentCloseSelect
:
723 return callOurFunction(myComponentClose
, uppCallComponentOpenProcInfo
, cp
);
724 case kComponentCanDoSelect
:
725 return callOurFunction(myComponentCanDo
, uppCallComponentCanDoProcInfo
, cp
);
726 case kDataHPlaybackHintsSelect
:
727 return callOurFunction(componentFunctions_2
[0].proc
, componentFunctions_2
[0].type
, cp
);
730 if (cp
->what
> 0 && cp
->what
<=kDataHGetDataAvailability64Select
&& componentFunctions
[cp
->what
].proc
)
731 return callOurFunction(componentFunctions
[cp
->what
].proc
, componentFunctions
[cp
->what
].type
, cp
);
733 FIXME("unhandled select 0x%x\n",cp
->what
);
734 return badComponentSelector
;