📄 sipdialogvoip.cxx
字号:
}#endif return true; }else{ return false; }}bool SipDialogVoip::a1101_termwait_terminated_notransactions( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::no_transactions, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer) ){ lastInvite=NULL; SipSMCommand cmd( CommandString( dialogState.callId, SipCommandString::call_terminated), SipSMCommand::dialog_layer, SipSMCommand::dispatcher); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/ ); /* Tell the GUI */ //CommandString cmdstr( dialogState.callId, SipCommandString::call_terminated); //sipStack->getCallback()->handleCommand("gui", cmdstr );#ifdef IPSEC_SUPPORT if(ipsecSession){ cerr << "Clearing" << endl; if(ipsecSession->stop() != 0) cerr << "Not all IPSEC parameters were confired cleared. Check and remove manually." << endl; }#endif return true; }else{ return false; }}//notify the gui that dialog is finished ... just some transactions need to //finish absorbing messages//also, reply to the dialog container when extra hang_up messages are received// (this happens when you hang up a call from the gui and then exit minisip,// the sipdialogmanagement would send a hang up and receive no call_term_early ...// with this, it works).bool SipDialogVoip::a1102_termwait_termwait_early( const SipSMCommand &command){ if( transitionMatch(command, SipCommandString::hang_up, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer) ) { CommandString cmdstr( dialogState.callId, SipCommandString::call_terminated_early); /* Tell the GUI, once only */ if( notifyEarlyTermination ) { sipStack->getCallback()->handleCommand("gui", cmdstr ); notifyEarlyTermination = false; } SipSMCommand cmd( cmdstr, SipSMCommand::dialog_layer, SipSMCommand::dispatcher); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/ ); //this is for the shutdown dialog return true; } else if ( notifyEarlyTermination && transitionMatch(SipResponse::type, command, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer, "2**")){ lastInvite=NULL; //Notify the GUI and the dialog container ... CommandString cmdstr( dialogState.callId, SipCommandString::call_terminated_early); /* Tell the GUI, once only */ sipStack->getCallback()->handleCommand("gui", cmdstr ); notifyEarlyTermination = false; //Tell the dialog container ... SipSMCommand cmd( cmdstr, SipSMCommand::dialog_layer, SipSMCommand::dispatcher); dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/ ); //this is for the shutdown dialog return true; }else{ return false; }}bool SipDialogVoip::a1201_incall_transferrequested_transfer( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::user_transfer, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer)){ //int bye_seq_no= requestSeqNo(); string referredUri = command.getCommandString().getParam(); ++dialogState.seqNo;/* MRef<SipTransaction*> refertrans( new SipTransactionNonInviteClient(sipStack, //MRef<SipDialog*>(this), dialogState.seqNo, "REFER", dialogState.callId)); dispatcher->getLayerTransaction()->addTransaction(refertrans); //registerTransactionToDialog(refertrans);*/ sendRefer(""/*refertrans->getBranch()*/, dialogState.seqNo, referredUri); return true; }else{ return false; }}bool SipDialogVoip::a1202_transferrequested_transferpending_202( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer, "202")){ MRef<SipResponse*> resp( (SipResponse*)*command.getCommandPacket() ); CommandString cmdstr(dialogState.callId, SipCommandString::transfer_pending ); sipStack->getCallback()->handleCommand("gui", cmdstr ); /* Minisip does not actually keep track of the transfer ... if the REFER is accepted by the far end, then shutdown the media */ getMediaSession()->stop(); signalIfNoTransactions(); return true; }else{ return false; }}bool SipDialogVoip::a1203_transferrequested_incall_36( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer, "3**\n4**\n5**\n6**")){ CommandString cmdstr( dialogState.callId, SipCommandString::transfer_refused, command.getCommandPacket()->getWarningMessage()); sipStack->getCallback()->handleCommand("gui", cmdstr ); return true; }else{ return false; }}bool SipDialogVoip::a1204_transferpending_transferpending_notify( const SipSMCommand &command) { bool ret = false; if (transitionMatch("NOTIFY", command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer)){ //this is just the same notify, lifted from the transaction up to the dialog ... //we can safely absorb it ... return true; } else if (transitionMatch("NOTIFY", command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer)){ MRef<SipRequest*> notif; notif = (SipRequest*)*command.getCommandPacket();/* MRef<SipTransaction*> notifyResp = new SipTransactionNonInviteServer( sipStack, //MRef<SipDialog*>(this), notif->getCSeq(), notif->getCSeqMethod(), notif->getLastViaBranch(), dialogState.callId); //TODO: remove second argument dispatcher->getLayerTransaction()->addTransaction(notifyResp); //registerTransactionToDialog(notifyResp);*/ SipSMCommand cmd(command); cmd.setDestination(SipSMCommand::transaction_layer); cmd.setSource(command.getSource()); dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/); sendNotifyOk(notif, ""/*notifyResp->getBranch()*/ ); ret = true; } return ret;}bool SipDialogVoip::a1301_incall_transferaskuser_REFER( const SipSMCommand &command){ if (transitionMatch("REFER", command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer)){/* MRef<SipTransaction*> cr( new SipTransactionNonInviteServer(sipStack, //MRef<SipDialog*>(this), command.getCommandPacket()->getCSeq(), command.getCommandPacket()->getCSeqMethod(), command.getCommandPacket()->getLastViaBranch(), dialogState.callId) ); dispatcher->getLayerTransaction()->addTransaction(cr); //registerTransactionToDialog(cr); SipSMCommand cmd(command); cmd.setDestination(SipSMCommand::transaction_layer); dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE);*/ if (command.getCommandPacket()->getType()=="REFER"){ lastRefer = dynamic_cast<SipRequest*>(*command.getCommandPacket()); }else{ lastRefer = NULL; } string referredUri=getReferredUri(lastRefer); /* Tell the GUI */ CommandString cmdstr(dialogState.callId, SipCommandString::transfer_requested, referredUri); sipStack->getCallback()->handleCommand("gui", cmdstr ); return true; }else{ return false; }}bool SipDialogVoip::a1302_transferaskuser_transferstarted_accept( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::user_transfer_accept, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer)){ sendReferOk(lastRefer->getDestinationBranch() ); /* start a new call ... */ string uri = getReferredUri(lastRefer); //string newCallId = phoneconf->sip->invite( uri ); CommandString invite("",SipCommandString::invite, uri); CommandString resp = phoneconf->sip->handleCommandResp("sip",invite); string newCallId=resp.getDestinationId(); /* Send the new callId to the GUI */ CommandString cmdstr(dialogState.callId, SipCommandString::call_transferred, newCallId); sipStack->getCallback()->handleCommand("gui", cmdstr ); return true; }else{ return false; }}bool SipDialogVoip::a1303_transferaskuser_incall_refuse( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::user_transfer_refuse, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer)){ sendReferReject(lastRefer->getDestinationBranch()); return true; }else{ return false; }}void SipDialogVoip::setUpStateMachine(){ State<SipSMCommand,string> *s_incall=new State<SipSMCommand,string>(this,"incall"); addState(s_incall); State<SipSMCommand,string> *s_byerequest=new State<SipSMCommand,string>(this,"bye_request"); addState(s_byerequest); State<SipSMCommand,string> *s_termwait=new State<SipSMCommand,string>(this,"termwait"); addState(s_termwait); State<SipSMCommand,string> *s_terminated=new State<SipSMCommand,string>(this,"terminated"); addState(s_terminated); // call transfer states State<SipSMCommand,string> *s_transferrequested=new State<SipSMCommand,string>(this,"transferrequested"); addState(s_transferrequested); State<SipSMCommand,string> *s_transferpending=new State<SipSMCommand,string>(this,"transferpending"); addState(s_transferpending); State<SipSMCommand,string> *s_transferaskuser=new State<SipSMCommand,string>(this,"transferaskuser"); addState(s_transferaskuser); State<SipSMCommand,string> *s_transferstarted=new State<SipSMCommand,string>(this,"transferstarted"); addState(s_transferstarted); // Ending a call new StateTransition<SipSMCommand,string>(this, "transition_incall_termwait_BYE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoip::a1001_incall_termwait_BYE, s_incall, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_incall_byerequest_hangup", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand& )) &SipDialogVoip::a1002_incall_byerequest_hangup, s_incall, s_byerequest); new StateTransition<SipSMCommand,string>(this, "transition_byerequest_termwait_26", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand& )) &SipDialogVoip::a1003_byerequest_termwait_26, s_byerequest,s_termwait); // Transaction/dialog management new StateTransition<SipSMCommand,string>(this, "transition_termwait_terminated_notransactions", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoip::a1101_termwait_terminated_notransactions, s_termwait, s_terminated); new StateTransition<SipSMCommand,string>(this, "transition_termwait_termwait_earlynotify", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoip::a1102_termwait_termwait_early, s_termwait, s_termwait); // Locally initiated call transfer new StateTransition<SipSMCommand,string>(this, "transition_incall_transferrequested_transfer", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoip::a1201_incall_transferrequested_transfer, s_incall, s_transferrequested); new StateTransition<SipSMCommand,string>(this, "transition_transferrequested_transferpending_202",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -