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

📄 vijxtacallcontrol.java

📁 jxta官方例程
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                if(me != null) {                        ByteArrayMessageElement remoteImageReceiveElement = (ByteArrayMessageElement) me;                        String remoteImageReceiveString = remoteImageReceiveElement.toString ();                        if( remoteImageReceiveString != null) {                                this.setRemotePeerReceive (Boolean.valueOf (remoteImageReceiveString).booleanValue ());                                if (LOG.isEnabledFor (Level.INFO)) {                    LOG.info ("Remote Image Receive Received: "+ remoteImageReceiveString);                }            }        }                    }                public void setRemotePeerTransmit (boolean remotePeerTransmit) {                this.remotePeerTransmit = remotePeerTransmit;    }        public void setRemotePeerReceive (boolean remotePeerReceive) {                this.remotePeerReceive = remotePeerReceive;    }        public boolean isRemotePeerTransmit () {                return this.remotePeerTransmit;    }        public boolean isRemotePeerReceive () {                return this.remotePeerReceive;    }                protected HashMap getConfigElements () {                HashMap elementMap = new HashMap ();                if (LOG.isEnabledFor (Level.INFO)) {                    LOG.info ("LocalPeer Transmit ? "+ this.getLocalMonitorControl ().isTransmit ());                }                if(this.getLocalMonitorControl ().isTransmit ()) {                        String imageQualityString = String.valueOf (getLocalMonitorControl ().getImageCompression ());                        StringMessageElement imageQualityElement = new StringMessageElement (                    TAG_IMAGE_QUALITY_ELEMENT, imageQualityString, null);                        elementMap.put (TAG_IMAGE_QUALITY_ELEMENT,imageQualityElement);                                    String imageFormatSizeString = String.valueOf (ViJxtaUtil.                    dimensionToString (getLocalMonitorControl ().getFormatSize ()));                        StringMessageElement imageFormatSizeElement = new StringMessageElement (                    TAG_IMAGE_FORMAT_SIZE_ELEMENT, imageFormatSizeString , null);                        elementMap.put (TAG_IMAGE_FORMAT_SIZE_ELEMENT,imageFormatSizeElement);                                    String imageFormatTypeString = String.valueOf (getLocalMonitorControl ().getMimeType ());                        StringMessageElement imageFormatTypeElement = new StringMessageElement (                    TAG_IMAGE_FORMAT_TYPE_ELEMENT, imageFormatTypeString , null);                        elementMap.put (TAG_IMAGE_FORMAT_TYPE_ELEMENT,imageFormatTypeElement);                    }else{            LOG.info("AddElement NOT TRANSMITTING");        }                String imageReceiveString = String.valueOf (getRemoteMonitorControl ().isReceive ());                StringMessageElement imageReceiveElement = new StringMessageElement (                TAG_IMAGE_RECEIVE_ELEMENT, imageReceiveString , null);                elementMap.put (TAG_IMAGE_RECEIVE_ELEMENT,imageReceiveElement);                boolean transmit = false;                /** fix for issue#236, check for JMF only necessary when local device         * is in use. for internet cams a JMF check can be skipped.         */        if(this.localVideoSourceType == this.LOCAL_DEVICE) {                       transmit = (this.isJMFPresent ?                getLocalMonitorControl ().isTransmit () : false);                    }else if(this.localVideoSourceType == this.NETWORKED_DEVICE) {                        transmit = true; //xxx there should be checking here for errors                    }else if(this.localVideoSourceType == this.NO_DEVICE) {                        transmit = false;                    }                String imageTransmitString = String.valueOf (transmit);                StringMessageElement imageTransmitElement = new StringMessageElement (                TAG_IMAGE_TRANSMIT_ELEMENT, imageTransmitString , null);                elementMap.put (TAG_IMAGE_TRANSMIT_ELEMENT,imageTransmitElement);                return elementMap;    }                /**     *  Command SendStartRquest to remote.     *  XML elements attached:     *      -compression(image quality) level that remote peer is sending.     *      -format size (ie: 360x240)     *      -image format type (ie: jpeg, png, bmp)     */    protected void localActionSendConfigRequest () {                HashMap configMap = getConfigElements ();                sendCommand (this.COMMAND_VIJXTA_CONFIG_REQUEST,                this.COMMAND_VIJXTA_CONFIG_ACCEPT,                configMap);                                setProtocolState (this.SESSION_VIJXTA_CONFIG_REQUEST_SENT);            }            protected void localActionSendConfigAccept () {                HashMap configMap = getConfigElements ();                sendCommand (this.COMMAND_VIJXTA_CONFIG_ACCEPT,                null,                configMap);                setProtocolState (this.SESSION_VIJXTA_CONFIG_ACCEPT_SENT);            }                /**     *  Command StartRquest received from remote     *  XML elements attached:     *      -compression(image quality) level that remote peer is sending.     *      -format size (ie: 360x240)     *      -image format type (ie: jpeg, png, bmp)     *  SendAccept back to remote peer with attached elements     *     */    protected void localActionStartRequestReceived (DialogMessage msg) {                                    }            /**     *  Sets if this sesseion is to be persisted     *  TODO     */    public void setPersistSession (boolean persist, String fileName) {                this.sessionPersisted = persist;                this.sessionFileName = fileName;            }        /**     *     */    public boolean isSessionPersisted () {                return this.sessionPersisted;    }        /**     *     */    public String getSessionPersistFileName () {                return this.sessionFileName;    }        /**     *     */    public void viewActionPlaceCall () {                sendCommand (this.COMMAND_VIJXTA_START_REQUEST,this.COMMAND_VIJXTA_START_ACCEPT);                setProtocolState (this.SESSION_VIJXTA_START_REQUEST_SENT);                this.setCallStartTime ();    }        public void viewActionEndCall () {                if(roundTripTimerTask != null) {                        roundTripTimerTask.cancel ();                    }                sendCommand (this.COMMAND_VIJXTA_HANGUP_REQUEST, this.COMMAND_VIJXTA_HANGUP_ACCEPT);                setProtocolState (this.SESSION_VIJXTA_HANGUP_REQUEST_SENT);                this.localActionEndCall ();    }        public boolean isLocallyInitiated () {                return this.locallyInitiated;    }            private void setConfigured(boolean configured) {                this.configured = configured;    }        private boolean isConfigured() {                return this.configured;    }        public void viewActionConfigured () {                this.setConfigured(true);                if (LOG.isEnabledFor (Level.INFO)) {            LOG.info ("viewActionConfigured");        }                if(this.isLocallyInitiated ()) {                        this.localActionSendConfigRequest ();                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("viewActionConfigured: Locally initited");            }                    }else{                                    if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("viewActionConfigured: NOT Locally initited");            }                        if(this.getProtocolState () == ViJxtaCallControl.SESSION_VIJXTA_CONFIG_REQUEST_RECEIVED) {                                if (LOG.isEnabledFor (Level.INFO)) {                    LOG.info ("viewActionConfigured: config request has been received");                }                                localActionSendConfigAccept ();                            }else{                                if (LOG.isEnabledFor (Level.INFO)) {                    LOG.info ("viewActionConfigured: config request has NOT been received. starting timer");                }                                /** we'll wait 40 second for a config to come from the controlling                 *  peer. if none arrives then we go down. */                configWaitTimerTask = new TimerTask () {                    public void run () {                        if(getProtocolState () == ViJxtaCallControl.SESSION_VIJXTA_CONFIG_REQUEST_RECEIVED) {                                                        if (LOG.isEnabledFor (Level.INFO)) {                                LOG.info ("configWaitTimerTask: CONFIG REQUEST Received");                            }                                                                                    localActionSendConfigAccept ();                                                    }else{                                                        if (LOG.isEnabledFor (Level.INFO)) {                                LOG.info ("configWaitTimerTask: Timeout wating for remote config");                            }                                                        destroy ();                        }                    }                };                                generalTimer.schedule (configWaitTimerTask, CONFIG_WAIT_TIMOUT);                            }                                }    }    /**     *  Command EndCall reveived from remote peer     */    private void localActionEndCall () {                if (LOG.isEnabledFor (Level.INFO)) {            LOG.info ("localActionEndCall");        }                setCallEndTime ();                if(receiveTimeoutThread != null) {                        receiveTimeoutThread.stopThread ();                        receiveTimeoutThread = null;        }                this.stopTransmitReceive ();                this.stopMonitors ();    }        private void stopMonitors () {                if (LOG.isEnabledFor (Level.INFO)) {            LOG.info ("stopMonitors");        }                if(localMonitorControl != null) {                        getLocalMonitorControl ().stopMonitor ();                        getLocalMonitorControl ().releaseHardware ();        }                if(remoteMonitorControl != null) {                        getRemoteMonitorControl ().stopMonitor ();                        getRemoteMonitorControl ().releaseHardware ();        }    }        private void stopTransmitReceive () {                if(this.getLocalMonitorControl () != null) {                        getLocalMonitorControl ().stopTransmit ();        }                if(remoteMonitorControl != null) {                        getRemoteMonitorControl ().stopReceive ();        }    }                    /**     *  Sets the time in ms this call started     */    protected void setCallStartTime () {                                this.callStartTime = System.currentTimeMillis ();    }        /**     *  Sets the time in ms this call ended     */    protected void setCallEndTime () {        

⌨️ 快捷键说明

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