📄 sipdialogconfvoip.cxx
字号:
"INVITE", dialogState.callId)); dispatcher->getLayerTransaction()->addTransaction(trans); //registerTransactionToDialog(trans);*/ //realm = resp->getRealm(); realm=resp->getAuthenticateProperty("realm"); //nonce = resp->getNonce(); nonce=resp->getAuthenticateProperty("nonce"); sendAuthInvite(""/*trans->getBranch()*/); return true; }else{ return false; }}bool SipDialogConfVoip::a21_callingauth_callingauth_18X( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, IGN, SipSMCommand::dialog_layer, "18*")){ MRef<SipResponse*> resp ( (SipResponse*)*command.getCommandPacket() );#ifdef ENABLE_TS ts.save( RINGING );#endif CommandString cmdstr(dialogState.callId, SipCommandString::remote_ringing); cmdstr.setParam3(confId); //getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); sipStack->getCallback()->handleCommand("sip_conf", cmdstr ); dialogState.remoteTag = command.getCommandPacket()->getHeaderValueTo()->getParameter("tag"); string peerUri = resp->getFrom().getString(); MRef<SdpPacket*> sdp((SdpPacket*)*resp->getContent()); if ( !sdp.isNull() ){ //Early media getMediaSession()->setSdpAnswer( sdp, peerUri ); } return true; }else{ return false; }}bool SipDialogConfVoip::a22_callingauth_callingauth_1xx( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, IGN, SipSMCommand::dialog_layer, "1**")){ dialogState.remoteTag = command.getCommandPacket()->getHeaderValueTo()->getParameter("tag"); return true; }else{ return false; }}bool SipDialogConfVoip::a23_callingauth_incall_2xx( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, IGN, SipSMCommand::dialog_layer, "2**")){ MRef<SipResponse*> resp( (SipResponse*)*command.getCommandPacket() ); string peerUri = resp->getFrom().getString(); setLogEntry( new LogEntryOutgoingCompletedCall() ); getLogEntry()->start = time( NULL ); getLogEntry()->peerSipUri = peerUri; dialogState.remoteTag = command.getCommandPacket()->getHeaderValueTo()->getParameter("tag"); CommandString cmdstr(dialogState.callId, SipCommandString::invite_ok, "", (getMediaSession()->isSecure()?"secure":"unprotected"), confId); //getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); sipStack->getCallback()->handleCommand("sip_conf", cmdstr ); if(!sortMIME(*resp->getContent(), peerUri, 3)) return false;#ifdef IPSEC_SUPPORT // Check if IPSEC was required if (ipsecSession->required() && !ipsecSession->offered) return false;#endif return true; }else{ return false; }}bool SipDialogConfVoip::a24_calling_termwait_2xx( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, IGN, SipSMCommand::dialog_layer, "2**")){ //int bye_seq_no= requestSeqNo(); ++dialogState.seqNo;// setCurrentState(toState);/* MRef<SipTransaction*> byetrans = new SipTransactionNonInviteClient(sipStack, //MRef<SipDialog*>(this), dialogState.seqNo, "BYE", dialogState.callId); dispatcher->getLayerTransaction()->addTransaction(byetrans); //registerTransactionToDialog(byetrans);*/ sendBye(""/*byetrans->getBranch()*/, dialogState.seqNo); CommandString cmdstr(dialogState.callId, SipCommandString::security_failed); cmdstr.setParam3(confId); //getDialogContainer()->getCallback()->sipcb_handleCommand(cmdstr); sipStack->getCallback()->handleCommand("sip_conf", cmdstr ); getMediaSession()->stop(); signalIfNoTransactions(); return true; } else{ return false; }}bool SipDialogConfVoip::a25_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*/ );#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; }}bool SipDialogConfVoip::a26_callingnoauth_termwait_transporterror( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::transport_error, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer )){ CommandString cmdstr(dialogState.callId, SipCommandString::transport_error); cmdstr.setParam3(confId); //getDialogContainer()->getCallback()->sipcb_handleCommand(cmdstr); sipStack->getCallback()->handleCommand("sip_conf", cmdstr ); return true; }else{ return false; }}//Copy of a8!bool SipDialogConfVoip::a26_callingauth_termwait_cancel( const SipSMCommand &command){ if ( transitionMatch(command, SipCommandString::cancel, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer) || transitionMatch(command, SipCommandString::hang_up, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer)){// setCurrentState(toState);/* MRef<SipTransaction*> canceltrans( new SipTransactionNonInviteClient(sipStack, //MRef<SipDialog*>(this), dialogState.seqNo, "CANCEL", dialogState.callId)); dispatcher->getLayerTransaction()->addTransaction(canceltrans); //registerTransactionToDialog(canceltrans);*/ sendCancel(""/*canceltrans->getBranch()*/); getMediaSession()->stop(); signalIfNoTransactions(); return true; }else{ return false; }}bool SipDialogConfVoip::a27_incall_incall_ACK( const SipSMCommand &command){ if (transitionMatch("ACK", command, SipSMCommand::transaction_layer, IGN)){ //... //cerr << "Received ACK in SipDialogConfVoIP!!!!!!!!!!!!!!!!!!!!!!!"<< endl; MRef<SipResponse*> resp( (SipResponse*)*command.getCommandPacket() ); massert(dynamic_cast<SdpPacket*>(*resp->getContent())!=NULL); MRef<SdpPacket*> sdp = (SdpPacket*)*resp->getContent(); string numToConnect = sdp->getSessionLevelAttribute("conf_#participants"); int num = 0; //--- Convert each digit char and add into result. int t=0; while (numToConnect[t] >= '0' && numToConnect[t] <='9') { num = (num * 10) + (numToConnect[t] - '0'); t++; } string users=""; for(t=0;t<num;t++) //connectList[t]= sdp->getSessionLevelAttribute("participant_"+itoa(t+1)); users=users+sdp->getSessionLevelAttribute("participant_"+itoa(t+1))+";"; //cerr<<"==============users: "+users<<endl; CommandString cmdstr(dialogState.callId, "invite_ack", users,(getMediaSession()->isSecure()?"secure":"unprotected"),confId); //getDialogContainer()->getCallback()->sipcb_handleCommand(cmdstr); sipStack->getCallback()->handleCommand("sip_conf", cmdstr ); #ifdef IPSEC_SUPPORT // Check if IPSEC was required if (ipsecSession->required() && !ipsecSession->offered) return false;#endif return true; }else{ return false; }}void SipDialogConfVoip::setUpStateMachine(){ State<SipSMCommand,string> *s_start=new State<SipSMCommand,string>(this,"start"); addState(s_start); State<SipSMCommand,string> *s_callingnoauth=new State<SipSMCommand,string>(this,"callingnoauth"); addState(s_callingnoauth); State<SipSMCommand,string> *s_callingauth=new State<SipSMCommand,string>(this,"callingauth"); addState(s_callingauth); State<SipSMCommand,string> *s_incall=new State<SipSMCommand,string>(this,"incall"); addState(s_incall); 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); State<SipSMCommand,string> *s_ringing=new State<SipSMCommand,string>(this,"ringing"); addState(s_ringing); new StateTransition<SipSMCommand,string>(this, "transition_start_callingnoauth_invite", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a0_start_callingnoauth_invite, s_start, s_callingnoauth); new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_callingnoauth_18X", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a1_callingnoauth_callingnoauth_18X, s_callingnoauth, s_callingnoauth); new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_callingnoauth_1xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a2_callingnoauth_callingnoauth_1xx, s_callingnoauth, s_callingnoauth); new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_incall_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a3_callingnoauth_incall_2xx, s_callingnoauth, s_incall); new StateTransition<SipSMCommand,string>(this, "transition_callingauth_termwait_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a24_calling_termwait_2xx, s_callingnoauth, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_incall_termwait_BYE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a5_incall_termwait_BYE, s_incall, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_incall_termwait_hangup", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand& )) &SipDialogConfVoip::a6_incall_termwait_hangup, s_incall, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_CANCEL", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a7_callingnoauth_termwait_CANCEL, s_callingnoauth, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_cancel", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a8_callingnoauth_termwait_cancel, s_callingnoauth, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_callingauth_40X", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a20_callingnoauth_callingauth_40X, s_callingnoauth, s_callingauth); new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_36", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a9_callingnoauth_termwait_36, s_callingnoauth, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_start_ringing_INVITE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a10_start_ringing_INVITE, s_start, s_ringing); new StateTransition<SipSMCommand,string>(this, "transition_ringing_incall_accept", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a11_ringing_incall_accept, s_ringing, s_incall); new StateTransition<SipSMCommand,string>(this, "transition_ringing_termwait_CANCEL", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a12_ringing_termwait_CANCEL, s_ringing, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_ringing_termwait_reject", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a13_ringing_termwait_reject, s_ringing, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_start_termwait_INVITE", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a16_start_termwait_INVITE, s_start, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_callingauth_callingauth_18X", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a21_callingauth_callingauth_18X, s_callingauth, s_callingauth); new StateTransition<SipSMCommand,string>(this, "transition_callingauth_callingauth_1xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a22_callingauth_callingauth_1xx, s_callingauth, s_callingauth); new StateTransition<SipSMCommand,string>(this, "transition_callingauth_incall_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a23_callingauth_incall_2xx, s_callingauth, s_incall); new StateTransition<SipSMCommand,string>(this, "transition_callingauth_termwait_2xx", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a24_calling_termwait_2xx, s_callingauth, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_callingauth_termwait_resp36", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a9_callingnoauth_termwait_36, s_callingauth, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_termwait_terminated_notransactions", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a25_termwait_terminated_notransactions, s_termwait, s_terminated); new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_transporterror", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a26_callingnoauth_termwait_transporterror, s_callingnoauth, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_callingauth_termwait_cancel", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a26_callingauth_termwait_cancel, s_callingauth, s_termwait); new StateTransition<SipSMCommand,string>(this, "transition_incall_incall_ACK", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogConfVoip::a27_incall_incall_ACK, s_incall, s_incall); setCurrentState(s_start);}#ifdef IPSEC_SUPPORTSipDialogConfVoip::SipDialogConfVoip(MRef<ConfMessageRouter*> confCb, MRef<SipStack*> stack, MRef<SipDialogConfig*> callconfig, MRef<SipSoftPhoneConfiguration*> pconf, MRef<Session *> mediaSession, minilist<ConfMember> *list, string confid, string cid, MRef<MsipIpsecAPI *> ipsecSession) : SipDialog(stack,callconfig), confCallback(confCb), lastInvite(NULL), phoneconf(pconf), mediaSession(mediaSession), ipsecSession(ipsecSession)#elseSipDialogConfVoip::SipDialogConfVoip(MRef<ConfMessageRouter*> confCb, MRef<SipStack*> stack, MRef<SipDialogConfig*> callconfig, MRef<SipSoftPhoneConfiguration*> pconf, MRef<Session *> mediaSession, minilist<ConfMember> *conflist,string confid, string cid) : SipDialog(stack,callconfig), confCallback(confCb), lastInvite(NULL), phoneconf(pconf), mediaSession(mediaSession)#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -