void AVC_FormatManager::query()
{
	// Find available formats and video standards.

	int port = -1;
	AVC_DeviceDescriptor* dd = dynamic_cast<AVC_DeviceDescriptor*>(mDeviceDescriptor);
	std::auto_ptr<iec61883Reader> reader;
	std::auto_ptr<iec61883Connection> connection;
	int node = discoverAVC(&port, &dd->getGUID());
	
	if(node == -1)
		return;

	if ( port != -1 ) {
		// capture a single frame and retrieve it's properties
		iec61883Connection::CheckConsistency( port, node );
		connection = std::auto_ptr<iec61883Connection>(new iec61883Connection(port, node));
			
		int channel = connection->GetChannel();
		reader = std::auto_ptr<iec61883Reader>(new iec61883Reader( port, channel));

		reader->StartThread();
		
		// Wait for the reader to indicate that something has happened
			
		if(!reader->WaitForAction(5)) {
			std::cerr<<"AVC_FormatManager: Timed out retrieving format.\n";
		} else {
			// Get the next frame
			Frame* frame = reader->GetFrame();
			if(!frame) {
					std::cout<<"AVC_FormatManager: Error retrieving format parameters.\n";
			}

			// get format-properties
			mWidth = frame->GetWidth();
			mHeight = frame->GetHeight();
			mBytesPerLine = mWidth;
			mImageSize = mWidth*mHeight*3;
			
			// create the formats
			Format* yuv = new Format("YUYV", v4l2_fourcc('Y','U','Y','V'));
			mFormats.push_back(yuv);

			Format* rgb = new Format("RGB", v4l2_fourcc('R', 'G', 'B', 0));
			mFormats.push_back(rgb);
			
			setFormat(yuv);
			
			// and the proper video-standards
			mIsPal = frame->IsPAL();
			if(mIsPal) {
				VideoStandard* pal = new VideoStandard("PAL", VideoStandard::PAL);
				mStandards.push_back(pal);
				yuv->addResolution(720, 576);			
				rgb->addResolution(720, 576);			
			} else {
				VideoStandard* ntsc = new VideoStandard("NTSC", VideoStandard::NTSC);
				mStandards.push_back(ntsc);						
				yuv->addResolution(720, 480);			
				rgb->addResolution(720, 480);			
			}
			
			// release the frame 
			reader->DoneWithFrame( frame );
		}
		
		// and stop capturing
		reader->StopThread();
	}
}