📄 sipdialogp2tuser.cxx
字号:
setUpStateMachine();}SipDialogP2Tuser::~SipDialogP2Tuser(){ }void SipDialogP2Tuser::handleSdp(MRef<SdpPacket*> /*sdp*/){#ifdef OLD_MEDIA int codec=0; Codec *c=NULL;// for (unsigned i=0; i< getDialogContainer()->getPhoneConfig()->inherited->codecs.size(); i++) for (unsigned i=0; i< getPhoneConfig()->inherited->codecs.size(); i++)// if (getDialogContainer()->getPhoneConfig()->inherited->codecs[i]->get_sdp_media_type()==codec) if (getPhoneConfig()->inherited->codecs[i]->getSdpMediaType()==codec)// c = getDialogContainer()->getPhoneConfig()->inherited->codecs[i]; c = getPhoneConfig()->inherited->codecs[i]; assert(c!=NULL); int port; myIp = sdp->getRemoteAddr(port); myRTPport = port; myRTCPport = port + 1; myCodec = c; //IPAddress *ip = sdp->getRemoteAddr(port); //soundSender->setRemoteAddr( ip, port ); //soundSender->setCodec(c); //soundReceiver->registerSoundSource(-2); //FIXME: #endif}void SipDialogP2Tuser::sendInvite(const string &branch){ // mdbg << "ERROR: SipDialogP2Tuser::sendInvite() UNIMPLEMENTED"<< end;// string call_id = getDialogConfig().callId; MRef<SipInvite*> inv; string keyAgreementMessage; inv= MRef<SipInvite*>(new SipInvite( branch, /*getDialogConfig().callId*/ dialogState.callId, dialogState.remoteUri, getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyIpAddr->getString(), getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyPort,// getDialogConfig().inherited->localIpString, getDialogConfig()->inherited->externalContactIP, getDialogConfig()->inherited->getLocalSipPort(getPhoneConfig()->useSTUN), //getDialogConfig().inherited->userUri, getDialogConfig()->inherited->sipIdentity->getSipUri(), dialogState.seqNo,// requestSeqNo(),// getSoundReceiver()->getSocket()->get_port(),// getP2TDialog()->getRTPPort(), // getDialog()->getDialogConfig().localMediaPort, /*getDialogConfig().inherited->codecs,*/ getDialogConfig()->inherited->transport) ); #ifdef MINISIP_MEMDEBUG inv.setUser("SipDialogP2Tuser");#endif inv->getHeaderValueFrom()->setParameter("tag",dialogState.localTag); //add P2T stuff to the invite message modifyP2TInvite(inv); // mdbg << "SipDialogP2Tuser::sendInvite(): sending INVITE to transaction"<<end;// ts.save( INVITE_END ); MRef<SipMessage*> pktr(*inv);#ifdef MINISIP_MEMDEBUG pktr.setUser("SipDialogP2Tuser");#endif SipSMCommand scmd( pktr, SipSMCommand::TU, SipSMCommand::transaction ); // scmd.setDispatched(true); // What was I thinging about here?? --EE // handleCommand(scmd); getDialogContainer()->enqueueCommand(scmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); setLastInvite(inv);}void SipDialogP2Tuser::sendAuthInvite(const string &branch){ // merr << "ERROR: SipDialogP2Tuser::sendAuthInvite() UNIMPLEMENTED"<< end;// string call_id = getDialogConfig().callId; //SipInvite * inv; MRef<SipInvite*> inv; string keyAgreementMessage; inv= new SipInvite( branch, /*getDialogConfig().callId*/ dialogState.callId, dialogState.remoteUri, getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyIpAddr->getString(), getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyPort, // getDialogConfig().inherited->localIpString, getDialogConfig()->inherited->externalContactIP, getDialogConfig()->inherited->getLocalSipPort(getPhoneConfig()->useSTUN), //getDialogConfig().inherited->userUri, getDialogConfig()->inherited->sipIdentity->getSipUri(), dialogState.seqNo, // requestSeqNo(), getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyUsername, nonce, realm, getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyPassword, // getSoundReceiver()->getSocket()->get_port(), //getP2TDialog()->getRTPPort(), // getDialog()->getDialogConfig().localMediaPort, /*getDialogConfig().inherited->codecs,*/ getDialogConfig()->inherited->transport); inv->getHeaderValueFrom()->setParameter("tag",dialogState.localTag);// mdbg << "SipDialogP2Tuser::sendInvite(): sending INVITE to transaction"<<end;#ifndef _MSC_VER ts.save( INVITE_END );#endif //add p2t stuff to the INVITE message modifyP2TInvite(inv); MRef<SipMessage*> pref(*inv); SipSMCommand cmd(pref, SipSMCommand::TU, SipSMCommand::transaction);// handleCommand(cmd); getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE); setLastInvite(inv);}#ifdef NEVERDEFINED_ERSADFSvoid SipDialogP2Tuser::sendAck(string branch){ // mdbg << "ERROR: SipDialogP2Tuser::sendAck() UNIMPLEMENTED" << end; assert( !lastResponse.isNull()); SipAck *ack = new SipAck( branch, *lastResponse, getDialogConfig()->uri_foreign, getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyIpAddr->getString()); //TODO: // ack.add_header( new SipHeaderRoute(getDialog()->getRouteSet() ) );// mdbg << "SipDialogP2Tuser:sendAck(): sending ACK directly to remote" << end; // if(socket == NULL){ // No StreamSocket, create one or use UDP// Socket *sock=NULL; if(getDialogConfig()->proxyConnection == NULL){ getDialogConfig()->inherited->sipTransport->sendMessage(ack, *(getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyIpAddr), //*toaddr, getDialogConfig()->inherited->proxyPort, //port, // sock, //(Socket *)NULL, //socket, getDialogConfig()->proxyConnection, "BUGBUGBUG", getDialogConfig()->inherited->transport ); }else{ // A StreamSocket exists, try to use it mdbg << "Sending packet using existing StreamSocket"<<end; getDialogConfig()->inherited->sipTransport->sendMessage( ack, (StreamSocket *)getDialogConfig()->proxyConnection, "BUGBUGBUG"); } return; // } /* if(dynamic_cast<StreamSocket *>(socket) != NULL){ // A StreamSocket exists, try to use it mdbg << "Sending packet using existing StreamSocket"<<end; getDialog()->getDialogConfig().sipTransport->sendMessage(pack,(StreamSocket *)socket); return; } */}#endifvoid SipDialogP2Tuser::sendBye(const string &branch, int bye_seq_no){ //string tmp = getDialogConfig().inherited->userUri; string tmp = getDialogConfig()->inherited->sipIdentity->getSipUri(); uint32_t i = tmp.find("@"); assert(i!=string::npos); i++; string domain; for ( ; i < tmp.length() ; i++) domain = domain+tmp[i];// mdbg << "///////////Creating bye with uri_foreign="<<getDialogConfig().uri_foreign << " and doman="<< domain<< end; MRef<SipBye*> bye = new SipBye( branch, getLastInvite(), dialogState.remoteUri, //getDialogConfig().inherited->userUri, getDialogConfig()->inherited->sipIdentity->getSipUri(), domain,// getDialogConfig().seqNo+1, bye_seq_no///, ///localCalled ); bye->getHeaderValueFrom()->setParameter("tag",dialogState.localTag); bye->getHeaderValueTo()->setParameter("tag",dialogState.remoteTag); MRef<SipMessage*> pref(*bye); SipSMCommand cmd( pref, SipSMCommand::TU, SipSMCommand::transaction);// handleCommand(cmd); getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE);}void SipDialogP2Tuser::sendCancel(const string &branch){ assert( !lastInvite.isNull()); MRef<SipCancel*> cancel = new SipCancel( branch, lastInvite, dialogState.remoteUri, //getDialogConfig().inherited->userUri, getDialogConfig()->inherited->sipIdentity->getSipUri(), getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyIpAddr->getString()///, ///localCalled ); cancel->getHeaderValueFrom()->setParameter("tag",dialogState.localTag); cancel->getHeaderValueTo()->setParameter("tag",dialogState.remoteTag); MRef<SipMessage*> pref(*cancel); SipSMCommand cmd( pref, SipSMCommand::TU, SipSMCommand::transaction);// handleCommand( cmd ); getDialogContainer()->enqueueCommand( cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE );}void SipDialogP2Tuser::sendInviteOk(const string &branch){ MRef<SipResponse*> ok= new SipResponse(branch, 200,"OK", MRef<SipMessage*>(*getLastInvite())); ok->getHeaderValueTo()->setParameter("tag",dialogState.localTag);#ifdef OLD_MEDIA int32_t codecmatch = ((SdpPacket*)*getLastInvite()->getContent())->getCodecMatch(getDialogConfig()->inherited->codecs); vector<Codec *> orderedcodecs = getDialogConfig()->inherited->codecs; for (unsigned i=0; i<orderedcodecs.size(); i++) if (orderedcodecs[i]->getSdpMediaType()==codecmatch){ Codec *tmp = orderedcodecs[0]; orderedcodecs[0]=orderedcodecs[i]; orderedcodecs[i]=tmp; } //getSoundSender()->setCodec(orderedcodecs[0]); myCodec=orderedcodecs[0]; if (getDialogConfig()->inherited->secured && (getDialogConfig()->inherited->ka_type & KEY_MGMT_METHOD_MIKEY))// ok->setContent( new SdpPacket(getDialogConfig().inherited->localIpString, ok->setContent( new SdpPacket(getDialogConfig()->inherited->externalContactIP, // getSoundReceiver()->getSocket()->get_port(), getP2TDialog()->getRTPPort(), orderedcodecs, key_mgmt) ); else// ok->setContent( new SdpPacket(getDialogConfig().inherited->localIpString, ok->setContent( new SdpPacket(getDialogConfig()->inherited->externalContactIP, // getSoundReceiver()->getSocket()->get_port(), getP2TDialog()->getRTPPort(), orderedcodecs) );#endif// setLastResponse(ok); MRef<SipMessage*> pref(*ok); SipSMCommand cmd( pref, SipSMCommand::TU, SipSMCommand::transaction);// handleCommand(cmd); getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE);}void SipDialogP2Tuser::sendByeOk(MRef<SipBye*> bye, const string &branch){ MRef<SipResponse*> ok= new SipResponse( branch, 200,"OK", MRef<SipMessage*>(*bye) ); ok->getHeaderValueTo()->setParameter("tag",dialogState.localTag);// setLastResponse(ok); MRef<SipMessage*> pref(*ok); SipSMCommand cmd( pref, SipSMCommand::TU, SipSMCommand::transaction);// handleCommand(cmd); getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE);}void SipDialogP2Tuser::sendReject(const string &branch){ MRef<SipResponse*> ringing = new SipResponse(branch,486,"Temporary unavailable", MRef<SipMessage*>(*getLastInvite())); ringing->getHeaderValueTo()->setParameter("tag",dialogState.localTag);// setLastResponse(ringing); MRef<SipMessage*> pref(*ringing); SipSMCommand cmd( pref,SipSMCommand::TU, SipSMCommand::transaction);// handleCommand(cmd); getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE);}void SipDialogP2Tuser::sendRinging(const string &branch){ MRef<SipResponse*> ringing = new SipResponse(branch,180,"Ringing", MRef<SipMessage*>(*getLastInvite())); ringing->getHeaderValueTo()->setParameter("tag",dialogState.localTag);// setLastResponse(ringing); MRef<SipMessage*> pref(*ringing); SipSMCommand cmd( pref, SipSMCommand::TU, SipSMCommand::transaction);// handleCommand(cmd); getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE);}void SipDialogP2Tuser::sendNotAcceptable(const string &branch){ MRef<SipResponse*> not_acceptable = new SipResponse(branch,606,"Not Acceptable", MRef<SipMessage*>(*getLastInvite())); #ifdef MINISIP_MEMDEBUG not_acceptable.setUser("SipDialogP2Tuser");#endif not_acceptable->getHeaderValueTo()->setParameter("tag",dialogState.localTag);// setLastResponse(not_acceptable); MRef<SipMessage*> pref(*not_acceptable);#ifdef MINISIP_MEMDEBUG pref.setUser("SipDialogP2Tuser");#endif SipSMCommand cmd( pref, SipSMCommand::TU, SipSMCommand::transaction);// handleCommand(cmd); getDialogContainer()->enqueueCommand(cmd, HIGH_PRIO_QUEUE, PRIO_LAST_IN_QUEUE);}bool SipDialogP2Tuser::handleCommand(const SipSMCommand &c){ mdbg << "SipDialogP2Tuser::handleCommand got "<< c << end; if (c.getType()==SipSMCommand::COMMAND_PACKET && getCallId().length()>0){ if (c.getCommandPacket()->getCallId()!=getCallId()){ return false; } if (c.getType()!=SipSMCommand::COMMAND_PACKET && c.getCommandPacket()->getCSeq()!= dialogState.seqNo){ return false; } } //check callID also for CommandString if(c.getType()==SipSMCommand::COMMAND_STRING){ if (c.getCommandString().getDestinationId()!= getCallId()) return false; } // if (c.getType()!=SipSMCommand::COMMAND_PACKET && // c.getCommandPacket()->getCSeq()!= command_seq_no)// return false; // mdbg << "SipDialogP2Tuser::handlePacket() got "<< c << end; return SipDialog::handleCommand(c);}MRef<SipInvite*> SipDialogP2Tuser::getLastInvite(){ return lastInvite;}void SipDialogP2Tuser::setLastInvite(MRef<SipInvite*> i){ lastInvite = i; #ifdef MINISIP_MEMDEBUG lastInvite.setUser("SipDialogP2Tuser::lastInvite");#endif}MRef<LogEntry *> SipDialogP2Tuser::getLogEntry(){ return logEntry;}void SipDialogP2Tuser::setLogEntry( MRef<LogEntry *> logEntry ){ this->logEntry = logEntry;}void SipDialogP2Tuser::modifyP2TInvite(MRef<SipInvite*>inv){ //Add Accept-Contact Header inv->set_P2T(); //Add SDP Session Level Attributes assert(dynamic_cast<SdpPacket*>(*inv->getContent())!=NULL); MRef<SdpPacket*> sdp = (SdpPacket*)*inv->getContent(); sdp->setSessionLevelAttribute("p2tGroupListServer", getDialogConfig()->inherited->externalContactIP + ":" + itoa(getPhoneConfig()->p2tGroupListServerPort)); sdp->setSessionLevelAttribute("p2tGroupIdentity", getP2TDialog()->getGroupList()->getGroupIdentity()); sdp->setSessionLevelAttribute("p2tGroupListProt","http/xml"); }void SipDialogP2Tuser::reportSipDialogP2T(int status){ getP2TDialog()->modifyUser(dialogState.remoteUri, myIp, myRTPport, myRTCPport, myCodec, getCallId());}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -