⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipdialogconfvoip.cxx

📁 MiniSip Client with DomainKeys Authentication, Sip, Audio communications, Echo Cancel
💻 CXX
📖 第 1 页 / 共 5 页
字号:
/* Copyright (C) 2004-2006 the Minisip Team  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA *//* Copyright (C) 2004  * * Authors: Erik Eliasson <eliasson@it.kth.se> *	Johan Bilien <jobi@via.ecp.fr> *	Joachim Orrblad <joachim[at]orrblad.com> */	    /* Name * 	SipDialogConfVoip.cxx * Authors * 	Erik Eliasson, eliasson@it.kth.se 	Bilge Cetin <bilge[at]kth.se>	Max Loubser <loubser[at]kth.se>*/#include<config.h>#include<libminisip/sip/SipDialogConfVoip.h>#include<libmutil/massert.h>//#include<libmsip/SipDialogContainer.h>#include<libmsip/SipResponse.h>#include<libmsip/SipTransactionInviteClientUA.h>#include<libmsip/SipTransactionInviteServerUA.h>#include<libmsip/SipTransactionNonInviteClient.h>#include<libmsip/SipTransactionNonInviteServer.h>#include<libmsip/SipTransactionUtils.h>#include<libmsip/SipDialog.h>#include<libmsip/SipCommandString.h>#include<libmsip/SipHeaderTo.h>#include<libmsip/SipHeaderAcceptContact.h>#include<libmsip/SipHeaderFrom.h>#include<libmsip/SipHeaderWarning.h>#include<libmsip/SipMIMEContent.h>#include<libmsip/SipMessageContent.h>#include<libminisip/sip/DefaultDialogHandler.h>#include<libminisip/conference/ConfMessageRouter.h>#include<libmutil/itoa.h>#include<libmutil/Timestamp.h>#include<libmutil/termmanip.h>#include<libmutil/dbg.h>#include<libmsip/SipSMCommand.h>#include <time.h>#include<libminisip/gui/LogEntry.h>#include<libmsip/SipCommandString.h>#include<libminisip/mediahandler/MediaHandler.h>#include<libmutil/MemObject.h>#include <iostream>#include<time.h>#include<libmnetutil/IP4Address.h>#ifdef _WIN32_WCE#	include"../include/minisip_wce_extra_includes.h"#endifusing namespace std;/*                                                             a13:reject/send40X                                                                  +------------+                                                                  |            |                 +---------------+   INVITE           +--------------+CANCEL   |                 |               |   a10:transIR; 180 |              |a12:tCncl|                 |     start     |------------------->|    ringing   |---------+                 |               |                    |              |         |a26transport_err +---------------+                    +--------------+         |gui(failed)              |                                    |                |  +----------------+     | invite                             |                |  |                |     V a0: new TransInvite                |                |  |              +---------------+                            |                |  |         +----|               |----+                       |                |  |     1xx |    |Calling_noauth |    | 180                   |                |  |a2:(null)+--->|               |<---+ a1: gui(ringing)      |                |  +--------------+---------------+                            |                |  |                X   ^ |     |       2xx/a3: send ACK       |                |  |    [XACK/a15X] +---+ |     +------------------------------+                |  |                      |                                    |                |  +----------------+     |  40X                               | accept_invite  |  |                |     V  a20: send_auth                    | a11: send 200  |  |              +---------------+                            |                |  |         +----|               |----+                       |                |  |     1xx |    |Calling_stored |    | 180                   |                |  |a22:(nul)+--->|               |<---+ a21: gui(ringing)     |                |  |              +---------------+                            |                |  |                      |                                    |                |  |                      | 2xx                                |                |  |                      v a23: [Xsend ACKX]                  |                |  |              +---------------+                            |                |  |          +---|               |<---------------------------+                |  |  ACK            |   in call     |-------+                                     |  |  a27     +---|               |       |                                     |  |              +---------------+       |                                     |  |                      |               | bye                                 |  |cancel                | BYE           | a6:TransByeInit                     |  |a8/a: new TrnsCncl    V a5:new ByeResp|                                     |  +------------->+---------------+       |                                     |  |3-699/a9:gui()|               |       |                                     |  +------------->|   termwait    |<------+-------------------------------------+  |              |               |  +------------->+---------------+                         |			 | a25: no_transactions			 V phone(call_terminated)                 +---------------+		 |               |		 |  terminated   |		 |               |                 +---------------+		    CANCEL   a7:TrnsCnclRsp   */  bool SipDialogConfVoip::a0_start_callingnoauth_invite( const SipSMCommand &command){//cerr<<"************************************invite receivedqwe"<<endl;	if (transitionMatch(command, 				SipCommandString::invite,				SipSMCommand::dialog_layer,				SipSMCommand::dialog_layer)){#ifdef ENABLE_TS		ts.save("a0_start_callingnoauth_invite");#endif		//cerr<<"sending invite1*************"<<endl;		//int seqNo = requestSeqNo();		//cerr<<"dialogState.seqNo*************"+itoa(dialogState.seqNo)<<endl;		++dialogState.seqNo;//		setLocalCalled(false);		localCalled=false;		dialogState.remoteUri= command.getCommandString().getParam();		//cerr<<"dialogState.callId*************"+dialogState.callId<<endl;		//cerr<<"dialogState.seqNo*************"+itoa(dialogState.seqNo)<<endl;/*		MRef<SipTransaction*> invtrans = new SipTransactionInviteClient(sipStack, 				//MRef<SipDialog *>(this), 				dialogState.seqNo, 				"INVITE", 				dialogState.callId);				invtrans->setSocket( phoneconf->proxyConnection );		//cerr<<"sending invite3*************"<<endl;		dispatcher->getLayerTransaction()->addTransaction(invtrans);		//registerTransactionToDialog(invtrans);*/		//cerr<<"sending invite*************"<<endl;		/*CommandString cmdstr("", "myuri", getDialogConfig()->inherited.sipIdentity->getSipUri());				cmdstr.setParam3(confId);				//getDialogContainer()->getCallback()->sipcb_handleCommand(cmdstr);		getDialogContainer()->getCallback()->sipcb_handleConfCommand( cmdstr );*/		sendInvite(""/*invtrans->getBranch()*/);		//MessageRouter * ptr=(MessageRouter *)(getDialogContainer()->getCallback());		//adviceList=(ptr->getConferenceController()->getConnectedList());		return true;	}else{		return false;	}}bool SipDialogConfVoip::a1_callingnoauth_callingnoauth_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 );	    //We must maintain the dialog state. We copy the remote tag and	    //the remote sequence number	    dialogState.remoteTag = command.getCommandPacket()->getHeaderValueTo()->getParameter("tag");	    dialogState.remoteSeqNo = command.getCommandPacket()->getCSeq();	    	    string peerUri = command.getCommandPacket()->getFrom().getString();	    MRef<SdpPacket*> sdp((SdpPacket*)*resp->getContent());	    if ( !sdp.isNull() ){		    //Early media		    getMediaSession()->setSdpAnswer( sdp, peerUri );	    }	    return true;	}	else{	    return false;	}}bool SipDialogConfVoip::a2_callingnoauth_callingnoauth_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::a3_callingnoauth_incall_2xx( const SipSMCommand &command){	if (transitionMatch(SipResponse::type, command, IGN, SipSMCommand::dialog_layer, "2**")){#ifdef ENABLE_TS		ts.save("a3_callingnoauth_incall_2xx");#endif		MRef<SipResponse*> resp(  (SipResponse*)*command.getCommandPacket() );		lastResponse=resp;		string peerUri = resp->getFrom().getString();		setLogEntry( new LogEntryOutgoingCompletedCall() );		getLogEntry()->start = time( NULL );		getLogEntry()->peerSipUri = peerUri;		dialogState.remoteTag = command.getCommandPacket()->getHeaderValueTo()->getParameter("tag");		//parsing sdp part for conf:		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, SipCommandString::invite_ok, users,(getMediaSession()->isSecure()?"secure":"unprotected"),confId);								//getDialogContainer()->getCallback()->sipcb_handleCommand(cmdstr);		sipStack->getCallback()->handleCommand("sip_conf", cmdstr );		//cerr<<"****************************sendack is called**********************"<<endl;		//sendAck(getLastInvite()->getDestinationBranch() );		//BM		MRef<ConfMessageRouter*> ptr= confCallback;//(ConfMessageRouter*) *(getDialogContainer()->getConfCallback());		adviceList=(ptr->getConferenceController(confId)->getConnectedList());		sendAck(getLastInvite()->getDestinationBranch());				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::a5_incall_termwait_BYE( const SipSMCommand &command){		if (transitionMatch("BYE", command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer)){		MRef<SipRequest*> bye = (SipRequest*) *command.getCommandPacket();		//mdbg << "log stuff"<< end;		if( getLogEntry() ){			((LogEntrySuccess *)(*( getLogEntry() )))->duration = 			time( NULL ) - getLogEntry()->start; 			getLogEntry()->handle();		}/*		MRef<SipTransaction*> byeresp = new SipTransactionNonInviteServer(sipStack, 				//MRef<SipDialog*>(this), 				bye->getCSeq(),				bye->getLastViaBranch(), 				bye->getCSeqMethod(), 				dialogState.callId);		dispatcher->getLayerTransaction()->addTransaction(byeresp);		//registerTransactionToDialog(byeresp);		SipSMCommand cmd(command);		cmd.setDestination(SipSMCommand::transaction_layer);		cmd.setSource(command.getSource());		dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE);*/				sendByeOk(bye, ""/*byeresp->getBranch()*/ );		CommandString cmdstr(dialogState.callId, SipCommandString::remote_hang_up);		cmdstr.setParam3(confId);		//getDialogContainer()->getCallback()->sipcb_handleCommand(cmdstr);		sipStack->getCallback()->handleCommand("sip_conf", cmdstr );		getMediaSession()->stop();				signalIfNoTransactions();		return true;	}else{		return false;	}}bool SipDialogConfVoip::a6_incall_termwait_hangup( const SipSMCommand &command){//	merr << "EEEEEEEE: a6: got command."<< end;//	merr <<"EEEEE: type is "<< command.getType()<< end;	if (transitionMatch(command, 				SipCommandString::hang_up,				SipSMCommand::dialog_layer,				SipSMCommand::dialog_layer)){//		merr << "EEEEEE match"<< end;//		setCurrentState(toState);		//int bye_seq_no= requestSeqNo();		++dialogState.seqNo;/*		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);				if (getLogEntry()){			(dynamic_cast< LogEntrySuccess * >(*( getLogEntry() )))->duration = time( NULL ) - getLogEntry()->start; 			getLogEntry()->handle();		}				getMediaSession()->stop();		signalIfNoTransactions();		return true;	}else{//		merr << "EEEEEE no match"<< end;		return false;	}}bool SipDialogConfVoip::a7_callingnoauth_termwait_CANCEL( const SipSMCommand &command){	if (transitionMatch("CANCEL", command, SipSMCommand::transaction_layer, IGN)){//		setCurrentState(toState);/*		MRef<SipTransaction*> cancelresp( 				new SipTransactionNonInviteServer(					sipStack,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -