All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.sarxos.webcam.ds.jmf.JmfDriver Maven / Gradle / Ivy

package com.github.sarxos.webcam.ds.jmf;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Format;

import com.github.sarxos.webcam.WebcamDevice;
import com.github.sarxos.webcam.WebcamDriver;


public class JmfDriver implements WebcamDriver {

	private static List devices = null;

	@Override
	public List getDevices() {

		if (devices == null) {

			devices = new ArrayList();

			@SuppressWarnings("unchecked")
			Vector cdis = CaptureDeviceManager.getDeviceList(new Format("RGB"));
			Iterator di = cdis.iterator();

			while (di.hasNext()) {
				CaptureDeviceInfo cdi = (CaptureDeviceInfo) di.next();
				devices.add(new JmfDevice(cdi));
			}
		}

		return devices;
	}

	@Override
	public boolean isThreadSafe() {
		return false;
	}
}