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
69 #undef GetCurrentProcess
92 #undef IsWindowVisible
104 #undef STDMETHODCALLTYPE
110 #define NONAMELESSSTRUCT
111 #define NONAMELESSUNION
120 #include "wine/unicode.h"
121 #include "wine/debug.h"
123 #include "qtprivate.h"
125 WINE_DEFAULT_DEBUG_CHANNEL(qtdatahandler
);
127 static ComponentDescription myType
=
136 typedef struct DHData
138 WineDataRefRecord dataRef
;
142 DataHCompletionUPP AsyncCompletionRtn
;
145 static pascal ComponentResult
myComponentRoutineProc ( ComponentParameters
*
146 cp
, Handle componentStorage
);
148 void RegisterWineDataHandler( void )
150 ComponentRoutineUPP MyComponentRoutineUPP
;
152 MyComponentRoutineUPP
= NewComponentRoutineUPP(&myComponentRoutineProc
);
153 RegisterComponent( &myType
, MyComponentRoutineUPP
, 0, NULL
, NULL
, NULL
);
156 static pascal ComponentResult
myDataHCanUseDataRef ( DataHandler dh
,
161 WineDataRefRecord
*record
= (WineDataRefRecord
*)(*dataRef
);
162 TRACE("%p %p %p\n",dh
,dataRef
,useFlags
);
163 if (record
->pReader
== NULL
)
164 return badComponentSelector
;
165 *useFlags
= kDataHCanRead
;
169 static pascal ComponentResult
myDataHSetDataRef ( DataHandler dh
, Handle dataRef
)
171 Handle storage
= GetComponentInstanceStorage(dh
);
172 DHData
*data
= (DHData
*)*storage
;
173 WineDataRefRecord
* newRef
= (WineDataRefRecord
*)(*dataRef
);
175 if (newRef
->pReader
!= data
->dataRef
.pReader
)
176 IAsyncReader_AddRef(newRef
->pReader
);
177 data
->dataRef
= *newRef
;
181 static pascal ComponentResult
myDataHGetAvailableFileSize ( DataHandler dh
,
184 Handle storage
= GetComponentInstanceStorage(dh
);
185 DHData
*data
= (DHData
*)*storage
;
191 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
192 *fileSize
= available
;
196 static pascal ComponentResult
myDataHGetFileSize ( DataHandler dh
, long *fileSize
)
198 Handle storage
= GetComponentInstanceStorage(dh
);
199 DHData
*data
= (DHData
*)*storage
;
205 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
210 static pascal ComponentResult
myDataHScheduleData ( DataHandler dh
,
211 Ptr PlaceToPutDataPtr
,
215 DataHSchedulePtr scheduleRec
,
216 DataHCompletionUPP CompletionRtn
)
218 Handle storage
= GetComponentInstanceStorage(dh
);
219 DHData
*data
= (DHData
*)*storage
;
221 LONGLONG offset
= FileOffset
;
222 BYTE
* buffer
= (BYTE
*)PlaceToPutDataPtr
;
224 TRACE("%p %p %li %li %li %p %p\n",dh
, PlaceToPutDataPtr
, FileOffset
, DataSize
, RefCon
, scheduleRec
, CompletionRtn
);
226 hr
= IAsyncReader_SyncRead(data
->dataRef
.pReader
, offset
, DataSize
, buffer
);
227 TRACE("result %x\n",hr
);
230 if (data
->AsyncCompletionRtn
)
231 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
233 data
->AsyncPtr
= PlaceToPutDataPtr
;
234 data
->AsyncRefCon
= RefCon
;
235 data
->AsyncCompletionRtn
= CompletionRtn
;
241 static pascal ComponentResult
myDataHFinishData (DataHandler dh
, Ptr PlaceToPutDataPtr
, Boolean Cancel
)
243 Handle storage
= GetComponentInstanceStorage(dh
);
244 DHData
*data
= (DHData
*)*storage
;
245 if (!data
->AsyncCompletionRtn
)
247 if (!PlaceToPutDataPtr
|| PlaceToPutDataPtr
== data
->AsyncPtr
)
250 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
251 data
->AsyncPtr
= NULL
;
252 data
->AsyncRefCon
= 0;
253 data
->AsyncCompletionRtn
= NULL
;
258 static pascal ComponentResult
myDataHGetData ( DataHandler dh
,
264 Handle storage
= GetComponentInstanceStorage(dh
);
265 DHData
*data
= (DHData
*)*storage
;
266 BYTE
*target
= (BYTE
*)*h
;
267 LONGLONG off
= offset
;
270 TRACE("%p %p %li %li %li\n",dh
, h
, hOffset
, offset
, size
);
271 hr
= IAsyncReader_SyncRead(data
->dataRef
.pReader
, off
, size
, target
+hOffset
);
272 TRACE("result %x\n",hr
);
277 static pascal ComponentResult
myDataHCompareDataRef ( DataHandler dh
,
278 Handle dataRef
, Boolean
*equal
)
280 WineDataRefRecord
*ptr1
;
281 Handle storage
= GetComponentInstanceStorage(dh
);
282 DHData
*data
= (DHData
*)*storage
;
285 ptr1
= (WineDataRefRecord
*)dataRef
;
287 *equal
= (ptr1
->pReader
== data
->dataRef
.pReader
);
291 static pascal ComponentResult
myDataHGetDataRef ( DataHandler dh
, Handle
*dataRef
)
293 Handle storage
= GetComponentInstanceStorage(dh
);
300 static pascal ComponentResult
myDataHGetScheduleAheadTime ( DataHandler dh
,
308 static pascal ComponentResult
myDataHGetInfoFlags ( DataHandler dh
, UInt32
*flags
)
315 static pascal ComponentResult
myDataHGetFileTypeOrdering ( DataHandler dh
,
316 DataHFileTypeOrderingHandle
*orderingListHandle
)
318 OSType orderlist
[1] = {kDataHFileTypeExtension
};
320 PtrToHand( &orderlist
, (Handle
*)orderingListHandle
, sizeof(OSType
));
325 const char *const fname
;
326 const int sig_length
;
330 static const signature stream_sigs
[] = {
331 {"video.asf",4,{0x30,0x26,0xb2,0x75}},
332 {"video.mov",8,{0x00,0x00,0x00,0x14,0x66,0x74,0x79,0x70}},
333 {"video.mp4",8,{0x00,0x00,0x00,0x18,0x66,0x74,0x79,0x70}},
334 {"video.m4v",8,{0x00,0x00,0x00,0x1c,0x66,0x74,0x79,0x70}},
335 {"video.flv",4,{0x46,0x4C,0x56,0x01}},
336 {"video.mpg",3,{0x00,0x00,0x01}},
337 {"avideo.rm",4,{0x2E,0x52,0x4D,0x46}}
340 static pascal ComponentResult
myDataHGetFileName ( DataHandler dh
, Str255 str
)
342 Handle storage
= GetComponentInstanceStorage(dh
);
343 DHData
*data
= (DHData
*)*storage
;
344 TRACE("%p %s\n",str
,debugstr_guid(&data
->dataRef
.streamSubtype
));
346 /* Todo Expand this list */
347 if (IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_MPEG1Video
) ||
348 IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_MPEG1System
))
349 CFStringGetPascalString(CFSTR("video.mpg"),str
,256,kCFStringEncodingMacRoman
);
350 else if(IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_Asf
))
351 CFStringGetPascalString(CFSTR("video.asf"),str
,256,kCFStringEncodingMacRoman
);
352 else if(IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_Avi
))
353 CFStringGetPascalString(CFSTR("video.avi"),str
,256,kCFStringEncodingMacRoman
);
354 else if(IsEqualIID(&data
->dataRef
.streamSubtype
, &MEDIASUBTYPE_QTMovie
))
355 CFStringGetPascalString(CFSTR("video.mov"),str
,256,kCFStringEncodingMacRoman
);
358 BYTE header
[10] = {0,0,0,0,0,0,0,0,0,0};
360 IAsyncReader_SyncRead(data
->dataRef
.pReader
, 0, 8, header
);
362 for (i
= 0; i
< ARRAY_SIZE(stream_sigs
); i
++)
363 if (memcmp(header
, stream_sigs
[i
].sig
, stream_sigs
[i
].sig_length
)==0)
365 str
[0] = strlen(stream_sigs
[i
].fname
);
366 memcpy(str
+ 1, stream_sigs
[i
].fname
, str
[0]);
370 return badComponentSelector
;
376 static pascal ComponentResult
myDataHOpenForRead(DataHandler dh
)
382 static pascal ComponentResult
myDataHTask(DataHandler dh
)
384 Handle storage
= GetComponentInstanceStorage(dh
);
385 DHData
*data
= (DHData
*)*storage
;
387 if (data
->AsyncCompletionRtn
)
389 TRACE("Sending Completion\n");
390 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
391 data
->AsyncPtr
= NULL
;
392 data
->AsyncRefCon
= 0;
393 data
->AsyncCompletionRtn
= NULL
;
398 static pascal ComponentResult
myDataHPlaybackHints(DataHandler dh
, long flags
,
399 unsigned long minFileOffset
, unsigned long maxFileOffset
,
402 TRACE("%lu %lu %li\n",minFileOffset
, maxFileOffset
, bytesPerSecond
);
406 static pascal ComponentResult
myDataHPlaybackHints64(DataHandler dh
, long flags
,
407 wide
*minFileOffset
, wide
*maxFileOffset
,
410 if (TRACE_ON(qtdatahandler
))
412 SInt64 minFileOffset64
= WideToSInt64(*minFileOffset
);
413 LONGLONG minFileOffsetLL
= minFileOffset64
;
414 SInt64 maxFileOffset64
= WideToSInt64(*maxFileOffset
);
415 LONGLONG maxFileOffsetLL
= maxFileOffset64
;
417 TRACE("%s %s %li\n",wine_dbgstr_longlong(minFileOffsetLL
), wine_dbgstr_longlong(maxFileOffsetLL
), bytesPerSecond
);
422 static pascal ComponentResult
myDataHGetFileSize64(DataHandler dh
, wide
* fileSize
)
424 Handle storage
= GetComponentInstanceStorage(dh
);
425 DHData
*data
= (DHData
*)*storage
;
432 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
434 *fileSize
= SInt64ToWide(total64
);
438 static pascal ComponentResult
myDataHGetFileSizeAsync ( DataHandler dh
, wide
*fileSize
, DataHCompletionUPP CompletionRtn
, long RefCon
)
440 Handle storage
= GetComponentInstanceStorage(dh
);
441 DHData
*data
= (DHData
*)*storage
;
448 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
450 *fileSize
= SInt64ToWide(total64
);
454 if (data
->AsyncCompletionRtn
)
455 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
457 data
->AsyncPtr
= (Ptr
)fileSize
;
458 data
->AsyncRefCon
= RefCon
;
459 data
->AsyncCompletionRtn
= CompletionRtn
;
465 static pascal ComponentResult
myDataHGetAvailableFileSize64(DataHandler dh
, wide
* fileSize
)
467 Handle storage
= GetComponentInstanceStorage(dh
);
468 DHData
*data
= (DHData
*)*storage
;
475 IAsyncReader_Length(data
->dataRef
.pReader
,&total
,&available
);
477 *fileSize
= SInt64ToWide(total64
);
481 static pascal ComponentResult
myDataHScheduleData64( DataHandler dh
,
482 Ptr PlaceToPutDataPtr
,
483 const wide
* FileOffset
,
486 DataHSchedulePtr scheduleRec
,
487 DataHCompletionUPP CompletionRtn
)
489 Handle storage
= GetComponentInstanceStorage(dh
);
490 DHData
*data
= (DHData
*)*storage
;
492 SInt64 fileOffset64
= WideToSInt64(*FileOffset
);
493 LONGLONG offset
= fileOffset64
;
494 BYTE
* buffer
= (BYTE
*)PlaceToPutDataPtr
;
496 TRACE("%p %p %s %li %li %p %p\n",dh
, PlaceToPutDataPtr
, wine_dbgstr_longlong(offset
), DataSize
, RefCon
, scheduleRec
, CompletionRtn
);
498 hr
= IAsyncReader_SyncRead(data
->dataRef
.pReader
, offset
, DataSize
, buffer
);
499 TRACE("result %x\n",hr
);
502 if (data
->AsyncCompletionRtn
)
503 InvokeDataHCompletionUPP(data
->AsyncPtr
, data
->AsyncRefCon
, noErr
, data
->AsyncCompletionRtn
);
505 data
->AsyncPtr
= PlaceToPutDataPtr
;
506 data
->AsyncRefCon
= RefCon
;
507 data
->AsyncCompletionRtn
= CompletionRtn
;
513 static const struct { LPVOID proc
; ProcInfoType type
;} componentFunctions
[] =
517 {myDataHGetData
, kPascalStackBased
518 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
519 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
520 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
521 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
522 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
523 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
524 }, /* kDataHGetDataSelect */
525 {NULL
, 0}, /* kDataHPutDataSelect */
526 {NULL
, 0}, /* kDataHFlushDataSelect */
527 {NULL
, 0}, /* kDataHOpenForWriteSelect */
528 {NULL
, 0}, /* kDataHCloseForWriteSelect */
530 {myDataHOpenForRead
, kPascalStackBased
531 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
532 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
533 }, /* kDataHOpenForReadSelect
535 {NULL
, 0}, /* kDataHCloseForReadSelect */
536 {myDataHSetDataRef
, kPascalStackBased
537 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
538 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
539 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
540 }, /* kDataHSetDataRefSelect */
541 {myDataHGetDataRef
, kPascalStackBased
542 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
543 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
544 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
545 }, /* kDataHGetDataRefSelect */
546 {myDataHCompareDataRef
, kPascalStackBased
547 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
548 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
549 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
550 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean
*)))
551 }, /* kDataHCompareDataRefSelect */
552 {myDataHTask
, kPascalStackBased
553 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
554 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
555 }, /* kDataHTaskSelect */
556 {myDataHScheduleData
, kPascalStackBased
557 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
558 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
559 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr
)))
560 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
561 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
562 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
563 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr
)))
564 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP
)))
565 }, /* kDataHScheduleDataSelect */
566 {myDataHFinishData
, kPascalStackBased
567 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
568 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
569 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr
)))
570 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean
)))
571 }, /* kDataHFinishDataSelect */
572 {NULL
, 0}, /* kDataHFlushCacheSelect 0x10 */
573 {NULL
, 0}, /* kDataHResolveDataRefSelect */
574 {myDataHGetFileSize
, kPascalStackBased
575 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
576 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
577 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
578 }, /* kDataHGetFileSizeSelect */
579 {myDataHCanUseDataRef
, kPascalStackBased
580 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
581 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
582 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle
)))
583 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long*)))
584 }, /* kDataHCanUseDataRefSelect */
585 {NULL
, 0}, /* kDataHGetVolumeListSelect */
586 {NULL
, 0}, /* kDataHWriteSelect */
587 {NULL
, 0}, /* kDataHPreextendSelect */
588 {NULL
, 0}, /* kDataHSetFileSizeSelect */
589 {NULL
, 0}, /* kDataHGetFreeSpaceSelect */
590 {NULL
, 0}, /* kDataHCreateFileSelect */
591 {NULL
, 0}, /* kDataHGetPreferredBlockSizeSelect */
592 {NULL
, 0}, /* kDataHGetDeviceIndexSelect */
593 {NULL
, 0}, /* kDataHIsStreamingDataHandlerSelect */
594 {NULL
, 0}, /* kDataHGetDataInBufferSelect */
595 {myDataHGetScheduleAheadTime
, kPascalStackBased
596 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
597 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
598 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
599 }, /* kDataHGetScheduleAheadTimeSelect */
600 /* End of Required List */
601 {NULL
, 0}, /* kDataHSetCacheSizeLimitSelect */
602 {NULL
, 0}, /* kDataHGetCacheSizeLimitSelect 0x20 */
603 {NULL
, 0}, /* kDataHGetMovieSelect */
604 {NULL
, 0}, /* kDataHAddMovieSelect */
605 {NULL
, 0}, /* kDataHUpdateMovieSelect */
606 {NULL
, 0}, /* kDataHDoesBufferSelect */
607 {myDataHGetFileName
, kPascalStackBased
608 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
609 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
610 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Str255
*)))
611 }, /* kDataHGetFileNameSelect */
612 {myDataHGetAvailableFileSize
, kPascalStackBased
613 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
614 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
615 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
616 }, /* kDataHGetAvailableFileSizeSelect */
617 {NULL
, 0}, /* kDataHGetMacOSFileTypeSelect */
618 {NULL
, 0}, /* kDataHGetMIMETypeSelect */
619 {NULL
, 0}, /* kDataHSetDataRefWithAnchorSelect */
620 {NULL
, 0}, /* kDataHGetDataRefWithAnchorSelect */
621 {NULL
, 0}, /* kDataHSetMacOSFileTypeSelect */
622 {NULL
, 0}, /* kDataHSetTimeBaseSelect */
623 {myDataHGetInfoFlags
, kPascalStackBased
624 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
625 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
626 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(UInt32
*)))
627 }, /* kDataHGetInfoFlagsSelect */
628 {myDataHScheduleData64
, kPascalStackBased
629 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
630 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
631 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr
)))
632 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide
*)))
633 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
634 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
635 | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr
)))
636 | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP
)))
637 }, /* kDataHScheduleData64Select */
638 {NULL
, 0}, /* kDataHWrite64Select */
639 {myDataHGetFileSize64
, kPascalStackBased
640 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
641 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
642 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide
*)))
643 }, /* kDataHGetFileSize64Select 0x30 */
644 {NULL
, 0}, /* kDataHPreextend64Select */
645 {NULL
, 0}, /* kDataHSetFileSize64Select */
646 {NULL
, 0}, /* kDataHGetFreeSpace64Select */
647 {NULL
, 0}, /* kDataHAppend64Select */
648 {NULL
, 0}, /* kDataHReadAsyncSelect */
649 {NULL
, 0}, /* kDataHPollReadSelect */
650 {NULL
, 0}, /* kDataHGetDataAvailabilitySelect */
651 {NULL
, 0}, /* 0x0038 */
652 {NULL
, 0}, /* 0x0039 */
653 {myDataHGetFileSizeAsync
, kPascalStackBased
654 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
655 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
656 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide
*)))
657 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(DataHCompletionUPP
)))
658 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
659 }, /* kDataHGetFileSizeAsyncSelect */
660 {NULL
, 0}, /* kDataHGetDataRefAsTypeSelect */
661 {NULL
, 0}, /* kDataHSetDataRefExtensionSelect */
662 {NULL
, 0}, /* kDataHGetDataRefExtensionSelect */
663 {NULL
, 0}, /* kDataHGetMovieWithFlagsSelect */
664 {NULL
, 0}, /* 0x3F */
665 {myDataHGetFileTypeOrdering
, kPascalStackBased
666 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
667 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
668 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DataHFileTypeOrderingHandle
*)))
669 }, /* kDataHGetFileTypeOrderingSelect 0x40 */
670 {NULL
, 0}, /* kDataHCreateFileWithFlagsSelect */
671 {NULL
, 0}, /* kDataHGetMIMETypeAsyncSelect */
672 {NULL
, 0}, /* kDataHGetInfoSelect */
673 {NULL
, 0}, /* kDataHSetIdleManagerSelect */
674 {NULL
, 0}, /* kDataHDeleteFileSelect */
675 {NULL
, 0}, /* kDataHSetMovieUsageFlagsSelect */
676 {NULL
, 0}, /* kDataHUseTemporaryDataRefSelect */
677 {NULL
, 0}, /* kDataHGetTemporaryDataRefCapabilitiesSelect */
678 {NULL
, 0}, /* kDataHRenameFileSelect */
679 {NULL
, 0}, /* 0x4A */
680 {NULL
, 0}, /* 0x4B */
681 {NULL
, 0}, /* 0x4C */
682 {NULL
, 0}, /* 0x4D */
683 {myDataHGetAvailableFileSize64
, kPascalStackBased
684 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
685 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
686 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide
*)))
687 }, /* kDataHGetAvailableFileSize64Select */
688 {NULL
, 0}, /* kDataHGetDataAvailability64Select */
691 static const struct { LPVOID proc
; ProcInfoType type
;} componentFunctions_2
[] =
693 {myDataHPlaybackHints
, kPascalStackBased
694 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
695 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
696 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
697 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(unsigned long)))
698 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(unsigned long)))
699 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
700 }, /* kDataHPlaybackHintsSelect 0x103 */
701 {myDataHPlaybackHints64
, kPascalStackBased
702 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult
)))
703 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler
)))
704 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
705 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide
*)))
706 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(wide
*)))
707 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
708 }, /* kDataHPlaybackHints64Select 0x10E */
709 {NULL
, 0}, /* kDataHGetDataRateSelect 0x110 */
710 {NULL
, 0}, /* kDataHSetTimeHintsSelect 0x111 */
713 /* Component Functions */
715 static pascal ComponentResult
myComponentOpen(ComponentInstance ci
, ComponentInstance self
)
720 ZeroMemory(&myData
,sizeof(DHData
));
721 PtrToHand( &myData
, &storage
, sizeof(DHData
));
722 SetComponentInstanceStorage(self
,storage
);
727 static pascal ComponentResult
myComponentClose(ComponentInstance ci
, ComponentInstance self
)
729 Handle storage
= GetComponentInstanceStorage(self
);
733 data
= (DHData
*)*storage
;
734 if (data
&& data
->dataRef
.pReader
!= NULL
)
735 IAsyncReader_Release(data
->dataRef
.pReader
);
736 DisposeHandle(storage
);
737 SetComponentInstanceStorage(self
,NULL
);
742 static pascal ComponentResult
myComponentCanDo(ComponentInstance ci
, SInt16 ftnNumber
)
744 TRACE("test 0x%x\n",ftnNumber
);
745 if (ftnNumber
<= kComponentOpenSelect
&& ftnNumber
>= kComponentCanDoSelect
)
747 if (ftnNumber
== kDataHPlaybackHintsSelect
)
749 if (ftnNumber
== kDataHPlaybackHints64Select
)
751 if (ftnNumber
> kDataHGetDataAvailability64Select
)
753 TRACE("impl? %i\n",(componentFunctions
[ftnNumber
].proc
!= NULL
));
754 return (componentFunctions
[ftnNumber
].proc
!= NULL
);
759 static ComponentResult
callOurFunction(LPVOID proc
, ProcInfoType type
, ComponentParameters
* cp
)
761 ComponentRoutineUPP myUUP
;
762 ComponentResult result
;
764 myUUP
= NewComponentFunctionUPP(proc
, type
);
765 result
= CallComponentFunction(cp
, myUUP
);
766 DisposeComponentFunctionUPP(myUUP
);
770 static pascal ComponentResult
myComponentRoutineProc ( ComponentParameters
* cp
,
771 Handle componentStorage
)
775 case kComponentOpenSelect
:
776 return callOurFunction(myComponentOpen
, uppCallComponentOpenProcInfo
, cp
);
777 case kComponentCloseSelect
:
778 return callOurFunction(myComponentClose
, uppCallComponentOpenProcInfo
, cp
);
779 case kComponentCanDoSelect
:
780 return callOurFunction(myComponentCanDo
, uppCallComponentCanDoProcInfo
, cp
);
781 case kDataHPlaybackHintsSelect
:
782 return callOurFunction(componentFunctions_2
[0].proc
, componentFunctions_2
[0].type
, cp
);
783 case kDataHPlaybackHints64Select
:
784 return callOurFunction(componentFunctions_2
[1].proc
, componentFunctions_2
[1].type
, cp
);
787 if (cp
->what
> 0 && cp
->what
<=kDataHGetDataAvailability64Select
&& componentFunctions
[cp
->what
].proc
)
788 return callOurFunction(componentFunctions
[cp
->what
].proc
, componentFunctions
[cp
->what
].type
, cp
);
790 FIXME("unhandled select 0x%x\n",cp
->what
);
791 return badComponentSelector
;