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

📄 vijxtacallcontrol.java

📁 jxta官方例程
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                                isJMFPresent = false;                            }                                                            this.remoteMonitorControl = new RemoteMonitorControl (this);                        templateMessage = new DialogMessage (this.viJxtaDialog.getGroup ()            .getPeerGroup ().getPeerName (), null, this.viJxtaDialog.getGroup ()            .getPeerGroup ().getPeerGroupID ().toString (), this.viJxtaDialog                    .getGroup ().getPeerGroup ().getPeerGroupName ());                        generalTimer = new Timer (true);                        roundTripTimerTask = new TimerTask () {                                public void run () {                                        localActionSendRoundTripRequest ();                }            };                                                                    }            }//constructor            /**     *  Returns the Dialog that this module is attched.     */    public Dialog getDialog () {                return this.viJxtaDialog;    }        public void initSession () {        if(this.isLocallyInitiated ()) {            if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("locally inititated");            }                        this.sendCommand (this.COMMAND_VIJXTA_INVITE_REQUEST, this.COMMAND_VIJXTA_INVITE_ACCEPT);                        this.setProtocolState (this.SESSION_VIJXTA_INVITE_REQUEST_SENT);                        generalTimer.schedule(roundTripTimerTask, this.ROUND_TRIP_INTERVAL, this.ROUND_TRIP_INTERVAL);        }else{            if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("NOT locally inititated");            }        }    }        public int getLocalVideoSourceType () {                return localVideoSourceType;    }                public void setLocalVideoSourceType (int localVideoSourceType) {                this.localVideoSourceType = localVideoSourceType;                if(this.localVideoSourceType == this.LOCAL_DEVICE && this.isJMFPresent)  {                        this.localMonitorControl = new LocalDeviceMonitorControl (this);                    }else if( this.localVideoSourceType == this.NETWORKED_DEVICE) {                        this.localMonitorControl = new NetworkedDeviceMonitorControl (this);                    }else if( this.localVideoSourceType == this.NO_DEVICE) {                        this.localMonitorControl = new NoDeviceMonitorControl (this);        }                this.localMonitorControl.addErrorListener (this);    }        public String getErrorMessage () {                return this.errorMessage;    }        private void setErrorMessage (String errorMessage) {                this.errorMessage = errorMessage;    }            public void deviceErrorEncountered (String errorString) {                setErrorMessage (errorString);                this.destroy ();    }        /**     *  Executes the session protocol logic.     *     *  basic order of operations:     *      SessionInviteRequest -->     *                                  <-- SessionInviteAccept     *      CallConfigRequest -->     *                                  <-- CallConfigAccept     *      CallStartRequest -->     *                                  <-- CallStartAccept     *      CallHangupRequest -->     *                                  <-- CallHangupAccept     *      SessionEndRequest -->     *                                  <-- SessionEndAccept     *     *  The Peer to Send an invitation controls the session start and call start.     *  After this either peer may place the call on hold. Once on hold only the     *  peer to place the call on hold may resume the call. CallHangup may be     *  performed by either peer. Quality elements are added to startcall     *  commands. Video data messages are not squenced and do not require ack's.     *  Session logic is limited to two peers. Protocol state is used as an     *  event notification mechanism and to determine protocol command order.     *  This is not an adaptive protocol. Strict order of operations is observed     */    public void callControl (String command, DialogMessage msg) {                if(COMMAND_VIJXTA_INVITE_REQUEST.equals (command) ) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_INVITE_REQUEST+" received");            }                        if (getProtocolState () == this.SESSION_VIJXTA_DISCONNECTED) {                                setProtocolState (this.SESSION_VIJXTA_INVITE_REQUEST_RECEIVED);                                sendCommand (this.COMMAND_VIJXTA_INVITE_ACCEPT);                                setProtocolState (this.SESSION_VIJXTA_INVITE_ACCEPT_SENT);                                // from here a config ui starts and we wait for a a config req                                generalTimer.schedule(roundTripTimerTask, this.ROUND_TRIP_INTERVAL, this.ROUND_TRIP_INTERVAL);                            }else{                                postProtocolStateException (this.SESSION_VIJXTA_DISCONNECTED);                            }                                            }else if(COMMAND_VIJXTA_INVITE_ACCEPT.equals (command) ) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_INVITE_ACCEPT+" received");            }                        if (getProtocolState () == this.SESSION_VIJXTA_INVITE_REQUEST_SENT) {                                updateAckThread (command);                                setProtocolState (this.SESSION_VIJXTA_INVITE_ACCEPT_RECEIVED);                                // wait as user configs                            }else{                                postProtocolStateException (this.SESSION_VIJXTA_INVITE_REQUEST_SENT);                            }                    }else if(COMMAND_VIJXTA_CONFIG_REQUEST.equals (command) ) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_CONFIG_REQUEST+" received");            }                        if (getProtocolState () == this.SESSION_VIJXTA_INVITE_ACCEPT_SENT) {                                parseConfigMessage (msg);                                setProtocolState (this.SESSION_VIJXTA_CONFIG_REQUEST_RECEIVED);                                localActionConfigRequestReceived (msg);                                            }else{                                postProtocolStateException (this.SESSION_VIJXTA_INVITE_ACCEPT_SENT);                            }                    }else if(COMMAND_VIJXTA_CONFIG_ACCEPT.equals (command) ) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_CONFIG_ACCEPT+" received");            }                        if (getProtocolState () == this.SESSION_VIJXTA_CONFIG_REQUEST_SENT) {                                updateAckThread (command);                                parseConfigMessage (msg);                                setProtocolState (this.SESSION_VIJXTA_CONFIG_ACCEPT_RECEIVED);                                localActionConfigAcceptReceived (msg);                            }else{                                postProtocolStateException (this.SESSION_VIJXTA_CONFIG_REQUEST_SENT);                            }                    }else if(COMMAND_VIJXTA_START_REQUEST.equals (command) ) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_START_REQUEST+" received");            }                        if (getProtocolState () == this.SESSION_VIJXTA_CONFIG_ACCEPT_SENT) {                                setProtocolState (this.SESSION_VIJXTA_START_REQUEST_RECEIVED);                                            }else{                                postProtocolStateException (this.SESSION_VIJXTA_CONFIG_ACCEPT_SENT);                                            }                    }else if(COMMAND_VIJXTA_START_ACCEPT.equals (command) ) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_START_ACCEPT+" received");            }                        if (getProtocolState () == this.SESSION_VIJXTA_START_REQUEST_SENT) {                                updateAckThread (command);                                setProtocolState (this.SESSION_VIJXTA_START_ACCEPT_RECEIVED);                                setProtocolState (this.SESSION_VIJXTA_INCALL);                            }else{                                postProtocolStateException (this.SESSION_VIJXTA_START_REQUEST_SENT);                            }                    }else if (COMMAND_VIJXTA_HOLD_REQUEST.equals (command)) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_HOLD_REQUEST+" received");            }                                    if(getProtocolState () == this.SESSION_VIJXTA_INCALL) {                                                                setProtocolState (this.SESSION_VIJXTA_HOLD_REQUEST_RECEIVED);                                sendCommand (this.COMMAND_VIJXTA_HOLD_ACCEPT, null);                                setProtocolState (this.SESSION_VIJXTA_HOLD_ACCEPT_SENT);                                //place call on hold - we did not initiate the hold                                localActionHoldCall (false);                                setProtocolState (this.SESSION_VIJXTA_HOLDING);                            }else{                                postProtocolStateException (this.SESSION_VIJXTA_INCALL);                            }                    }else if(COMMAND_VIJXTA_HOLD_ACCEPT.equals (command) ) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_HOLD_ACCEPT+" received");            }                        if(getProtocolState () == this.SESSION_VIJXTA_HOLD_REQUEST_SENT) {                                updateAckThread (command);                                setProtocolState (this.SESSION_VIJXTA_HOLD_ACCEPT_RECEIVED);                //place call on hold - we initiate the hold                localActionHoldCall (true);                                setProtocolState (this.SESSION_VIJXTA_HOLDING);                            }else{                                postProtocolStateException (this.SESSION_VIJXTA_HOLD_REQUEST_SENT);                            }                    }else if(COMMAND_VIJXTA_RESUME_REQUEST.equals (command)) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_RESUME_REQUEST+" received");            }                        if(getProtocolState () == this.SESSION_VIJXTA_HOLDING) {                                setProtocolState (this.SESSION_VIJXTA_RESUME_REQUEST_RECEIVED);                                sendCommand (this.COMMAND_VIJXTA_RESUME_ACCEPT, null);                                setProtocolState (this.SESSION_VIJXTA_RESUME_ACCEPT_SENT);                                // resume call                localActionResumeCall ();                                setProtocolState (this.SESSION_VIJXTA_INCALL);                            }else{                                                postProtocolStateException (this.SESSION_VIJXTA_HOLDING);                            }                    }else if(COMMAND_VIJXTA_RESUME_ACCEPT.equals (command)) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_RESUME_ACCEPT+" received");            }                        if(getProtocolState () == this.SESSION_VIJXTA_RESUME_REQUEST_SENT) {                                updateAckThread (command);                                setProtocolState (this.SESSION_VIJXTA_RESUME_ACCEPT_RECEIVED);                                // resume call                localActionResumeCall ();                                setProtocolState (this.SESSION_VIJXTA_INCALL);                            }else{                                postProtocolStateException (this.SESSION_VIJXTA_RESUME_REQUEST_SENT);                            }                    }else if(COMMAND_VIJXTA_HANGUP_REQUEST.equals (command)) {                        if (LOG.isEnabledFor (Level.INFO)) {                LOG.info ("callControl : "+this.COMMAND_VIJXTA_HANGUP_REQUEST+" received");            }                                    if(getProtocolState () == this.SESSION_VIJXTA_INCALL) {                                setProtocolState (this.SESSION_VIJXTA_HANGUP_REQUEST_RECEIVED);                                sendCommand (this.COMMAND_VIJXTA_HANGUP_ACCEPT, null);                                setProtocolState (this.SESSION_VIJXTA_HANGUP_ACCEPT_SENT);                                // hangup call - stop transfering data                localActionEndCall ();                                setProtocolState (this.SESSION_VIJXTA_ENDED);                                if(roundTripTimerTask != null) {                                        roundTripTimerTask.cancel ();                                    }            }else{                                postProtocolStateException (this.SESSION_VIJXTA_INCALL);                            }

⌨️ 快捷键说明

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