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

📄 localdevicemonitorcontrol.java

📁 Myjxta的源代码 基于JXTA的P2P即时通信系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            if(this.getTransmitState() == this.STOPPED) {                                this.stopMonitorCapture ();                                this.stopMonitor();                                this.releaseHardware ();            }            }        public int getTransmitState() {                return this.transmitState;    }        public void setTransmitState(int transmitState) {                this.transmitState = transmitState;    }            public void pauseMonitor() {                this.setMonitorState (this.PAUSED);    }        public void resumeMonitor() {                this.setMonitorState (this.STARTED);                synchronized(monitorPausedLock) {                        monitorPausedLock.notifyAll();        }    }        public void pauseTransmit() {                this.setTransmitState(this.PAUSED);    }        public void resumeTransmit() {                this.setTransmitState (this.STARTED);                synchronized(transmitPausedLock) {                        transmitPausedLock.notifyAll();        }    }        public long getImageCaptureDelay () {                return this.imageCaptureDelay;    }        public void setRefreshRate(int refreshRate) {                if(refreshRate >= this.MINIMUM_FRAMES_PER_SECOND &&                refreshRate <= this.MAXIMUM_FRAMES_PER_SECOND) {                        this.refreshRate = refreshRate;                        this.imageCaptureDelay = ((Long)refreshRateTable.get(new Integer(refreshRate))).longValue ();        }else{                        this.refreshRate = this.DEFAULT_FRAMES_PER_SECOND;                        this.imageCaptureDelay = ((Long)refreshRateTable.get(new Integer(this.DEFAULT_FRAMES_PER_SECOND))).longValue ();        }            }        public void addErrorListener(DeviceMonitorControl.DeviceErrorListener listener) {                }        public int getRefreshRate() {                return this.refreshRate;    }        private void setupImageWriter () {                Iterator writers = ImageIO.getImageWritersByFormatName (this.JPG_IMAGE_TYPE);                if (writers.hasNext ()) {                        imageWriter = (ImageWriter)writers.next ();        }else{            if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("Writer not available for image format " +                     this.JPG_MIME_TYPE);            }        }                jpegParams = new JPEGImageWriteParam (null);                jpegParams.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);                jpegParams.setCompressionQuality (this.getImageCompresionAsFloat (getImageCompression()));    }        private float getImageCompresionAsFloat(int intImageCompression) {                float floatImageCompression = 0.0f;                if(intImageCompression == 0) {                        floatImageCompression = 0.0f;        }else{                        floatImageCompression = (float) ((float) intImageCompression / 100);        }                return floatImageCompression;    }        public void imageCaptured (Image image) {                if(!captureLock.isLocked ()) {                        try {                                long in = System.currentTimeMillis ();                                BufferedImage capturedImage = new BufferedImage (                        image.getWidth (null), image.getHeight (null),                        BufferedImage.TYPE_INT_RGB);                                Graphics g = capturedImage.createGraphics ();                                g.drawImage (image, 0, 0, null);                                g.dispose ();                                ByteArrayOutputStream bos = new ByteArrayOutputStream ();                                ImageOutputStream ios = ImageIO.createImageOutputStream (bos);                                imageWriter.setOutput (ios);                                IIOImage iio = new IIOImage (capturedImage,null,null);                                imageWriter.write (null,iio,jpegParams);                                ios.flush ();                                ios.close ();                                outgoingBuffer.addLast (bos);                                long out = System.currentTimeMillis ();                                this.imageEncodeTime = out - in;                                if(this.averageImageEncodeTime != 0 ) {                                        this.averageImageEncodeTime =                             (this.averageImageEncodeTime + this.imageEncodeTime) / 2;                }                            }catch(Exception x) {                x.printStackTrace ();            }                        synchronized(captureLock) {                                captureLock.setLocked (true);            }                        if(bufferStarvedLock.isLocked ()) {                                synchronized(bufferStarvedLock) {                                        bufferStarvedLock.setLocked (false);                                        bufferStarvedLock.notifyAll ();                }            }        }    }        private Iterator getCaptureDevices (VideoFormat videoFormat) {                Iterator itr = CaptureDeviceManager.getDeviceList (                videoFormat).iterator ();                return itr != null ? itr : Collections.EMPTY_LIST.iterator ();    }        // returns a list of CaptureDeviceInfo    protected Iterator getImagingCaptureDevices () {                Iterator itr = null;                itr = getCaptureDevices (new VideoFormat (VideoFormat.RGB));                if(itr.hasNext ()) {                               }else{                                                itr = getCaptureDevices (new VideoFormat (VideoFormat.YUV));                        if(itr.hasNext ()) {                                            }else{                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                LOG.info("NO YUV cap device");                }            }        }                return itr;    }        // returns a list of strings. capture device names.    public Iterator getCaptureDeviceNames() {                ArrayList deviceNames = new ArrayList();                Iterator itr = getImagingCaptureDevices();                                while(itr.hasNext ()) {                                                CaptureDeviceInfo deviceInfo = (CaptureDeviceInfo) itr.next ();                        deviceNames.add (deviceInfo.getName ());        }                return deviceNames.iterator ();    }                public void setCaptureDevice(String deviceName) {                Iterator itr = getImagingCaptureDevices ();                        while(itr.hasNext()) {                                CaptureDeviceInfo cdi = (CaptureDeviceInfo) itr.next ();                                if(cdi.getName ().equals (deviceName)) {                                        setCaptureDevice(cdi);                                        break;                }            }    }            protected void setCaptureDevice (CaptureDeviceInfo captureDeviceInfo) {                this.selectedCaptureDeviceInfo = captureDeviceInfo;    }        public CaptureDeviceInfo getSelectedCaptureDevice () {                return this.selectedCaptureDeviceInfo;    }        protected Format[] getSelectedCaptureDeviceFormats () {                CaptureDeviceInfo captureDeviceInfo = getSelectedCaptureDevice ();                return captureDeviceInfo != null ? captureDeviceInfo.getFormats () : null;    }        // returns a string of format sizes    public Iterator getCaptureDeviceFormats() {                ArrayList formatStrings = new ArrayList();                Format[] formats = getSelectedCaptureDevice().getFormats ();                for (int i = 0; i < formats.length; i++) {            String size = null;            if (formats[i] instanceof RGBFormat) {                RGBFormat rgbFormat = (RGBFormat) formats[i];                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("format.getSize " + rgbFormat.getSize());                }                if (rgbFormat.getSize() != null) {                    size = ViJxtaUtil.dimensionToString(rgbFormat.getSize());                    formatStrings.add(size);                } else {                    if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                        LOG.info("Null RGB formatSize - discarded");                    }                }            } else if (formats[i] instanceof YUVFormat) {                YUVFormat yuvFormat = (YUVFormat) formats[i];                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("format.getSize " + yuvFormat.getSize());                }                if (yuvFormat.getSize() != null) {                    size = ViJxtaUtil.dimensionToString(yuvFormat.getSize());                    formatStrings.add(size);                } else {                    if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                        LOG.info("Null YUV formatSize - discarded");                    }                }            }        }                return formatStrings.iterator ();    }            public void setFormat(String formatString) {        Dimension size = ViJxtaUtil.stringToDimension (formatString);                Format[] formats = getSelectedCaptureDeviceFormats ();                for(int i = 0; i < formats.length; i++) {                        if(formats[i] instanceof RGBFormat) {                                RGBFormat rgbFormat = (RGBFormat) formats[i];                                if(rgbFormat.getSize ().equals (size)) {                                        setFormat (rgbFormat);                                        break;                }                                            }else if(formats[i] instanceof YUVFormat) {                                YUVFormat yuvFormat = (YUVFormat) formats[i];                                if(yuvFormat.getSize ().equals (size)) {                                        setFormat (yuvFormat);                                        break;                }            }        }                setMimeType (Monitor.JPG_MIME_TYPE);            }        protected void setFormat (VideoFormat videoFormat) {                this.selectedVideoFormat = videoFormat;    }        private void setMimeType(String mimeType) {                if(mimeType!=null) {                            this.mimeType = mimeType;        }else{            this.mimeType = this.UNKNOWN_MIME_TYPE;        }        

⌨️ 快捷键说明

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