Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to keep a list of SG Components pointers?



Hi, I have been trying (unsuccessfully) to get a list of QT vdig components.

I basically want to have atleast 4 cameras (of any sort isight, DV, etc) connected to my mac and have a choice in my window as to which one the input is coming from.
I have managed to get the number of currently 'plugged in' components and their names but this requires opening the component momentarily and then closing it (if it exists). If it does exist the count is incremented and the 'user friendly' name is added to the dictionary ie'iSight, Built-in iSight' etc

What I cant do is also add the components pointer to the dictionary in a usable fashion so that when I choose a different source I dont have to go through the findNextComponent and compare the VDGetInputName to the one I have chosen.

This seems to be a waste of time searching and researching for the same components over and over.

Also I dont know if this method would work for multiple external iSights or cameras of the same make and model as it would probably only find the first item each time.

here is my cutdown version that just returns the number of connected inputs
- (int)numberOfAvailableDevices
{
	ComponentDescription desc;
	Component theComp = 0;
	ComponentInstance theInst;
	
	int foundAvail = 0,i,maxFound;
	
	desc.componentType = videoDigitizerComponentType;
	desc.componentSubType = 0;
	desc.componentManufacturer = 0;
	desc.componentFlags = 0;
	desc.componentFlagsMask = 0;
	
	maxFound = CountComponents(&desc);
		
	for (i=0;i<maxFound;i++)
    {   
		theComp = FindNextComponent(theComp,&desc);
		theInst = OpenComponent(theComp)		
		if (theInst) != NULL)
		{	
			foundAvail++;
			CloseComponent(theInst);
		}
	}
	return (foundAvail);
}

the arrary version


- (NSArray *)availableDevices
{
	NSMutableArray *array = [NSMutableArray array];
	
	ComponentDescription compdesc;
	Component comp;
	//ComponentInstance theInstance;
	Str255 compName255;
	NSString *compName;
	ComponentInstance theInst;
	
	compdesc.componentType = videoDigitizerComponentType;
	compdesc.componentSubType = 0;
	compdesc.componentManufacturer = 0;
	compdesc.componentFlags = 0;
	compdesc.componentFlagsMask = 0;
	
	while((comp = FindNextComponent(comp, &compdesc)))
	{
		Handle name = NewHandleClear(200);
		ComponentDescription exportCD;
		
		theInst = OpenComponent(comp);
		
		if (theInst!= NULL)
		if (GetComponentInfo(comp, &exportCD, name, nil, nil) == noErr)
		{
			//char *namePStr = (char*)*name;
			//NSString *nameStr = [NSString stringWithCString:namePStr+1 length:*namePStr];
			
			//NSLog(@" name: %@",nameStr);
			
			VDGetInputName(theInst,0,compName255);
			compName = PStringToNSString(compName255);
			
			NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
				compName, @"name",
				[NSData dataWithBytes:&comp length:sizeof(comp)], @"component",
				[NSNumber numberWithLong:exportCD.componentType], @"type",
				[NSNumber numberWithLong:exportCD.componentSubType], @"subtype",
				[NSNumber numberWithLong:exportCD.componentManufacturer], @"manufacturer",
				nil];
			[array addObject:dictionary];
			//[nameStr release];
		}
		
		DisposeHandle(name);
	}
	return array;
}

Any help or ideas would be GREATLY appreciated.

Thanx

Kieren
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.