📄 sunvideoplusmanual.java
字号:
// Issue error popup dialog issueError("Must specify at least one Video size"); return false; } public void doVideoFormats() { if (!anyVideo) { // add a dummy format entry videoFormats.put("off", new VideoFormat(VideoFormat.RGB)); } Checkbox cAnalog = cAnalogGroup.getSelectedCheckbox(); sAnalog = ""; if (cAnalog == cNTSC) { sAnalog = "ntsc"; } else if (cAnalog == cPAL) { sAnalog = "pal"; } else { System.err.println("No analog signal specified"); return; } if (!opiVidCap.setSignal(sAnalog)) { System.err.println("Video analog signal not recognized"); return; } Checkbox cPort = cPortGroup.getSelectedCheckbox(); int port = 1; if (cPort == cPort1) { port = 1; } else if (cPort == cPort2) { port = 2; } else if (cPort == cSvhs) { port = 0; } else { System.err.println("No port specified"); return; } if (!opiVidCap.setPort(port)) { System.err.println("Video source not recognized on port"); return; } sPort = "" + port; if (cCif.getState()) { opiVidCap.setScale(2); sSize = "cif"; getVideoFormats(); } if (cQuarter.getState()) { opiVidCap.setScale(4); sSize = "qcif"; getVideoFormats(); } if (cFull.getState() && cFull.isEnabled()) { opiVidCap.setScale(1); sSize = "fcif"; getVideoFormats(); } } private void getVideoFormats() { if (cH261.getState()) { if (!(sSize.equals("fcif"))) { sVideoFormat = "h261"; getH261Format(); } } if (cH263.getState()) { if (!(sSize.equals("fcif"))) { sVideoFormat = "h263"; getH263Format(); } } if (cJpeg.getState()) { if (!(sSize.equals("fcif"))) { sVideoFormat = "jpeg"; getJpegFormat(); } } if (cRGB.getState()) { sVideoFormat = "rgb"; getRGBFormat(); } if (cYUV.getState()) { sVideoFormat = "yuv"; getYUVFormat(); } } private void getRGBFormat() { if (!opiVidCap.setCompress("RGB")) return; /* * If sizes are wanted, the only valid sizes are * NTSC * fcif (640 x 480) * cif (320 x 240) * qcif (160 x 120) * PAL * fcif (768 x 576) * cif (384 x 288) * qcif (192 x 144) */ Dimension size = new Dimension(opiVidCap.getWidth(), opiVidCap.getHeight()); addVideoFormat(new RGBFormat(size, Format.NOT_SPECIFIED, Format.byteArray, Format.NOT_SPECIFIED, 16, 0xF800, 0x7E0, 0x1F, 2, Format.NOT_SPECIFIED, Format.FALSE, Format.NOT_SPECIFIED)); } private void getYUVFormat() { if (!opiVidCap.setCompress("YUV")) return; /* * If sizes are wanted, the only valid sizes are * NTSC * fcif (640 x 480) * cif (320 x 240) * qcif (160 x 120) * PAL * fcif (768 x 576) * cif (384 x 288) * qcif (192 x 144) * * The capture stream is actually interleaved YVYU format. * This is defined in the offset values below. */ Dimension size = new Dimension(opiVidCap.getWidth(), opiVidCap.getHeight()); addVideoFormat(new YUVFormat(size, Format.NOT_SPECIFIED, Format.byteArray, Format.NOT_SPECIFIED, YUVFormat.YUV_YUYV, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, 0, 3, 1)); } private void getJpegFormat() { if (!opiVidCap.setCompress("Jpeg")) return; /* * If sizes are wanted, the only valid sizes are * NTSC * cif (320 x 240) * qcif (160 x 120) * PAL * cif (384 x 288) * qcif (192 x 144) */ Dimension size = new Dimension(opiVidCap.getWidth(), opiVidCap.getHeight()); addVideoFormat(new VideoFormat(VideoFormat.JPEG, size, Format.NOT_SPECIFIED, Format.byteArray, Format.NOT_SPECIFIED)); } private void getH261Format() { if (!opiVidCap.setCompress("H261")) return; /* * If sizes are wanted, the only valid sizes are * cif (352 x 288) * qcif (176 x 144) */ Dimension size = new Dimension(opiVidCap.getWidth(), opiVidCap.getHeight()); addVideoFormat(new VideoFormat(VideoFormat.H261, size, Format.NOT_SPECIFIED, Format.byteArray, Format.NOT_SPECIFIED)); } private void getH263Format() { if (!opiVidCap.setCompress("H263")) return; /* * If sizes are wanted, the only valid sizes are * cif (352 x 288) * qcif (176 x 144) */ Dimension size = new Dimension(opiVidCap.getWidth(), opiVidCap.getHeight()); addVideoFormat(new VideoFormat(VideoFormat.H263, size, Format.NOT_SPECIFIED, Format.byteArray, Format.NOT_SPECIFIED)); } public void issueError(String err) { System.err.println(err); Toolkit.getDefaultToolkit().beep(); } public Enumeration sortedFormats(Hashtable formats) { Vector sorted = new Vector(); keyloop: for (Enumeration en = formats.keys(); en.hasMoreElements(); ) { String key = (String) en.nextElement(); for (int i = 0; i < sorted.size(); i++) { if (key.compareTo((String)sorted.elementAt(i)) < 0) { sorted.insertElementAt(key, i); continue keyloop; } } sorted.addElement(key); } return sorted.elements(); } public Vector getDeviceInfo() { try { while (!finished) { synchronized (lock) { lock.wait(); } if (needFormat) { needFormat = false; doFormat(); } } } catch (InterruptedException ie) { mydispose(); return null; } String locatorPrefix = "sunvideoplus://" + id; mydispose(); /* * 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.getName(); if (devName.startsWith(locatorPrefix)) CaptureDeviceManager.removeDevice(cdi); } devices = new Vector(); if (anyVideo) { for (Enumeration ve = sortedFormats(videoFormats); ve.hasMoreElements(); ) { String vKey = (String) ve.nextElement(); Format vForm = (VideoFormat)videoFormats.get(vKey); Format[] farray = null; farray = new Format[1]; farray[0] = vForm; String name = locatorPrefix + "/" + vKey; CaptureDeviceInfo cdi = new CaptureDeviceInfo(name, new MediaLocator(name), farray); CaptureDeviceManager.addDevice(cdi); devices.addElement(cdi); } } try { CaptureDeviceManager.commit(); System.err.println("SunVideoPlusManual: Committed ok"); } catch (java.io.IOException ioe) { System.err.println("SunVideoPlusManual: error committing cdm"); } return devices; } } class DBListener implements ActionListener { int id; public DBListener(int id) { this.id = id; } public void actionPerformed(ActionEvent ae) { createDialog(id); } } class BorderPanel extends Panel { int insets = 7; public BorderPanel() { } public BorderPanel(int insets) { this.insets = insets; } public Insets getInsets() { return new Insets(insets, insets, insets, insets); } public void paint(Graphics g) { if (insets != 0) { Color bc = getBackground(); super.paint(g); Dimension size = getSize(); g.setColor(bc.darker()); g.drawLine(2, 2, size.width - 3, 2); g.drawLine(2, 2, 2, size.height - 3); g.setColor(bc.brighter()); g.drawLine(size.width - 3, 2, size.width - 3, size.height - 3); g.drawLine(2, size.height - 3, size.width - 3, size.height - 3); } } } public static void main(String [] args) { SunVideoPlusManual m = new SunVideoPlusManual(); m.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -