📄 localdevicemonitorcontrol.java
字号:
this.mimeType = mimeType; }else{ this.mimeType = this.UNKNOWN_MIME_TYPE; } } public long getAverageImageEncodeTime() { return this.averageImageEncodeTime; } public String getMimeType() { return this.mimeType!=null ? this.mimeType : this.UNKNOWN_MIME_TYPE; } public MediaLocator getSelectedCaptureDeviceMediaLocator () { return getSelectedCaptureDevice () != null ? getSelectedCaptureDevice ().getLocator () : null; } public MonitorCDS getCustomDataSource () { if( getMonitorDataSource () == null) { DataSource captureDataSource = null; System.out.println ("Building MonitorDataSource"); MediaLocator captureLocator = getSelectedCaptureDeviceMediaLocator (); if(captureLocator == null) { System.out.println ("MediaLocator for capture device is NULL"); return null; } try{ captureDataSource = Manager.createDataSource (captureLocator); }catch(NoDataSourceException ndsx) { ndsx.printStackTrace (); }catch(IOException iox) { iox.printStackTrace (); } if(captureDataSource == null) { System.out.println ("DataSource is NULL"); return null; } try{ captureDataSource.connect (); }catch(IOException iox) { iox.printStackTrace (); } if(captureDataSource instanceof CaptureDevice) { CaptureDevice captureDevice = (CaptureDevice) captureDataSource; FormatControl[] controls = captureDevice.getFormatControls (); for(int i = 0 ; i < controls.length; i++) { FormatControl formatContorls = (FormatControl) controls[i]; Format[] formats = formatContorls.getSupportedFormats (); for(int j = 0; j < formats.length; j++) { if (formats[j].matches (getSelectedVideoFormat ())) { Format capFormat = formats[j].intersects (getSelectedVideoFormat ()); formatContorls.setFormat (capFormat); break; } } } monitorDataSource = new MonitorCDS (captureDataSource); }else { System.out.println ("DataSource is NOT an instance of CaptureDevice"); return null; } } return monitorDataSource; } public void obtainHardware() { try{ MonitorCDS ds = this.getCustomDataSource (); MonitorStream ms = (MonitorStream) ds.getStreams ()[0]; ms.addImageCaptureListener (this); monitorControl = (MonitorControl)ds.getControl ("jmfsample.MonitorStream"); if (LOG.isEnabledFor (Level.INFO)) { LOG.info("Monitor control = " + monitorControl); } if (monitorControl != null) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info("Monitor control component = " + monitorControl.getControlComponent ()); } setMonitorComponent ( monitorControl.getControlComponent ()); if (LOG.isEnabledFor (Level.INFO)) { LOG.info("Monitor control component = " + this.getMonitorComponent ()); } }else{ if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("NO MONITOR CONTROL"); } } }catch(Exception iox) { stopMonitor (); stopMonitorCapture(); iox.printStackTrace (); } if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("obtainHardware"); } } public void startMonitorCapture () { this.setupImageWriter(); this.setMonitorState (this.STARTED); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("startMonitorCapture"); } } public void startMonitor() { monitorControl.setEnabled (true); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("startMonitor"); } } public void stopMonitor() { if(monitorControl != null) { monitorControl.setEnabled (false); } if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("stopMonitor"); } } public void startTransmit() { this.setTransmitState(this.STARTED); this.start(); this.dispatchThread.start(); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("startTransmit"); } } public boolean isTransmit () { return transmit; } public void setTransmit (boolean trans) { transmit = trans; } public int getOutgoingBufferSize () { return outgoingBuffer.size (); } public int getMessagesSent () { return messagesSent; } public int getBytesSent () { return bytesSent; } public void releaseHardware() { this.stopMonitor(); this.stopMonitorCapture (); try { if(this.getMonitorDataSource () != null) { this.getMonitorDataSource ().stop (); this.getMonitorDataSource ().disconnect (); this.monitorControl = null; this.monitorDataSource = null; } }catch(IOException iox) { iox.printStackTrace (); } if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("Release Hardware"); } } public void stopMonitorCapture () { this.setMonitorState (this.STOPPED); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("stopMonitorCapture"); } } public void stopTransmit() { this.setTransmitState (this.STOPPED); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("stopTransmit"); } } public int getBufferSize() { return this.outgoingBuffer.size(); } public DialogMessage getNewTemplateMessage () { return (DialogMessage)this.templateMessage.clone (); } public int getImagesPerMessage () { return this.imagesPerMessage; } public void setImagesPerMessage (int imagesPerMessage) { if(imagesPerMessage < this.MINIMUM_IMAGES_PER_MESSAGE) { this.imagesPerMessage = this.MINIMUM_IMAGES_PER_MESSAGE; }else{ this.imagesPerMessage = imagesPerMessage; } } /** * Statistical Accessor. Returns the time delta of encoding an image */ public long getImageEncodeTime () { return this.imageEncodeTime; } public void setImageCompression (int imageCompression) { if(imageCompression >= this.MINIMUM_IMAGE_COMPRESSION) { this.imageCompression = imageCompression; }else { this.imageCompression = this.MINIMUM_IMAGE_COMPRESSION; } } public int getImageCompression () { return imageCompression; } private int getMonitorState () { return this.monitorState; } private void setMonitorState (int monitorState) { this.monitorState = monitorState; } class MyLock extends Object { private boolean locked = false; public boolean isLocked () { return locked; } public void setLocked (boolean locked) { this.locked = locked; } } public Component getMonitorComponent () { return this.monitor; } private void setMonitorComponent (Component monitorComponent) { this.monitor = monitorComponent; } public VideoFormat getSelectedVideoFormat () { return this.selectedVideoFormat; } public MonitorCDS getMonitorDataSource () { return this.monitorDataSource; } protected void setMonitorDataSource (MonitorCDS monitorDataSource) { this.monitorDataSource = monitorDataSource; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -