📄 sipdialogconfvoip.cxx
字号:
//MRef<SipDialog*>(this), command.getCommandPacket()->getCSeq(), command.getCommandPacket()->getCSeqMethod(), command.getCommandPacket()->getLastViaBranch(), dialogState.callId )); dispatcher->getLayerTransaction()->addTransaction(cancelresp); //registerTransactionToDialog(cancelresp); SipSMCommand cmd(command); cmd.setSource(SipSMCommand::dialog_layer); cmd.setDestination(SipSMCommand::transaction_layer); dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE);*/ getMediaSession()->stop(); signalIfNoTransactions(); return true; }else{ return false; }}bool SipDialogConfVoip::a8_callingnoauth_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; }}//Note: This is also used as: callingauth_terminated_36bool SipDialogConfVoip::a9_callingnoauth_termwait_36( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, IGN, SipSMCommand::dialog_layer, "3**\n4**\n5**\n6**")){ MRef<LogEntry *> rejectedLog( new LogEntryCallRejected() ); rejectedLog->start = time( NULL ); rejectedLog->peerSipUri = dialogState.remoteTag; if (sipResponseFilterMatch(MRef<SipResponse*>((SipResponse*)*command.getCommandPacket()),"404")){ CommandString cmdstr(dialogState.callId, SipCommandString::remote_user_not_found); cmdstr.setParam3(confId); sipStack->getCallback()->handleCommand("sip_conf", cmdstr); //getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr); ((LogEntryFailure *)*rejectedLog)->error = "User not found"; setLogEntry( rejectedLog ); rejectedLog->handle(); }else if (sipResponseFilterMatch(MRef<SipResponse*>((SipResponse*)*command.getCommandPacket()),"606")){ ((LogEntryFailure *)*rejectedLog)->error = "User could not handle the call"; setLogEntry( rejectedLog ); rejectedLog->handle(); CommandString cmdstr( dialogState.callId, SipCommandString::remote_unacceptable, command.getCommandPacket()->getWarningMessage()); cmdstr.setParam3(confId); //getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); sipStack->getCallback()->handleCommand("sip_conf", cmdstr ); } else if (sipResponseFilterMatch(MRef<SipResponse*>((SipResponse*)*command.getCommandPacket()),"4**")){ ((LogEntryFailure *)*rejectedLog)->error = "User rejected the call"; setLogEntry( rejectedLog ); rejectedLog->handle(); CommandString cmdstr( dialogState.callId, SipCommandString::remote_reject); cmdstr.setParam3(confId); //getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); sipStack->getCallback()->handleCommand("sip_conf", cmdstr ); } else{ merr << "ERROR: received response in SipDialogConfVoip" " that could not be handled (unimplemented)"<< end; } getMediaSession()->stop(); signalIfNoTransactions(); return true; }else{ return false; }}bool SipDialogConfVoip::a10_start_ringing_INVITE( const SipSMCommand &command){ fprintf( stderr, "SipDialogConfVoip::a10_start_ringing_INVITE\n" ); if (transitionMatch("INVITE", command, IGN, SipSMCommand::dialog_layer)){ dialogState.remoteUri = command.getCommandPacket()->getHeaderValueFrom()->getUri().getUserName()+"@"+ command.getCommandPacket()->getHeaderValueFrom()->getUri().getIp(); getDialogConfig()->inherited->sipIdentity->setSipUri( command.getCommandPacket()->getHeaderValueTo()->getUri().getUserIpString() ); //We must maintain our dialog state. This is the first //message we receive for this dialog and we copy the remote //tag and the remote sequence number. dialogState.remoteTag = command.getCommandPacket()->getHeaderValueFrom()->getParameter("tag"); dialogState.remoteSeqNo = command.getCommandPacket()->getCSeq(); //dialogState.seqNo = command.getCommandPacket()->getCSeq(); (we do not need to set to the same at the remote one - remove)// setLocalCalled(true); localCalled=true; setLastInvite(MRef<SipRequest*>((SipRequest*)*command.getCommandPacket())); string peerUri = command.getCommandPacket()->getFrom().getString(); //MRef<SipMessageContent *> Offer = *command.getCommandPacket()->getContent(); if(!sortMIME(*command.getCommandPacket()->getContent(), peerUri, 10)){ merr << "No MIME match" << end; return false; }#ifdef IPSEC_SUPPORT // Check if IPSEC was required if (ipsecSession->required() && !ipsecSession->offered){ cerr << "I require IPSEC or nothing at all!" << endl; return false; }#endif/* MRef<SipTransaction*> ir( new SipTransactionInviteServer( sipStack, //MRef<SipDialog*>( this ), command.getCommandPacket()->getCSeq(), command.getCommandPacket()->getCSeqMethod(), command.getCommandPacket()->getLastViaBranch(), dialogState.callId) ); dispatcher->getLayerTransaction()->addTransaction(ir); //registerTransactionToDialog(ir); // command.setSource(SipSMCommand::dialog_layer); // command.setDestination(SipSMCommand::transaction_layer); // mdbg << "^^^^ SipDialogVoip: re-handling packet for transaction to catch:"<<command<<end; SipSMCommand cmd(command); cmd.setDestination(SipSMCommand::transaction_layer); dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE);*/ if(type=="join") { string users=confId+";"; //cerr<<"*************users "+itoa((*adviceList).size())<<endl; for(int t=0;t<(*adviceList).size();t++) users=users+ (((*adviceList)[t]).uri); //cerr<<"*************users "+users<<endl;} /*CommandString cmdstr(dialogState.callId, SipCommandString::incoming_available, dialogState.remoteUri, (getMediaSession()->isSecure()?"secure":"unprotected") );*/ CommandString cmdstr(dialogState.callId, "conf_join_received", dialogState.remoteUri, (getMediaSession()->isSecure()?"secure":"unprotected"),users );//bm sipStack->getCallback()->handleCommand("gui", cmdstr ); } else { //cerr<<"a10 confIdidididididi "+confId<<endl; CommandString cmdstr(dialogState.callId, "conf_connect_received", dialogState.remoteUri, (getMediaSession()->isSecure()?"secure":"unprotected"),confId);//bm sipStack->getCallback()->handleCommand("sip_conf", cmdstr ); } //getDialogContainer()->getCallback()->sipcb_handleConfCommand( cmdstr ); sendRinging(""/*ir->getBranch()*/); if( getDialogConfig()->inherited->autoAnswer ){ CommandString accept( dialogState.callId, SipCommandString::accept_invite ); SipSMCommand sipcmd(accept, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer); dispatcher->enqueueCommand(sipcmd,HIGH_PRIO_QUEUE/*, PRIO_LAST_IN_QUEUE*/); } return true; }else{ return false; }}bool SipDialogConfVoip::a11_ringing_incall_accept( const SipSMCommand &command){ if (transitionMatch(command, SipCommandString::accept_invite, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer)){#ifdef ENABLE_TS ts.save(USER_ACCEPT);#endif //bm numConnected=0; string users=command.getCommandString().getParam2(); confId=command.getCommandString().getParam3(); //cerr<<"users=command.getCommandString().getParam2() "+users<<endl; string line=""; unsigned int i=0; while (users.length()!=0 &&!(i>(users.length()-1))){ line+=users[i++]; if(users[i]==';') { connectedList.push_back((ConfMember(line, ""))); //connectedList[numConnected]=line; //cerr<< "line: " + line << endl; line=""; numConnected++; massert(numConnected==connectedList.size()); i++; } } /* for(int t=numConnected;t<10;t++) connectedList[t]=""; */ //bm CommandString cmdstr(dialogState.callId, SipCommandString::invite_ok,dialogState.remoteUri, (getMediaSession()->isSecure()?"secure":"unprotected") ); //getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); //getDialogContainer()->getCallback()->sipcb_handleConfCommand( cmdstr ); massert( !getLastInvite().isNull() ); sendInviteOk(getLastInvite()->getDestinationBranch() ); CommandString cmdstr2("", "myuri", getDialogConfig()->inherited->sipIdentity->getSipUri()); cmdstr2.setParam3(confId); //getDialogContainer()->getCallback()->sipcb_handleCommand(cmdstr); sipStack->getCallback()->handleCommand("sip_conf", cmdstr2 ); getMediaSession()->start(); MRef<LogEntry *> logEntry = new LogEntryIncomingCompletedCall(); logEntry->start = time( NULL ); logEntry->peerSipUri = getLastInvite()->getFrom().getString(); setLogEntry( logEntry ); return true; }else{ return false; }}bool SipDialogConfVoip::a12_ringing_termwait_CANCEL( const SipSMCommand &command){ if (transitionMatch("CANCEL", command, IGN, IGN)){ //FIXME: is this correct - this should probably be handled //in the already existing transaction./* 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); // mdbg << "^^^^ SipDialogVoip: re-handling packet for transaction to catch."<<end; dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE);*/ // mdbg << "^^^^ SipDialogVoip: sending ok to cancel packet"<<end; /* Tell the GUI */ CommandString cmdstr(dialogState.callId, SipCommandString::remote_cancelled_invite); cmdstr.setParam3(confId); //getDialogContainer()->getCallback()->sipcb_handleCommand( cmdstr ); sipStack->getCallback()->handleCommand("sip_conf", cmdstr ); sendInviteOk(""/*cr->getBranch()*/ ); getMediaSession()->stop(); signalIfNoTransactions(); return true; }else{ return false; }}bool SipDialogConfVoip::a13_ringing_termwait_reject( const SipSMCommand &command){ if ( transitionMatch(command, SipCommandString::reject_invite, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer) || transitionMatch(command, SipCommandString::hang_up, SipSMCommand::dialog_layer, SipSMCommand::dialog_layer)){ sendReject( getLastInvite()->getDestinationBranch() ); getMediaSession()->stop(); signalIfNoTransactions(); return true; }else{ return false; }}bool SipDialogConfVoip::a16_start_termwait_INVITE( const SipSMCommand &command){ if (transitionMatch("INVITE", command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer)){ setLastInvite(MRef<SipRequest*>((SipRequest *)*command.getCommandPacket()));/* MRef<SipTransaction*> ir( new SipTransactionInviteServer(sipStack, //MRef<SipDialog*>(this), command.getCommandPacket()->getCSeq(), command.getCommandPacket()->getCSeqMethod(), command.getCommandPacket()->getLastViaBranch(), dialogState.callId )); dispatcher->getLayerTransaction()->addTransaction(ir); //registerTransactionToDialog(ir); SipSMCommand cmd(command); cmd.setDestination(SipSMCommand::transaction_layer); dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE);*/ sendNotAcceptable( command.getCommandPacket()->getDestinationBranch() ); signalIfNoTransactions(); return true; }else{ return false; }}bool SipDialogConfVoip::a20_callingnoauth_callingauth_40X( const SipSMCommand &command){ if (transitionMatch(SipResponse::type, command, IGN, SipSMCommand::dialog_layer, "407\n401")){ MRef<SipResponse*> resp( (SipResponse*)*command.getCommandPacket() ); dialogState.remoteTag = command.getCommandPacket()->getHeaderValueTo()->getParameter("tag"); //int seqNo = requestSeqNo(); ++dialogState.seqNo;/* MRef<SipTransaction*> trans( new SipTransactionInviteClient(sipStack, //MRef<SipDialog*>(this), dialogState.seqNo,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -