FileDocCategorySizeDatePackage
V4LDeviceQuery.javaAPI DocJMF 2.1.1e2518Mon May 12 12:21:30 BST 2003com.sun.media.protocol.v4l

V4LDeviceQuery

public class V4LDeviceQuery extends CaptureDeviceInfo

Fields Summary
private transient V4LCapture
capture
private transient Vector
vecFormats
private transient byte[]
buffer
protected transient Dimension[]
sizes
Constructors Summary
public V4LDeviceQuery(int index)

	int iPal, iSize;
	int i;
	VCapability vcap = new VCapability();
	capture = new V4LCapture(index);
	capture.getCapability(vcap);
	
	name = "v4l:" + vcap.name + ":" + index;
	System.err.println("Name = " + name);
	tryFormat(capture, VPicture.VIDEO_PALETTE_RGB24, 320, 240);
	for (iPal = VPicture.VIDEO_PALETTE_RGB565; iPal < VPicture.VIDEO_PALETTE_YUV410P; iPal++) {
	    for (iSize = 0; iSize < sizes.length; iSize++) {
		tryFormat(capture, iPal, sizes[iSize].width, sizes[iSize].height);
	    }
	}

	formats = new Format[vecFormats.size()];
	Enumeration enum = vecFormats.elements();
	
	i = 0;
	while (enum.hasMoreElements()) {
	    Format f = (Format) enum.nextElement();
	    formats[i++] = f;
	}
	locator = new MediaLocator("v4l://" + index);
    
Methods Summary
private voidaddFormat(javax.media.Format fin)


        
	Enumeration enum = vecFormats.elements();
	while (enum.hasMoreElements()) {
	    Format f = (Format) enum.nextElement();
	    if (f.equals(fin))
		return;
	}

	//System.err.println("New format = " + fin);
	vecFormats.addElement(fin);
    
private voidtryFormat(V4LCapture capture, int palette, int width, int height)

	System.err.println("Trying " + palette + " " + width + " " + height);
	if (capture.setFormat(capture.paletteToDepth(palette),
			      palette, width, height, 30f) < 0)
	    return;

	if (capture.start() < 0)
	    return;

	// Try a few times
	for (int i = 0; i < 5; i++) {
	    if (capture.readNextFrame(buffer, 0, buffer.length) >= 0) {
		// Format is supported, add it
		Format f = capture.paletteToFormat(palette, new Dimension(width, height));
		System.err.println("Format is " + f);
		if (f != null)
		    addFormat(f);
		capture.stop();
		return;
	    }
	}
	// Not supported
	
	capture.stop();