FileDocCategorySizeDatePackage
SunVideoPlusAuto.javaAPI DocJMF 2.1.1e9813Mon May 12 12:20:34 BST 2003None

SunVideoPlusAuto

public class SunVideoPlusAuto extends Object

Fields Summary
private static String
DEVICE_PREFIX
private static String
PROTOCOL
private static String
LOCATOR_PREFIX
private static boolean
DO_PAL
int
currentID
Constructors Summary
public SunVideoPlusAuto()

    
      
	/*
	 * First remove any old entries
	 */
	Vector devices = (Vector) CaptureDeviceManager.
						getDeviceList(null).clone();
	Enumeration enum = devices.elements();
	while (enum.hasMoreElements()) {
	    CaptureDeviceInfo cdi = (CaptureDeviceInfo) enum.nextElement();
	    String devName = cdi.getLocator().getProtocol();
	    if (devName.equals(PROTOCOL))
		CaptureDeviceManager.removeDevice(cdi);
	}

	int nDevices = 0;
	for (int i = 0; i < 10; i++) {
	    File fl = new File(DEVICE_PREFIX + i);
	    if (fl.exists()) {
		if (DO_PAL) {
		    generalDevice(i, "PAL");
		    // If generating PAL, do both
		    // Garbage collect to release the PAL datasource
		    // otherwise it sometimes hangs before completing NTSC
		    System.gc();
		    generalDevice(i, "NTSC");
		} else {
		    generalDevice(i, null);
		}
		// No longer generate specific configurations,
		// let capture preview handle selection.
		// doDevice(i);
		nDevices++;
	    }
	}

	try {
	    CaptureDeviceManager.commit();
	    System.err.println("SunVideoPlusAuto: Committed ok");
	} catch (java.io.IOException ioe) {
	    System.err.println("SunVideoPlusAuto: error committing cdm");
	}
    
Methods Summary
protected voiddoDevice(int id)

	currentID = id;
	FormatSetup fd = new FormatSetup(currentID);
	Vector cdiv = fd.getDeviceInfo();
	if (cdiv != null && cdiv.size() > 0) {
	    for (int i = 0; i < cdiv.size(); i++) {
		CaptureDeviceInfo cdi = 
				(CaptureDeviceInfo) cdiv.elementAt(i);
		// At the moment, the name and locator are identical
		System.err.println("CaptureDeviceInfo = "
					+ cdi.getName());
//			System.err.println("CaptureDeviceInfo = "
//						+ cdi.getName() + " "
//						+ cdi.getLocator());
	    }
	}
    
protected voidgeneralDevice(int id, java.lang.String signal)

	// Add the general device
	javax.media.protocol.DataSource dsource = null;
	String url = LOCATOR_PREFIX + id;
	if (signal != null)
	    url += "////" + signal.toLowerCase();
	try {
	    dsource = Manager.createDataSource(new MediaLocator(url));
	} catch (Exception ex) {
	}
	if (dsource != null && dsource instanceof
		      com.sun.media.protocol.sunvideoplus.DataSource) {
	    CaptureDeviceInfo cdi = ((CaptureDevice)dsource).
						getCaptureDeviceInfo();
	    if (cdi != null) {
		String name = cdi.getName();
		if (signal == null) {
		    CaptureDeviceManager.addDevice(cdi);
		} else {
		    name = cdi.getName() + " (" + signal + ")";
		    CaptureDeviceManager.addDevice(new CaptureDeviceInfo(name,
					cdi.getLocator(), cdi.getFormats()));
		}
		System.err.println("CaptureDeviceInfo = "
					+ name + " "
					+ cdi.getLocator());
	    }
	    dsource.disconnect();
	}
    
public static voidmain(java.lang.String[] args)

	if (args.length > 0) {
	    if (args.length > 1) {
		System.err.println(
				"Usage: java SunVideoPlusAuto [ ntsc | pal ]");
		System.exit(1);
	    }
	    if (args[0].equalsIgnoreCase("ntsc")) {
		SunVideoPlusAuto.setPALSignal(false);
	    } else if (args[0].equalsIgnoreCase("pal")) {
		SunVideoPlusAuto.setPALSignal(true);
	    } else {
		System.err.println(
				"Usage: java SunVideoPlusAuto [ ntsc | pal ]");
		System.exit(1);
	    }
	}
	SunVideoPlusAuto m = new SunVideoPlusAuto();
	System.exit(0);
    
public static voidsetPALSignal(boolean pal)

	DO_PAL = pal;