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

📄 sipdialogvoipclient.cxx

📁 MiniSip Client with DomainKeys Authentication, Sip, Audio communications, Echo Cancel
💻 CXX
📖 第 1 页 / 共 3 页
字号:
                        CommandString cmdstr(dialogState.callId, SipCommandString::remote_user_not_found);			assert(sipStack);			assert(sipStack->getCallback());			sipStack->getCallback()->handleCommand("gui", 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());			sipStack->getCallback()->handleCommand( "gui", 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);			sipStack->getCallback()->handleCommand( "gui",cmdstr );		}		else{			merr << "ERROR: received response in SipDialogVoipClient"				" that could not be handled (unimplemented)"<< end;                }				getMediaSession()->stop();		signalIfNoTransactions();		return true;	}else{		return false;	}}bool SipDialogVoipClient::a2008_callingnoauth_callingauth_40X( const SipSMCommand &command){	if (transitionMatch(SipResponse::type, command,SipSMCommand::transaction_layer, SipSMCommand::dialog_layer, "407\n401")){				MRef<SipResponse*> resp( (SipResponse*)*command.getCommandPacket() );		dialogState.updateState( resp ); //nothing will happen ... 4xx responses do not update ...		++dialogState.seqNo;/*		MRef<SipTransaction*> trans( 			new SipTransactionInviteClientUA(sipStack, 				//MRef<SipDialog*>(this), 				dialogState.seqNo, 				"INVITE", 				dialogState.callId));		dispatcher->getLayerTransaction()->addTransaction(trans);		//registerTransactionToDialog(trans);*/				//realm = resp->getRealm();		realm = resp->getAuthenticateProperty("realm");		//nonce = resp->getNonce();		nonce = resp->getAuthenticateProperty("nonce");		sendAuthInvite(""/*trans->getBranch()*/);		return true;	}else{		return false;	}}bool SipDialogVoipClient::a2009_callingauth_callingauth_18X( const SipSMCommand &command){		if (transitionMatch(SipResponse::type, command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer, "18*")){		MRef<SipResponse*> resp (  (SipResponse*)*command.getCommandPacket()  );#ifdef ENABLE_TS		ts.save( RINGING );#endif		CommandString cmdstr(dialogState.callId, SipCommandString::remote_ringing);		sipStack->getCallback()->handleCommand("gui", cmdstr );		dialogState.updateState( resp );		string peerUri = dialogState.remoteUri;				MRef<SdpPacket*> sdp((SdpPacket*)*resp->getContent());		if ( !sdp.isNull() ){			//Early media			getMediaSession()->setSdpAnswer( sdp, peerUri );		}		return true;	}else{		return false;	}}bool SipDialogVoipClient::a2010_callingauth_callingauth_1xx( const SipSMCommand &command){	if (transitionMatch(SipResponse::type, command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer, "1**")){		dialogState.updateState( MRef<SipResponse*> ( (SipResponse*)*command.getCommandPacket() ) );		return true;	}else{		return false;	}}bool SipDialogVoipClient::a2011_callingauth_incall_2xx( const SipSMCommand &command){	if (transitionMatch(SipResponse::type, command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer, "2**")){		MRef<SipResponse*> resp( (SipResponse*)*command.getCommandPacket() );				dialogState.updateState( resp );//CESC: for now, route set is updated at the transaction layer						//string peerUri = resp->getFrom().getString().substr(4);		string peerUri = dialogState.remoteUri;				setLogEntry( new LogEntryOutgoingCompletedCall() );		getLogEntry()->start = time( NULL );		getLogEntry()->peerSipUri = peerUri;				CommandString cmdstr(dialogState.callId, 				SipCommandString::invite_ok, 				"",				(getMediaSession()->isSecure()?"secure":"unprotected")				);		sipStack->getCallback()->handleCommand("gui", cmdstr );		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 SipDialogVoipClient::a2012_calling_termwait_2xx( const SipSMCommand &command){		if (transitionMatch(SipResponse::type, command, SipSMCommand::transaction_layer, SipSMCommand::dialog_layer, "2**")){		++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);		CommandString cmdstr(dialogState.callId, SipCommandString::security_failed);		sipStack->getCallback()->handleCommand("gui", cmdstr);		getMediaSession()->stop();		signalIfNoTransactions();		return true;	}else{		return false;	}}bool SipDialogVoipClient::a2013_callingnoauth_termwait_transporterror( const SipSMCommand &command){	if (transitionMatch(command, 				SipCommandString::transport_error,				SipSMCommand::transaction_layer,				SipSMCommand::dialog_layer )){		CommandString cmdstr(dialogState.callId, SipCommandString::transport_error);		sipStack->getCallback()->handleCommand("gui",cmdstr);		signalIfNoTransactions();		return true;	}else{		return false;	}}//Copy of a8!bool SipDialogVoipClient::a2014_callingauth_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);		string inv_branch = getLastInvite()->getFirstViaBranch();/*			MRef<SipTransaction*> canceltrans( 			new SipTransactionNonInviteClient(sipStack, 				//MRef<SipDialog*>(this), 				dialogState.seqNo, 				"CANCEL", 				dialogState.callId)); 		canceltrans->setBranch(inv_branch);		dispatcher->getLayerTransaction()->addTransaction(canceltrans);		//registerTransactionToDialog(canceltrans);*/		sendCancel(""/*inv_branch*/);		getMediaSession()->stop();		signalIfNoTransactions();		return true;	}else{		return false;	}}bool SipDialogVoipClient::a2015_calling_pracksent_100rel( const SipSMCommand &command){        if (transitionMatch(SipResponse::type,                                command,                                SipSMCommand::transaction_layer,                                SipSMCommand::dialog_layer,                                "1**")){                MRef<SipResponse*> resp( (SipResponse*)*command.getCommandPacket() );                if (!(resp->requires("100rel") && resp->getStatusCode()!=100)){			return false;		}				sendPrack(resp);				return true;	}else{		return false;	}}bool SipDialogVoipClient::a2016_pracksent_calling_2XX( const SipSMCommand &command){        if (transitionMatch(SipResponse::type,                                command,                                SipSMCommand::transaction_layer,                                SipSMCommand::dialog_layer,                                "2**")){		return true;	}else{		return false;	}}void SipDialogVoipClient::setUpStateMachine(){	State<SipSMCommand,string> *s_start=new State<SipSMCommand,string>(this,"start");	addState(s_start);	State<SipSMCommand,string> *s_callingnoauth=new State<SipSMCommand,string>(this,"callingnoauth");	addState(s_callingnoauth);	State<SipSMCommand,string> *s_callingauth=new State<SipSMCommand,string>(this,"callingauth");	addState(s_callingauth);	State<SipSMCommand,string> *s_pracksent=new State<SipSMCommand,string>(this,"pracksent");	addState(s_pracksent);	MRef<State<SipSMCommand,string> *> s_incall = getState("incall");	MRef<State<SipSMCommand,string> *> s_termwait= getState("termwait");	new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_pracksent_100rel",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2015_calling_pracksent_100rel, 			s_callingnoauth, s_pracksent);	new StateTransition<SipSMCommand,string>(this, "transition_pracksent_callingnoauth_2XX",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2016_pracksent_calling_2XX, 			s_pracksent, s_callingnoauth);	new StateTransition<SipSMCommand,string>(this, "transition_start_callingnoauth_invite",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2001_start_callingnoauth_invite, 			s_start, s_callingnoauth);	new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_callingnoauth_18X",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2002_callingnoauth_callingnoauth_18X, 			s_callingnoauth, s_callingnoauth);	new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_callingnoauth_1xx",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2003_callingnoauth_callingnoauth_1xx, 			s_callingnoauth, s_callingnoauth);	new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_incall_2xx",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2004_callingnoauth_incall_2xx, 			s_callingnoauth, s_incall);	// Must be added after the noauth->incall transition since this is	// the "fallback one" if we don't accept the 2XX reply (for example	// authentication error)	new StateTransition<SipSMCommand,string>(this, "transition_callingauth_termwait_2xx",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2012_calling_termwait_2xx,			s_callingnoauth, s_termwait);	new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_CANCEL",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2005_callingnoauth_termwait_CANCEL,			s_callingnoauth, s_termwait);	new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_cancel",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2006_callingnoauth_termwait_cancel,			s_callingnoauth, s_termwait);	new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_callingauth_40X",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2008_callingnoauth_callingauth_40X,			s_callingnoauth, s_callingauth);	new StateTransition<SipSMCommand,string>(this, "transition_callingnoauth_termwait_36",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2007_callingnoauth_termwait_36,			s_callingnoauth, s_termwait);	new StateTransition<SipSMCommand,string>(this, "transition_callingauth_callingauth_18X",			(bool (StateMachine<SipSMCommand,string>::*)(const SipSMCommand&)) &SipDialogVoipClient::a2009_callingauth_callingauth_18X, 			s_callingauth, s_callingauth);	new StateTransition<SipSMCommand,string>(this, "transition_callingauth_callingauth_1xx",

⌨️ 快捷键说明

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