[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Sep 24 14:36:16 CDT 2010


branch "master" has been updated
       via  e5d12167a35edbe36d6e4ba1a3d13e1759d8e75a (commit)
      from  930d1be64f35173f51c39dac97b0b093da85e7cd (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |   78 +++++++++++++++++++++++++++++++++----------
 src/PJSipSessionModule.h   |    4 ++-
 2 files changed, 63 insertions(+), 19 deletions(-)


- Log -----------------------------------------------------------------
commit e5d12167a35edbe36d6e4ba1a3d13e1759d8e75a
Author: Mark Michelson <mmichelson at digium.com>
Date:   Fri Sep 24 14:36:28 2010 -0500

    Add Invite state replication to ze code.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 40b85bd..fcf9581 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -160,6 +160,7 @@ TransactionState PJSipTransactionModInfo::transactionStateTranslate(pjsip_tsx_st
 PJSipSessionModInfo::PJSipSessionModInfo(pjsip_inv_session *inv_session) : mSessionState(new SipSessionStateItem), mNeedsReplication(true)
 {
    mSessionState->key = IceUtil::generateUUID();
+   updateSessionState(inv_session);
 }
 
 PJSipSessionModInfo::~PJSipSessionModInfo()
@@ -168,12 +169,7 @@ PJSipSessionModInfo::~PJSipSessionModInfo()
    mSession = 0;
 }
 
-/* In keeping with the other ModInfo classes, there
- * is an update function. Unlike the other items, this
- * involves Asterisk SCF data and not PJSIP data, so I'm
- * leaving this a stub for the time being.
- */
-void PJSipSessionModInfo::updateSessionState()
+void PJSipSessionModInfo::updateSessionState(pjsip_inv_session *inv_session)
 {
    mSessionState->mSources = mSession->getSources();
    mSessionState->mSinks = mSession->getSinks();
@@ -182,6 +178,15 @@ void PJSipSessionModInfo::updateSessionState()
    //instead.
    Ice::Current dummy;
    mSessionState->mMediaSession = mSession->getMediaSession(dummy);
+
+   //Now we get stuff from the inv_session itself.
+   mInviteState->mCancelling = inv_session->cancelling == PJ_TRUE ? true : false;
+   mInviteState->mPendingCancel = inv_session->pending_cancel == PJ_TRUE ? true : false;
+   mInviteState->mCause = inv_session->cause;
+   mInviteState->mCauseText = std::string(pj_strbuf(&inv_session->cause_text), pj_strlen(&inv_session->cause_text));
+   mInviteState->mNotify = inv_session->notify == PJ_TRUE ? true : false;
+   mInviteState->mLastAckCseq = inv_session->last_ack_cseq;
+   mInviteState->mCurrentState = inviteStateTranslate(inv_session->state);
 }
 
 SipSessionPtr PJSipSessionModInfo::getSessionPtr()
@@ -194,11 +199,46 @@ void PJSipSessionModInfo::setSessionPtr(SipSessionPtr sessionPtr)
    mSession = sessionPtr;
 }
 
+InviteSessionState PJSipSessionModInfo::inviteStateTranslate(pjsip_inv_state state)
+{
+   InviteSessionState retState;
+   switch (state)
+   {
+   case PJSIP_INV_STATE_NULL:
+      retState = InviteSessionStateNull;
+      break;
+   case PJSIP_INV_STATE_CALLING:
+      retState = InviteSessionStateCalling;
+      break;
+   case PJSIP_INV_STATE_INCOMING:
+      retState = InviteSessionStateIncoming;
+      break;
+   case PJSIP_INV_STATE_EARLY:
+      retState = InviteSessionStateEarly;
+      break;
+   case PJSIP_INV_STATE_CONNECTING:
+      retState = InviteSessionStateConnecting;
+      break;
+   case PJSIP_INV_STATE_CONFIRMED:
+      retState = InviteSessionStateConfirmed;
+      break;
+   case PJSIP_INV_STATE_DISCONNECTED:
+      retState = InviteSessionStateDisconnected;
+      break;
+   default:
+      std::cerr << "[WARNING] Unknwon PJSIP INVITE state encountered: " << state << std::endl;
+      retState = InviteSessionStateNull;
+      break;
+   }
+   return retState;
+}
+
 static void replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransactionModInfo *tsxInfo,
 		PJSipSessionModInfo *sessionInfo)
 {
 	SipStateItemSeq setItems;
 	Ice::StringSeq removeItems;
+	
 	if (dlgInfo)
 	{
 		if (dlgInfo->mNeedsRemoval == true)
@@ -211,28 +251,30 @@ static void replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransactionModInfo
 			dlgInfo->mNeedsReplication = false;
 		}
 	}
-	if (tsxInfo)
+	if (sessionInfo)
 	{
-		if (tsxInfo->mNeedsRemoval == true)
+		if (sessionInfo->mNeedsRemoval == true)
 		{
-			removeItems.push_back(tsxInfo->mTransactionState->key);
+			removeItems.push_back(sessionInfo->mInviteState->key);
+			removeItems.push_back(sessionInfo->mSessionState->key);
 		}
-		else if (tsxInfo->mNeedsReplication == true)
+		else if (sessionInfo->mNeedsReplication == true)
 		{
-			setItems.push_back(tsxInfo->mTransactionState);
-			tsxInfo->mNeedsReplication = false;
+			setItems.push_back(sessionInfo->mInviteState);
+			setItems.insert(setItems.begin(), sessionInfo->mSessionState);
+			sessionInfo->mNeedsReplication = false;
 		}
 	}
-	if (sessionInfo)
+	if (tsxInfo)
 	{
-		if (sessionInfo->mNeedsRemoval == true)
+		if (tsxInfo->mNeedsRemoval == true)
 		{
-			removeItems.push_back(sessionInfo->mSessionState->key);
+			removeItems.push_back(tsxInfo->mTransactionState->key);
 		}
-		else if (sessionInfo->mNeedsReplication == true)
+		else if (tsxInfo->mNeedsReplication == true)
 		{
-			setItems.push_back(sessionInfo->mSessionState);
-			sessionInfo->mNeedsReplication = false;
+			setItems.push_back(tsxInfo->mTransactionState);
+			tsxInfo->mNeedsReplication = false;
 		}
 	}
 	SipStateReplicatorPrx replicator = SipChannelServiceDataModel::getInstance().getStateReplicator();
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index c9ca467..208fadb 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -62,13 +62,15 @@ class PJSipSessionModInfo
 public:
 	PJSipSessionModInfo(pjsip_inv_session *inv_session);
 	~PJSipSessionModInfo();
-	void updateSessionState();
+	void updateSessionState(pjsip_inv_session *inv_session);
 	SipSessionPtr getSessionPtr();
 	void setSessionPtr(SipSessionPtr sessionPtr);
 	SipSessionStateItemPtr mSessionState;
+	SipInviteSessionStateItemPtr mInviteState;
 	bool mNeedsReplication;
 	bool mNeedsRemoval;
 private:
+	InviteSessionState inviteStateTranslate(pjsip_inv_state state);
 	SipSessionPtr mSession;
 };
 

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list