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
122 #include "wine/unicode.h"
123 #include "wine/debug.h"
125 #include "qtprivate.h"
127 WINE_DEFAULT_DEBUG_CHANNEL(qtdatahandler
);
129 static ComponentDescription myType
=
138 typedef struct DHData
140 WineDataRefRecord dataRef
;
144 DataHCompletionUPP AsyncCompletionRtn
;
147 static pascal ComponentResult
myComponentRoutineProc ( ComponentParameters
*
148 cp
, Handle componentStorage
);
150 void RegisterWineDataHandler( void )
152 ComponentRoutineUPP MyComponentRoutineUPP
;
154 MyComponentRoutineUPP
= NewComponentRoutineUPP(&myComponentRoutineProc
);
155 RegisterComponent( &myType
, MyComponentRoutineUPP
, 0, NULL
, NULL
, NULL
);
158 static pascal ComponentResult
myDataHCanUseDataRef ( DataHandler dh
,
163 WineDataRefRecord
*record
= (WineDataRefRecord
*)(*dataRef
);
164 TRACE("%p %p %p\n",dh
,dataRef
,useFlags
);
165 if (record
->pReader
== NULL
)
166 return badComponentSelector
;
167 *useFlags
= kDataHCanRead
;
171 static pascal ComponentResult
myDataHSetDataRef ( DataHandler dh
, Handle dataRef
)
173 Handle storage
= GetComponentInstanceStorage(dh
);
174 DHData
*data
= (DHData
*)*storage
;
175 WineDataRefRecord
* newRef
= (WineDataRefRecord
*)(*dataRef
);
177 if (newRef
->pReader
!= data
->dataRef
.pReader
)
178 IAsyncReader_AddRef(newRef
->pReader
);
179 data
->dataRef
= *newRef
;
183 static pascal ComponentResult
myDataHGetAvailableFileSize ( DataHandler dh
,
186 Handle storage
= GetComponentInstanceStorage(dh
);
187 DHData
*data
= (DHData
*)*storage
;
193 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
194 *fileSize
= available
;
198 static pascal ComponentResult
myDataHGetFileSize ( DataHandler dh
, long *fileSize
)
200 Handle storage
= GetComponentInstanceStorage(dh
);
201 DHData
*data
= (DHData
*)*storage
;
207 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
212 static pascal ComponentResult
myDataHScheduleData ( DataHandler dh
,
213 Ptr PlaceToPutDataPtr
,
217 DataHSchedulePtr scheduleRec
,
218 DataHCompletionUPP CompletionRtn
)
220 Handle storage
= GetComponentInstanceStorage(dh
);
221 DHData
*data
= (DHData
*)*storage
;
223 LONGLONG offset
= FileOffset
;
224 BYTE
* buffer
= (BYTE
*)PlaceToPutDataPtr
;
226 TRACE("%p %p %li %li %li %p %p\n",dh
, PlaceToPutDataPtr
, FileOffset
, DataSize
, RefCon
, scheduleRec
, CompletionRtn
);
228 hr
= IAsyncReader_SyncRead(data
->dataRef
.pReader
, offset
, DataSize
, buffer
);
229 TRACE("result %x\n",hr
);
232 if (data
->AsyncCompletionRtn
)
233 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
235 data
->AsyncPtr
= PlaceToPutDataPtr
;
236 data
->AsyncRefCon
= RefCon
;
237 data
->AsyncCompletionRtn
= CompletionRtn
;
243 static pascal ComponentResult
myDataHFinishData (DataHandler dh
, Ptr PlaceToPutDataPtr
, Boolean Cancel
)
245 Handle storage
= GetComponentInstanceStorage(dh
);
246 DHData
*data
= (DHData
*)*storage
;
247 if (!data
->AsyncCompletionRtn
)
249 if (!PlaceToPutDataPtr
|| PlaceToPutDataPtr
== data
->AsyncPtr
)
252 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
253 data
->AsyncPtr
= NULL
;
254 data
->AsyncRefCon
= 0;
255 data
->AsyncCompletionRtn
= NULL
;
260 static pascal ComponentResult
myDataHGetData ( DataHandler dh
,
266 Handle storage
= GetComponentInstanceStorage(dh
);
267 DHData
*data
= (DHData
*)*storage
;
268 BYTE
*target
= (BYTE
*)*h
;
269 LONGLONG off
= offset
;
272 TRACE("%p %p %li %li %li\n",dh
, h
, hOffset
, offset
, size
);
273 hr
= IAsyncReader_SyncRead(data
->dataRef
.pReader
, off
, size
, target
+hOffset
);
274 TRACE("result %x\n",hr
);
279 static pascal ComponentResult
myDataHCompareDataRef ( DataHandler dh
,
280 Handle dataRef
, Boolean
*equal
)
282 WineDataRefRecord
*ptr1
;
283 Handle storage
= GetComponentInstanceStorage(dh
);
284 DHData
*data
= (DHData
*)*storage
;
287 ptr1
= (WineDataRefRecord
*)dataRef
;
289 *equal
= (ptr1
->pReader
== data
->dataRef
.pReader
);
293 static pascal ComponentResult
myDataHGetDataRef ( DataHandler dh
, Handle
*dataRef
)
295 Handle storage
= GetComponentInstanceStorage(dh
);
302 static pascal ComponentResult
myDataHGetScheduleAheadTime ( DataHandler dh
,
310 static pascal ComponentResult
myDataHGetInfoFlags ( DataHandler dh
, UInt32
*flags
)
317 static pascal ComponentResult
myDataHGetFileTypeOrdering ( DataHandler dh
,
318 DataHFileTypeOrderingHandle
*orderingListHandle
)
320 OSType orderlist
[1] = {kDataHFileTypeExtension
};
322 PtrToHand( &orderlist
, (Handle
*)orderingListHandle
, sizeof(OSType
));
327 const CFStringRef fname
;
328 const int sig_length
;
332 static const signature stream_sigs
[] = {
333 {CFSTR("video.asf"),4,{0x30,0x26,0xb2,0x75}},
334 {CFSTR("video.mov"),8,{0x00,0x00,0x00,0x14,0x66,0x74,0x79,0x70}},
335 {CFSTR("video.mp4"),8,{0x00,0x00,0x00,0x18,0x66,0x74,0x79,0x70}},
336 {CFSTR("video.m4v"),8,{0x00,0x00,0x00,0x1c,0x66,0x74,0x79,0x70}},
337 {CFSTR("video.flv"),4,{0x46,0x4C,0x56,0x01}},
338 {CFSTR("video.mpg"),3,{0x00,0x00,0x01}},
339 {CFSTR("avideo.rm"),4,{0x2E,0x52,0x4D,0x46}}
342 static pascal ComponentResult
myDataHGetFileName ( DataHandler dh
, Str255 str
)
344 Handle storage
= GetComponentInstanceStorage(dh
);
345 DHData
*data
= (DHData
*)*storage
;
346 TRACE("%p %s\n",str
,debugstr_guid(&data
->dataRef
.streamSubtype
));
348 /* Todo Expand this list */
349 if (IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_MPEG1Video
) ||
350 IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_MPEG1System
))
351 CFStringGetPascalString(CFSTR("video.mpg"),str
,256,kCFStringEncodingMacRoman
);
352 else if(IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_Asf
))
353 CFStringGetPascalString(CFSTR("video.asf"),str
,256,kCFStringEncodingMacRoman
);
354 else if(IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_Avi
))
355 CFStringGetPascalString(CFSTR("video.avi"),str
,256,kCFStringEncodingMacRoman
);
356 else if(IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_QTMovie
))
357 CFStringGetPascalString(CFSTR("video.mov"),str
,256,kCFStringEncodingMacRoman
);
360 BYTE header
[10] = {0,0,0,0,0,0,0,0,0,0};
362 IAsyncReader_SyncRead(data
->dataRef
.pReader
, 0, 8, header
);
364 for (i
=0; i
< sizeof(stream_sigs
)/sizeof(signature
); i
++)
365 if (memcmp(header
, stream_sigs
[i
].sig
, stream_sigs
[i
].sig_length
)==0)
367 CFStringGetPascalString(stream_sigs
[i
].fname
,str
,256,kCFStringEncodingMacRoman
);
371 return badComponentSelector
;
377 static pascal ComponentResult
myDataHOpenForRead(DataHandler dh
)
383 static pascal ComponentResult
myDataHTask(DataHandler dh
)
385 Handle storage
= GetComponentInstanceStorage(dh
);
386 DHData
*data
= (DHData
*)*storage
;
388 if (data
->AsyncCompletionRtn
)
390 TRACE("Sending Completion\n");
391 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
392 data
->AsyncPtr
= NULL
;
393 data
->AsyncRefCon
= 0;
394 data
->AsyncCompletionRtn
= NULL
;
399 static pascal ComponentResult
myDataHPlaybackHints(DataHandler dh
, long flags
,
400 unsigned long minFileOffset
, unsigned long maxFileOffset
,
403 TRACE("%lu %lu %li\n",minFileOffset
, maxFileOffset
, bytesPerSecond
);
407 static pascal ComponentResult
myDataHPlaybackHints64(DataHandler dh
, long flags
,
408 wide
*minFileOffset
, wide
*maxFileOffset
,
411 if (TRACE_ON(qtdatahandler
))
413 SInt64 minFileOffset64
= WideToSInt64(*minFileOffset
);
414 LONGLONG minFileOffsetLL
= minFileOffset64
;
415 SInt64 maxFileOffset64
= WideToSInt64(*maxFileOffset
);
416 LONGLONG maxFileOffsetLL
= maxFileOffset64
;
418 TRACE("%s %s %li\n",wine_dbgstr_longlong(minFileOffsetLL
), wine_dbgstr_longlong(maxFileOffsetLL
), bytesPerSecond
);
423 static pascal ComponentResult
myDataHGetFileSize64(DataHandler dh
, wide
* fileSize
)
425 Handle storage
= GetComponentInstanceStorage(dh
);
426 DHData
*data
= (DHData
*)*storage
;
433 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
435 *fileSize
= SInt64ToWide(total64
);
439 static pascal ComponentResult
myDataHGetFileSizeAsync ( DataHandler dh
, wide
*fileSize
, DataHCompletionUPP CompletionRtn
, long RefCon
)
441 Handle storage
= GetComponentInstanceStorage(dh
);
442 DHData
*data
= (DHData
*)*storage
;
449 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
451 *fileSize
= SInt64ToWide(total64
);
455 if (data
->AsyncCompletionRtn
)
456 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
458 data
->AsyncPtr
= (Ptr
)fileSize
;
459 data
->AsyncRefCon
= RefCon
;
460 data
->AsyncCompletionRtn
= CompletionRtn
;
466 static pascal ComponentResult
myDataHGetAvailableFileSize64(DataHandler dh
, wide
* fileSize
)
468 Handle storage
= GetComponentInstanceStorage(dh
);
469 DHData
*data
= (DHData
*)*storage
;
476 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
478 *fileSize
= SInt64ToWide(total64
);
482 static pascal ComponentResult
myDataHScheduleData64( DataHandler dh
,
483 Ptr PlaceToPutDataPtr
,
484 const wide
* FileOffset
,
487 DataHSchedulePtr scheduleRec
,
488 DataHCompletionUPP CompletionRtn
)
490 Handle storage
= GetComponentInstanceStorage(dh
);
491 DHData
*data
= (DHData
*)*storage
;
493 SInt64 fileOffset64
= WideToSInt64(*FileOffset
);
494 LONGLONG offset
= fileOffset64
;
495 BYTE
* buffer
= (BYTE
*)PlaceToPutDataPtr
;
497 TRACE("%p %p %s %li %li %p %p\n",dh
, PlaceToPutDataPtr
, wine_dbgstr_longlong(offset
), DataSize
, RefCon
, scheduleRec
, CompletionRtn
);
499 hr
= IAsyncReader_SyncRead(data
->dataRef
.pReader
, offset
, DataSize
, buffer
);
500 TRACE("result %x\n",hr
);
503 if (data
->AsyncCompletionRtn
)
504 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
506 data
->AsyncPtr
= PlaceToPutDataPtr
;
507 data
->AsyncRefCon
= RefCon
;
508 data
->AsyncCompletionRtn
= CompletionRtn
;
514 static const struct { LPVOID proc
; ProcInfoType type
;} componentFunctions
[] =
518 {myDataHGetData
, kPascalStackBased
519 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
520 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
521 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
522 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
523 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
524 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
525 }, /* kDataHGetDataSelect */
526 {NULL
, 0}, /* kDataHPutDataSelect */
527 {NULL
, 0}, /* kDataHFlushDataSelect */
528 {NULL
, 0}, /* kDataHOpenForWriteSelect */
529 {NULL
, 0}, /* kDataHCloseForWriteSelect */
531 {myDataHOpenForRead
, kPascalStackBased
532 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
533 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
534 }, /* kDataHOpenForReadSelect
536 {NULL
, 0}, /* kDataHCloseForReadSelect */
537 {myDataHSetDataRef
, kPascalStackBased
538 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
539 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
540 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
541 }, /* kDataHSetDataRefSelect */
542 {myDataHGetDataRef
, kPascalStackBased
543 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
544 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
545 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
546 }, /* kDataHGetDataRefSelect */
547 {myDataHCompareDataRef
, kPascalStackBased
548 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
549 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
550 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
551 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean
*)))
552 }, /* kDataHCompareDataRefSelect */
553 {myDataHTask
, kPascalStackBased
554 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
555 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
556 }, /* kDataHTaskSelect */
557 {myDataHScheduleData
, kPascalStackBased
558 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
559 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
560 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr
)))
561 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
562 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
563 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
564 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr
)))
565 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP
)))
566 }, /* kDataHScheduleDataSelect */
567 {myDataHFinishData
, 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(Ptr
)))
571 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean
)))
572 }, /* kDataHFinishDataSelect */
573 {NULL
, 0}, /* kDataHFlushCacheSelect 0x10 */
574 {NULL
, 0}, /* kDataHResolveDataRefSelect */
575 {myDataHGetFileSize
, kPascalStackBased
576 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
577 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
578 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
579 }, /* kDataHGetFileSizeSelect */
580 {myDataHCanUseDataRef
, kPascalStackBased
581 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
582 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
583 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
584 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long*)))
585 }, /* kDataHCanUseDataRefSelect */
586 {NULL
, 0}, /* kDataHGetVolumeListSelect */
587 {NULL
, 0}, /* kDataHWriteSelect */
588 {NULL
, 0}, /* kDataHPreextendSelect */
589 {NULL
, 0}, /* kDataHSetFileSizeSelect */
590 {NULL
, 0}, /* kDataHGetFreeSpaceSelect */
591 {NULL
, 0}, /* kDataHCreateFileSelect */
592 {NULL
, 0}, /* kDataHGetPreferredBlockSizeSelect */
593 {NULL
, 0}, /* kDataHGetDeviceIndexSelect */
594 {NULL
, 0}, /* kDataHIsStreamingDataHandlerSelect */
595 {NULL
, 0}, /* kDataHGetDataInBufferSelect */
596 {myDataHGetScheduleAheadTime
, kPascalStackBased
597 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
598 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
599 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
600 }, /* kDataHGetScheduleAheadTimeSelect */
601 /* End of Required List */
602 {NULL
, 0}, /* kDataHSetCacheSizeLimitSelect */
603 {NULL
, 0}, /* kDataHGetCacheSizeLimitSelect 0x20 */
604 {NULL
, 0}, /* kDataHGetMovieSelect */
605 {NULL
, 0}, /* kDataHAddMovieSelect */
606 {NULL
, 0}, /* kDataHUpdateMovieSelect */
607 {NULL
, 0}, /* kDataHDoesBufferSelect */
608 {myDataHGetFileName
, 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(Str255
*)))
612 }, /* kDataHGetFileNameSelect */
613 {myDataHGetAvailableFileSize
, kPascalStackBased
614 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
615 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
616 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
617 }, /* kDataHGetAvailableFileSizeSelect */
618 {NULL
, 0}, /* kDataHGetMacOSFileTypeSelect */
619 {NULL
, 0}, /* kDataHGetMIMETypeSelect */
620 {NULL
, 0}, /* kDataHSetDataRefWithAnchorSelect */
621 {NULL
, 0}, /* kDataHGetDataRefWithAnchorSelect */
622 {NULL
, 0}, /* kDataHSetMacOSFileTypeSelect */
623 {NULL
, 0}, /* kDataHSetTimeBaseSelect */
624 {myDataHGetInfoFlags
, kPascalStackBased
625 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
626 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
627 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(UInt32
*)))
628 }, /* kDataHGetInfoFlagsSelect */
629 {myDataHScheduleData64
, kPascalStackBased
630 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
631 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
632 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr
)))
633 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide
*)))
634 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
635 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
636 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr
)))
637 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP
)))
638 }, /* kDataHScheduleData64Select */
639 {NULL
, 0}, /* kDataHWrite64Select */
640 {myDataHGetFileSize64
, kPascalStackBased
641 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
642 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
643 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide
*)))
644 }, /* kDataHGetFileSize64Select 0x30 */
645 {NULL
, 0}, /* kDataHPreextend64Select */
646 {NULL
, 0}, /* kDataHSetFileSize64Select */
647 {NULL
, 0}, /* kDataHGetFreeSpace64Select */
648 {NULL
, 0}, /* kDataHAppend64Select */
649 {NULL
, 0}, /* kDataHReadAsyncSelect */
650 {NULL
, 0}, /* kDataHPollReadSelect */
651 {NULL
, 0}, /* kDataHGetDataAvailabilitySelect */
652 {NULL
, 0}, /* 0x0038 */
653 {NULL
, 0}, /* 0x0039 */
654 {myDataHGetFileSizeAsync
, kPascalStackBased
655 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
656 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
657 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide
*)))
658 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(DataHCompletionUPP
)))
659 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
660 }, /* kDataHGetFileSizeAsyncSelect */
661 {NULL
, 0}, /* kDataHGetDataRefAsTypeSelect */
662 {NULL
, 0}, /* kDataHSetDataRefExtensionSelect */
663 {NULL
, 0}, /* kDataHGetDataRefExtensionSelect */
664 {NULL
, 0}, /* kDataHGetMovieWithFlagsSelect */
665 {NULL
, 0}, /* 0x3F */
666 {myDataHGetFileTypeOrdering
, kPascalStackBased
667 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
668 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
669 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DataHFileTypeOrderingHandle
*)))
670 }, /* kDataHGetFileTypeOrderingSelect 0x40 */
671 {NULL
, 0}, /* kDataHCreateFileWithFlagsSelect */
672 {NULL
, 0}, /* kDataHGetMIMETypeAsyncSelect */
673 {NULL
, 0}, /* kDataHGetInfoSelect */
674 {NULL
, 0}, /* kDataHSetIdleManagerSelect */
675 {NULL
, 0}, /* kDataHDeleteFileSelect */
676 {NULL
, 0}, /* kDataHSetMovieUsageFlagsSelect */
677 {NULL
, 0}, /* kDataHUseTemporaryDataRefSelect */
678 {NULL
, 0}, /* kDataHGetTemporaryDataRefCapabilitiesSelect */
679 {NULL
, 0}, /* kDataHRenameFileSelect */
680 {NULL
, 0}, /* 0x4A */
681 {NULL
, 0}, /* 0x4B */
682 {NULL
, 0}, /* 0x4C */
683 {NULL
, 0}, /* 0x4D */
684 {myDataHGetAvailableFileSize64
, kPascalStackBased
685 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
686 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
687 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide
*)))
688 }, /* kDataHGetAvailableFileSize64Select */
689 {NULL
, 0}, /* kDataHGetDataAvailability64Select */
692 static const struct { LPVOID proc
; ProcInfoType type
;} componentFunctions_2
[] =
694 {myDataHPlaybackHints
, kPascalStackBased
695 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
696 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
697 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
698 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(unsigned long)))
699 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(unsigned long)))
700 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
701 }, /* kDataHPlaybackHintsSelect 0x103 */
702 {myDataHPlaybackHints64
, kPascalStackBased
703 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
704 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
705 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
706 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide
*)))
707 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(wide
*)))
708 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
709 }, /* kDataHPlaybackHints64Select 0x10E */
710 {NULL
, 0}, /* kDataHGetDataRateSelect 0x110 */
711 {NULL
, 0}, /* kDataHSetTimeHintsSelect 0x111 */
714 /* Component Functions */
716 static pascal ComponentResult
myComponentOpen(ComponentInstance ci
, ComponentInstance self
)
721 ZeroMemory(&myData
,sizeof(DHData
));
722 PtrToHand( &myData
, &storage
, sizeof(DHData
));
723 SetComponentInstanceStorage(self
,storage
);
728 static pascal ComponentResult
myComponentClose(ComponentInstance ci
, ComponentInstance self
)
730 Handle storage
= GetComponentInstanceStorage(self
);
734 data
= (DHData
*)*storage
;
735 if (data
&& data
->dataRef
.pReader
!= NULL
)
736 IAsyncReader_Release(data
->dataRef
.pReader
);
737 DisposeHandle(storage
);
738 SetComponentInstanceStorage(self
,NULL
);
743 static pascal ComponentResult
myComponentCanDo(ComponentInstance ci
, SInt16 ftnNumber
)
745 TRACE("test 0x%x\n",ftnNumber
);
746 if (ftnNumber
<= kComponentOpenSelect
&& ftnNumber
>= kComponentCanDoSelect
)
748 if (ftnNumber
== kDataHPlaybackHintsSelect
)
750 if (ftnNumber
== kDataHPlaybackHints64Select
)
752 if (ftnNumber
> kDataHGetDataAvailability64Select
)
754 TRACE("impl? %i\n",(componentFunctions
[ftnNumber
].proc
!= NULL
));
755 return (componentFunctions
[ftnNumber
].proc
!= NULL
);
760 static ComponentResult
callOurFunction(LPVOID proc
, ProcInfoType type
, ComponentParameters
* cp
)
762 ComponentRoutineUPP myUUP
;
763 ComponentResult result
;
765 myUUP
= NewComponentFunctionUPP(proc
, type
);
766 result
= CallComponentFunction(cp
, myUUP
);
767 DisposeComponentFunctionUPP(myUUP
);
771 static pascal ComponentResult
myComponentRoutineProc ( ComponentParameters
* cp
,
772 Handle componentStorage
)
776 case kComponentOpenSelect
:
777 return callOurFunction(myComponentOpen
, uppCallComponentOpenProcInfo
, cp
);
778 case kComponentCloseSelect
:
779 return callOurFunction(myComponentClose
, uppCallComponentOpenProcInfo
, cp
);
780 case kComponentCanDoSelect
:
781 return callOurFunction(myComponentCanDo
, uppCallComponentCanDoProcInfo
, cp
);
782 case kDataHPlaybackHintsSelect
:
783 return callOurFunction(componentFunctions_2
[0].proc
, componentFunctions_2
[0].type
, cp
);
784 case kDataHPlaybackHints64Select
:
785 return callOurFunction(componentFunctions_2
[1].proc
, componentFunctions_2
[1].type
, cp
);
788 if (cp
->what
> 0 && cp
->what
<=kDataHGetDataAvailability64Select
&& componentFunctions
[cp
->what
].proc
)
789 return callOurFunction(componentFunctions
[cp
->what
].proc
, componentFunctions
[cp
->what
].type
, cp
);
791 FIXME("unhandled select 0x%x\n",cp
->what
);
792 return badComponentSelector
;