📄 sipdialogp2t.cxx
字号:
if(uri==""){ merr<<"SipDialogP2T:: Error in a17. User didn't exist."<<end; return false; } //send Revoke message /*vc->*/getFloorControlSender() ->send_APP_FC(P2T::APP_REVOKE, /*vc->*/getDialogConfig()->local_ssrc, P2T::APP_NAME, /*vc->*/getGroupList()->getUser(uri)->getAddress(), /*vc->*/getGroupList()->getUser(uri)->getRTCPport(), /*vc->*/getGroupList()->getUser(uri)->getSeqNo(), 3); //start RtcpTransactionIdleFloor MRef<GroupListUserElement*> ue = /*vc->*/getGroupList()->getUser(uri); MRef<SipTransaction*> gf = new RtcpTransactionIdleFloor(MRef<SipDialog*>(/* *vc */ this), ue->getSeqNo(), ue->getAddress(), ue->getRTCPport(), dialogState.callId, ue->getSSRC()); /*vc->*/registerTransaction(gf); CommandString cmd(/*vc->*/getCallId(), "p2tReleaseFloor", itoa(ue->getSSRC()), itoa(ue->getSeqNo())); SipSMCommand scmd(cmd, SipSMCommand::TU, SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(scmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); //inform GUI CommandString cmd2(/*vc->*/getCallId(),string("p2tFloorReleased")); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmd2 ); //reset states /*vc->*/setStates(P2T::STATUS_CONNECTED); //stop listening //vc->getSoundReceiver()->stop(); return true; }else{ return false; }}bool SipDialogP2T::a18_talk_talk_revoke( const SipSMCommand &command){ if (transitionMatch(command, "p2tREVOKE")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; //check sequence number int sNo=0; uint32_t x; for(x=0;x<command.getCommandString().getParam2().size();x++) sNo = (sNo*10) + (command.getCommandString().getParam2()[x]-'0'); int ssrc=0; for(x=0;x<command.getCommandString().getParam().size();x++) ssrc = (ssrc*10) + (command.getCommandString().getParam()[x]-'0'); if(sNo==/*vc->*/dialogState.seqNo){ //inform GUI CommandString cmd2(/*vc->*/getCallId(),string("p2tFloorRevokePassiv"), /*vc->*/getGroupList()->getUser(ssrc)->getUri(), command.getCommandString().getParam3()); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmd2 ); } return true; }else{ return false; }}bool SipDialogP2T::a19_listenreq_listenreq( const SipSMCommand &command){ if (transitionMatch(command, "p2tREQUEST")){ //start RtcpTransactionGrantFloor //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine;#ifdef MINISIP_MEMDEBUG// vc.setUser("WARNING - transaction");#endif //uri string uri = command.getCommandString().getParam3(); //seqNo string p2 = command.getCommandString().getParam2(); //ssrc string p = command.getCommandString().getParam(); int ssrc=0; for(uint32_t k=0;k<p.size(); k++){ ssrc = (ssrc*10)+(p[k]-'0'); } mdbg<<"---------------------------------"<<end; mdbg<<"SipDialogP2T:: a19_listenreq_listenreq"<<end; mdbg<<"ssrc="<<itoa(ssrc)<<end; //mdbg<<"status="<<itoa(vc->getGroupList()->getUser(ssrc)->getStatus())<<end; mdbg<<"REQUESTING="<<P2T::STATUS_REQUESTING<<end; mdbg<<"----------------------------------"<<end; int sNo=0; for(uint32_t x=0;x<p2.size();x++) sNo = (sNo*10) + (p2[x]-'0'); //check if user is participating in the session if (/*vc->*/getGroupList()->isParticipant(uri)){ //check if it is a new user that is requesting if(/*vc->*/getGroupList()->getUser(uri)->getStatus()==P2T::STATUS_REQUESTING) return false; MRef<GroupListUserElement*> ue = /*vc->*/getGroupList()->getUser(uri); ue->setSSRC(ssrc); ue->setSeqNo(sNo); ue->setStatus(P2T::STATUS_REQUESTING); MRef<SipTransaction*> gf = new RtcpTransactionGrantFloor(MRef<SipDialog*>(/* *vc */), sNo, ue->getAddress(), ue->getRTCPport(), dialogState.callId, ssrc); /*vc->*/registerTransaction(gf); CommandString cmd(/*vc->*/getCallId(), "p2tSendGrant", itoa(ssrc), itoa(sNo), uri); SipSMCommand scmd(cmd, SipSMCommand::TU, SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(scmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); } else if (/*vc->*/getGroupList()->isParticipant(ssrc)){ //check if it is a new user that is requesting if(/*vc->*/getGroupList()->getUser(ssrc)->getStatus()==P2T::STATUS_REQUESTING) return false; MRef<GroupListUserElement*> ue = /*vc->*/getGroupList()->getUser(ssrc); ue->setSSRC(ssrc); ue->setSeqNo(sNo); ue->setStatus(P2T::STATUS_REQUESTING); MRef<SipTransaction*> gf = new RtcpTransactionGrantFloor(MRef<SipDialog*>(/* *vc */ this), sNo, ue->getAddress(), ue->getRTCPport(), dialogState.callId, ssrc); /*vc->*/registerTransaction(gf); CommandString cmd(/*vc->*/getCallId(), "p2tSendGrant", itoa(ssrc), itoa(sNo), uri); SipSMCommand scmd(cmd, SipSMCommand::TU, SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(scmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); } else{ //unknown user //stay in IDLE return false; } return true; }else{ return false; }}bool SipDialogP2T::a80_idle_terminated( const SipSMCommand &command){ if (transitionMatch(command, "p2tTerminate")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; /*vc->*/terminateSession(); return true; }else{ return false; }}bool SipDialogP2T::a81_talkreq_terminated( const SipSMCommand &command){ if (transitionMatch(command, "p2tTerminate")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; /*vc->*/terminateSession(); return true; }else{ return false; }}bool SipDialogP2T::a82_listenreq_terminated( const SipSMCommand &command){ if (transitionMatch(command, "p2tTerminate")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; /*vc->*/terminateSession(); return true; }else{ return false; }}bool SipDialogP2T::a83_talk_terminated( const SipSMCommand &command){ if (transitionMatch(command, "p2tTerminate")){ //start RtcpTransactionReleaseFloor //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine;#ifdef MINISIP_MEMDEBUG //vc.setUser("WARNING - transaction");#endif //start RtcpTransactionReleaseFloor for(uint32_t k=0;k</*vc->*/getGroupList()->getAllUser().size();k++){ //filter out own user //if(vc->getGroupList()->getAllUser().at(k)->getUri()==vc->getDialogConfig().inherited->userUri) if(/*vc->*/getGroupList()->getAllUser()[k]->getUri()==/*vc->*/getDialogConfig()->inherited->sipIdentity->getSipUri()) continue; //filter out NOTAVAILABLE users if(/*vc->*/getGroupList()->getAllUser()[k]->getStatus()==P2T::STATUS_NOTAVAILABLE) continue; //start transaction MRef<SipTransaction*> rf = new RtcpTransactionReleaseFloor(MRef<SipDialog *>(/* *vc */ this), /*vc->*/dialogState.seqNo, /*vc->*/getGroupList()->getAllUser()[k]->getAddress(), /*vc->*/getGroupList()->getAllUser()[k]->getRTCPport(), dialogState.callId, /*vc->*/getGroupList()->getAllUser()[k]->getSSRC()); /*vc->*/registerTransaction(rf); CommandString cmd(/*vc->*/getCallId(),"p2tReleaseFloor", itoa(/*vc->*/getGroupList()->getAllUser()[k]->getSSRC()), itoa(/*vc->*/dialogState.seqNo), /*vc->*/getGroupList()->getAllUser()[k]->getUri()); SipSMCommand scmd(cmd, SipSMCommand::TU, SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(scmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); } //terminate Session /*vc->*/terminateSession(); return true; }else{ return false; }}bool SipDialogP2T::a84_collision_terminated( const SipSMCommand &command){ if (transitionMatch(command, "p2tTerminate")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; /*vc->*/terminateSession(); return true; }else{ return false; }}bool SipDialogP2T::a85_listen_terminated( const SipSMCommand &command){ if (transitionMatch(command, "p2tTerminate")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; /*vc->*/terminateSession(); return true; }else{ return false; }}bool SipDialogP2T::a86_releasepend_terminated( const SipSMCommand &command){ if (transitionMatch(command, "p2tTerminate")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; /*vc->*/terminateSession(); return true; }else{ return false; }}bool SipDialogP2T::a87_resent_terminated( const SipSMCommand &command){ if (transitionMatch(command, "p2tTerminate")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; /*vc->*/terminateSession(); return true; }else{ return false; }}bool SipDialogP2T::a97_idle_talkreq_collisioner( const SipSMCommand &command){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; if (transitionMatch(command, "p2tREQUEST") && /*vc->*/p2tCollisioner){ //start RtcpTransactionGetFloor #ifdef MINISIP_MEMDEBUG //vc.setUser("WARNING - transaction");#endif //time measurement#ifndef _MSC_VER if(/*vc->*/p2tPerformance){ ts.start(); }#endif //increment sequence number /*vc->*/dialogState.seqNo++; //start RtcpTransactionGetFloor for(uint32_t k=0;k</*vc->*/getGroupList()->getAllUser().size();k++){ //filter out own user //if(vc->getGroupList()->getAllUser().at(k)->getUri()==vc->getDialogConfig().inherited->userUri) if(/*vc->*/getGroupList()->getAllUser()[k]->getUri()==/*vc->*/getDialogConfig()->inherited->sipIdentity->getSipUri()) continue; //filter out NOTAVAILABLE users if(/*vc->*/getGroupList()->getAllUser()[k]->getStatus()==P2T::STATUS_NOTAVAILABLE) continue; //start transaction MRef<SipTransaction*> gf = new RtcpTransactionGetFloor(MRef<SipDialog *>(/* *vc */ this), /*vc->*/dialogState.seqNo, /*vc->*/getGroupList()->getAllUser()[k]->getAddress(), /*vc->*/getGroupList()->getAllUser()[k]->getRTCPport(), dialogState.callId); MRef<RtcpTransactionGetFloor*>gf_casted = MRef<RtcpTransactionGetFloor*>((RtcpTransactionGetFloor*)*gf); gf_casted->setUser(/*vc->*/ getGroupList()->getAllUser()[k]->getUri()); if(/*vc->*/getGroupList()->getAllUser()[k]->getUri()==command.getCommandString().getParam3()){ gf_casted->first_invitation=true; } /*vc->*/registerTransaction(gf); CommandString cmd(/*vc->*/getCallId(),"p2tSendRequest", itoa(/*vc->*/getGroupList()->getAllUser()[k]->getSSRC()), itoa(/*vc->*/dialogState.seqNo), /*vc->*/getGroupList()->getAllUser()[k]->getUri()); SipSMCommand scmd(cmd, SipSMCommand::TU, SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(scmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); } //send received Floor REQUEST message to transaction /*vc->*/getDialogContainer()->enqueueCommand(command, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); return true; }else{ return false; }}bool SipDialogP2T::a98_idle_idle_performance( const SipSMCommand &command){ if (transitionMatch(command, "p2tPerformance")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; /*vc->*/p2tPerformance=true; string init_data; init_data = "Timer Values[ms]\r\n"; ostringstream Str; Str<<P2T::timerRESEND; init_data += "timerRESEND;" + Str.str() + "\r\n"; init_data += "timerREVOKE;" + itoa(P2T::timerREVOKE) + "\r\n"; init_data += "timerGRANT;" + itoa(P2T::timerGRANT) + "\r\n"; init_data += "timerIDLE;" + itoa(P2T::timerIDLE) + "\r\n"; init_data += "timerTAKEN;" + itoa(P2T::timerTAKEN) + "\r\n"; init_data += "timerRelTIMEOUT;" + itoa(P2T::timerRelTIMEOUT) + "\r\n"; init_data += "timerGetTIMEOUT;" + itoa(P2T::timerGetTIMEOUT) + "\r\n"; init_data += "timerGetFloorTERMINATE;" + itoa(P2T::timerGetFloorTERMINATE) + "\r\n"; init_data += "timerGrantFloorTERMINATE;" + itoa(P2T::timerGrantFloorTERMINATE) + "\r\n"; init_data += "timerRelFloorTERMINATE;" + itoa(P2T::timerRelFloorTERMINATE) + "\r\n"; init_data += "timerIdleFloorTERMINATE;" + itoa(P2T::timerIdleFloorTERMINATE) + "\r\n";#ifndef _MSC_VER ts.init(P2T::PERFORMANCE_FILE, init_data);#endif return true; }else{ return false; }}bool SipDialogP2T::a99_idle_idle_collisioner( const SipSMCommand &command){ if (transitionMatch(command, "p2tCollisioner")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; /*vc->*/p2tCollisioner=true; return true; }else{ return false; }}/** * SipDialogP2T::setUpStateMachine() * defines the states and transactions for the state machine. */void SipDialogP2T::setUpStateMachine(){ //states: State<SipSMCommand,string> *s_idle=new State<SipSMCommand,string>(this,"idle"); addState(s_idle); State<SipSMCommand,string> *s_talk_req=new State<SipSMCommand,string>(this,"talk_req"); addState(s_talk_req); State<SipSMCommand,string> *s_talk=new State<SipSMCommand,string>(this,"talk"); addState(s_talk); State<SipSMCommand,string> *s_release_pend=new State<SipSMCommand,string>(this,"release_pend"); addState(s_release_pend); State<SipSMCommand,string> *s_listen_req=new State<SipSMCommand,string>(this,"listen_req"); addState(s_listen_req); State<SipSMCommand,string> *s_listen=new State<SipSMCommand,string>(this,"listen"); addState(s_listen); State<SipSMCommand,string> *s_collision=new State<SipSMCommand,string>(this,"collision"); addState(s_collision); State<SipSMCommand,string> *s_resent=new State<SipSMCommand,string>(this,"resent"); addState(s_resent); State<SipSMCommand,string> *s_terminated=new State<SipSMCommand,string>(this,"terminated"); addState(s_terminated); //transactions:// StateTransition<SipSMCommand,string> *transition_idle_talkreq= new StateTransition<SipSMCommand,string>(this, "transition_idle_talkreq", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2T::a0_idle_talkreq, s_idle, s_talk_req );// StateTransition<SipSMCommand,string> *transition_talkreq_talk= new StateTransition<SipSMCommand,string>(this, "transition_talkreq_talk", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2T::a1_talkreq_talk, s_talk_req, s_talk );// StateTransition<SipSMCommand,string> *transition_talk_releasepend= new StateTransition<SipSMCommand,string>(this, "transition_talk_releasepend", (bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogP2T::a2_talk_releasepend, s_talk, s_release_pend );// StateTransition<SipSMCommand,string> *transition_releasepend_idle= new StateTransition<SipSMCommand,string>(this,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -