⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sunvideoplusmanual.java

📁 jmf的示例程序,学习jmf入门示例,很好很强大,什么功能都有
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * @(#)SunVideoPlusManual.java	1.3 01/03/13 * * Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */import javax.media.*;import javax.media.format.VideoFormat;import javax.media.format.RGBFormat;import javax.media.format.YUVFormat;import javax.media.format.AudioFormat;import java.util.*;import java.awt.*;import java.awt.event.*;import java.io.File;import com.sun.media.protocol.sunvideoplus.*;public class SunVideoPlusManual extends Frame {    private static String DEVICE_PREFIX = "/dev/o1k";    CaptureDeviceInfo [] devices = null;    int currentID = -1;        public SunVideoPlusManual() {	super("SunVideoPlus");	Font lblFont = new Font("Dialog", Font.BOLD + Font.ITALIC, 12);	setLayout(new BorderLayout());	BorderPanel bp = new BorderPanel();	bp.setLayout(new BorderLayout(0, 0));	Panel p = new Panel();	p.setLayout(new FlowLayout(FlowLayout.LEFT));	Label lbl = new Label("Configure Capture Devices");	lbl.setFont(lblFont);	p.add(lbl);	bp.add(BorderLayout.NORTH, p);	p = new Panel();	p.setLayout(new FlowLayout());	int nDevices = 0;	for (int i = 0; i < 10; i++) {	    File fl = new File(DEVICE_PREFIX + i);	    if (fl.exists()) {		Button device = new Button(DEVICE_PREFIX + i);		p.add(device);		device.addActionListener( new DBListener(i) );		nDevices++;	    }	}	bp.add(BorderLayout.CENTER, p);	add(BorderLayout.NORTH, bp);	devices = new CaptureDeviceInfo[nDevices];	p = new Panel();	p.setLayout(new FlowLayout());	Button bDone = new Button("Done");	bDone.addActionListener( new ActionListener() {	    public void actionPerformed(ActionEvent ae) {		if (currentID != -1) {		    System.err.println("Need to close other window first");		    return;		}		dispose();		System.exit(0);	    }	} );	p.add(bDone);	add(BorderLayout.SOUTH, p);	pack();	addWindowListener( new WindowAdapter() {	    public void windowClosing(WindowEvent we) {		if (currentID != -1) {		    System.err.println("Need to close other window first");		    return;		}		dispose();		System.exit(0);	    }	} );    }    public void createDialog(int id) {	if (currentID == id)	    return;	currentID = id;	Thread t = new Thread( new Runnable() {	    public void run() {		FormatsDialog fd = new FormatsDialog(currentID);		fd.setVisible(true);		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());		    }		}				currentID = -1;	    }	} );	t.start();	// Create a CaptureDeviceInfo....    }    class FormatsDialog extends Frame {	int id;	Button bFormat, bCancel;	CheckboxGroup cAnalogGroup;	Checkbox cNTSC, cPAL;	CheckboxGroup cPortGroup;	Checkbox cPort1, cPort2, cSvhs;	Checkbox cH261, cH263, cJpeg, cRGB, cYUV;	Checkbox cFull, cCif, cQuarter;	boolean fullVideo = false;	boolean anyVideo = true;	String sAnalog, sPort, sVideoFormat, sSize;	Hashtable videoFormats = new Hashtable();	OPICapture opiVidCap = null;	Integer lock = new Integer(1);	boolean finished = false;	boolean needFormat = false;		public FormatsDialog(int id) {	    super("sunvideoplus:" + DEVICE_PREFIX + id);	    this.id = id;	    setLayout(new BorderLayout());	    cAnalogGroup = new CheckboxGroup();	    cNTSC = new Checkbox("NTSC", true, cAnalogGroup);	    cPAL = new Checkbox("PAL", false, cAnalogGroup);	    cPortGroup = new CheckboxGroup();	    cPort1 = new Checkbox("1", true, cPortGroup);	    cPort2 = new Checkbox("2", false, cPortGroup);	    cSvhs = new Checkbox("S-VHS", false, cPortGroup);	    ItemListener videoListener = new ItemListener() {		public void itemStateChanged(ItemEvent e) {		    fullVideo = (cRGB.getState() | cYUV.getState());		    anyVideo = (cH261.getState() | cH263.getState()				| cJpeg.getState() | fullVideo);		    cFull.setEnabled(fullVideo);		    cCif.setEnabled(anyVideo);		    cQuarter.setEnabled(anyVideo);		}	    };	    cH261 = new Checkbox("h.261", false);	    cH261.addItemListener(videoListener);	    cH263 = new Checkbox("h.263", false);	    cH263.addItemListener(videoListener);	    cJpeg = new Checkbox("Jpeg", true);	    cJpeg.addItemListener(videoListener);	    cRGB = new Checkbox("RGB", false);	    cRGB.addItemListener(videoListener);	    cYUV = new Checkbox("YUV", false);	    cYUV.addItemListener(videoListener);	    cFull = new Checkbox("full cif", false);	    cFull.setEnabled(false);	    cCif = new Checkbox("cif", true);	    cQuarter = new Checkbox("quarter cif", false);	    bFormat = new Button("Add Formats");	    bCancel = new Button("Cancel");	    	    opiVidCap = new OPICapture(null);	    if (!opiVidCap.connect(id)) {		throw new Error("Unable to connect to device");	    }	    Font lblFont = new Font("Dialog", Font.BOLD + Font.ITALIC, 12);	    BorderPanel bp = new BorderPanel();	    bp.setLayout(new BorderLayout(0, 0));	    Panel p = new Panel();	    p.setLayout(new FlowLayout(FlowLayout.LEFT));	    Label lbl = new Label("Video Input Formats");	    lbl.setFont(lblFont);	    p.add(lbl);	    bp.add(BorderLayout.NORTH, p);	    Panel cp = new Panel();	    cp.setLayout(new BorderLayout());	    p = new Panel();	    p.setLayout(new FlowLayout());	    p.add(new Label("Analog"));	    p.add(cNTSC);	    p.add(cPAL);	    cp.add(BorderLayout.NORTH, p);	    p = new Panel();	    p.setLayout(new FlowLayout());	    p.add(new Label("Port"));	    p.add(cPort1);	    p.add(cPort2);	    p.add(cSvhs);	    cp.add(BorderLayout.SOUTH, p);	    bp.add(BorderLayout.CENTER, cp);	    	    cp = new Panel();	    cp.setLayout(new BorderLayout());	    p = new Panel();	    p.setLayout(new FlowLayout());	    p.add(new Label("Formats"));	    p.add(cH261);	    p.add(cH263);	    p.add(cJpeg);	    p.add(cRGB);	    p.add(cYUV);	    cp.add(BorderLayout.CENTER, p);	    p = new Panel();	    p.setLayout(new FlowLayout());	    p.add(new Label("Sizes"));	    p.add(cFull);	    p.add(cCif);	    p.add(cQuarter);	    cp.add(BorderLayout.SOUTH, p);	    bp.add(BorderLayout.SOUTH, cp);	    add(BorderLayout.NORTH, bp);	    p = new Panel();	    p.setLayout(new FlowLayout());	    p.add(bFormat);	    p.add(bCancel);	    add(BorderLayout.SOUTH, p);	    pack();	    addWindowListener( new WindowAdapter() {		public void windowClosing(WindowEvent we) {		    synchronized (lock) {			finished = true;			lock.notify();		    }		}	    } );	    bCancel.addActionListener( new ActionListener() {		public void actionPerformed(ActionEvent ae) {		    synchronized (lock) {			finished = true;			lock.notify();		    }		}	    } );	    bFormat.addActionListener( new ActionListener() {		public void actionPerformed(ActionEvent ae) {		    needFormat = true;		    synchronized (lock) {			lock.notify();		    }		}	    } );	}	private void addVideoFormat(Format fin) {	    String sVideo = sPort + "/" + sVideoFormat + "/"					+ sSize + "/"					+ sAnalog;	    System.err.println("New format " + sVideo + " = " + fin);	    videoFormats.put(sVideo, fin);	}	public void mydispose() {	    opiVidCap.disconnect();	    dispose();	    System.err.println("Disconnected driver");	}		public void doFormat() {	    if (!checkVideoFormats())		return;	    if (anyVideo) {		doVideoFormats();	    }	    finished = true;	}	public boolean checkVideoFormats() {	    if (!anyVideo)		return true;	    if (cCif.getState() | cQuarter.getState() |				    (cFull.getState() && cFull.isEnabled()))		return true;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -