#include #include #include #include #include #include #include #include #include #include #include static QTAtomSpec videoConfig; static IDHDeviceID deviceID; static IDHNotificationID notificationID; 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); } static OSStatus notificationProc(IDHGenericEvent* event, void* userData) { ComponentInstance theInst = userData; printf("Got notification for device 0x%x, notification 0x%x, event 0x%x, userdata 0x%x\n", event->eventHeader.deviceID, event->eventHeader.notificationID, event->eventHeader.event, userData); // Reenable notification IDHNotifyMeWhen(theInst, event->eventHeader.notificationID, kIDHEventEveryEvent); return noErr; } static void doControlTest(ComponentInstance theInst, QTAtomSpec *currentIsochConfig, UInt8 op1, UInt8 op2) { //Component control; ComponentInstance controlInst; ComponentResult result; IDHDeviceStatus devStatus; DVCTransactionParams pParams; char in[4], out[16]; //char in[44], out[44]; 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; #if 1 // fill up the avc frame in[0] = kAVCStatusInquiryCommand; //kAVCControlCommand; in[1] = 0x20; // for now in[2] = op1; in[3] = op2; #else // fill up the avc frame in[0] = 0x00; in[1] = 0x58; // for now in[2] = 0x50; in[3] = 0x00; in[4] = 0xff; in[5] = 0x00; // for now in[6] = 0x00; in[7] = 0x00; in[8] = 0xff; in[9] = 0xff; in[10] = 0xff; in[11] = 0xff; in[12] = 0x00; in[13] = 0x00; in[14] = 0x00; in[15] = 0x1b; in[16] = 0x5c; in[17] = 0x44; in[18] = 0x43; in[19] = 0x49; in[20] = 0x4d; in[21] = 0x5c; in[22] = 0x31; in[23] = 0x30; in[24] = 0x31; in[25] = 0x43; in[26] = 0x41; in[27] = 0x4e; in[28] = 0x4f; in[29] = 0x4e; in[30] = 0x5c; in[31] = 0x41; in[32] = 0x55; in[33] = 0x54; in[34] = 0x5f; in[35] = 0x30; in[36] = 0x31; in[37] = 0x30; in[38] = 0x33; in[39] = 0x2e; in[40] = 0x4a; in[41] = 0x50; in[42] = 0x47; in[43] = 0x00; #endif // 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; printf("Waiting for a camera...\n"); 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 time1.value.lo+1) { //printf("read device time1, scale: %d, time 0x%x:0x%x\n", // time1.scale, time1.value.hi, time1.value.lo); //printf("read device time2, scale: %d, time 0x%x:0x%x\n", // time2.scale, time2.value.hi, time2.value.lo); printf("Diff is %d\n", time2.value.lo-time1.value.lo); } } while (1); } #endif error: if( err != noErr) printf("error %d(0x%x)\n", err, err); if(deviceList) { QTUnlockContainer( deviceList); QTDisposeAtomContainer(deviceList); } CloseComponent(theInst); } int main(int argc, char **argv) { UInt32 seed = GetComponentListModSeed(); UInt32 num; Handle aName; ComponentDescription desc, aDesc; Component aComponent; int pos = 1; printf("Component seed is %d\n", seed); desc.componentType = 'ihlr'; /* A unique 4-byte code indentifying the command set */ desc.componentSubType = 0; /* Particular flavor of this instance */ desc.componentManufacturer = 0; /* Vendor indentification */ desc.componentFlags = 0; /* 8 each for Component,Type,SubType,Manuf/revision */ desc.componentFlagsMask = 0; /* Mask for specifying which flags to consider in search, zero during registration */ num = CountComponents(&desc); printf("%d components match\n", num); aComponent = 0; aName = NewHandleClear(200); while (aComponent = FindNextComponent(aComponent, &desc)) { OSStatus oops; printf("Found component 0x%x:", aComponent); oops = GetComponentInfo(aComponent, &aDesc, aName, NULL, NULL); if(oops) printf("GetComponentInfo() returned error %d\n", oops); else { if(GetHandleSize(aName)) printP(*aName); else printf("Unnamed"); print4(", Type ", aDesc.componentType); print4(", SubType ", aDesc.componentSubType); print4(", Manufacturer ", aDesc.componentManufacturer); printf("\n"); } } num = 0; do { ComponentInstance theInst; theInst = OpenDefaultComponent('ihlr', 'dv '); //printf("Instance is 0x%x\n", theInst); if(theInst == NULL) return; num++; usleep(50000); CloseComponent(theInst); } while (0); OpenDV(); return 0; }