/* * Copyright (c) 2009 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* cc -framework QuickTime -I/System/Library/Extensions/IOFWDV.kext/Headers -I/System/Library/Frameworks/QuickTime.framework/Headers -I/System/Library/Frameworks/Carbon.framework/Headers testcomp.c /System/Library/Extensions/IOFWDV.kext/libIOFWDV.a -o testcomp */ #include #include #include #include #include #include //#define TARGET_CARBON 1 #include //#include //#include #include "IsochronousDataHandler.h" #include "DeviceControl.h" static int done = 0; static int file = 0; static QTAtomSpec videoConfig; static void printP(const char *s) { int len = *s++; while(len--) printf("%c", *s++); } static void print4(const char *s, UInt32 val) { printf("%s'%c%c%c%c'(0x%x)", s, val>>24, val>>16, val>>8, val, val); } // called when a new isoch read is received static OSStatus DVIsochComponentReadCallback( IDHGenericEvent *eventRecord, void *userData) { OSErr result = noErr; IDHParameterBlock *pb = (IDHParameterBlock *) eventRecord; #if 1 ComponentInstance theInst = userData; if(file) write(file, pb->buffer, pb->actualCount); result = IDHReleaseBuffer( theInst, pb); // fill out structure pb->buffer = NULL; pb->requestedCount = 120000; pb->actualCount = 0; pb->completionProc = DVIsochComponentReadCallback; // do another read result = IDHRead( theInst, pb); if( result != noErr) { printf("IDHRead error %d\n", result); } #else printf("read complete for block 0x%x, refcon 0x%x\n", pb, userData); #endif done++; return result; } // called when a new isoch read is received static OSStatus DVIsochComponentWriteCallback( IDHGenericEvent *eventRecord, void *userData) { OSErr result = noErr; IDHParameterBlock *pb = (IDHParameterBlock *) eventRecord; #if 1 ComponentInstance theInst = userData; if(file) { int len; len = read(file, pb->buffer, 120000); if(len < 120000) return result; } #if WRITEBUFF #else pb->buffer = nil; #endif // fill out structure pb->requestedCount = 120000; pb->actualCount = 0; pb->completionProc = DVIsochComponentWriteCallback; // do another write result = IDHWrite( theInst, pb); if( result != noErr) { printf("IDHWrite error %d\n", result); } #else printf("write complete for block 0x%x, refcon 0x%x\n", pb, userData); #endif done++; return result; } static void doControlTest(ComponentInstance theInst, QTAtomSpec *currentIsochConfig) { //Component control; ComponentInstance controlInst; ComponentResult result; IDHDeviceStatus devStatus; DVCTransactionParams pParams; char in[4], out[16]; int i; result = IDHGetDeviceControl(theInst, &controlInst); if(result) goto Exit; //controlInst = OpenComponent(control); // get the local node's fw ref id result = IDHGetDeviceStatus( theInst, currentIsochConfig, &devStatus); if(result) goto Exit; //result = FWClockPrivSetFWReferenceID(clockInst, (FWReferenceID) devStatus.localNodeID ); //if(result) // goto Exit; // set the clock's fw id //clockInst = OpenDefaultComponent(clockComponentType, systemMicrosecondClock); if(!controlInst) goto Exit; // fill up the avc frame in[0] = 0x00; //kAVCControlCommand; in[1] = 0x20; // for now in[2] = 0xc3; //kAVCPlayOpcode; in[3] = 0x75; //kAVCPlayForward; // fill up the transaction parameter block pParams.commandBufferPtr = in; pParams.commandLength = sizeof(in); pParams.responseBufferPtr = out; pParams.responseBufferSize = sizeof(out); pParams.responseHandler = NULL; do { for(i=0; i 0) break; sleep(1); } while(true); QTLockContainer( deviceList); // find the cmp atom deviceAtom = QTFindChildByIndex( deviceList, kParentAtomIsContainer, kIDHUseCMPAtomType, 1, nil); if( deviceAtom == nil) goto error; // get the value of the cmp atom QTCopyAtomDataToPtr( deviceList, deviceAtom, true, sizeof( cmpFlag), &cmpFlag, &size); // find the version atom deviceAtom = QTFindChildByIndex( deviceList, kParentAtomIsContainer, kIDHIsochVersionAtomType, 1, nil); if( deviceAtom == nil) goto error; // get the value of the version atom QTCopyAtomDataToPtr( deviceList, deviceAtom, true, sizeof( isoversion), &isoversion, &size); printf("Version 0x%x. %d DV devices, use CMP flag is %d\n", isoversion, nDVDevices, cmpFlag); for( i=0; i