📄 sipdialogp2t.cxx
字号:
if(/*vc->*/checkStates(P2T::STATUS_GRANT)==true || /*vc->*/highestPrio(P2T::STATUS_COLLISION, users)==true){ return false; } //start for all users with highest priority a RtcpTransactionGrantFloor. //to one of them finally a TAKEN message will arrive. if(users.size()==0){ merr<<"SipDialogP2T:: in a7: Collision but no user found!"<<end; return true; } for(uint32_t k=0;k<users.size();k++){ MRef<SipTransaction*> gf = new RtcpTransactionGrantFloor(MRef<SipDialog*>(/* *vc */ this), /*vc->*/getGroupList()->getUser(users[k])->getSeqNo(), /*vc->*/getGroupList()->getUser(users[k])->getAddress(), /*vc->*/getGroupList()->getUser(users[k])->getRTCPport(), dialogState.callId, /*vc->*/getGroupList()->getUser(users[k])->getSSRC()); /*vc->*/registerTransaction(gf); CommandString cmd(/*vc->*/getCallId(), "p2tSendGrant", itoa(/*vc->*/getGroupList()->getUser(users[k])->getSSRC()), itoa(/*vc->*/getGroupList()->getUser(users[k])->getSeqNo()), users[k]); SipSMCommand scmd(cmd, SipSMCommand::TU, SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(scmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); } return true; }else{ return false; }}bool SipDialogP2T::a8_talkreq_collision( const SipSMCommand &command){ //not all users have granted, there are other users with the same priority if (transitionMatch(command, "p2tRequestAnswered")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; vector<string> users; if(/*vc->*/allAnswered()==false) return false; /*mdbg<<"---------------------"<<end; mdbg<<"SipDialogP2T:: a8"<<end; mdbg<<"checkStates="<<vc->checkStates(P2T::STATUS_GRANT)<<end; mdbg<<"highestPrio="<<vc->highestPrio(P2T::STATUS_COLLISION, users)<<end; mdbg<<"users.empty="<<users.empty()<<end; mdbg<<"ssrc="<<command.getCommandString().getParam()<<end; mdbg<<"seqno="<<command.getCommandString().getParam2()<<end; mdbg<<"user="<<command.getCommandString().getParam3()<<end; mdbg<<"--------------------"<<end;*/ //check if it is a collision if(/*vc->*/checkStates(P2T::STATUS_GRANT)==true || /*vc->*/highestPrio(P2T::STATUS_COLLISION, users)==false || users.empty()==true){ return false; } //set counterCollision /*vc->*/counterCollision=1; //set resend timer int timer_value = int(P2T::timerRESEND * rand()/(RAND_MAX+1.0)); merr<<"---------------------"<<end; merr<<"SipDialogP2T:: a8 timer_value="<<itoa(timer_value)<<end; merr<<"---------------------"<<end; /*if(vc->getDialogConfig().inherited->userUri=="floh2@ssvl.kth.se") vc->requestTimeout(10000, "timerRESEND"); else vc->requestTimeout(60000, "timerRESEND");*/ /*vc->*/requestTimeout(timer_value, "timerRESEND"); return true; }else{ return false; }}bool SipDialogP2T::a9_collision_listenreq( const SipSMCommand &command){ if (transitionMatch(command, "p2tREQUEST") ){ //start RtcpTransactionGrantFloor //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; //check collision flag if (command.getCommandString().getParam3()!=itoa(/*vc->*/counterCollision)) return false; //collision counter string p3 = command.getCommandString().getParam3(); //seqNo string p2 = command.getCommandString().getParam2(); //ssrc string p = command.getCommandString().getParam(); int sNo=0; int ssrc=0; int cc=0; for(uint32_t k=0;k<p3.size();k++) cc = (cc*10) + (p3[k]-'0'); for(uint32_t x=0;x<p2.size();x++) sNo = (sNo*10) + (p2[x]-'0'); for(uint32_t l=0;l<p.size();l++) ssrc = (ssrc*10) + (p[l]-'0'); //check if user is participating in the session if (/*vc->*/getGroupList()->isParticipant(ssrc)){ MRef<GroupListUserElement*> ue = /*vc->*/getGroupList()->getUser(ssrc); //check seqNr and status. Should not be a user that has granted the floor //before the collision. if(ue->getSeqNo()==sNo && ue->getStatus()==P2T::STATUS_COLLISION){ MRef<SipTransaction*> gf = new RtcpTransactionGrantFloor(MRef<SipDialog*>(/* *vc */ this), sNo, ue->getAddress(), ue->getRTCPport(), dialogState.callId, ssrc); //set collision counter value for the Floor GRANT message MRef<RtcpTransactionGrantFloor*>gf_casted = MRef<RtcpTransactionGrantFloor*>((RtcpTransactionGrantFloor*)*gf); gf_casted->setCollisionCounter(cc); /*vc->*/registerTransaction(gf); ue->setStatus(P2T::STATUS_REQUESTING); CommandString cmd(/*vc->*/getCallId(), "p2tSendGrant", itoa(ssrc), itoa(sNo)); SipSMCommand scmd(cmd, SipSMCommand::TU, SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(scmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); } } else{ //not valid user //stay in collision return false; } return true; }else{ return false; }}bool SipDialogP2T::a10_collision_resent_timer( const SipSMCommand &command){ if (transitionMatch(command, "timerRESEND")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; //vc->getDialogConfig().seqNo++; merr<<"------------------------"<<end; merr<<"a10: send REQUEST "<<end; merr<<"----------------------"<<end; //start RtcpTransactionGetFloor for(uint32_t k=0;k</*vc->*/getGroupList()->getAllUser().size();k++){ //take only COLLISIONED users if(/*vc->*/getGroupList()->getAllUser()[k]->getStatus()==P2T::STATUS_COLLISION){ //reset the state /*vc->*/getGroupList()->getAllUser()[k]->setStatus(P2T::STATUS_CONNECTED); //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, /*vc->*/getGroupList()->getAllUser()[k]->getSSRC()); merr<<"Collision with "<< /*vc->*/getGroupList()->getAllUser()[k]->getUri()<<end; MRef<RtcpTransactionGetFloor*>gf_casted = MRef<RtcpTransactionGetFloor*>((RtcpTransactionGetFloor*)*gf); gf_casted->setUser(/*vc->*/getGroupList()->getAllUser()[k]->getUri()); gf_casted->setCollisionCounter(/*vc->*/counterCollision); /*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); } } return true; }else{ return false; }}bool SipDialogP2T::a11_resent_collision_collision( const SipSMCommand &command){ //not all users have granted, there are other users with the same priority if (transitionMatch(command, "p2tRequestAnswered")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; //check CollisionCounter if(command.getCommandString().getParam3()!=itoa(/*vc->*/counterCollision)) return false; if(/*vc->*/allAnswered()==false) return false; //check if it is a collision if(/*vc->*/checkStates(P2T::STATUS_GRANT)==true){ return false; } //increase counterCollison /*vc->*/counterCollision++; //set resend timer int timer_value = int(P2T::timerRESEND * rand()/(RAND_MAX+1.0)); /*vc->*/requestTimeout(timer_value, "timerRESEND"); merr<<"---------------------"<<end; merr<<"SipDialogP2T:: a11 COLLISION again timer_value="<<itoa(timer_value)<<end; //merr<<"ssrc="<<command.getCommandString().getParam()<<end; //merr<<"seqno="<<command.getCommandString().getParam2()<<end; //merr<<"user="<<command.getCommandString().getParam3()<<end; merr<<"---------------------"<<end; return true; }else{ return false; }}bool SipDialogP2T::a12_resent_talk( const SipSMCommand &command){ if (transitionMatch(command, "p2tRequestAnswered")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; vector<string> users; if(/*vc->*/allAnswered()==false){ return false; } if(/*vc->*/checkStates(P2T::STATUS_GRANT) ==false){ return false; } /*merr<<"---------------------"<<end; merr<<"SipDialogP2T:: a12 talk"<<end; merr<<"ssrc="<<command.getCommandString().getParam()<<end; merr<<"seqno="<<command.getCommandString().getParam2()<<end; merr<<"user="<<command.getCommandString().getParam3()<<end; merr<<"---------------------"<<end;*/ //time measurements#ifndef _MSC_VER if(/*vc->*/p2tPerformance){ ts.stop(); merr<<"used time:"<<ts.writeElapsedTime("Push-2-Talk delay")<<end; }#endif //send Floor TAKEN to all 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 RtcpTransactionTakenFloor MRef<SipTransaction*> gf = new RtcpTransactionTakenFloor(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(gf); CommandString cmd(/*vc->*/getCallId(), "p2tSendTaken", itoa(/*vc->*/getGroupList()->getAllUser()[k]->getSSRC()), itoa(/*vc->*/dialogState.seqNo)); SipSMCommand scmd(cmd, SipSMCommand::TU, SipSMCommand::transaction); /*vc->*/getDialogContainer()->enqueueCommand(scmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); } //inform GUI CommandString cmdstr(/*vc->*/getCallId(), "p2tFloorGranted"); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); /****** Start SoundSender *******/ //vc->getSoundSender()->initCrypto(); //vc->getSoundSender()->start(); return true; }else{ return false; }}bool SipDialogP2T::a13_resent_resent( const SipSMCommand &command){ if (transitionMatch(command, "p2tRequestAnswered")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; if(/*vc->*/allAnswered()==true){ return false; } merr<<"---------------------"<<end; merr<<"SipDialogP2T:: a13 wait until all users has sent their response"<<end; merr<<"ssrc="<<command.getCommandString().getParam()<<end; merr<<"seqno="<<command.getCommandString().getParam2()<<end; merr<<"cf="<<command.getCommandString().getParam3()<<end; merr<<"---------------------"<<end; //wait until all users has sent their responses return true; }else{ return false; }}bool SipDialogP2T::a14_listen_listen( const SipSMCommand &command){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; if (transitionMatch(command, "timerREVOKE") && /*vc->*/counterRevoke<2 ){ //find talking user string uri = ""; for(uint32_t k=0;k</*vc->*/getGroupList()->getAllUser().size();k++){ if(/*vc->*/getGroupList()->getAllUser()[k]->getStatus()==P2T::STATUS_TALKING) uri = /*vc->*/getGroupList()->getAllUser()[k]->getUri(); } int warningCode=0; //send first warning if(/*vc->*/counterRevoke==0){ warningCode=1; //inform GUI CommandString cmd2(/*vc->*/getCallId(),string("p2tFloorRevokeActive")); /*vc->*/getDialogContainer()->getCallback()->sipcb_handleCommand( cmd2 ); } //send second warning else if(/*vc->*/counterRevoke==1){ warningCode=2; } /*vc->*/counterRevoke++; /*vc->*/requestTimeout(P2T::timerREVOKE, "timerREVOKE"); /*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(), warningCode); return true; }else{ return false; }}bool SipDialogP2T::a15_talkreq_talkreq( const SipSMCommand &command){ if (transitionMatch(command, "p2tRequestAnswered")){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; if(/*vc->*/allAnswered()==true){ return false; } mdbg<<"---------------------"<<end; mdbg<<"SipDialogP2T:: a15 wait until all users has sent their response"<<end; mdbg<<"ssrc="<<command.getCommandString().getParam()<<end; mdbg<<"seqno="<<command.getCommandString().getParam2()<<end; mdbg<<"user="<<command.getCommandString().getParam3()<<end; mdbg<<"---------------------"<<end; //wait until all users has sent their responses return true; }else{ return false; }}bool SipDialogP2T::a16_releasepend_releasepend( const SipSMCommand &command){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; if (transitionMatch(command, "p2tFloorReleased") && /*vc->*/checkStates(P2T::STATUS_RELEASED)==false ){ //check if all has answered RELEASE message if(/*vc->*/allAnswered()==true) return false; //wait until all users has sent their responses return true; }else{ return false; }}bool SipDialogP2T::a17_listen_idle_revoke( const SipSMCommand &command){ //MRef<SipDialogP2T *>vc= (SipDialogP2T *)sipStateMachine; if (transitionMatch(command, "timerREVOKE") && /*vc->*/counterRevoke>=2 ){ //find talking user string uri = ""; for(uint32_t k=0;k</*vc->*/getGroupList()->getAllUser().size();k++){ if(/*vc->*/getGroupList()->getAllUser()[k]->getStatus()==P2T::STATUS_TALKING) uri = /*vc->*/getGroupList()->getAllUser()[k]->getUri(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -